#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 /*<<< orphan*/ int64_t;

/* Variables and functions */
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ ev_getc(struct ev_input *);
char ev_peekc(struct ev_input *);
int /*<<< orphan*/ ev_strtoll(struct ev_input *);
int /*<<< orphan*/ eval_expr(struct ev_input *);
scalar_t__ isdigit(char);
int64_t eval_factor(struct ev_input *e) {
  int64_t v;
  if (isdigit(ev_peekc(e))) {
    v = ev_strtoll(e);
  } else if (ev_peekc(e) == '-') {
    ev_getc(e);
    v = -ev_strtoll(e);
  } else if (ev_peekc(e) == '(') {
    ev_getc(e);
    v = eval_expr(e);
    assert(ev_peekc(e) == ')');
    ev_getc(e);
  } else {
    assert(0);
  }
  return v;
}


x86 assembly (clang, -O0):
<eval_factor>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <ev_peekc@plt>
movsbl %al,%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
je     1198 <eval_factor+0x38>
mov    -0x8(%rbp),%rdi
call   1060 <ev_strtoll@plt>
mov    %eax,-0xc(%rbp)
jmp    1232 <eval_factor+0xd2>
mov    -0x8(%rbp),%rdi
call   1050 <ev_peekc@plt>
movsbl %al,%eax
cmp    $0x2d,%eax
jne    11cd <eval_factor+0x6d>
mov    -0x8(%rbp),%rdi
call   1040 <ev_getc@plt>
mov    -0x8(%rbp),%rdi
call   1060 <ev_strtoll@plt>
mov    %eax,%ecx
xor    %eax,%eax
sub    %ecx,%eax
mov    %eax,-0xc(%rbp)
jmp    122d <eval_factor+0xcd>
mov    -0x8(%rbp),%rdi
call   1050 <ev_peekc@plt>
movsbl %al,%eax
cmp    $0x28,%eax
jne    1221 <eval_factor+0xc1>
mov    -0x8(%rbp),%rdi
call   1040 <ev_getc@plt>
mov    -0x8(%rbp),%rdi
call   1080 <eval_expr@plt>
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <ev_peekc@plt>
movsbl %al,%eax
cmp    $0x29,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
mov    -0x8(%rbp),%rdi
call   1040 <ev_getc@plt>
jmp    1228 <eval_factor+0xc8>
xor    %edi,%edi
call   1070 <assert@plt>
jmp    122d <eval_factor+0xcd>
jmp    1232 <eval_factor+0xd2>
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<eval_factor>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1050 <ev_peekc@plt>
movsbl %al,%edi
call   1030 <isdigit@plt>
test   %rax,%rax
je     1186 <eval_factor+0x26>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1060 <ev_strtoll@plt>
mov    %rbx,%rdi
call   1050 <ev_peekc@plt>
mov    %rbx,%rdi
cmp    $0x2d,%al
jne    11a6 <eval_factor+0x46>
call   1040 <ev_getc@plt>
mov    %rbx,%rdi
call   1060 <ev_strtoll@plt>
neg    %eax
jmp    11e9 <eval_factor+0x89>
call   1050 <ev_peekc@plt>
cmp    $0x28,%al
jne    11e2 <eval_factor+0x82>
mov    %rbx,%rdi
call   1040 <ev_getc@plt>
mov    %rbx,%rdi
call   1080 <eval_expr@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1050 <ev_peekc@plt>
xor    %edi,%edi
cmp    $0x29,%al
sete   %dil
call   1070 <assert@plt>
mov    %rbx,%rdi
call   1040 <ev_getc@plt>
mov    %ebp,%eax
jmp    11e9 <eval_factor+0x89>
xor    %edi,%edi
call   1070 <assert@plt>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.ev_input = type { i32 }
define i32 @eval_factor(%struct.ev_input* %0) {
%2 = alloca %struct.ev_input*
%3 = alloca i32
store %struct.ev_input* %0, %struct.ev_input** %2
%4 = load %struct.ev_input*, %struct.ev_input** %2
%5 = call signext i8 @ev_peekc(%struct.ev_input* %4)
%6 = call i64 @isdigit(i8 signext %5)
%7 = icmp ne i64 %6, 0
br i1 %7, label %8, label %11
8: ; preds = %1
%9 = load %struct.ev_input*, %struct.ev_input** %2
%10 = call i32 @ev_strtoll(%struct.ev_input* %9)
store i32 %10, i32* %3
br label %44
11: ; preds = %1
%12 = load %struct.ev_input*, %struct.ev_input** %2
%13 = call signext i8 @ev_peekc(%struct.ev_input* %12)
%14 = sext i8 %13 to i32
%15 = icmp eq i32 %14, 45
br i1 %15, label %16, label %22
16: ; preds = %11
%17 = load %struct.ev_input*, %struct.ev_input** %2
%18 = call i32 @ev_getc(%struct.ev_input* %17)
%19 = load %struct.ev_input*, %struct.ev_input** %2
%20 = call i32 @ev_strtoll(%struct.ev_input* %19)
%21 = sub nsw i32 0, %20
store i32 %21, i32* %3
br label %43
22: ; preds = %11
%23 = load %struct.ev_input*, %struct.ev_input** %2
%24 = call signext i8 @ev_peekc(%struct.ev_input* %23)
%25 = sext i8 %24 to i32
%26 = icmp eq i32 %25, 40
br i1 %26, label %27, label %40
27: ; preds = %22
%28 = load %struct.ev_input*, %struct.ev_input** %2
%29 = call i32 @ev_getc(%struct.ev_input* %28)
%30 = load %struct.ev_input*, %struct.ev_input** %2
%31 = call i32 @eval_expr(%struct.ev_input* %30)
store i32 %31, i32* %3
%32 = load %struct.ev_input*, %struct.ev_input** %2
%33 = call signext i8 @ev_peekc(%struct.ev_input* %32)
%34 = sext i8 %33 to i32
%35 = icmp eq i32 %34, 41
%36 = zext i1 %35 to i32
%37 = call i32 @assert(i32 %36)
%38 = load %struct.ev_input*, %struct.ev_input** %2
%39 = call i32 @ev_getc(%struct.ev_input* %38)
br label %42
40: ; preds = %22
%41 = call i32 @assert(i32 0)
br label %42
42: ; preds = %40, %27
br label %43
43: ; preds = %42, %16
br label %44
44: ; preds = %43, %8
%45 = load i32, i32* %3
ret i32 %45
}

