void if_statement(struct compile_state *state, struct triple *first) {
  struct triple *test, *jmp1, *jmp2, *middle, *end;
  jmp1 = jmp2 = middle = 0;
  eat(state, 73);
  eat(state, 10);
  test = expr(state);
  bool(state, test);
  test = lfalse_expr(state, read_expr(state, test));
  eat(state, 11);
  middle = label(state);
  jmp1 = branch(state, middle, test);
  flatten(state, first, test);
  flatten(state, first, jmp1);
  flatten(state, first, label(state));
  statement(state, first);
  if (peek(state) == 67) {
    eat(state, 67);
    end = label(state);
    jmp2 = branch(state, end, 0);
    flatten(state, first, jmp2);
    flatten(state, first, middle);
    statement(state, first);
    flatten(state, first, end);
  } else {
    flatten(state, first, middle);
  }
}


x86 assembly (clang, -O0):
<if_statement>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x30(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x49,%esi
mov    $0x0,%al
call   1040 <eat@plt>
mov    -0x8(%rbp),%rdi
mov    $0xa,%esi
mov    $0x0,%al
call   1040 <eat@plt>
mov    -0x8(%rbp),%rdi
mov    $0x0,%al
call   10a0 <expr@plt>
cltq
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    $0x0,%al
call   10b0 <bool@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    $0x0,%al
call   1050 <read_expr@plt>
mov    -0x50(%rbp),%rdi
mov    %eax,%esi
mov    $0x0,%al
call   1080 <lfalse_expr@plt>
cltq
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0xb,%esi
mov    $0x0,%al
call   1040 <eat@plt>
mov    -0x8(%rbp),%rdi
mov    $0x0,%al
call   1070 <label@plt>
cltq
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    $0x0,%al
call   1090 <branch@plt>
cltq
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    $0x0,%al
call   10c0 <flatten@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    $0x0,%al
call   10c0 <flatten@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x0,%al
call   1070 <label@plt>
mov    -0x48(%rbp),%rdi
mov    -0x40(%rbp),%rsi
mov    %eax,%edx
mov    $0x0,%al
call   10c0 <flatten@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0x0,%al
call   1060 <statement@plt>
mov    -0x8(%rbp),%rdi
mov    $0x0,%al
call   1030 <peek@plt>
cmp    $0x43,%eax
jne    1366 <if_statement+0x1c6>
mov    -0x8(%rbp),%rdi
mov    $0x43,%esi
mov    $0x0,%al
call   1040 <eat@plt>
mov    -0x8(%rbp),%rdi
mov    $0x0,%al
call   1070 <label@plt>
cltq
mov    %rax,-0x38(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x38(%rbp),%rsi
xor    %edx,%edx
mov    $0x0,%al
call   1090 <branch@plt>
cltq
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x28(%rbp),%rdx
mov    $0x0,%al
call   10c0 <flatten@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x30(%rbp),%rdx
mov    $0x0,%al
call   10c0 <flatten@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0x0,%al
call   1060 <statement@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x38(%rbp),%rdx
mov    $0x0,%al
call   10c0 <flatten@plt>
jmp    1379 <if_statement+0x1d9>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x30(%rbp),%rdx
mov    $0x0,%al
call   10c0 <flatten@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<if_statement>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
mov    $0x49,%esi
xor    %eax,%eax
call   1040 <eat@plt>
mov    %rbx,%rdi
mov    $0xa,%esi
xor    %eax,%eax
call   1040 <eat@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   10a0 <expr@plt>
movslq %eax,%r15
mov    %rbx,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   10b0 <bool@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1050 <read_expr@plt>
mov    %rbx,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1080 <lfalse_expr@plt>
movslq %eax,%r12
mov    %rbx,%rdi
mov    $0xb,%esi
xor    %eax,%eax
call   1040 <eat@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1070 <label@plt>
movslq %eax,%r15
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
xor    %eax,%eax
call   1090 <branch@plt>
movslq %eax,%r13
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r12,%rdx
xor    %eax,%eax
call   10c0 <flatten@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r13,%rdx
xor    %eax,%eax
call   10c0 <flatten@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1070 <label@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   10c0 <flatten@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1060 <statement@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <peek@plt>
cmp    $0x43,%eax
jne    12df <if_statement+0x13f>
mov    %rbx,%rdi
mov    $0x43,%esi
xor    %eax,%eax
call   1040 <eat@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1070 <label@plt>
movslq %eax,%r12
mov    %rbx,%rdi
mov    %r12,%rsi
xor    %edx,%edx
xor    %eax,%eax
call   1090 <branch@plt>
movslq %eax,%rdx
mov    %rbx,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   10c0 <flatten@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
xor    %eax,%eax
call   10c0 <flatten@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1060 <statement@plt>
mov    %r12,%r15
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    10c0 <flatten@plt>

LLVM IR (-O0):
%struct.compile_state = type opaque
%struct.triple = type opaque
define void @if_statement(%struct.compile_state* %0, %struct.triple* %1) {
%3 = alloca %struct.compile_state*
%4 = alloca %struct.triple*
%5 = alloca %struct.triple*
%6 = alloca %struct.triple*
%7 = alloca %struct.triple*
%8 = alloca %struct.triple*
%9 = alloca %struct.triple*
store %struct.compile_state* %0, %struct.compile_state** %3
store %struct.triple* %1, %struct.triple** %4
store %struct.triple* null, %struct.triple** %8
store %struct.triple* null, %struct.triple** %7
store %struct.triple* null, %struct.triple** %6
%10 = load %struct.compile_state*, %struct.compile_state** %3
%11 = call i32 (%struct.compile_state*, i32, ...) bitcast (i32 (...)* @eat to i32 (%struct.compile_state*, i32, ...)*)(%struct.compile_state* %10, i32 73)
%12 = load %struct.compile_state*, %struct.compile_state** %3
%13 = call i32 (%struct.compile_state*, i32, ...) bitcast (i32 (...)* @eat to i32 (%struct.compile_state*, i32, ...)*)(%struct.compile_state* %12, i32 10)
%14 = load %struct.compile_state*, %struct.compile_state** %3
%15 = call i32 (%struct.compile_state*, ...) bitcast (i32 (...)* @expr to i32 (%struct.compile_state*, ...)*)(%struct.compile_state* %14)
%16 = sext i32 %15 to i64
%17 = inttoptr i64 %16 to %struct.triple*
store %struct.triple* %17, %struct.triple** %5
%18 = load %struct.compile_state*, %struct.compile_state** %3
%19 = load %struct.triple*, %struct.triple** %5
%20 = call i32 (%struct.compile_state*, %struct.triple*, ...) bitcast (i32 (...)* @bool to i32 (%struct.compile_state*, %struct.triple*, ...)*)(%struct.compile_state* %18, %struct.triple* %19)
%21 = load %struct.compile_state*, %struct.compile_state** %3
%22 = load %struct.compile_state*, %struct.compile_state** %3
%23 = load %struct.triple*, %struct.triple** %5
%24 = call i32 (%struct.compile_state*, %struct.triple*, ...) bitcast (i32 (...)* @read_expr to i32 (%struct.compile_state*, %struct.triple*, ...)*)(%struct.compile_state* %22, %struct.triple* %23)
%25 = call i32 (%struct.compile_state*, i32, ...) bitcast (i32 (...)* @lfalse_expr to i32 (%struct.compile_state*, i32, ...)*)(%struct.compile_state* %21, i32 %24)
%26 = sext i32 %25 to i64
%27 = inttoptr i64 %26 to %struct.triple*
store %struct.triple* %27, %struct.triple** %5
%28 = load %struct.compile_state*, %struct.compile_state** %3
%29 = call i32 (%struct.compile_state*, i32, ...) bitcast (i32 (...)* @eat to i32 (%struct.compile_state*, i32, ...)*)(%struct.compile_state* %28, i32 11)
%30 = load %struct.compile_state*, %struct.compile_state** %3
%31 = call i32 (%struct.compile_state*, ...) bitcast (i32 (...)* @label to i32 (%struct.compile_state*, ...)*)(%struct.compile_state* %30)
%32 = sext i32 %31 to i64
%33 = inttoptr i64 %32 to %struct.triple*
store %struct.triple* %33, %struct.triple** %8
%34 = load %struct.compile_state*, %struct.compile_state** %3
%35 = load %struct.triple*, %struct.triple** %8
%36 = load %struct.triple*, %struct.triple** %5
%37 = call i32 (%struct.compile_state*, %struct.triple*, %struct.triple*, ...) bitcast (i32 (...)* @branch to i32 (%struct.compile_state*, %struct.triple*, %struct.triple*, ...)*)(%struct.compile_state* %34, %struct.triple* %35, %struct.triple* %36)
%38 = sext i32 %37 to i64
%39 = inttoptr i64 %38 to %struct.triple*
store %struct.triple* %39, %struct.triple** %6
%40 = load %struct.compile_state*, %struct.compile_state** %3
%41 = load %struct.triple*, %struct.triple** %4
%42 = load %struct.triple*, %struct.triple** %5
%43 = call i32 (%struct.compile_state*, %struct.triple*, %struct.triple*, ...) bitcast (i32 (...)* @flatten to i32 (%struct.compile_state*, %struct.triple*, %struct.triple*, ...)*)(%struct.compile_state* %40, %struct.triple* %41, %struct.triple* %42)
%44 = load %struct.compile_state*, %struct.compile_state** %3
%45 = load %struct.triple*, %struct.triple** %4
%46 = load %struct.triple*, %struct.triple** %6
%47 = call i32 (%struct.compile_state*, %struct.triple*, %struct.triple*, ...) bitcast (i32 (...)* @flatten to i32 (%struct.compile_state*, %struct.triple*, %struct.triple*, ...)*)(%struct.compile_state* %44, %struct.triple* %45, %struct.triple* %46)
%48 = load %struct.compile_state*, %struct.compile_state** %3
%49 = load %struct.triple*, %struct.triple** %4
%50 = load %struct.compile_state*, %struct.compile_state** %3
%51 = call i32 (%struct.compile_state*, ...) bitcast (i32 (...)* @label to i32 (%struct.compile_state*, ...)*)(%struct.compile_state* %50)
%52 = call i32 (%struct.compile_state*, %struct.triple*, i32, ...) bitcast (i32 (...)* @flatten to i32 (%struct.compile_state*, %struct.triple*, i32, ...)*)(%struct.compile_state* %48, %struct.triple* %49, i32 %51)
%53 = load %struct.compile_state*, %struct.compile_state** %3
%54 = load %struct.triple*, %struct.triple** %4
%55 = call i32 (%struct.compile_state*, %struct.triple*, ...) bitcast (i32 (...)* @statement to i32 (%struct.compile_state*, %struct.triple*, ...)*)(%struct.compile_state* %53, %struct.triple* %54)
%56 = load %struct.compile_state*, %struct.compile_state** %3
%57 = call i32 (%struct.compile_state*, ...) bitcast (i32 (...)* @peek to i32 (%struct.compile_state*, ...)*)(%struct.compile_state* %56)
%58 = icmp eq i32 %57, 67
br i1 %58, label %59, label %86
59: ; preds = %2
%60 = load %struct.compile_state*, %struct.compile_state** %3
%61 = call i32 (%struct.compile_state*, i32, ...) bitcast (i32 (...)* @eat to i32 (%struct.compile_state*, i32, ...)*)(%struct.compile_state* %60, i32 67)
%62 = load %struct.compile_state*, %struct.compile_state** %3
%63 = call i32 (%struct.compile_state*, ...) bitcast (i32 (...)* @label to i32 (%struct.compile_state*, ...)*)(%struct.compile_state* %62)
%64 = sext i32 %63 to i64
%65 = inttoptr i64 %64 to %struct.triple*
store %struct.triple* %65, %struct.triple** %9
%66 = load %struct.compile_state*, %struct.compile_state** %3
%67 = load %struct.triple*, %struct.triple** %9
%68 = call i32 (%struct.compile_state*, %struct.triple*, i32, ...) bitcast (i32 (...)* @branch to i32 (%struct.compile_state*, %struct.triple*, i32, ...)*)(%struct.compile_state* %66, %struct.triple* %67, i32 0)
%69 = sext i32 %68 to i64
%70 = inttoptr i64 %69 to %struct.triple*
store %struct.triple* %70, %struct.triple** %7
%71 = load %struct.compile_state*, %struct.compile_state** %3
%72 = load %struct.triple*, %struct.triple** %4
%73 = load %struct.triple*, %struct.triple** %7
%74 = call i32 (%struct.compile_state*, %struct.triple*, %struct.triple*, ...) bitcast (i32 (...)* @flatten to i32 (%struct.compile_state*, %struct.triple*, %struct.triple*, ...)*)(%struct.compile_state* %71, %struct.triple* %72, %struct.triple* %73)
%75 = load %struct.compile_state*, %struct.compile_state** %3
%76 = load %struct.triple*, %struct.triple** %4
%77 = load %struct.triple*, %struct.triple** %8
%78 = call i32 (%struct.compile_state*, %struct.triple*, %struct.triple*, ...) bitcast (i32 (...)* @flatten to i32 (%struct.compile_state*, %struct.triple*, %struct.triple*, ...)*)(%struct.compile_state* %75, %struct.triple* %76, %struct.triple* %77)
%79 = load %struct.compile_state*, %struct.compile_state** %3
%80 = load %struct.triple*, %struct.triple** %4
%81 = call i32 (%struct.compile_state*, %struct.triple*, ...) bitcast (i32 (...)* @statement to i32 (%struct.compile_state*, %struct.triple*, ...)*)(%struct.compile_state* %79, %struct.triple* %80)
%82 = load %struct.compile_state*, %struct.compile_state** %3
%83 = load %struct.triple*, %struct.triple** %4
%84 = load %struct.triple*, %struct.triple** %9
%85 = call i32 (%struct.compile_state*, %struct.triple*, %struct.triple*, ...) bitcast (i32 (...)* @flatten to i32 (%struct.compile_state*, %struct.triple*, %struct.triple*, ...)*)(%struct.compile_state* %82, %struct.triple* %83, %struct.triple* %84)
br label %91
86: ; preds = %2
%87 = load %struct.compile_state*, %struct.compile_state** %3
%88 = load %struct.triple*, %struct.triple** %4
%89 = load %struct.triple*, %struct.triple** %8
%90 = call i32 (%struct.compile_state*, %struct.triple*, %struct.triple*, ...) bitcast (i32 (...)* @flatten to i32 (%struct.compile_state*, %struct.triple*, %struct.triple*, ...)*)(%struct.compile_state* %87, %struct.triple* %88, %struct.triple* %89)
br label %91
91: ; preds = %86, %59
ret void
}

LLVM IR (-O2):
%struct.compile_state = type opaque
%struct.triple = type opaque
define void @if_statement(%struct.compile_state* %0, %struct.triple* %1) {
%3 = tail call i32 (%struct.compile_state*, i32, ...) bitcast (i32 (...)* @eat to i32 (%struct.compile_state*, i32, ...)*)(%struct.compile_state* %0, i32 73)
%4 = tail call i32 (%struct.compile_state*, i32, ...) bitcast (i32 (...)* @eat to i32 (%struct.compile_state*, i32, ...)*)(%struct.compile_state* %0, i32 10)
%5 = tail call i32 (%struct.compile_state*, ...) bitcast (i32 (...)* @expr to i32 (%struct.compile_state*, ...)*)(%struct.compile_state* %0)
%6 = sext i32 %5 to i64
%7 = inttoptr i64 %6 to %struct.triple*
%8 = tail call i32 (%struct.compile_state*, %struct.triple*, ...) bitcast (i32 (...)* @bool to i32 (%struct.compile_state*, %struct.triple*, ...)*)(%struct.compile_state* %0, %struct.triple* %7)
%9 = tail call i32 (%struct.compile_state*, %struct.triple*, ...) bitcast (i32 (...)* @read_expr to i32 (%struct.compile_state*, %struct.triple*, ...)*)(%struct.compile_state* %0, %struct.triple* %7)
%10 = tail call i32 (%struct.compile_state*, i32, ...) bitcast (i32 (...)* @lfalse_expr to i32 (%struct.compile_state*, i32, ...)*)(%struct.compile_state* %0, i32 %9)
%11 = sext i32 %10 to i64
%12 = inttoptr i64 %11 to %struct.triple*
%13 = tail call i32 (%struct.compile_state*, i32, ...) bitcast (i32 (...)* @eat to i32 (%struct.compile_state*, i32, ...)*)(%struct.compile_state* %0, i32 11)
%14 = tail call i32 (%struct.compile_state*, ...) bitcast (i32 (...)* @label to i32 (%struct.compile_state*, ...)*)(%struct.compile_state* %0)
%15 = sext i32 %14 to i64
%16 = inttoptr i64 %15 to %struct.triple*
%17 = tail call i32 (%struct.compile_state*, %struct.triple*, %struct.triple*, ...) bitcast (i32 (...)* @branch to i32 (%struct.compile_state*, %struct.triple*, %struct.triple*, ...)*)(%struct.compile_state* %0, %struct.triple* %16, %struct.triple* %12)
%18 = sext i32 %17 to i64
%19 = inttoptr i64 %18 to %struct.triple*
%20 = tail call i32 (%struct.compile_state*, %struct.triple*, %struct.triple*, ...) bitcast (i32 (...)* @flatten to i32 (%struct.compile_state*, %struct.triple*, %struct.triple*, ...)*)(%struct.compile_state* %0, %struct.triple* %1, %struct.triple* %12)
%21 = tail call i32 (%struct.compile_state*, %struct.triple*, %struct.triple*, ...) bitcast (i32 (...)* @flatten to i32 (%struct.compile_state*, %struct.triple*, %struct.triple*, ...)*)(%struct.compile_state* %0, %struct.triple* %1, %struct.triple* %19)
%22 = tail call i32 (%struct.compile_state*, ...) bitcast (i32 (...)* @label to i32 (%struct.compile_state*, ...)*)(%struct.compile_state* %0)
%23 = tail call i32 (%struct.compile_state*, %struct.triple*, i32, ...) bitcast (i32 (...)* @flatten to i32 (%struct.compile_state*, %struct.triple*, i32, ...)*)(%struct.compile_state* %0, %struct.triple* %1, i32 %22)
%24 = tail call i32 (%struct.compile_state*, %struct.triple*, ...) bitcast (i32 (...)* @statement to i32 (%struct.compile_state*, %struct.triple*, ...)*)(%struct.compile_state* %0, %struct.triple* %1)
%25 = tail call i32 (%struct.compile_state*, ...) bitcast (i32 (...)* @peek to i32 (%struct.compile_state*, ...)*)(%struct.compile_state* %0)
%26 = icmp eq i32 %25, 67
br i1 %26, label %27, label %38
27: ; preds = %2
%28 = tail call i32 (%struct.compile_state*, i32, ...) bitcast (i32 (...)* @eat to i32 (%struct.compile_state*, i32, ...)*)(%struct.compile_state* %0, i32 67)
%29 = tail call i32 (%struct.compile_state*, ...) bitcast (i32 (...)* @label to i32 (%struct.compile_state*, ...)*)(%struct.compile_state* %0)
%30 = sext i32 %29 to i64
%31 = inttoptr i64 %30 to %struct.triple*
%32 = tail call i32 (%struct.compile_state*, %struct.triple*, i32, ...) bitcast (i32 (...)* @branch to i32 (%struct.compile_state*, %struct.triple*, i32, ...)*)(%struct.compile_state* %0, %struct.triple* %31, i32 0)
%33 = sext i32 %32 to i64
%34 = inttoptr i64 %33 to %struct.triple*
%35 = tail call i32 (%struct.compile_state*, %struct.triple*, %struct.triple*, ...) bitcast (i32 (...)* @flatten to i32 (%struct.compile_state*, %struct.triple*, %struct.triple*, ...)*)(%struct.compile_state* %0, %struct.triple* %1, %struct.triple* %34)
%36 = tail call i32 (%struct.compile_state*, %struct.triple*, %struct.triple*, ...) bitcast (i32 (...)* @flatten to i32 (%struct.compile_state*, %struct.triple*, %struct.triple*, ...)*)(%struct.compile_state* %0, %struct.triple* %1, %struct.triple* %16)
%37 = tail call i32 (%struct.compile_state*, %struct.triple*, ...) bitcast (i32 (...)* @statement to i32 (%struct.compile_state*, %struct.triple*, ...)*)(%struct.compile_state* %0, %struct.triple* %1)
br label %38
38: ; preds = %2, %27
%39 = phi %struct.triple* [ %31, %27 ], [ %16, %2 ]
%40 = tail call i32 (%struct.compile_state*, %struct.triple*, %struct.triple*, ...) bitcast (i32 (...)* @flatten to i32 (%struct.compile_state*, %struct.triple*, %struct.triple*, ...)*)(%struct.compile_state* %0, %struct.triple* %1, %struct.triple* %39)
ret void
}