#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*/ uint32_t;

/* Variables and functions */
int /*<<< orphan*/ EX_USAGE;
int /*<<< orphan*/ errx(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ format_parse_entries(int /*<<< orphan*/ *,
                                        int /*<<< orphan*/);
int /*<<< orphan*/ free(int /*<<< orphan*/ *);
int getopt(int, char **, char const *);
int /*<<< orphan*/ load_file(char *, int /*<<< orphan*/ **,
                             int /*<<< orphan*/ *);
char *optarg;
char *strchr(char *, char);
int /*<<< orphan*/ strncmp(char *, char *, int);
int /*<<< orphan*/ usage();
int /*<<< orphan*/ usb_dump_entries();
int /*<<< orphan*/ usb_import_entries(char *, char *, int /*<<< orphan*/ *,
                                      int /*<<< orphan*/);
int main(int argc, char **argv) {
  const char *params = "i:F:h";
  char *fname;
  char *section;
  char *module;
  char *postfix;
  uint8_t *ptr;
  uint32_t len;
  int c;
  int any_opt = 0;
  while ((c = getopt(argc, argv, params)) != -1) {
    switch (c) {
    case 'i':
      fname = optarg;
      load_file(fname, &ptr, &len);
      module = strchr(fname, ',');
      if (module == NULL) {
        errx(EX_USAGE,
             "Invalid input "
             "file name '%s'",
             fname);
      }
      *module++ = 0;
      postfix = strchr(module, '.');
      if (postfix)
        *postfix = 0;
      section = fname;
      if (strncmp(section, "usb_", 4) == 0)
        usb_import_entries(section, module, ptr, len);
      else
        errx(EX_USAGE, "Invalid section '%s'", section);
      free(ptr);
      any_opt = 1;
      break;
    case 'F':
      fname = optarg;
      load_file(fname, &ptr, &len);
      format_parse_entries(ptr, len);
      free(ptr);
      any_opt = 1;
      break;
    default:
      usage();
      break;
    }
  }
  if (any_opt == 0)
    usage();
  usb_dump_entries();
  return (0);
}


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)
lea    0xe43(%rip),%rax
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x4c(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   10b0 <getopt@plt>
mov    %eax,-0x48(%rbp)
cmp    $0xffffffff,%eax
je     134d <main+0x1ad>
mov    -0x48(%rbp),%eax
mov    %eax,-0x50(%rbp)
sub    $0x46,%eax
je     1301 <main+0x161>
jmp    11f8 <main+0x58>
mov    -0x50(%rbp),%eax
sub    $0x69,%eax
jne    1341 <main+0x1a1>
jmp    1209 <main+0x69>
mov    0x2de8(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
lea    -0x40(%rbp),%rsi
lea    -0x44(%rbp),%rdx
call   10a0 <load_file@plt>
mov    -0x20(%rbp),%rdi
mov    $0x2c,%esi
call   1070 <strchr@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    125e <main+0xbe>
mov    0x2d94(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rdx
lea    0xdad(%rip),%rsi
call   1060 <errx@plt>
mov    -0x30(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x30(%rbp)
movb   $0x0,(%rax)
mov    -0x30(%rbp),%rdi
mov    $0x2e,%esi
call   1070 <strchr@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
je     1294 <main+0xf4>
mov    -0x38(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
lea    0xd7c(%rip),%rsi
mov    $0x4,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%eax
jne    12d3 <main+0x133>
mov    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x40(%rbp),%rdx
mov    -0x44(%rbp),%ecx
call   10c0 <usb_import_entries@plt>
jmp    12ec <main+0x14c>
mov    0x2d06(%rip),%rax
mov    (%rax),%edi
mov    -0x28(%rbp),%rdx
lea    0xd41(%rip),%rsi
call   1060 <errx@plt>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
movl   $0x1,-0x4c(%rbp)
jmp    1348 <main+0x1a8>
mov    0x2cf0(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
lea    -0x40(%rbp),%rsi
lea    -0x44(%rbp),%rdx
call   10a0 <load_file@plt>
mov    -0x40(%rbp),%rdi
mov    -0x44(%rbp),%esi
call   1080 <format_parse_entries@plt>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
movl   $0x1,-0x4c(%rbp)
jmp    1348 <main+0x1a8>
mov    $0x0,%al
call   1090 <usage@plt>
jmp    11c8 <main+0x28>
cmpl   $0x0,-0x4c(%rbp)
jne    135e <main+0x1be>
mov    $0x0,%al
call   1090 <usage@plt>
mov    $0x0,%al
call   1050 <usb_dump_entries@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
mov    $0x1,%r15b
lea    0xe43(%rip),%r14
mov    0x2e34(%rip),%r13
jmp    11d7 <main+0x37>
cs nopw 0x0(%rax,%rax,1)
xor    %eax,%eax
call   1090 <usage@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
call   10b0 <getopt@plt>
cmp    $0xffffffff,%eax
je     12ee <main+0x14e>
cmp    $0x46,%eax
je     1292 <main+0xf2>
cmp    $0x69,%eax
jne    11d0 <main+0x30>
mov    %r13,%r12
mov    0x0(%r13),%r13
mov    %r13,%rdi
lea    0x10(%rsp),%rsi
lea    0xc(%rsp),%rdx
call   10a0 <load_file@plt>
mov    %r13,%rdi
mov    $0x2c,%esi
call   1070 <strchr@plt>
mov    %rax,%r15
test   %rax,%rax
jne    1241 <main+0xa1>
mov    0x2db0(%rip),%rax
mov    (%rax),%edi
lea    0xdcd(%rip),%rsi
mov    %r13,%rdx
call   1060 <errx@plt>
mov    %r15,%rax
add    $0x1,%r15
movb   $0x0,(%rax)
mov    %r15,%rdi
mov    $0x2e,%esi
call   1070 <strchr@plt>
test   %rax,%rax
je     1260 <main+0xc0>
movb   $0x0,(%rax)
mov    %r13,%rdi
lea    0xdb9(%rip),%rsi
mov    $0x4,%edx
call   1040 <strncmp@plt>
test   %eax,%eax
je     12c5 <main+0x125>
mov    0x2d61(%rip),%rax
mov    (%rax),%edi
lea    0xda0(%rip),%rsi
mov    %r13,%rdx
call   1060 <errx@plt>
jmp    12d9 <main+0x139>
mov    0x0(%r13),%rdi
lea    0x10(%rsp),%rsi
lea    0xc(%rsp),%rdx
call   10a0 <load_file@plt>
mov    0x10(%rsp),%rdi
mov    0xc(%rsp),%esi
call   1080 <format_parse_entries@plt>
mov    0x10(%rsp),%rdi
call   1030 <free@plt>
xor    %r15d,%r15d
jmp    11d7 <main+0x37>
mov    0x10(%rsp),%rdx
mov    0xc(%rsp),%ecx
mov    %r13,%rdi
mov    %r15,%rsi
call   10c0 <usb_import_entries@plt>
mov    0x10(%rsp),%rdi
call   1030 <free@plt>
xor    %r15d,%r15d
mov    %r12,%r13
jmp    11d7 <main+0x37>
test   $0x1,%r15b
je     12fb <main+0x15b>
xor    %eax,%eax
call   1090 <usage@plt>
xor    %eax,%eax
call   1050 <usb_dump_entries@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"i:F:h\00"
@optarg = global i8* null
@EX_USAGE = global i32 0
@.str.1 = [29 x i8] c"Invalid input file name '%s'\00"
@.str.2 = [5 x i8] c"usb_\00"
@.str.3 = [21 x i8] c"Invalid section '%s'\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i32*
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8** %6
store i32 0, i32* %14
br label %15
15: ; preds = %73, %2
%16 = load i32, i32* %4
%17 = load i8**, i8*** %5
%18 = load i8*, i8** %6
%19 = call i32 @getopt(i32 %16, i8** %17, i8* %18)
store i32 %19, i32* %13
%20 = icmp ne i32 %19, -1
br i1 %20, label %21, label %74
21: ; preds = %15
%22 = load i32, i32* %13
switch i32 %22, label %71 [
i32 105, label %23
i32 70, label %62
]
23: ; preds = %21
%24 = load i8*, i8** @optarg
store i8* %24, i8** %7
%25 = load i8*, i8** %7
%26 = call i32 @load_file(i8* %25, i32** %11, i32* %12)
%27 = load i8*, i8** %7
%28 = call i8* @strchr(i8* %27, i8 signext 44)
store i8* %28, i8** %9
%29 = load i8*, i8** %9
%30 = icmp eq i8* %29, null
br i1 %30, label %31, label %35
31: ; preds = %23
%32 = load i32, i32* @EX_USAGE
%33 = load i8*, i8** %7
%34 = call i32 @errx(i32 %32, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i8* %33)
br label %35
35: ; preds = %31, %23
%36 = load i8*, i8** %9
%37 = getelementptr inbounds i8, i8* %36, i32 1
store i8* %37, i8** %9
store i8 0, i8* %36
%38 = load i8*, i8** %9
%39 = call i8* @strchr(i8* %38, i8 signext 46)
store i8* %39, i8** %10
%40 = load i8*, i8** %10
%41 = icmp ne i8* %40, null
br i1 %41, label %42, label %44
42: ; preds = %35
%43 = load i8*, i8** %10
store i8 0, i8* %43
br label %44
44: ; preds = %42, %35
%45 = load i8*, i8** %7
store i8* %45, i8** %8
%46 = load i8*, i8** %8
%47 = call i32 @strncmp(i8* %46, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 4)
%48 = icmp eq i32 %47, 0
br i1 %48, label %49, label %55
49: ; preds = %44
%50 = load i8*, i8** %8
%51 = load i8*, i8** %9
%52 = load i32*, i32** %11
%53 = load i32, i32* %12
%54 = call i32 @usb_import_entries(i8* %50, i8* %51, i32* %52, i32 %53)
br label %59
55: ; preds = %44
%56 = load i32, i32* @EX_USAGE
%57 = load i8*, i8** %8
%58 = call i32 @errx(i32 %56, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i8* %57)
br label %59
59: ; preds = %55, %49
%60 = load i32*, i32** %11
%61 = call i32 @free(i32* %60)
store i32 1, i32* %14
br label %73
62: ; preds = %21
%63 = load i8*, i8** @optarg
store i8* %63, i8** %7
%64 = load i8*, i8** %7
%65 = call i32 @load_file(i8* %64, i32** %11, i32* %12)
%66 = load i32*, i32** %11
%67 = load i32, i32* %12
%68 = call i32 @format_parse_entries(i32* %66, i32 %67)
%69 = load i32*, i32** %11
%70 = call i32 @free(i32* %69)
store i32 1, i32* %14
br label %73
71: ; preds = %21
%72 = call i32 (...) @usage()
br label %73
73: ; preds = %71, %62, %59
br label %15
74: ; preds = %15
%75 = load i32, i32* %14
%76 = icmp eq i32 %75, 0
br i1 %76, label %77, label %79
77: ; preds = %74
%78 = call i32 (...) @usage()
br label %79
79: ; preds = %77, %74
%80 = call i32 (...) @usb_dump_entries()
ret i32 0
}

LLVM IR (-O2):
@.str = [6 x i8] c"i:F:h\00"
@optarg = global i8* null
@EX_USAGE = global i32 0
@.str.1 = [29 x i8] c"Invalid input file name '%s'\00"
@.str.2 = [5 x i8] c"usb_\00"
@.str.3 = [21 x i8] c"Invalid section '%s'\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = bitcast i32** %3 to i8*
%6 = bitcast i32* %4 to i8*
br label %7
7: ; preds = %45, %2
%8 = phi i1 [ false, %45 ], [ true, %2 ]
br label %9
9: ; preds = %7, %46
%10 = call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
switch i32 %10, label %46 [
i32 -1, label %48
i32 105, label %11
i32 70, label %37
]
11: ; preds = %9
%12 = load i8*, i8** @optarg
%13 = call i32 @load_file(i8* %12, i32** %3, i32* %4)
%14 = call i8* @strchr(i8* dereferenceable(1) %12, i8 signext 44)
%15 = icmp eq i8* %14, null
br i1 %15, label %16, label %19
16: ; preds = %11
%17 = load i32, i32* @EX_USAGE
%18 = call i32 @errx(i32 %17, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i8* %12)
br label %19
19: ; preds = %16, %11
%20 = getelementptr inbounds i8, i8* %14, i64 1
store i8 0, i8* %14
%21 = call i8* @strchr(i8* %20, i8 signext 46)
%22 = icmp eq i8* %21, null
br i1 %22, label %24, label %23
23: ; preds = %19
store i8 0, i8* %21
br label %24
24: ; preds = %23, %19
%25 = call i32 @strncmp(i8* %12, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 4)
%26 = icmp eq i32 %25, 0
br i1 %26, label %27, label %31
27: ; preds = %24
%28 = load i32*, i32** %3
%29 = load i32, i32* %4
%30 = call i32 @usb_import_entries(i8* %12, i8* %20, i32* %28, i32 %29)
br label %34
31: ; preds = %24
%32 = load i32, i32* @EX_USAGE
%33 = call i32 @errx(i32 %32, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i8* %12)
br label %34
34: ; preds = %31, %27
%35 = load i32*, i32** %3
%36 = call i32 @free(i32* %35)
br label %45
37: ; preds = %9
%38 = load i8*, i8** @optarg
%39 = call i32 @load_file(i8* %38, i32** %3, i32* %4)
%40 = load i32*, i32** %3
%41 = load i32, i32* %4
%42 = call i32 @format_parse_entries(i32* %40, i32 %41)
%43 = load i32*, i32** %3
%44 = call i32 @free(i32* %43)
br label %45
45: ; preds = %37, %34
br label %7
46: ; preds = %9
%47 = call i32 (...) @usage()
br label %9
48: ; preds = %9
br i1 %8, label %49, label %51
49: ; preds = %48
%50 = call i32 (...) @usage()
br label %51
51: ; preds = %49, %48
%52 = call i32 (...) @usb_dump_entries()
ret i32 0
}