#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 uc_program {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ uc_program_close(struct uc_program **);
struct uc_program *uc_program_open(char const *);
int uc_state_machine_run(struct uc_program *);
int main(int argc, char const *argv[]) {
  if (argc < 2) {
    printf("ERROR! File must be specified!\n");
    return 1;
  }
  struct uc_program *program = uc_program_open(argv[1]);
  if (program == NULL) {
    printf("ERROR! Something went wrong when reading the file!\n");
    return 1;
  }
  int status = uc_state_machine_run(program);
  uc_program_close(&program);
  return status;
}


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)
cmpl   $0x2,-0x8(%rbp)
jge    1178 <main+0x38>
lea    0xe99(%rip),%rdi
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11c7 <main+0x87>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <uc_program_open@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11ac <main+0x6c>
lea    0xe85(%rip),%rdi
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11c7 <main+0x87>
mov    -0x18(%rbp),%rdi
call   1040 <uc_state_machine_run@plt>
mov    %eax,-0x1c(%rbp)
lea    -0x18(%rbp),%rdi
call   1060 <uc_program_close@plt>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
cmp    $0x1,%edi
jg     1153 <main+0x13>
lea    0xee2(%rip),%rdi
jmp    1183 <main+0x43>
mov    0x8(%rsi),%rdi
call   1050 <uc_program_open@plt>
mov    %rax,0x8(%rsp)
test   %rax,%rax
je     117c <main+0x3c>
mov    %rax,%rdi
call   1040 <uc_state_machine_run@plt>
mov    %eax,%ebx
lea    0x8(%rsp),%rdi
call   1060 <uc_program_close@plt>
jmp    118d <main+0x4d>
lea    0xe7d(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.uc_program = type { i32 }
@.str = [32 x i8] c"ERROR! File must be specified!\0A\00"
@.str.1 = [52 x i8] c"ERROR! Something went wrong when reading the file!\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.uc_program*
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp slt i32 %8, 2
br i1 %9, label %10, label %12
10: ; preds = %2
%11 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %26
12: ; preds = %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
%16 = call %struct.uc_program* @uc_program_open(i8* %15)
store %struct.uc_program* %16, %struct.uc_program** %6
%17 = load %struct.uc_program*, %struct.uc_program** %6
%18 = icmp eq %struct.uc_program* %17, null
br i1 %18, label %19, label %21
19: ; preds = %12
%20 = call i32 @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %3
br label %26
21: ; preds = %12
%22 = load %struct.uc_program*, %struct.uc_program** %6
%23 = call i32 @uc_state_machine_run(%struct.uc_program* %22)
store i32 %23, i32* %7
%24 = call i32 @uc_program_close(%struct.uc_program** %6)
%25 = load i32, i32* %7
store i32 %25, i32* %3
br label %26
26: ; preds = %21, %19, %10
%27 = load i32, i32* %3
ret i32 %27
}

LLVM IR (-O2):
%struct.uc_program = type { i32 }
@str = [51 x i8] c"ERROR! Something went wrong when reading the file!\00"
@str.2 = [31 x i8] c"ERROR! File must be specified!\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.uc_program*
%4 = icmp slt i32 %0, 2
br i1 %4, label %5, label %7
5: ; preds = %2
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str.2, i64 0, i64 0))
br label %20
7: ; preds = %2
%8 = bitcast %struct.uc_program** %3 to i8*
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call %struct.uc_program* @uc_program_open(i8* %10)
store %struct.uc_program* %11, %struct.uc_program** %3
%12 = icmp eq %struct.uc_program* %11, null
br i1 %12, label %13, label %15
13: ; preds = %7
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @str, i64 0, i64 0))
br label %18
15: ; preds = %7
%16 = tail call i32 @uc_state_machine_run(%struct.uc_program* %11)
%17 = call i32 @uc_program_close(%struct.uc_program** %3)
br label %18
18: ; preds = %15, %13
%19 = phi i32 [ 1, %13 ], [ %16, %15 ]
br label %20
20: ; preds = %18, %5
%21 = phi i32 [ 1, %5 ], [ %19, %18 ]
ret i32 %21
}