#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 INT_MAX;
int evaluate(char const *);
int /*<<< orphan*/ printf(char *, char const *, ...);
int /*<<< orphan*/ usage();
int main(int argc, const char *argv[]) {
  int val = 0;
  if (argc < 2) {
    usage();
    return -1;
  }
  val = evaluate(argv[1]);
  if (val == INT_MAX) {
    printf("Invalid expression %s\n", argv[1]);
    return -1;
  }
  printf("%s = %d\n", argv[1], val);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    116a <main+0x3a>
mov    $0x0,%al
call   1050 <usage@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11ce <main+0x9e>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1040 <evaluate@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    0x2e64(%rip),%rcx
cmp    (%rcx),%eax
jne    11ae <main+0x7e>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe65(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11ce <main+0x9e>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
mov    -0x14(%rbp),%edx
lea    0xe57(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
cmp    $0x1,%edi
jg     1144 <main+0x14>
xor    %eax,%eax
call   1050 <usage@plt>
mov    $0xffffffff,%ebx
jmp    1186 <main+0x56>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
call   1040 <evaluate@plt>
mov    0x2e91(%rip),%rcx
mov    0x8(%rbx),%rsi
cmp    (%rcx),%eax
jne    1174 <main+0x44>
lea    0xe9a(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0xffffffff,%ebx
jmp    1186 <main+0x56>
lea    0xe9c(%rip),%rdi
xor    %ebx,%ebx
mov    %eax,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@INT_MAX = global i32 0
@.str = [23 x i8] c"Invalid expression %s\0A\00"
@.str.1 = [9 x i8] c"%s = %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
%7 = load i32, i32* %4
%8 = icmp slt i32 %7, 2
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = call i32 (...) @usage()
store i32 -1, i32* %3
br label %30
11: ; preds = %2
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 1
%14 = load i8*, i8** %13
%15 = call i32 @evaluate(i8* %14)
store i32 %15, i32* %6
%16 = load i32, i32* %6
%17 = load i32, i32* @INT_MAX
%18 = icmp eq i32 %16, %17
br i1 %18, label %19, label %24
19: ; preds = %11
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 1
%22 = load i8*, i8** %21
%23 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %22)
store i32 -1, i32* %3
br label %30
24: ; preds = %11
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 1
%27 = load i8*, i8** %26
%28 = load i32, i32* %6
%29 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* %27, i32 %28)
store i32 0, i32* %3
br label %30
30: ; preds = %24, %19, %9
%31 = load i32, i32* %3
ret i32 %31
}

LLVM IR (-O2):
@INT_MAX = global i32 0
@.str = [23 x i8] c"Invalid expression %s\0A\00"
@.str.1 = [9 x i8] c"%s = %d\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 (...) @usage()
br label %17
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i32 @evaluate(i8* %8)
%10 = load i32, i32* @INT_MAX
%11 = icmp eq i32 %9, %10
%12 = load i8*, i8** %7
br i1 %11, label %13, label %15
13: ; preds = %6
%14 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %12)
br label %17
15: ; preds = %6
%16 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* %12, i32 %9)
br label %17
17: ; preds = %15, %13, %4
%18 = phi i32 [ -1, %4 ], [ -1, %13 ], [ 0, %15 ]
ret i32 %18
}