#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 /*<<< orphan*/ abort();
unsigned char atoi(char *);
char *basename(char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char);
int getopt(int, char **, char *);
int /*<<< orphan*/ isprint(char);
char *optarg;
scalar_t__ opterr;
int optind;
char optopt;
int /*<<< orphan*/ print_bits(unsigned char);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ stderr;
char *strdup(char *);
int /*<<< orphan*/ uses(char *);
int /*<<< orphan*/ version();
int main(int argc, char **argv) {
  unsigned char x = 0;
  int aflag = 0;
  int hflag = 0;
  int vflag = 0;
  char *bvalue = NULL;
  char *dvalue = NULL;
  int index;
  int c;
  char *basec, *bname;
  opterr = 0;
  while ((c = getopt(argc, argv, "ab:d:hv")) != -1)
    switch (c) {
    case 'a':
      aflag = 1;
      break;
    case 'b':
      bvalue = optarg;
      break;
    case 'd':
      dvalue = optarg;
      break;
    case 'h':
      hflag = 1;
      break;
    case 'v':
      vflag = 1;
      break;
    case '?':
      if (optopt == 'b' || optopt == 'd')
        fprintf(stderr, "Option -%c requires an argument.\n", optopt);
      else if (isprint(optopt))
        fprintf(stderr, "Unknown option `-%c'.\n", optopt);
      else
        fprintf(stderr, "Unknown option character `\\x%x'.\n", optopt);
      return 1;
    default:
      abort();
    }
  for (index = optind; index < argc; index++)
    printf("Non-option argument %s\n", argv[index]);
  if (hflag == 1) {
    basec = strdup(argv[0]);
    bname = basename(basec);
    uses(bname);
    return 0;
  }
  if (vflag == 1) {
    version();
    return 0;
  }
  if (dvalue != NULL)
    x = atoi(dvalue);
  print_bits(x);
  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)
