#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ block(char *);
int /*<<< orphan*/ emitln(char *, ...);
int /*<<< orphan*/ expression();
int /*<<< orphan*/ match(char);
int /*<<< orphan*/ newLabel(char *);
int /*<<< orphan*/ postLabel(char *, char *);
void doDo() {
  char label1[10];
  char label2[10];
  match('d');
  newLabel(label1);
  newLabel(label2);
  emitln("#DO");
  expression();
  emitln("MOV\t%%eax, %%ecx");
  emitln("JECXZ\t%s", label2);
  postLabel(label1, "#beginning of DO block");
  emitln("PUSH\t%%ecx");
  block(label2);
  match('e');
  emitln("POP\t%%ecx");
  emitln("LOOP\t%s", label1);
  emitln("SUBL\t$4,%%esp\t#Increase stack in case of Break");
  postLabel(label2, "#ENDDO");
  emitln("ADDL\t$4,%%esp\t#Get ecx off stack in case of break");
}


x86 assembly (clang, -O0):
<doDo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    $0x64,%edi
call   1070 <match@plt>
lea    -0xa(%rbp),%rdi
call   1050 <newLabel@plt>
lea    -0x14(%rbp),%rdi
call   1050 <newLabel@plt>
lea    0xe75(%rip),%rdi
mov    $0x0,%al
call   1030 <emitln@plt>
mov    $0x0,%al
call   1060 <expression@plt>
lea    0xe64(%rip),%rdi
mov    $0x0,%al
call   1030 <emitln@plt>
lea    -0x14(%rbp),%rsi
lea    0xe63(%rip),%rdi
mov    $0x0,%al
call   1030 <emitln@plt>
lea    -0xa(%rbp),%rdi
lea    0xe5a(%rip),%rsi
call   1040 <postLabel@plt>
lea    0xe65(%rip),%rdi
mov    $0x0,%al
call   1030 <emitln@plt>
lea    -0x14(%rbp),%rdi
call   1080 <block@plt>
mov    $0x65,%edi
call   1070 <match@plt>
lea    0xe4f(%rip),%rdi
mov    $0x0,%al
call   1030 <emitln@plt>
lea    -0xa(%rbp),%rsi
lea    0xe47(%rip),%rdi
mov    $0x0,%al
call   1030 <emitln@plt>
lea    0xe41(%rip),%rdi
mov    $0x0,%al
call   1030 <emitln@plt>
lea    -0x14(%rbp),%rdi
lea    0xe5e(%rip),%rsi
call   1040 <postLabel@plt>
lea    0xe59(%rip),%rdi
mov    $0x0,%al
call   1030 <emitln@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<doDo>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    $0x64,%edi
call   1070 <match@plt>
lea    0xe(%rsp),%r14
mov    %r14,%rdi
call   1050 <newLabel@plt>
lea    0x4(%rsp),%rbx
mov    %rbx,%rdi
call   1050 <newLabel@plt>
lea    0xe6e(%rip),%rdi
xor    %eax,%eax
call   1030 <emitln@plt>
xor    %eax,%eax
call   1060 <expression@plt>
lea    0xe5d(%rip),%rdi
xor    %eax,%eax
call   1030 <emitln@plt>
lea    0xe60(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <emitln@plt>
lea    0xe58(%rip),%rsi
mov    %r14,%rdi
call   1040 <postLabel@plt>
lea    0xe60(%rip),%rdi
xor    %eax,%eax
call   1030 <emitln@plt>
mov    %rbx,%rdi
call   1080 <block@plt>
mov    $0x65,%edi
call   1070 <match@plt>
lea    0xe4b(%rip),%rdi
xor    %eax,%eax
call   1030 <emitln@plt>
lea    0xe47(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1030 <emitln@plt>
lea    0xe3e(%rip),%rdi
xor    %eax,%eax
call   1030 <emitln@plt>
lea    0xe5f(%rip),%rsi
mov    %rbx,%rdi
call   1040 <postLabel@plt>
lea    0xe57(%rip),%rdi
xor    %eax,%eax
call   1030 <emitln@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [4 x i8] c"#DO\00"
@.str.1 = [17 x i8] c"MOV\09%%eax, %%ecx\00"
@.str.2 = [9 x i8] c"JECXZ\09%s\00"
@.str.3 = [23 x i8] c"#beginning of DO block\00"
@.str.4 = [11 x i8] c"PUSH\09%%ecx\00"
@.str.5 = [10 x i8] c"POP\09%%ecx\00"
@.str.6 = [8 x i8] c"LOOP\09%s\00"
@.str.7 = [47 x i8] c"SUBL\09$4,%%esp\09#Increase stack in case of Break\00"
@.str.8 = [7 x i8] c"#ENDDO\00"
@.str.9 = [50 x i8] c"ADDL\09$4,%%esp\09#Get ecx off stack in case of break\00"
define void @doDo() {
%1 = alloca [10 x i8]
%2 = alloca [10 x i8]
%3 = call i32 @match(i8 signext 100)
%4 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%5 = call i32 @newLabel(i8* %4)
%6 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%7 = call i32 @newLabel(i8* %6)
%8 = call i32 (i8*, ...) @emitln(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%9 = call i32 (...) @expression()
%10 = call i32 (i8*, ...) @emitln(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%11 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%12 = call i32 (i8*, ...) @emitln(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %11)
%13 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%14 = call i32 @postLabel(i8* %13, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0))
%15 = call i32 (i8*, ...) @emitln(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
%16 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%17 = call i32 @block(i8* %16)
%18 = call i32 @match(i8 signext 101)
%19 = call i32 (i8*, ...) @emitln(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0))
%20 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%21 = call i32 (i8*, ...) @emitln(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0), i8* %20)
%22 = call i32 (i8*, ...) @emitln(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.7, i64 0, i64 0))
%23 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%24 = call i32 @postLabel(i8* %23, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0))
%25 = call i32 (i8*, ...) @emitln(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.9, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"#DO\00"
@.str.1 = [17 x i8] c"MOV\09%%eax, %%ecx\00"
@.str.2 = [9 x i8] c"JECXZ\09%s\00"
@.str.3 = [23 x i8] c"#beginning of DO block\00"
@.str.4 = [11 x i8] c"PUSH\09%%ecx\00"
@.str.5 = [10 x i8] c"POP\09%%ecx\00"
@.str.6 = [8 x i8] c"LOOP\09%s\00"
@.str.7 = [47 x i8] c"SUBL\09$4,%%esp\09#Increase stack in case of Break\00"
@.str.8 = [7 x i8] c"#ENDDO\00"
@.str.9 = [50 x i8] c"ADDL\09$4,%%esp\09#Get ecx off stack in case of break\00"
define void @doDo() {
%1 = alloca [10 x i8]
%2 = alloca [10 x i8]
%3 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%5 = tail call i32 @match(i8 signext 100)
%6 = call i32 @newLabel(i8* %3)
%7 = call i32 @newLabel(i8* %4)
%8 = call i32 (i8*, ...) @emitln(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%9 = call i32 (...) @expression()
%10 = call i32 (i8*, ...) @emitln(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%11 = call i32 (i8*, ...) @emitln(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %4)
%12 = call i32 @postLabel(i8* %3, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0))
%13 = call i32 (i8*, ...) @emitln(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
%14 = call i32 @block(i8* %4)
%15 = call i32 @match(i8 signext 101)
%16 = call i32 (i8*, ...) @emitln(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0))
%17 = call i32 (i8*, ...) @emitln(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0), i8* %3)
%18 = call i32 (i8*, ...) @emitln(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.7, i64 0, i64 0))
%19 = call i32 @postLabel(i8* %4, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0))
%20 = call i32 (i8*, ...) @emitln(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.9, i64 0, i64 0))
ret void
}