# Homework 8

## Due date

This assignment *must* be submitted
as a single file
for Homework 8
of the ECE 209.602 / CSCI 373.002 section
on UNCA moodle
by 11:00 PM on Wednesday, 3 November.

You can use whatever name you wish for the file, but submit it
in either ASCII text or OpenOffice Text (.odt) format.
MS Word 2007 will save in either of these formats.

## The task

Using the rules discussed in the handouts on
Translating C to C: Control structures
and
Translating C to C: Simple Expressions,
"compile" the following two sequences of C statements into simple C statements
in which (1) at most one operator appears on the right hand side
of an assignment statement and (2) the only "control" structures are
one of the following three:

`goto ``label` ;

`if (``variable` == 0) goto `label` ;

`if (``variable` != 0) goto `label` ;

Of course your program is going to have lots of `goto`

's
and labels.

### C code sequence 1

int m, n, t, lcm, gcd ;
while (m != n) {
if (m < n) {
t = m ;
m = n ;
n = t ;
} else {
m = m - n ;
}
}
gcd = m ;
lcm = i*j/gcd ;

### C code sequence 2

int p, q, x ;
if (p && q == 5 || p == q) {
x = p*p + q*q ;
} else {
x = q ;
}