#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 */

/* Variables and functions */
char get();
char peek();
int term();
int expression() {
  int result = term();
  while (peek() == '+' || peek() == '-')
    if (get() == '+')
      result += term();
    else
      result -= term();
  return result;
}


x86 assembly (clang, -O0):
<expression>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1040 <term@plt>
mov    %eax,-0x4(%rbp)
mov    $0x0,%al
call   1030 <peek@plt>
movsbl %al,%ecx
mov    $0x1,%al
cmp    $0x2b,%ecx
mov    %al,-0x5(%rbp)
je     116d <expression+0x3d>
mov    $0x0,%al
call   1030 <peek@plt>
movsbl %al,%eax
cmp    $0x2d,%eax
sete   %al
mov    %al,-0x5(%rbp)
mov    -0x5(%rbp),%al
test   $0x1,%al
jne    117d <expression+0x4d>
jmp    11b8 <expression+0x88>
mov    $0x0,%al
call   1050 <get@plt>
movsbl %al,%eax
cmp    $0x2b,%eax
jne    11a2 <expression+0x72>
mov    $0x0,%al
call   1040 <term@plt>
add    -0x4(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11b3 <expression+0x83>
mov    $0x0,%al
call   1040 <term@plt>
mov    %eax,%ecx
mov    -0x4(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x4(%rbp)
jmp    1142 <expression+0x12>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<expression>:
push   %rbp
push   %rbx
push   %rax
xor    %eax,%eax
call   1040 <term@plt>
mov    %eax,%ebp
jmp    115c <expression+0x2c>
xchg   %ax,%ax
xor    %eax,%eax
call   1050 <get@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1040 <term@plt>
mov    %eax,%ecx
neg    %ecx
cmp    $0x2b,%bl
cmove  %eax,%ecx
add    %ecx,%ebp
xor    %eax,%eax
call   1030 <peek@plt>
cmp    $0x2b,%al
je     1140 <expression+0x10>
xor    %eax,%eax
call   1030 <peek@plt>
cmp    $0x2d,%al
je     1140 <expression+0x10>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @expression() {
%1 = alloca i32
%2 = call i32 (...) @term()
store i32 %2, i32* %1
br label %3
3: ; preds = %25, %0
%4 = call signext i8 (...) @peek()
%5 = sext i8 %4 to i32
%6 = icmp eq i32 %5, 43
br i1 %6, label %11, label %7
7: ; preds = %3
%8 = call signext i8 (...) @peek()
%9 = sext i8 %8 to i32
%10 = icmp eq i32 %9, 45
br label %11
11: ; preds = %7, %3
%12 = phi i1 [ true, %3 ], [ %10, %7 ]
br i1 %12, label %13, label %26
13: ; preds = %11
%14 = call signext i8 (...) @get()
%15 = sext i8 %14 to i32
%16 = icmp eq i32 %15, 43
br i1 %16, label %17, label %21
17: ; preds = %13
%18 = call i32 (...) @term()
%19 = load i32, i32* %1
%20 = add nsw i32 %19, %18
store i32 %20, i32* %1
br label %25
21: ; preds = %13
%22 = call i32 (...) @term()
%23 = load i32, i32* %1
%24 = sub nsw i32 %23, %22
store i32 %24, i32* %1
br label %25
25: ; preds = %21, %17
br label %3
26: ; preds = %11
%27 = load i32, i32* %1
ret i32 %27
}

LLVM IR (-O2):
define i32 @expression() {
%1 = tail call i32 (...) @term()
br label %2
2: ; preds = %9, %0
%3 = phi i32 [ %1, %0 ], [ %15, %9 ]
%4 = tail call signext i8 (...) @peek()
%5 = icmp eq i8 %4, 43
br i1 %5, label %9, label %6
6: ; preds = %2
%7 = tail call signext i8 (...) @peek()
%8 = icmp eq i8 %7, 45
br i1 %8, label %9, label %16
9: ; preds = %2, %6
%10 = tail call signext i8 (...) @get()
%11 = icmp eq i8 %10, 43
%12 = tail call i32 (...) @term()
%13 = sub i32 0, %12
%14 = select i1 %11, i32 %12, i32 %13
%15 = add i32 %3, %14
br label %2
16: ; preds = %6
ret i32 %3
}