#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 ev_input {
  int dummy;
};
typedef int int64_t;

/* Variables and functions */
char ev_getc(struct ev_input *);
char ev_peekc(struct ev_input *);
int eval_factor(struct ev_input *);
int64_t eval_term(struct ev_input *e) {
  int64_t v0, v1;
  char op;
  v0 = eval_factor(e);
  while (ev_peekc(e) == '*' || ev_peekc(e) == '/' || ev_peekc(e) == '&') {
    op = ev_getc(e);
    v1 = eval_factor(e);
    if (op == '*')
      v0 = v0 * v1;
    else if (op == '&')
      v0 = v0 & v1;
    else
      v0 = v0 / v1;
  }
  return v0;
}


x86 assembly (clang, -O0):
<eval_term>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <eval_factor@plt>
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <ev_peekc@plt>
movsbl %al,%ecx
mov    $0x1,%al
cmp    $0x2a,%ecx
mov    %al,-0x12(%rbp)
je     1191 <eval_term+0x61>
mov    -0x8(%rbp),%rdi
call   1050 <ev_peekc@plt>
movsbl %al,%ecx
mov    $0x1,%al
cmp    $0x2f,%ecx
mov    %al,-0x12(%rbp)
je     1191 <eval_term+0x61>
mov    -0x8(%rbp),%rdi
call   1050 <ev_peekc@plt>
movsbl %al,%eax
cmp    $0x26,%eax
sete   %al
mov    %al,-0x12(%rbp)
mov    -0x12(%rbp),%al
test   $0x1,%al
jne    11a1 <eval_term+0x71>
jmp    1204 <eval_term+0xd4>
mov    -0x8(%rbp),%rdi
call   1030 <ev_getc@plt>
mov    %al,-0x11(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <eval_factor@plt>
mov    %eax,-0x10(%rbp)
movsbl -0x11(%rbp),%eax
cmp    $0x2a,%eax
jne    11d5 <eval_term+0xa5>
mov    -0xc(%rbp),%eax
imul   -0x10(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    11ff <eval_term+0xcf>
movsbl -0x11(%rbp),%eax
cmp    $0x26,%eax
jne    11f0 <eval_term+0xc0>
mov    -0xc(%rbp),%eax
and    -0x10(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    11fa <eval_term+0xca>
mov    -0xc(%rbp),%eax
cltd
idivl  -0x10(%rbp)
mov    %eax,-0xc(%rbp)
jmp    11ff <eval_term+0xcf>
jmp    1148 <eval_term+0x18>
mov    -0xc(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<eval_term>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%rbp
call   1040 <eval_factor@plt>
jmp    1146 <eval_term+0x16>
xchg   %ax,%ax
mov    %r14d,%eax
cltd
idiv   %ecx
mov    %eax,%r14d
mov    %rbp,%rdi
call   1050 <ev_peekc@plt>
cmp    $0x2a,%al
je     116d <eval_term+0x3d>
mov    %rbp,%rdi
call   1050 <ev_peekc@plt>
cmp    $0x2f,%al
je     116d <eval_term+0x3d>
mov    %rbp,%rdi
call   1050 <ev_peekc@plt>
cmp    $0x26,%al
jne    11a5 <eval_term+0x75>
mov    %rbp,%rdi
call   1030 <ev_getc@plt>
mov    %eax,%ebx
mov    %rbp,%rdi
call   1040 <eval_factor@plt>
mov    %eax,%ecx
cmp    $0x26,%bl
je     11a0 <eval_term+0x70>
cmp    $0x2a,%bl
jne    1140 <eval_term+0x10>
imul   %ecx,%r14d
jmp    1149 <eval_term+0x19>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
and    %ecx,%r14d
jmp    1149 <eval_term+0x19>
mov    %r14d,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.ev_input = type { i32 }
define i32 @eval_term(%struct.ev_input* %0) {
%2 = alloca %struct.ev_input*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8
store %struct.ev_input* %0, %struct.ev_input** %2
%6 = load %struct.ev_input*, %struct.ev_input** %2
%7 = call i32 @eval_factor(%struct.ev_input* %6)
store i32 %7, i32* %3
br label %8
8: ; preds = %50, %1
%9 = load %struct.ev_input*, %struct.ev_input** %2
%10 = call signext i8 @ev_peekc(%struct.ev_input* %9)
%11 = sext i8 %10 to i32
%12 = icmp eq i32 %11, 42
br i1 %12, label %23, label %13
13: ; preds = %8
%14 = load %struct.ev_input*, %struct.ev_input** %2
%15 = call signext i8 @ev_peekc(%struct.ev_input* %14)
%16 = sext i8 %15 to i32
%17 = icmp eq i32 %16, 47
br i1 %17, label %23, label %18
18: ; preds = %13
%19 = load %struct.ev_input*, %struct.ev_input** %2
%20 = call signext i8 @ev_peekc(%struct.ev_input* %19)
%21 = sext i8 %20 to i32
%22 = icmp eq i32 %21, 38
br label %23
23: ; preds = %18, %13, %8
%24 = phi i1 [ true, %13 ], [ true, %8 ], [ %22, %18 ]
br i1 %24, label %25, label %51
25: ; preds = %23
%26 = load %struct.ev_input*, %struct.ev_input** %2
%27 = call signext i8 @ev_getc(%struct.ev_input* %26)
store i8 %27, i8* %5
%28 = load %struct.ev_input*, %struct.ev_input** %2
%29 = call i32 @eval_factor(%struct.ev_input* %28)
store i32 %29, i32* %4
%30 = load i8, i8* %5
%31 = sext i8 %30 to i32
%32 = icmp eq i32 %31, 42
br i1 %32, label %33, label %37
33: ; preds = %25
%34 = load i32, i32* %3
%35 = load i32, i32* %4
%36 = mul nsw i32 %34, %35
store i32 %36, i32* %3
br label %50
37: ; preds = %25
%38 = load i8, i8* %5
%39 = sext i8 %38 to i32
%40 = icmp eq i32 %39, 38
br i1 %40, label %41, label %45
41: ; preds = %37
%42 = load i32, i32* %3
%43 = load i32, i32* %4
%44 = and i32 %42, %43
store i32 %44, i32* %3
br label %49
45: ; preds = %37
%46 = load i32, i32* %3
%47 = load i32, i32* %4
%48 = sdiv i32 %46, %47
store i32 %48, i32* %3
br label %49
49: ; preds = %45, %41
br label %50
50: ; preds = %49, %33
br label %8
51: ; preds = %23
%52 = load i32, i32* %3
ret i32 %52
}

LLVM IR (-O2):
%struct.ev_input = type { i32 }
define i32 @eval_term(%struct.ev_input* %0) {
%2 = tail call i32 @eval_factor(%struct.ev_input* %0)
br label %3
3: ; preds = %20, %1
%4 = phi i32 [ %2, %1 ], [ %21, %20 ]
%5 = tail call signext i8 @ev_peekc(%struct.ev_input* %0)
%6 = icmp eq i8 %5, 42
br i1 %6, label %13, label %7
7: ; preds = %3
%8 = tail call signext i8 @ev_peekc(%struct.ev_input* %0)
%9 = icmp eq i8 %8, 47
br i1 %9, label %13, label %10
10: ; preds = %7
%11 = tail call signext i8 @ev_peekc(%struct.ev_input* %0)
%12 = icmp eq i8 %11, 38
br i1 %12, label %13, label %24
13: ; preds = %3, %7, %10
%14 = tail call signext i8 @ev_getc(%struct.ev_input* %0)
%15 = tail call i32 @eval_factor(%struct.ev_input* %0)
switch i8 %14, label %22 [
i8 42, label %16
i8 38, label %18
]
16: ; preds = %13
%17 = mul nsw i32 %15, %4
br label %20
18: ; preds = %13
%19 = and i32 %15, %4
br label %20
20: ; preds = %18, %22, %16
%21 = phi i32 [ %17, %16 ], [ %19, %18 ], [ %23, %22 ]
br label %3
22: ; preds = %13
%23 = sdiv i32 %4, %15
br label %20
24: ; preds = %10
ret i32 %4
}