#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 do_op(int, int, char);
int eval_expr_1(char **);
int my_parse_nbr(char **);
int eval_expr_0(char **ps) {
  int lhs;
  int rhs;
  char op;
  lhs = my_parse_nbr(ps);
  while ((*ps)[0] != '\0' && (*ps)[0] != ')') {
    op = (*ps)[0];
    *ps = *ps + 1;
    if (op == '+' || op == '-')
      rhs = eval_expr_1(ps);
    else
      rhs = my_parse_nbr(ps);
    lhs = do_op(lhs, rhs, op);
  }
  return (lhs);
}


x86 assembly (clang, -O0):
<eval_expr_0>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <my_parse_nbr@plt>
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x12(%rbp)
je     1173 <eval_expr_0+0x43>
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%eax
cmp    $0x29,%eax
setne  %al
mov    %al,-0x12(%rbp)
mov    -0x12(%rbp),%al
test   $0x1,%al
jne    1183 <eval_expr_0+0x53>
jmp    11ef <eval_expr_0+0xbf>
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    (%rax),%al
mov    %al,-0x11(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rcx
add    $0x1,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
movsbl -0x11(%rbp),%eax
cmp    $0x2b,%eax
je     11bb <eval_expr_0+0x8b>
movsbl -0x11(%rbp),%eax
cmp    $0x2d,%eax
jne    11cc <eval_expr_0+0x9c>
mov    -0x8(%rbp),%rdi
call   1040 <eval_expr_1@plt>
mov    %eax,-0x10(%rbp)
jmp    11d8 <eval_expr_0+0xa8>
mov    -0x8(%rbp),%rdi
call   1030 <my_parse_nbr@plt>
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
movsbl -0x11(%rbp),%edx
call   1050 <do_op@plt>
mov    %eax,-0xc(%rbp)
jmp    1148 <eval_expr_0+0x18>
mov    -0xc(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<eval_expr_0>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%rbp
call   1030 <my_parse_nbr@plt>
jmp    1155 <eval_expr_0+0x25>
xchg   %ax,%ax
mov    %rbp,%rdi
call   1040 <eval_expr_1@plt>
mov    %eax,%esi
movsbl %bl,%edx
mov    %r14d,%edi
call   1050 <do_op@plt>
mov    %eax,%r14d
mov    0x0(%rbp),%rax
movzbl (%rax),%ebx
test   %bl,%bl
je     1184 <eval_expr_0+0x54>
cmp    $0x29,%bl
je     1184 <eval_expr_0+0x54>
add    $0x1,%rax
mov    %rax,0x0(%rbp)
cmp    $0x2d,%bl
je     1140 <eval_expr_0+0x10>
cmp    $0x2b,%bl
je     1140 <eval_expr_0+0x10>
mov    %rbp,%rdi
call   1030 <my_parse_nbr@plt>
jmp    1148 <eval_expr_0+0x18>
mov    %r14d,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @eval_expr_0(i8** %0) {
%2 = tail call i32 @my_parse_nbr(i8** %0)
br label %3
3: ; preds = %13, %1
%4 = phi i32 [ %2, %1 ], [ %15, %13 ]
%5 = load i8*, i8** %0
%6 = load i8, i8* %5
switch i8 %6, label %7 [
i8 0, label %16
i8 41, label %16
]
7: ; preds = %3
%8 = getelementptr inbounds i8, i8* %5, i64 1
store i8* %8, i8** %0
switch i8 %6, label %11 [
i8 45, label %9
i8 43, label %9
]
9: ; preds = %7, %7
%10 = tail call i32 @eval_expr_1(i8** %0)
br label %13
11: ; preds = %7
%12 = tail call i32 @my_parse_nbr(i8** %0)
br label %13
13: ; preds = %11, %9
%14 = phi i32 [ %10, %9 ], [ %12, %11 ]
%15 = tail call i32 @do_op(i32 %4, i32 %14, i8 signext %6)
br label %3
16: ; preds = %3, %3
ret i32 %4
}