#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*/ expr(struct compile_state *);
int /*<<< orphan*/ flatten(struct compile_state *, struct triple *,
                           int /*<<< orphan*/);
int /*<<< orphan*/ lvalue_conversion(struct compile_state *,
                                     int /*<<< orphan*/);
int peek(struct compile_state *);
void expr_statement(struct compile_state *state, struct triple *first) {
  if (peek(state) != 2) {
    flatten(state, first, lvalue_conversion(state, expr(state)));
  }
  eat(state, 2);
}


x86 assembly (clang, -O0):
<expr_statement>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <peek@plt>
cmp    $0x2,%eax
je     11ad <expr_statement+0x5d>
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <expr@plt>
mov    -0x28(%rbp),%rdi
mov    %eax,%esi
call   1070 <lvalue_conversion@plt>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    %eax,%edx
call   1060 <flatten@plt>
mov    -0x8(%rbp),%rdi
mov    $0x2,%esi
call   1040 <eat@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<expr_statement>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
call   1030 <peek@plt>
cmp    $0x2,%eax
je     1183 <expr_statement+0x33>
mov    %rbx,%rdi
call   1050 <expr@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1070 <lvalue_conversion@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %eax,%edx
call   1060 <flatten@plt>
mov    %rbx,%rdi
mov    $0x2,%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 @expr_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 @peek(%struct.compile_state* %5)
%7 = icmp ne i32 %6, 2
br i1 %7, label %8, label %16
8: ; preds = %2
%9 = load %struct.compile_state*, %struct.compile_state** %3
%10 = load %struct.triple*, %struct.triple** %4
%11 = load %struct.compile_state*, %struct.compile_state** %3
%12 = load %struct.compile_state*, %struct.compile_state** %3
%13 = call i32 @expr(%struct.compile_state* %12)
%14 = call i32 @lvalue_conversion(%struct.compile_state* %11, i32 %13)
%15 = call i32 @flatten(%struct.compile_state* %9, %struct.triple* %10, i32 %14)
br label %16
16: ; preds = %8, %2
%17 = load %struct.compile_state*, %struct.compile_state** %3
%18 = call i32 @eat(%struct.compile_state* %17, i32 2)
ret void
}

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