#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);
struct triple *mk_add_expr(struct compile_state *, struct triple *,
                           struct triple *);
struct triple *mk_sub_expr(struct compile_state *, struct triple *,
                           struct triple *);
struct triple *mult_expr(struct compile_state *);
int peek(struct compile_state *);
struct triple *add_expr(struct compile_state *state) {
  struct triple *def;
  int done;
  def = mult_expr(state);
  do {
    done = 0;
    switch (peek(state)) {
    case 38:
      eat(state, 38);
      def = mk_add_expr(state, def, mult_expr(state));
      break;
    case 39:
      eat(state, 39);
      def = mk_sub_expr(state, def, mult_expr(state));
      break;
    default:
      done = 1;
      break;
    }
  } while (!done);
  return def;
}


x86 assembly (clang, -O0):
<add_expr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1070 <mult_expr@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <peek@plt>
mov    %eax,%ecx
mov    %ecx,-0x18(%rbp)
sub    $0x26,%eax
je     119d <add_expr+0x4d>
jmp    118c <add_expr+0x3c>
mov    -0x18(%rbp),%eax
sub    $0x27,%eax
je     11dd <add_expr+0x8d>
jmp    121d <add_expr+0xcd>
mov    -0x8(%rbp),%rdi
mov    $0x26,%esi
call   1040 <eat@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1070 <mult_expr@plt>
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    %rax,%rdx
call   1060 <mk_add_expr@plt>
mov    %rax,-0x10(%rbp)
jmp    1224 <add_expr+0xd4>
mov    -0x8(%rbp),%rdi
mov    $0x27,%esi
call   1040 <eat@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rdi
call   1070 <mult_expr@plt>
mov    -0x38(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    %rax,%rdx
call   1050 <mk_sub_expr@plt>
mov    %rax,-0x10(%rbp)
jmp    1224 <add_expr+0xd4>
movl   $0x1,-0x14(%rbp)
jmp    1229 <add_expr+0xd9>
cmpl   $0x0,-0x14(%rbp)
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1169 <add_expr+0x19>
mov    -0x10(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<add_expr>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1070 <mult_expr@plt>
jmp    1183 <add_expr+0x33>
xchg   %ax,%ax
mov    %rbx,%rdi
mov    $0x27,%esi
call   1040 <eat@plt>
mov    %rbx,%rdi
call   1070 <mult_expr@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %rax,%rdx
call   1050 <mk_sub_expr@plt>
mov    %rax,%r14
mov    %rbx,%rdi
call   1030 <peek@plt>
cmp    $0x27,%eax
je     1160 <add_expr+0x10>
cmp    $0x26,%eax
jne    11bd <add_expr+0x6d>
mov    %rbx,%rdi
mov    $0x26,%esi
call   1040 <eat@plt>
mov    %rbx,%rdi
call   1070 <mult_expr@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %rax,%rdx
call   1060 <mk_add_expr@plt>
jmp    1183 <add_expr+0x33>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.triple = type { i32 }
%struct.compile_state = type { i32 }
define %struct.triple* @add_expr(%struct.compile_state* %0) {
%2 = alloca %struct.compile_state*
%3 = alloca %struct.triple*
%4 = alloca i32
store %struct.compile_state* %0, %struct.compile_state** %2
%5 = load %struct.compile_state*, %struct.compile_state** %2
%6 = call %struct.triple* @mult_expr(%struct.compile_state* %5)
store %struct.triple* %6, %struct.triple** %3
br label %7
7: ; preds = %28, %1
store i32 0, i32* %4
%8 = load %struct.compile_state*, %struct.compile_state** %2
%9 = call i32 @peek(%struct.compile_state* %8)
switch i32 %9, label %26 [
i32 38, label %10
i32 39, label %18
]
10: ; preds = %7
%11 = load %struct.compile_state*, %struct.compile_state** %2
%12 = call i32 @eat(%struct.compile_state* %11, i32 38)
%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* @mult_expr(%struct.compile_state* %15)
%17 = call %struct.triple* @mk_add_expr(%struct.compile_state* %13, %struct.triple* %14, %struct.triple* %16)
store %struct.triple* %17, %struct.triple** %3
br label %27
18: ; preds = %7
%19 = load %struct.compile_state*, %struct.compile_state** %2
%20 = call i32 @eat(%struct.compile_state* %19, i32 39)
%21 = load %struct.compile_state*, %struct.compile_state** %2
%22 = load %struct.triple*, %struct.triple** %3
%23 = load %struct.compile_state*, %struct.compile_state** %2
%24 = call %struct.triple* @mult_expr(%struct.compile_state* %23)
%25 = call %struct.triple* @mk_sub_expr(%struct.compile_state* %21, %struct.triple* %22, %struct.triple* %24)
store %struct.triple* %25, %struct.triple** %3
br label %27
26: ; preds = %7
store i32 1, i32* %4
br label %27
27: ; preds = %26, %18, %10
br label %28
28: ; preds = %27
%29 = load i32, i32* %4
%30 = icmp ne i32 %29, 0
%31 = xor i1 %30, true
br i1 %31, label %7, label %32
32: ; preds = %28
%33 = load %struct.triple*, %struct.triple** %3
ret %struct.triple* %33
}

LLVM IR (-O2):
%struct.triple = type { i32 }
%struct.compile_state = type { i32 }
define %struct.triple* @add_expr(%struct.compile_state* %0) {
%2 = tail call %struct.triple* @mult_expr(%struct.compile_state* %0)
br label %3
3: ; preds = %10, %1
%4 = phi %struct.triple* [ %2, %1 ], [ %11, %10 ]
%5 = tail call i32 @peek(%struct.compile_state* %0)
switch i32 %5, label %16 [
i32 38, label %6
i32 39, label %12
]
6: ; preds = %3
%7 = tail call i32 @eat(%struct.compile_state* %0, i32 38)
%8 = tail call %struct.triple* @mult_expr(%struct.compile_state* %0)
%9 = tail call %struct.triple* @mk_add_expr(%struct.compile_state* %0, %struct.triple* %4, %struct.triple* %8)
br label %10
10: ; preds = %6, %12
%11 = phi %struct.triple* [ %15, %12 ], [ %9, %6 ]
br label %3
12: ; preds = %3
%13 = tail call i32 @eat(%struct.compile_state* %0, i32 39)
%14 = tail call %struct.triple* @mult_expr(%struct.compile_state* %0)
%15 = tail call %struct.triple* @mk_sub_expr(%struct.compile_state* %0, %struct.triple* %4, %struct.triple* %14)
br label %10
16: ; preds = %3
ret %struct.triple* %4
}