#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 eval(char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ repl();
scalar_t__ strcmp(char *, char *);
int main(int argc, char **argv) {
  if (argc == 3 && strcmp(argv[1], "-e") == 0) {
    if (eval(argv[2]) == -1) {
      return 1;
    } else {
      return 0;
    }
  } else if (argc == 1) {
    repl();
    return 0;
  } else {
    printf("Usage: %s\n", argv[0]);
    printf("       %s -e <expression>\n", argv[0]);
    return 1;
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
jne    11ac <main+0x6c>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe91(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    11ac <main+0x6c>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1060 <eval@plt>
cmp    $0xffffffff,%eax
jne    11a0 <main+0x60>
movl   $0x1,-0x4(%rbp)
jmp    11f6 <main+0xb6>
movl   $0x0,-0x4(%rbp)
jmp    11f6 <main+0xb6>
cmpl   $0x1,-0x8(%rbp)
jne    11c9 <main+0x89>
mov    $0x0,%al
call   1030 <repl@plt>
movl   $0x0,-0x4(%rbp)
jmp    11f6 <main+0xb6>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe2c(%rip),%rdi
call   1040 <printf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe24(%rip),%rdi
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
cmp    $0x1,%edi
je     1188 <main+0x48>
mov    %rsi,%rbx
cmp    $0x3,%edi
jne    1163 <main+0x23>
mov    0x8(%rbx),%rdi
lea    0xea7(%rip),%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     1193 <main+0x53>
mov    (%rbx),%rsi
lea    0xe96(%rip),%rdi
call   1040 <printf@plt>
mov    (%rbx),%rsi
lea    0xe92(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%ebx
jmp    11a4 <main+0x64>
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <repl@plt>
jmp    11a4 <main+0x64>
mov    0x10(%rbx),%rdi
call   1060 <eval@plt>
xor    %ebx,%ebx
cmp    $0xffffffff,%eax
sete   %bl
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [3 x i8] c"-e\00"
@.str.1 = [11 x i8] c"Usage: %s\0A\00"
@.str.2 = [27 x i8] c" %s -e <expression>\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%6 = load i32, i32* %4
%7 = icmp eq i32 %6, 3
br i1 %7, label %8, label %22
8: ; preds = %2
%9 = load i8**, i8*** %5
%10 = getelementptr inbounds i8*, i8** %9, i64 1
%11 = load i8*, i8** %10
%12 = call i64 @strcmp(i8* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %22
14: ; preds = %8
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 2
%17 = load i8*, i8** %16
%18 = call i32 @eval(i8* %17)
%19 = icmp eq i32 %18, -1
br i1 %19, label %20, label %21
20: ; preds = %14
store i32 1, i32* %3
br label %36
21: ; preds = %14
store i32 0, i32* %3
br label %36
22: ; preds = %8, %2
%23 = load i32, i32* %4
%24 = icmp eq i32 %23, 1
br i1 %24, label %25, label %27
25: ; preds = %22
%26 = call i32 (...) @repl()
store i32 0, i32* %3
br label %36
27: ; preds = %22
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 0
%30 = load i8*, i8** %29
%31 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* %30)
%32 = load i8**, i8*** %5
%33 = getelementptr inbounds i8*, i8** %32, i64 0
%34 = load i8*, i8** %33
%35 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i8* %34)
store i32 1, i32* %3
br label %36
36: ; preds = %27, %25, %21, %20
%37 = load i32, i32* %3
ret i32 %37
}

LLVM IR (-O2):
@.str = [3 x i8] c"-e\00"
@.str.1 = [11 x i8] c"Usage: %s\0A\00"
@.str.2 = [27 x i8] c" %s -e <expression>\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
switch i32 %0, label %16 [
i32 3, label %3
i32 1, label %14
]
3: ; preds = %2
%4 = getelementptr inbounds i8*, i8** %1, i64 1
%5 = load i8*, i8** %4
%6 = tail call i64 @strcmp(i8* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %16
8: ; preds = %3
%9 = getelementptr inbounds i8*, i8** %1, i64 2
%10 = load i8*, i8** %9
%11 = tail call i32 @eval(i8* %10)
%12 = icmp eq i32 %11, -1
%13 = zext i1 %12 to i32
br label %21
14: ; preds = %2
%15 = tail call i32 (...) @repl()
br label %21
16: ; preds = %3, %2
%17 = load i8*, i8** %1
%18 = tail call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* %17)
%19 = load i8*, i8** %1
%20 = tail call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i8* %19)
br label %21
21: ; preds = %8, %16, %14
%22 = phi i32 [ 0, %14 ], [ 1, %16 ], [ %13, %8 ]
ret i32 %22
}