#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*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ printf(char *, unsigned long);
int /*<<< orphan*/ stderr;
scalar_t__ ulong_from_binary_string(char *, unsigned long *);
int /*<<< orphan*/ usage(char *);
int main(int argc, char **argv) {
  int argi;
  unsigned long x;
  if (argc < 2)
    usage(argv[0]);
  for (argi = 1; argi < argc; argi++) {
    if (ulong_from_binary_string(argv[argi], &x)) {
      printf("%08lx\n", x);
    } else {
      fprintf(stderr, "Non-binary input \"%s\".\n", argv[argi]);
    }
  }
  return 0;
}


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    116c <main+0x2c>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1060 <usage@plt>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11e7 <main+0xa7>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    -0x20(%rbp),%rsi
call   1030 <ulong_from_binary_string@plt>
cmp    $0x0,%rax
je     11b3 <main+0x73>
mov    -0x20(%rbp),%rsi
lea    0xe57(%rip),%rdi
call   1040 <printf@plt>
jmp    11d4 <main+0x94>
mov    0x2e26(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xe38(%rip),%rsi
call   1050 <fprintf@plt>
jmp    11d9 <main+0x99>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1173 <main+0x33>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rbx
cmp    $0x1,%edi
jg     116c <main+0x2c>
mov    (%rbx),%rdi
call   1060 <usage@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %edi,%r13d
mov    $0x1,%ebp
mov    %rsp,%r14
lea    0xe89(%rip),%r15
lea    0xe7b(%rip),%r12
jmp    11ae <main+0x6e>
nopw   0x0(%rax,%rax,1)
mov    0x2e49(%rip),%rax
mov    (%rax),%edi
mov    (%rbx,%rbp,8),%rdx
mov    %r15,%rsi
call   1050 <fprintf@plt>
add    $0x1,%rbp
cmp    %rbp,%r13
je     115b <main+0x1b>
mov    (%rbx,%rbp,8),%rdi
mov    %r14,%rsi
call   1030 <ulong_from_binary_string@plt>
test   %rax,%rax
je     1190 <main+0x50>
mov    (%rsp),%rsi
mov    %r12,%rdi
call   1040 <printf@plt>
jmp    11a5 <main+0x65>

LLVM IR (-O0):
@.str = [7 x i8] c"%08lx\0A\00"
@stderr = global i32 0
@.str.1 = [24 x i8] c"Non-binary input \22%s\22.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i64
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 %15
10: ; preds = %2
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 0
%13 = load i8*, i8** %12
%14 = call i32 @usage(i8* %13)
br label %15
15: ; preds = %10, %2
store i32 1, i32* %6
br label %16
16: ; preds = %40, %15
%17 = load i32, i32* %6
%18 = load i32, i32* %4
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %43
20: ; preds = %16
%21 = load i8**, i8*** %5
%22 = load i32, i32* %6
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8*, i8** %21, i64 %23
%25 = load i8*, i8** %24
%26 = call i64 @ulong_from_binary_string(i8* %25, i64* %7)
%27 = icmp ne i64 %26, 0
br i1 %27, label %28, label %31
28: ; preds = %20
%29 = load i64, i64* %7
%30 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i64 %29)
br label %39
31: ; preds = %20
%32 = load i32, i32* @stderr
%33 = load i8**, i8*** %5
%34 = load i32, i32* %6
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i8*, i8** %33, i64 %35
%37 = load i8*, i8** %36
%38 = call i32 @fprintf(i32 %32, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i8* %37)
br label %39
39: ; preds = %31, %28
br label %40
40: ; preds = %39
%41 = load i32, i32* %6
%42 = add nsw i32 %41, 1
store i32 %42, i32* %6
br label %16
43: ; preds = %16
ret i32 0
}

LLVM IR (-O2):
@.str = [7 x i8] c"%08lx\0A\00"
@stderr = global i32 0
@.str.1 = [24 x i8] c"Non-binary input \22%s\22.\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i64
%4 = bitcast i64* %3 to i8*
%5 = icmp slt i32 %0, 2
br i1 %5, label %6, label %9
6: ; preds = %2
%7 = load i8*, i8** %1
%8 = tail call i32 @usage(i8* %7)
br label %27
9: ; preds = %2
%10 = zext i32 %0 to i64
br label %11
11: ; preds = %9, %24
%12 = phi i64 [ 1, %9 ], [ %25, %24 ]
%13 = getelementptr inbounds i8*, i8** %1, i64 %12
%14 = load i8*, i8** %13
%15 = call i64 @ulong_from_binary_string(i8* %14, i64* %3)
%16 = icmp eq i64 %15, 0
br i1 %16, label %20, label %17
17: ; preds = %11
%18 = load i64, i64* %3
%19 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i64 %18)
br label %24
20: ; preds = %11
%21 = load i32, i32* @stderr
%22 = load i8*, i8** %13
%23 = call i32 @fprintf(i32 %21, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i8* %22)
br label %24
24: ; preds = %17, %20
%25 = add nuw nsw i64 %12, 1
%26 = icmp eq i64 %25, %10
br i1 %26, label %27, label %11
27: ; preds = %24, %6
ret i32 0
}