#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 evaluate(char *, long);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int, int);
int /*<<< orphan*/ free(char *);
char *read_file(char *, long *);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  int rc = 0;
  long int plen;
  char *buf = NULL;
  if (argc != 2) {
    fprintf(stderr, "Arguments found: %d, required: %d\n", argc, 2);
    return 1;
  }
  buf = read_file(argv[1], &plen);
  if (!buf) {
    return 2;
  }
  rc = evaluate(buf, plen);
  free(buf);
  return rc;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movq   $0x0,-0x28(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     1198 <main+0x58>
mov    0x2e6a(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%edx
lea    0xe7e(%rip),%rsi
mov    $0x2,%ecx
call   1040 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11e3 <main+0xa3>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x20(%rbp),%rsi
call   1050 <read_file@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    11c4 <main+0x84>
movl   $0x2,-0x4(%rbp)
jmp    11e3 <main+0xa3>
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1060 <evaluate@plt>
mov    %eax,-0x14(%rbp)
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
cmp    $0x2,%edi
jne    1175 <main+0x35>
mov    0x8(%rsi),%rdi
mov    %rsp,%rsi
call   1050 <read_file@plt>
test   %rax,%rax
je     1198 <main+0x58>
mov    %rax,%r14
mov    (%rsp),%rsi
mov    %rax,%rdi
call   1060 <evaluate@plt>
mov    %eax,%ebx
mov    %r14,%rdi
call   1030 <free@plt>
jmp    119d <main+0x5d>
mov    %edi,%edx
mov    0x2e62(%rip),%rax
mov    (%rax),%edi
lea    0xe79(%rip),%rsi
mov    $0x2,%ecx
call   1040 <fprintf@plt>
mov    $0x1,%ebx
jmp    119d <main+0x5d>
mov    $0x2,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
@stderr = global i32 0
@.str = [35 x i8] c"Arguments found: %d, required: %d\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i64
%4 = bitcast i64* %3 to i8*
%5 = icmp eq i32 %0, 2
br i1 %5, label %9, label %6
6: ; preds = %2
%7 = load i32, i32* @stderr
%8 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i32 %0, i32 2)
br label %18
9: ; preds = %2
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = call i8* @read_file(i8* %11, i64* %3)
%13 = icmp eq i8* %12, null
br i1 %13, label %18, label %14
14: ; preds = %9
%15 = load i64, i64* %3
%16 = call i32 @evaluate(i8* %12, i64 %15)
%17 = call i32 @free(i8* %12)
br label %18
18: ; preds = %9, %14, %6
%19 = phi i32 [ 1, %6 ], [ %16, %14 ], [ 2, %9 ]
ret i32 %19
}