#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 */
struct triple {
  int dummy;
};
struct compile_state {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ eat(struct compile_state *, int);
int /*<<< orphan*/ end_scope(struct compile_state *);
int peek(struct compile_state *);
int /*<<< orphan*/ start_scope(struct compile_state *);
int /*<<< orphan*/ statement(struct compile_state *, struct triple *);
void compound_statement(struct compile_state *state, struct triple *first) {
  eat(state, 3);
  start_scope(state);
  while (peek(state) != 4) {
    statement(state, first);
  }
  end_scope(state);
  eat(state, 4);
}


x86 assembly (clang, -O0):
<compound_statement>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x3,%esi
call   1040 <eat@plt>
mov    -0x8(%rbp),%rdi
call   1060 <start_scope@plt>
mov    -0x8(%rbp),%rdi
call   1030 <peek@plt>
cmp    $0x4,%eax
je     119b <compound_statement+0x4b>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <statement@plt>
jmp    1177 <compound_statement+0x27>
mov    -0x8(%rbp),%rdi
call   1070 <end_scope@plt>
mov    -0x8(%rbp),%rdi
mov    $0x4,%esi
call   1040 <eat@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<compound_statement>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
mov    $0x3,%esi
call   1040 <eat@plt>
mov    %rbx,%rdi
call   1060 <start_scope@plt>
nopl   0x0(%rax)
mov    %rbx,%rdi
call   1030 <peek@plt>
mov    %rbx,%rdi
cmp    $0x4,%eax
je     118a <compound_statement+0x3a>
mov    %r14,%rsi
call   1050 <statement@plt>
jmp    1170 <compound_statement+0x20>
call   1070 <end_scope@plt>
mov    %rbx,%rdi
mov    $0x4,%esi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <eat@plt>

LLVM IR (-O0):
%struct.compile_state = type { i32 }
%struct.triple = type { i32 }
define void @compound_statement(%struct.compile_state* %0, %struct.triple* %1) {
%3 = alloca %struct.compile_state*
%4 = alloca %struct.triple*
store %struct.compile_state* %0, %struct.compile_state** %3
store %struct.triple* %1, %struct.triple** %4
%5 = load %struct.compile_state*, %struct.compile_state** %3
%6 = call i32 @eat(%struct.compile_state* %5, i32 3)
%7 = load %struct.compile_state*, %struct.compile_state** %3
%8 = call i32 @start_scope(%struct.compile_state* %7)
br label %9
9: ; preds = %13, %2
%10 = load %struct.compile_state*, %struct.compile_state** %3
%11 = call i32 @peek(%struct.compile_state* %10)
%12 = icmp ne i32 %11, 4
br i1 %12, label %13, label %17
13: ; preds = %9
%14 = load %struct.compile_state*, %struct.compile_state** %3
%15 = load %struct.triple*, %struct.triple** %4
%16 = call i32 @statement(%struct.compile_state* %14, %struct.triple* %15)
br label %9
17: ; preds = %9
%18 = load %struct.compile_state*, %struct.compile_state** %3
%19 = call i32 @end_scope(%struct.compile_state* %18)
%20 = load %struct.compile_state*, %struct.compile_state** %3
%21 = call i32 @eat(%struct.compile_state* %20, i32 4)
ret void
}

LLVM IR (-O2):
%struct.compile_state = type { i32 }
%struct.triple = type { i32 }
define void @compound_statement(%struct.compile_state* %0, %struct.triple* %1) {
%3 = tail call i32 @eat(%struct.compile_state* %0, i32 3)
%4 = tail call i32 @start_scope(%struct.compile_state* %0)
%5 = tail call i32 @peek(%struct.compile_state* %0)
%6 = icmp eq i32 %5, 4
br i1 %6, label %11, label %7
7: ; preds = %2, %7
%8 = tail call i32 @statement(%struct.compile_state* %0, %struct.triple* %1)
%9 = tail call i32 @peek(%struct.compile_state* %0)
%10 = icmp eq i32 %9, 4
br i1 %10, label %11, label %7
11: ; preds = %7, %2
%12 = tail call i32 @end_scope(%struct.compile_state* %0)
%13 = tail call i32 @eat(%struct.compile_state* %0, i32 4)
ret void
}