LLVM IR (-O2):
%struct.ev_input = type { i32 }
define i32 @eval_factor(%struct.ev_input* %0) {
%2 = tail call signext i8 @ev_peekc(%struct.ev_input* %0)
%3 = tail call i64 @isdigit(i8 signext %2)
%4 = icmp eq i64 %3, 0
br i1 %4, label %7, label %5
5: ; preds = %1
%6 = tail call i32 @ev_strtoll(%struct.ev_input* %0)
br label %27
7: ; preds = %1
%8 = tail call signext i8 @ev_peekc(%struct.ev_input* %0)
%9 = icmp eq i8 %8, 45
br i1 %9, label %10, label %14
10: ; preds = %7
%11 = tail call i32 @ev_getc(%struct.ev_input* %0)
%12 = tail call i32 @ev_strtoll(%struct.ev_input* %0)
%13 = sub nsw i32 0, %12
br label %27
14: ; preds = %7
%15 = tail call signext i8 @ev_peekc(%struct.ev_input* %0)
%16 = icmp eq i8 %15, 40
br i1 %16, label %17, label %25
17: ; preds = %14
%18 = tail call i32 @ev_getc(%struct.ev_input* %0)
%19 = tail call i32 @eval_expr(%struct.ev_input* %0)
%20 = tail call signext i8 @ev_peekc(%struct.ev_input* %0)
%21 = icmp eq i8 %20, 41
%22 = zext i1 %21 to i32
%23 = tail call i32 @assert(i32 %22)
%24 = tail call i32 @ev_getc(%struct.ev_input* %0)
br label %27
25: ; preds = %14
%26 = tail call i32 @assert(i32 0)
br label %27
27: ; preds = %10, %25, %17, %5
%28 = phi i32 [ %6, %5 ], [ %13, %10 ], [ %19, %17 ], [ undef, %25 ]
ret i32 %28
}