#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 EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ dump(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int open_eeprom(char *);
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  int fd;
  if (argc < 2 || !*argv[1]) {
    fprintf(stderr, "Please give path to eeprom file as first argument\n");
    return EXIT_FAILURE;
  }
  fd = open_eeprom(argv[1]);
  if (fd >= 0) {
    dump(fd);
    close(fd);
  } else {
    return EXIT_FAILURE;
  }
  return EXIT_SUCCESS;
}


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)
jl     1171 <main+0x31>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
cmpb   $0x0,(%rax)
jne    1197 <main+0x57>
mov    0x2e68(%rip),%rax
mov    (%rax),%edi
lea    0xe7f(%rip),%rsi
call   1060 <fprintf@plt>
mov    0x2e4b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11e3 <main+0xa3>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1030 <open_eeprom@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jl     11c6 <main+0x86>
mov    -0x14(%rbp),%edi
call   1050 <dump@plt>
mov    -0x14(%rbp),%edi
call   1040 <close@plt>
jmp    11d7 <main+0x97>
mov    0x2e0b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11e3 <main+0xa3>
mov    0x2df2(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
cmp    $0x2,%edi
jl     1171 <main+0x31>
mov    0x8(%rsi),%rdi
cmpb   $0x0,(%rdi)
je     1171 <main+0x31>
call   1030 <open_eeprom@plt>
test   %eax,%eax
js     1186 <main+0x46>
mov    %eax,%ebx
mov    %eax,%edi
call   1050 <dump@plt>
mov    %ebx,%edi
call   1040 <close@plt>
mov    0x2e61(%rip),%rax
jmp    118d <main+0x4d>
mov    0x2e68(%rip),%rax
mov    (%rax),%edi
lea    0xe7f(%rip),%rsi
call   1060 <fprintf@plt>
mov    0x2e4b(%rip),%rax
mov    (%rax),%eax
pop    %rbx
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [51 x i8] c"Please give path to eeprom file as first argument\0A\00"
@EXIT_FAILURE = global i32 0
@EXIT_SUCCESS = global i32 0
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
%7 = load i32, i32* %4
%8 = icmp slt i32 %7, 2
br i1 %8, label %15, label %9
9: ; preds = %2
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i64 1
%12 = load i8*, i8** %11
%13 = load i8, i8* %12
%14 = icmp ne i8 %13, 0
br i1 %14, label %19, label %15
15: ; preds = %9, %2
%16 = load i32, i32* @stderr
%17 = call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0))
%18 = load i32, i32* @EXIT_FAILURE
store i32 %18, i32* %3
br label %35
19: ; preds = %9
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 1
%22 = load i8*, i8** %21
%23 = call i32 @open_eeprom(i8* %22)
store i32 %23, i32* %6
%24 = load i32, i32* %6
%25 = icmp sge i32 %24, 0
br i1 %25, label %26, label %31
26: ; preds = %19
%27 = load i32, i32* %6
%28 = call i32 @dump(i32 %27)
%29 = load i32, i32* %6
%30 = call i32 @close(i32 %29)
br label %33
31: ; preds = %19
%32 = load i32, i32* @EXIT_FAILURE
store i32 %32, i32* %3
br label %35
33: ; preds = %26
%34 = load i32, i32* @EXIT_SUCCESS
store i32 %34, i32* %3
br label %35
35: ; preds = %33, %31, %15
%36 = load i32, i32* %3
ret i32 %36
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [51 x i8] c"Please give path to eeprom file as first argument\0A\00"
@EXIT_FAILURE = global i32 0
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %9, label %4
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = load i8, i8* %6
%8 = icmp eq i8 %7, 0
br i1 %8, label %9, label %12
9: ; preds = %4, %2
%10 = load i32, i32* @stderr
%11 = tail call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0))
br label %18
12: ; preds = %4
%13 = tail call i32 @open_eeprom(i8* %6)
%14 = icmp sgt i32 %13, -1
br i1 %14, label %15, label %18
15: ; preds = %12
%16 = tail call i32 @dump(i32 %13)
%17 = tail call i32 @close(i32 %13)
br label %18
18: ; preds = %12, %15, %9
%19 = phi i32* [ @EXIT_FAILURE, %9 ], [ @EXIT_SUCCESS, %15 ], [ @EXIT_FAILURE, %12 ]
%20 = load i32, i32* %19
ret i32 %20
}