#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 */
int factor();
char get();
char peek();
int term() {
  int result = factor();
  while (peek() == '*' || peek() == '/')
    if (get() == '*')
      result *= factor();
    else
      result /= factor();
  return result;
}


x86 assembly (clang, -O0):
<term>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1050 <factor@plt>
mov    %eax,-0x4(%rbp)
mov    $0x0,%al
call   1030 <peek@plt>
movsbl %al,%ecx
mov    $0x1,%al
cmp    $0x2a,%ecx
mov    %al,-0x5(%rbp)
je     116d <term+0x3d>
mov    $0x0,%al
call   1030 <peek@plt>
movsbl %al,%eax
cmp    $0x2f,%eax
sete   %al
mov    %al,-0x5(%rbp)
mov    -0x5(%rbp),%al
test   $0x1,%al
jne    117d <term+0x4d>
jmp    11ba <term+0x8a>
mov    $0x0,%al
call   1040 <get@plt>
movsbl %al,%eax
cmp    $0x2a,%eax
jne    11a3 <term+0x73>
mov    $0x0,%al
call   1050 <factor@plt>
imul   -0x4(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11b5 <term+0x85>
mov    $0x0,%al
call   1050 <factor@plt>
mov    %eax,%ecx
mov    -0x4(%rbp),%eax
cltd
idiv   %ecx
mov    %eax,-0x4(%rbp)
jmp    1142 <term+0x12>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<term>:
push   %rbp
push   %rbx
push   %rax
xor    %eax,%eax
call   1050 <factor@plt>
jmp    1145 <term+0x15>
nopl   0x0(%rax)
mov    %ebp,%eax
cltd
idiv   %ecx
mov    %eax,%ebp
xor    %eax,%eax
call   1030 <peek@plt>
cmp    $0x2a,%al
je     115d <term+0x2d>
xor    %eax,%eax
call   1030 <peek@plt>
cmp    $0x2f,%al
jne    1179 <term+0x49>
xor    %eax,%eax
call   1040 <get@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1050 <factor@plt>
mov    %eax,%ecx
cmp    $0x2a,%bl
jne    1140 <term+0x10>
imul   %ecx,%ebp
jmp    1147 <term+0x17>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @term() {
%1 = alloca i32
%2 = call i32 (...) @factor()
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, 42
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, 47
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, 42
br i1 %16, label %17, label %21
17: ; preds = %13
%18 = call i32 (...) @factor()
%19 = load i32, i32* %1
%20 = mul nsw i32 %19, %18
store i32 %20, i32* %1
br label %25
21: ; preds = %13
%22 = call i32 (...) @factor()
%23 = load i32, i32* %1
%24 = sdiv 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 @term() {
%1 = tail call i32 (...) @factor()
br label %2
2: ; preds = %17, %0
%3 = phi i32 [ %1, %0 ], [ %18, %17 ]
%4 = tail call signext i8 (...) @peek()
%5 = icmp eq i8 %4, 42
br i1 %5, label %9, label %6
6: ; preds = %2
%7 = tail call signext i8 (...) @peek()
%8 = icmp eq i8 %7, 47
br i1 %8, label %9, label %19
9: ; preds = %2, %6
%10 = tail call signext i8 (...) @get()
%11 = icmp eq i8 %10, 42
%12 = tail call i32 (...) @factor()
br i1 %11, label %13, label %15
13: ; preds = %9
%14 = mul nsw i32 %12, %3
br label %17
15: ; preds = %9
%16 = sdiv i32 %3, %12
br label %17
17: ; preds = %15, %13
%18 = phi i32 [ %14, %13 ], [ %16, %15 ]
br label %2
19: ; preds = %6
ret i32 %3
}