#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();
int /*<<< orphan*/ condition();
int /*<<< orphan*/ emitln(char *);
int /*<<< orphan*/ match(char);
char *new_label();
int /*<<< orphan*/ post_label(char *);
int /*<<< orphan*/ snprintf(char *, int, char *, char *);
void do_while(void) {
  char *label1, *label2;
  char beqstr[32], brastr[32];
  match('w');
  label1 = new_label();
  label2 = new_label();
  post_label(label1);
  condition();
  snprintf(beqstr, 32, "BEQ %s", label2);
  emitln(beqstr);
  block();
  match('e');
  snprintf(brastr, 32, "BRA %s", label1);
  emitln(brastr);
  post_label(label2);
}


x86 assembly (clang, -O0):
<do_while>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    $0x77,%edi
call   1070 <match@plt>
mov    $0x0,%al
call   1040 <new_label@plt>
mov    %rax,-0x8(%rbp)
mov    $0x0,%al
call   1040 <new_label@plt>
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1090 <post_label@plt>
mov    $0x0,%al
call   1050 <condition@plt>
lea    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x20,%esi
lea    0xe44(%rip),%rdx
call   1060 <snprintf@plt>
lea    -0x30(%rbp),%rdi
call   1030 <emitln@plt>
mov    $0x0,%al
call   1080 <block@plt>
mov    $0x65,%edi
call   1070 <match@plt>
lea    -0x50(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    $0x20,%esi
lea    0xe18(%rip),%rdx
call   1060 <snprintf@plt>
lea    -0x50(%rbp),%rdi
call   1030 <emitln@plt>
mov    -0x10(%rbp),%rdi
call   1090 <post_label@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<do_while>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    $0x77,%edi
call   1070 <match@plt>
xor    %eax,%eax
call   1040 <new_label@plt>
mov    %rax,%r12
xor    %eax,%eax
call   1040 <new_label@plt>
mov    %rax,%r14
mov    %r12,%rdi
call   1090 <post_label@plt>
xor    %eax,%eax
call   1050 <condition@plt>
lea    0xe51(%rip),%rdx
lea    0x20(%rsp),%r15
mov    %r15,%rdi
mov    $0x20,%esi
mov    %r14,%rcx
call   1060 <snprintf@plt>
mov    %r15,%rdi
call   1030 <emitln@plt>
xor    %eax,%eax
call   1080 <block@plt>
mov    $0x65,%edi
call   1070 <match@plt>
lea    0xe23(%rip),%rdx
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x20,%esi
mov    %r12,%rcx
call   1060 <snprintf@plt>
mov    %rbx,%rdi
call   1030 <emitln@plt>
mov    %r14,%rdi
call   1090 <post_label@plt>
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [7 x i8] c"BEQ %s\00"
@.str.1 = [7 x i8] c"BRA %s\00"
define void @do_while() {
%1 = alloca i8*
%2 = alloca i8*
%3 = alloca [32 x i8]
%4 = alloca [32 x i8]
%5 = call i32 @match(i8 signext 119)
%6 = call i8* (...) @new_label()
store i8* %6, i8** %1
%7 = call i8* (...) @new_label()
store i8* %7, i8** %2
%8 = load i8*, i8** %1
%9 = call i32 @post_label(i8* %8)
%10 = call i32 (...) @condition()
%11 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 0
%12 = load i8*, i8** %2
%13 = call i32 @snprintf(i8* %11, i32 32, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %12)
%14 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 0
%15 = call i32 @emitln(i8* %14)
%16 = call i32 (...) @block()
%17 = call i32 @match(i8 signext 101)
%18 = getelementptr inbounds [32 x i8], [32 x i8]* %4, i64 0, i64 0
%19 = load i8*, i8** %1
%20 = call i32 @snprintf(i8* %18, i32 32, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %19)
%21 = getelementptr inbounds [32 x i8], [32 x i8]* %4, i64 0, i64 0
%22 = call i32 @emitln(i8* %21)
%23 = load i8*, i8** %2
%24 = call i32 @post_label(i8* %23)
ret void
}

LLVM IR (-O2):
@.str = [7 x i8] c"BEQ %s\00"
@.str.1 = [7 x i8] c"BRA %s\00"
define void @do_while() {
%1 = alloca [32 x i8]
%2 = alloca [32 x i8]
%3 = getelementptr inbounds [32 x i8], [32 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [32 x i8], [32 x i8]* %2, i64 0, i64 0
%5 = tail call i32 @match(i8 signext 119)
%6 = tail call i8* (...) @new_label()
%7 = tail call i8* (...) @new_label()
%8 = tail call i32 @post_label(i8* %6)
%9 = tail call i32 (...) @condition()
%10 = call i32 @snprintf(i8* %3, i32 32, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %7)
%11 = call i32 @emitln(i8* %3)
%12 = call i32 (...) @block()
%13 = call i32 @match(i8 signext 101)
%14 = call i32 @snprintf(i8* %4, i32 32, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %6)
%15 = call i32 @emitln(i8* %4)
%16 = call i32 @post_label(i8* %7)
ret void
}