#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 */
struct triple *assignment_expr(struct compile_state *);
int /*<<< orphan*/ eat(struct compile_state *, int);
struct triple *mkprog(struct compile_state *, struct triple *, struct triple *,
                      unsigned long);
int peek(struct compile_state *);
struct triple *expr(struct compile_state *state) {
  struct triple *def;
  def = assignment_expr(state);
  while (peek(state) == 5) {
    eat(state, 5);
    def = mkprog(state, def, assignment_expr(state), 0UL);
  }
  return def;
}


x86 assembly (clang, -O0):
<expr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <assignment_expr@plt>
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <peek@plt>
cmp    $0x5,%eax
jne    11af <expr+0x6f>
mov    -0x8(%rbp),%rdi
mov    $0x5,%esi
call   1040 <eat@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <assignment_expr@plt>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    %rax,%rdx
xor    %eax,%eax
mov    %eax,%ecx
call   1060 <mkprog@plt>
mov    %rax,-0x10(%rbp)
jmp    1159 <expr+0x19>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<expr>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
call   1050 <assignment_expr@plt>
nopl   0x0(%rax)
mov    %rax,%rbx
mov    %r14,%rdi
call   1030 <peek@plt>
cmp    $0x5,%eax
jne    1187 <expr+0x47>
mov    %r14,%rdi
mov    $0x5,%esi
call   1040 <eat@plt>
mov    %r14,%rdi
call   1050 <assignment_expr@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %rax,%rdx
xor    %ecx,%ecx
call   1060 <mkprog@plt>
jmp    1150 <expr+0x10>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
%struct.triple = type { i32 }
%struct.compile_state = type { i32 }
define %struct.triple* @expr(%struct.compile_state* %0) {
%2 = tail call %struct.triple* @assignment_expr(%struct.compile_state* %0)
%3 = tail call i32 @peek(%struct.compile_state* %0)
%4 = icmp eq i32 %3, 5
br i1 %4, label %5, label %12
5: ; preds = %1, %5
%6 = phi %struct.triple* [ %9, %5 ], [ %2, %1 ]
%7 = tail call i32 @eat(%struct.compile_state* %0, i32 5)
%8 = tail call %struct.triple* @assignment_expr(%struct.compile_state* %0)
%9 = tail call %struct.triple* @mkprog(%struct.compile_state* %0, %struct.triple* %6, %struct.triple* %8, i64 0)
%10 = tail call i32 @peek(%struct.compile_state* %0)
%11 = icmp eq i32 %10, 5
br i1 %11, label %5, label %12
12: ; preds = %5, %1
%13 = phi %struct.triple* [ %2, %1 ], [ %9, %5 ]
ret %struct.triple* %13
}