#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 */
typedef int /*<<< orphan*/ uint8_t;
typedef int /*<<< orphan*/ uint64_t;

/* Variables and functions */
int generate_eeprom(int /*<<< orphan*/, int /*<<< orphan*/ *,
                    int /*<<< orphan*/, int /*<<< orphan*/ *,
                    int /*<<< orphan*/);
int /*<<< orphan*/ *map_file(char const *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ unmap_file(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ usage(int /*<<< orphan*/);
int main(int argc, char **argv) {
  int err, ret = 0;
  uint8_t *txgen_image = NULL;
  uint64_t txgen_image_len = 0;
  uint8_t *iqalign_image = NULL;
  uint64_t iqalign_image_len = 0;
  const char *txgen_filepath;
  const char *iqalign_filepath;
  if (argc != 3) {
    usage(stderr);
    return 1;
  }
  txgen_filepath = argv[1];
  iqalign_filepath = argv[2];
  txgen_image = map_file(txgen_filepath, 1, &txgen_image_len);
  iqalign_image = map_file(iqalign_filepath, 1, &iqalign_image_len);
  if (!txgen_image || !iqalign_image) {
    ret = 1;
    goto out;
  }
  err = generate_eeprom(stdout, txgen_image, txgen_image_len, iqalign_image,
                        iqalign_image_len);
  if (err) {
    ret = 1;
    goto out;
  }
out:
  unmap_file(txgen_image, txgen_image_len);
  unmap_file(iqalign_image, iqalign_image_len);
  return ret;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movq   $0x0,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     119f <main+0x5f>
mov    0x2e54(%rip),%rax
mov    (%rax),%edi
call   1060 <usage@plt>
movl   $0x1,-0x4(%rbp)
jmp    125e <main+0x11e>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x40(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x48(%rbp)
mov    -0x40(%rbp),%rdi
mov    $0x1,%esi
lea    -0x24(%rbp),%rdx
call   1040 <map_file@plt>
mov    %rax,-0x20(%rbp)
mov    -0x48(%rbp),%rdi
mov    $0x1,%esi
lea    -0x34(%rbp),%rdx
call   1040 <map_file@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     11f9 <main+0xb9>
cmpq   $0x0,-0x30(%rbp)
jne    1205 <main+0xc5>
movl   $0x1,-0x18(%rbp)
jmp    1240 <main+0x100>
mov    0x2dcc(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rsi
mov    -0x24(%rbp),%edx
mov    -0x30(%rbp),%rcx
mov    -0x34(%rbp),%r8d
call   1030 <generate_eeprom@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     123b <main+0xfb>
movl   $0x1,-0x18(%rbp)
jmp    1240 <main+0x100>
jmp    1240 <main+0x100>
mov    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%esi
call   1050 <unmap_file@plt>
mov    -0x30(%rbp),%rdi
mov    -0x34(%rbp),%esi
call   1050 <unmap_file@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
movl   $0x0,0xc(%rsp)
movl   $0x0,0x8(%rsp)
cmp    $0x3,%edi
jne    11da <main+0x9a>
mov    0x8(%rsi),%rdi
mov    0x10(%rsi),%r15
mov    $0x1,%ebx
lea    0xc(%rsp),%rdx
mov    $0x1,%esi
call   1040 <map_file@plt>
mov    %rax,%r14
lea    0x8(%rsp),%rdx
mov    %r15,%rdi
mov    $0x1,%esi
call   1040 <map_file@plt>
mov    %rax,%r15
test   %r14,%r14
je     11c0 <main+0x80>
test   %r15,%r15
je     11c0 <main+0x80>
mov    0x2e35(%rip),%rax
mov    (%rax),%edi
mov    0xc(%rsp),%edx
mov    0x8(%rsp),%r8d
mov    %r14,%rsi
mov    %r15,%rcx
call   1030 <generate_eeprom@plt>
xor    %ebx,%ebx
test   %eax,%eax
setne  %bl
mov    0xc(%rsp),%esi
mov    %r14,%rdi
call   1050 <unmap_file@plt>
mov    0x8(%rsp),%esi
mov    %r15,%rdi
call   1050 <unmap_file@plt>
jmp    11ed <main+0xad>
mov    0x2dff(%rip),%rax
mov    (%rax),%edi
call   1060 <usage@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@stderr = global i32 0
@stdout = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32*
%9 = alloca i32
%10 = alloca i32*
%11 = alloca i32
%12 = alloca i8*
%13 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %7
store i32* null, i32** %8
store i32 0, i32* %9
store i32* null, i32** %10
store i32 0, i32* %11
%14 = load i32, i32* %4
%15 = icmp ne i32 %14, 3
br i1 %15, label %16, label %19
16: ; preds = %2
%17 = load i32, i32* @stderr
%18 = call i32 @usage(i32 %17)
store i32 1, i32* %3
br label %55
19: ; preds = %2
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 1
%22 = load i8*, i8** %21
store i8* %22, i8** %12
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 2
%25 = load i8*, i8** %24
store i8* %25, i8** %13
%26 = load i8*, i8** %12
%27 = call i32* @map_file(i8* %26, i32 1, i32* %9)
store i32* %27, i32** %8
%28 = load i8*, i8** %13
%29 = call i32* @map_file(i8* %28, i32 1, i32* %11)
store i32* %29, i32** %10
%30 = load i32*, i32** %8
%31 = icmp ne i32* %30, null
br i1 %31, label %32, label %35
32: ; preds = %19
%33 = load i32*, i32** %10
%34 = icmp ne i32* %33, null
br i1 %34, label %36, label %35
35: ; preds = %32, %19
store i32 1, i32* %7
br label %47
36: ; preds = %32
%37 = load i32, i32* @stdout
%38 = load i32*, i32** %8
%39 = load i32, i32* %9
%40 = load i32*, i32** %10
%41 = load i32, i32* %11
%42 = call i32 @generate_eeprom(i32 %37, i32* %38, i32 %39, i32* %40, i32 %41)
store i32 %42, i32* %6
%43 = load i32, i32* %6
%44 = icmp ne i32 %43, 0
br i1 %44, label %45, label %46
45: ; preds = %36
store i32 1, i32* %7
br label %47
46: ; preds = %36
br label %47
47: ; preds = %46, %45, %35
%48 = load i32*, i32** %8
%49 = load i32, i32* %9
%50 = call i32 @unmap_file(i32* %48, i32 %49)
%51 = load i32*, i32** %10
%52 = load i32, i32* %11
%53 = call i32 @unmap_file(i32* %51, i32 %52)
%54 = load i32, i32* %7
store i32 %54, i32* %3
br label %55
55: ; preds = %47, %16
%56 = load i32, i32* %3
ret i32 %56
}

LLVM IR (-O2):
@stderr = global i32 0
@stdout = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca i32
%5 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%6 = bitcast i32* %4 to i8*
store i32 0, i32* %4
%7 = icmp eq i32 %0, 3
br i1 %7, label %11, label %8
8: ; preds = %2
%9 = load i32, i32* @stderr
%10 = tail call i32 @usage(i32 %9)
br label %34
11: ; preds = %2
%12 = getelementptr inbounds i8*, i8** %1, i64 1
%13 = load i8*, i8** %12
%14 = getelementptr inbounds i8*, i8** %1, i64 2
%15 = load i8*, i8** %14
%16 = call i32* @map_file(i8* %13, i32 1, i32* %3)
%17 = call i32* @map_file(i8* %15, i32 1, i32* %4)
%18 = icmp ne i32* %16, null
%19 = icmp ne i32* %17, null
%20 = select i1 %18, i1 %19, i1 false
br i1 %20, label %21, label %28
21: ; preds = %11
%22 = load i32, i32* @stdout
%23 = load i32, i32* %3
%24 = load i32, i32* %4
%25 = call i32 @generate_eeprom(i32 %22, i32* %16, i32 %23, i32* %17, i32 %24)
%26 = icmp ne i32 %25, 0
%27 = zext i1 %26 to i32
br label %28
28: ; preds = %21, %11
%29 = phi i32 [ 1, %11 ], [ %27, %21 ]
%30 = load i32, i32* %3
%31 = call i32 @unmap_file(i32* %16, i32 %30)
%32 = load i32, i32* %4
%33 = call i32 @unmap_file(i32* %17, i32 %32)
br label %34
34: ; preds = %28, %8
%35 = phi i32 [ 1, %8 ], [ %29, %28 ]
ret i32 %35
}