movb   $0x0,-0x11(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
mov    0x2dca(%rip),%rax
movq   $0x0,(%rax)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xed5(%rip),%rdx
call   10b0 <getopt@plt>
mov    %eax,-0x38(%rbp)
cmp    $0xffffffff,%eax
je     1351 <main+0x1a1>
mov    -0x38(%rbp),%eax
add    $0xffffffc1,%eax
mov    %eax,%ecx
mov    %rcx,-0x50(%rbp)
sub    $0x37,%eax
ja     1345 <main+0x195>
mov    -0x50(%rbp),%rax
lea    0xdc4(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x1,-0x18(%rbp)
jmp    134c <main+0x19c>
mov    0x2da0(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
jmp    134c <main+0x19c>
mov    0x2d8d(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x30(%rbp)
jmp    134c <main+0x19c>
movl   $0x1,-0x1c(%rbp)
jmp    134c <main+0x19c>
movl   $0x1,-0x20(%rbp)
jmp    134c <main+0x19c>
mov    0x2d4a(%rip),%rax
movsbl (%rax),%eax
cmp    $0x62,%eax
je     12b5 <main+0x105>
mov    0x2d37(%rip),%rax
movsbl (%rax),%eax
cmp    $0x64,%eax
jne    12d9 <main+0x129>
mov    0x2d0c(%rip),%rax
mov    (%rax),%edi
lea    0xe23(%rip),%rsi
mov    0x2d14(%rip),%rax
movsbl (%rax),%edx
call   1050 <fprintf@plt>
jmp    1339 <main+0x189>
mov    0x2d00(%rip),%rax
movsbl (%rax),%edi
call   1090 <isprint@plt>
cmp    $0x0,%eax
je     1315 <main+0x165>
mov    0x2cd0(%rip),%rax
mov    (%rax),%edi
lea    0xe09(%rip),%rsi
mov    0x2cd8(%rip),%rax
movsbl (%rax),%edx
call   1050 <fprintf@plt>
jmp    1334 <main+0x184>
mov    0x2cac(%rip),%rax
mov    (%rax),%edi
lea    0xdfc(%rip),%rsi
mov    0x2cb4(%rip),%rax
movsbl (%rax),%edx
call   1050 <fprintf@plt>
jmp    1339 <main+0x189>
movl   $0x1,-0x4(%rbp)
jmp    140f <main+0x25f>
mov    $0x0,%al
call   1030 <abort@plt>
jmp    11fd <main+0x4d>
mov    0x2c80(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    138f <main+0x1df>
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xdc7(%rip),%rdi
call   1040 <printf@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    135d <main+0x1ad>
cmpl   $0x1,-0x1c(%rbp)
jne    13cb <main+0x21b>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   10d0 <strdup@plt>
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rdi
call   1060 <basename@plt>
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rdi
call   10a0 <uses@plt>
movl   $0x0,-0x4(%rbp)
jmp    140f <main+0x25f>
cmpl   $0x1,-0x20(%rbp)
jne    13e8 <main+0x238>
mov    $0x0,%al
call   1070 <version@plt>
movl   $0x0,-0x4(%rbp)
jmp    140f <main+0x25f>
cmpq   $0x0,-0x30(%rbp)
je     13ff <main+0x24f>
mov    -0x30(%rbp),%rdi
call   10c0 <atoi@plt>
mov    %al,-0x11(%rbp)
movzbl -0x11(%rbp),%edi
call   1080 <print_bits@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%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,%r14
mov    %edi,%ebx
mov    0x2df6(%rip),%rax
movq   $0x0,(%rax)
xor    %r13d,%r13d
lea    0xe25(%rip),%r12
xor    %r15d,%r15d
xor    %ebp,%ebp
mov    %ebx,%edi
mov    %r14,%rsi
mov    %r12,%rdx
call   10b0 <getopt@plt>
lea    -0x61(%rax),%ecx
cmp    $0x2,%ecx
jb     11e0 <main+0x30>
cmp    $0x63,%eax
jle    1226 <main+0x76>
cmp    $0x76,%eax
je     1219 <main+0x69>
cmp    $0x68,%eax
je     1221 <main+0x71>
cmp    $0x64,%eax
jne    133c <main+0x18c>
mov    0x2de4(%rip),%rax
mov    (%rax),%rbp
jmp    11e0 <main+0x30>
mov    $0x1,%r15d
jmp    11e0 <main+0x30>
mov    $0x1,%r13b
jmp    11e0 <main+0x30>
cmp    $0xffffffff,%eax
je     1261 <main+0xb1>
cmp    $0x3f,%eax
jne    133c <main+0x18c>
mov    0x2da5(%rip),%rbx
mov    (%rbx),%al
cmp    $0x64,%al
je     1249 <main+0x99>
cmp    $0x62,%al
jne    12d8 <main+0x128>
mov    0x2d78(%rip),%rcx
mov    (%rcx),%edi
movsbl %al,%edx
lea    0xdac(%rip),%rsi
jmp    1315 <main+0x165>
mov    %r15d,0xc(%rsp)
mov    %rbp,0x10(%rsp)
mov    0x2d66(%rip),%rax
movslq (%rax),%rax
cmp    %ebx,%eax
jge    12a4 <main+0xf4>
lea    (%r14,%rax,8),%r15
sub    %eax,%ebx
xor    %ebp,%ebp
lea    0xddb(%rip),%r12
nopl   0x0(%rax,%rax,1)
mov    (%r15,%rbp,8),%rsi
mov    %r12,%rdi
call   1040 <printf@plt>
add    $0x1,%rbp
cmp    %ebp,%ebx
jne    1290 <main+0xe0>
test   $0x1,%r13b
je     12c6 <main+0x116>
mov    (%r14),%rdi
call   10d0 <strdup@plt>
mov    %rax,%rdi
call   1060 <basename@plt>
mov    %rax,%rdi
call   10a0 <uses@plt>
xor    %ebx,%ebx
jmp    132b <main+0x17b>
cmpl   $0x1,0xc(%rsp)
jne    12fb <main+0x14b>
xor    %ebx,%ebx
xor    %eax,%eax
call   1070 <version@plt>
jmp    132b <main+0x17b>
movsbl %al,%edi
call   1090 <isprint@plt>
mov    0x2ce1(%rip),%rcx
mov    (%rcx),%edi
mov    (%rbx),%cl
movsbl %cl,%edx
test   %eax,%eax
je     130e <main+0x15e>
lea    0xd31(%rip),%rsi
jmp    1315 <main+0x165>
xor    %ebx,%ebx
mov    0x10(%rsp),%rdi
test   %rdi,%rdi
je     1321 <main+0x171>
call   10c0 <atoi@plt>
jmp    1323 <main+0x173>
lea    0xd2c(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%ebx
jmp    132b <main+0x17b>
xor    %eax,%eax
movzbl %al,%edi
call   1080 <print_bits@plt>
mov    %ebx,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
@opterr = global i64 0
@.str = [8 x i8] c"ab:d:hv\00"
@optarg = global i8* null
@optopt = global i8 0
@stderr = global i32 0
@.str.1 = [34 x i8] c"Option -%c requires an argument.\0A\00"
@.str.2 = [23 x i8] c"Unknown option `-%c'.\0A\00"
@.str.3 = [34 x i8] c"Unknown option character `\\x%x'.\0A\00"
@optind = global i32 0
@.str.4 = [24 x i8] c"Non-option argument %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i32
%13 = alloca i32
%14 = alloca i8*
%15 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8 0, i8* %6
store i32 0, i32* %7
store i32 0, i32* %8
store i32 0, i32* %9
store i8* null, i8** %10
store i8* null, i8** %11
store i64 0, i64* @opterr
br label %16
16: ; preds = %58, %2
%17 = load i32, i32* %4
%18 = load i8**, i8*** %5
%19 = call i32 @getopt(i32 %17, i8** %18, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
store i32 %19, i32* %13
%20 = icmp ne i32 %19, -1
br i1 %20, label %21, label %59
21: ; preds = %16
%22 = load i32, i32* %13
switch i32 %22, label %56 [
i32 97, label %23
i32 98, label %24
i32 100, label %26
i32 104, label %28
i32 118, label %29
i32 63, label %30
]
23: ; preds = %21
store i32 1, i32* %7
br label %58
24: ; preds = %21
%25 = load i8*, i8** @optarg
store i8* %25, i8** %10
br label %58
26: ; preds = %21
%27 = load i8*, i8** @optarg
store i8* %27, i8** %11
br label %58
28: ; preds = %21
store i32 1, i32* %8
br label %58
29: ; preds = %21
store i32 1, i32* %9
br label %58
30: ; preds = %21
%31 = load i8, i8* @optopt
%32 = sext i8 %31 to i32
%33 = icmp eq i32 %32, 98
br i1 %33, label %38, label %34
34: ; preds = %30
%35 = load i8, i8* @optopt
%36 = sext i8 %35 to i32
%37 = icmp eq i32 %36, 100
br i1 %37, label %38, label %42
38: ; preds = %34, %30
%39 = load i32, i32* @stderr
%40 = load i8, i8* @optopt
%41 = call i32 @fprintf(i32 %39, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i8 signext %40)
br label %55
42: ; preds = %34
%43 = load i8, i8* @optopt
%44 = call i32 @isprint(i8 signext %43)
%45 = icmp ne i32 %44, 0
br i1 %45, label %46, label %50
46: ; preds = %42
%47 = load i32, i32* @stderr
%48 = load i8, i8* @optopt
%49 = call i32 @fprintf(i32 %47, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i8 signext %48)
br label %54
50: ; preds = %42
%51 = load i32, i32* @stderr
%52 = load i8, i8* @optopt
%53 = call i32 @fprintf(i32 %51, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0), i8 signext %52)
br label %54
54: ; preds = %50, %46
br label %55
55: ; preds = %54, %38
store i32 1, i32* %3
br label %101
56: ; preds = %21
%57 = call i32 (...) @abort()
unreachable
58: ; preds = %29, %28, %26, %24, %23
br label %16
59: ; preds = %16
%60 = load i32, i32* @optind
store i32 %60, i32* %12
br label %61
61: ; preds = %72, %59
%62 = load i32, i32* %12
%63 = load i32, i32* %4
%64 = icmp slt i32 %62, %63
br i1 %64, label %65, label %75
65: ; preds = %61
%66 = load i8**, i8*** %5
%67 = load i32, i32* %12
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds i8*, i8** %66, i64 %68
%70 = load i8*, i8** %69
%71 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i8* %70)
br label %72
72: ; preds = %65
%73 = load i32, i32* %12
%74 = add nsw i32 %73, 1
store i32 %74, i32* %12
br label %61
75: ; preds = %61
%76 = load i32, i32* %8
%77 = icmp eq i32 %76, 1
br i1 %77, label %78, label %87
78: ; preds = %75
%79 = load i8**, i8*** %5
%80 = getelementptr inbounds i8*, i8** %79, i64 0
%81 = load i8*, i8** %80
%82 = call i8* @strdup(i8* %81)
store i8* %82, i8** %14
%83 = load i8*, i8** %14
%84 = call i8* @basename(i8* %83)
store i8* %84, i8** %15
%85 = load i8*, i8** %15
%86 = call i32 @uses(i8* %85)
store i32 0, i32* %3
br label %101
87: ; preds = %75
%88 = load i32, i32* %9
%89 = icmp eq i32 %88, 1
br i1 %89, label %90, label %92
90: ; preds = %87
%91 = call i32 (...) @version()
store i32 0, i32* %3
br label %101
92: ; preds = %87
%93 = load i8*, i8** %11
%94 = icmp ne i8* %93, null
br i1 %94, label %95, label %98
95: ; preds = %92
%96 = load i8*, i8** %11
%97 = call zeroext i8 @atoi(i8* %96)
store i8 %97, i8* %6
br label %98
98: ; preds = %95, %92
%99 = load i8, i8* %6
%100 = call i32 @print_bits(i8 zeroext %99)
store i32 0, i32* %3
br label %101
101: ; preds = %98, %90, %78, %55
%102 = load i32, i32* %3
ret i32 %102
}

LLVM IR (-O2):
@opterr = global i64 0
@.str = [8 x i8] c"ab:d:hv\00"
@optarg = global i8* null
@optopt = global i8 0
@stderr = global i32 0
@.str.1 = [34 x i8] c"Option -%c requires an argument.\0A\00"
@.str.2 = [23 x i8] c"Unknown option `-%c'.\0A\00"
@.str.3 = [34 x i8] c"Unknown option character `\\x%x'.\0A\00"
@optind = global i32 0
@.str.4 = [24 x i8] c"Non-option argument %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
store i64 0, i64* @opterr
br label %3
3: ; preds = %12, %2
%4 = phi i1 [ false, %2 ], [ true, %12 ]
%5 = phi i32 [ 0, %2 ], [ %8, %12 ]
%6 = phi i8* [ null, %2 ], [ %11, %12 ]
br label %7
7: ; preds = %12, %3
%8 = phi i32 [ %5, %3 ], [ 1, %12 ]
%9 = phi i8* [ %6, %3 ], [ %11, %12 ]
br label %10
10: ; preds = %7, %15
%11 = phi i8* [ %9, %7 ], [ %16, %15 ]
br label %12
12: ; preds = %14, %10
%13 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
switch i32 %13, label %31 [
i32 -1, label %33
i32 97, label %14
i32 98, label %14
i32 100, label %15
i32 104, label %3
i32 118, label %7
i32 63, label %17
]
14: ; preds = %12, %12
br label %12
15: ; preds = %12
%16 = load i8*, i8** @optarg
br label %10
17: ; preds = %12
%18 = load i8, i8* @optopt
switch i8 %18, label %22 [
i8 100, label %19
i8 98, label %19
]
19: ; preds = %17, %17
%20 = load i32, i32* @stderr
%21 = tail call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i8 signext %18)
br label %63
22: ; preds = %17
%23 = tail call i32 @isprint(i8 signext %18)
%24 = icmp eq i32 %23, 0
%25 = load i32, i32* @stderr
%26 = load i8, i8* @optopt
br i1 %24, label %29, label %27
27: ; preds = %22
%28 = tail call i32 @fprintf(i32 %25, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i8 signext %26)
br label %63
29: ; preds = %22
%30 = tail call i32 @fprintf(i32 %25, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0), i8 signext %26)
br label %63
31: ; preds = %12
%32 = tail call i32 (...) @abort()
unreachable
33: ; preds = %12
%34 = load i32, i32* @optind
%35 = icmp slt i32 %34, %0
br i1 %35, label %36, label %46
36: ; preds = %33
%37 = sext i32 %34 to i64
br label %38
38: ; preds = %36, %38
%39 = phi i64 [ %37, %36 ], [ %43, %38 ]
%40 = getelementptr inbounds i8*, i8** %1, i64 %39
%41 = load i8*, i8** %40
%42 = tail call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i8* %41)
%43 = add nsw i64 %39, 1
%44 = trunc i64 %43 to i32
%45 = icmp eq i32 %44, %0
br i1 %45, label %46, label %38
46: ; preds = %38, %33
br i1 %4, label %47, label %52
47: ; preds = %46
%48 = load i8*, i8** %1
%49 = tail call i8* @strdup(i8* %48)
%50 = tail call i8* @basename(i8* %49)
%51 = tail call i32 @uses(i8* %50)
br label %63
52: ; preds = %46
%53 = icmp eq i32 %8, 1
br i1 %53, label %54, label %56
54: ; preds = %52
%55 = tail call i32 (...) @version()
br label %63
56: ; preds = %52
%57 = icmp eq i8* %11, null
br i1 %57, label %60, label %58
58: ; preds = %56
%59 = tail call zeroext i8 @atoi(i8* %11)
br label %60
60: ; preds = %58, %56
%61 = phi i8 [ %59, %58 ], [ 0, %56 ]
%62 = tail call i32 @print_bits(i8 zeroext %61)
br label %63
63: ; preds = %19, %29, %27, %60, %54, %47
%64 = phi i32 [ 0, %47 ], [ 0, %54 ], [ 0, %60 ], [ 1, %27 ], [ 1, %29 ], [ 1, %19 ]
ret i32 %64
}