#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 *, char *);
int sscanf(char *, char *, unsigned long *);
int /*<<< orphan*/ stderr;
char *ulong_to_binary_string(unsigned long, char *);
int /*<<< orphan*/ usage(char *);
int main(int argc, char **argv) {
  int argi;
  unsigned long x;
  char binary_buffer[128];
  if (argc < 2)
    usage(argv[0]);
  for (argi = 1; argi < argc; argi++) {
    if (sscanf(argv[argi], "%ld", &x) == 1) {
      printf("%s\n", ulong_to_binary_string(x, binary_buffer));
    } else {
      fprintf(stderr, "Couldn't parse argument \"%s\" as decimal integer.\n",
              argv[argi]);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    117f <main+0x2f>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1060 <usage@plt>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    120f <main+0xbf>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xe5b(%rip),%rsi
lea    -0x20(%rbp),%rdx
call   1050 <sscanf@plt>
cmp    $0x1,%eax
jne    11db <main+0x8b>
mov    -0x20(%rbp),%rdi
lea    -0xa0(%rbp),%rsi
call   1070 <ulong_to_binary_string@plt>
mov    %rax,%rsi
lea    0xe33(%rip),%rdi
call   1030 <printf@plt>
jmp    11fc <main+0xac>
mov    0x2dfe(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xe11(%rip),%rsi
call   1040 <fprintf@plt>
jmp    1201 <main+0xb1>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1186 <main+0x36>
xor    %eax,%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x98,%rsp
mov    %rsi,%rbx
cmp    $0x1,%edi
jg     1185 <main+0x35>
mov    (%rbx),%rdi
call   1060 <usage@plt>
xor    %eax,%eax
add    $0x98,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %edi,%r12d
mov    $0x1,%r13d
lea    0xe6b(%rip),%r14
lea    0x8(%rsp),%r15
lea    0xe67(%rip),%rbp
jmp    11ce <main+0x7e>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    0x2e29(%rip),%rax
mov    (%rax),%edi
mov    (%rbx,%r13,8),%rdx
mov    %rbp,%rsi
call   1040 <fprintf@plt>
add    $0x1,%r13
cmp    %r13,%r12
je     1171 <main+0x21>
mov    (%rbx,%r13,8),%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   1050 <sscanf@plt>
cmp    $0x1,%eax
jne    11b0 <main+0x60>
mov    0x8(%rsp),%rdi
lea    0x10(%rsp),%rsi
call   1070 <ulong_to_binary_string@plt>
lea    0xe0c(%rip),%rdi
mov    %rax,%rsi
call   1030 <printf@plt>
jmp    11c5 <main+0x75>

LLVM IR (-O0):
@.str = [4 x i8] c"%ld\00"
@.str.1 = [4 x i8] c"%s\0A\00"
@stderr = global i32 0
@.str.2 = [50 x i8] c"Couldn't parse argument \22%s\22 as decimal integer.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i64
%8 = alloca [128 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp slt i32 %9, 2
br i1 %10, label %11, label %16
11: ; preds = %2
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 0
%14 = load i8*, i8** %13
%15 = call i32 @usage(i8* %14)
br label %16
16: ; preds = %11, %2
store i32 1, i32* %6
br label %17
17: ; preds = %43, %16
%18 = load i32, i32* %6
%19 = load i32, i32* %4
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %46
21: ; preds = %17
%22 = load i8**, i8*** %5
%23 = load i32, i32* %6
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8*, i8** %22, i64 %24
%26 = load i8*, i8** %25
%27 = call i32 @sscanf(i8* %26, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64* %7)
%28 = icmp eq i32 %27, 1
br i1 %28, label %29, label %34
29: ; preds = %21
%30 = load i64, i64* %7
%31 = getelementptr inbounds [128 x i8], [128 x i8]* %8, i64 0, i64 0
%32 = call i8* @ulong_to_binary_string(i64 %30, i8* %31)
%33 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %32)
br label %42
34: ; preds = %21
%35 = load i32, i32* @stderr
%36 = load i8**, i8*** %5
%37 = load i32, i32* %6
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i8*, i8** %36, i64 %38
%40 = load i8*, i8** %39
%41 = call i32 @fprintf(i32 %35, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.2, i64 0, i64 0), i8* %40)
br label %42
42: ; preds = %34, %29
br label %43
43: ; preds = %42
%44 = load i32, i32* %6
%45 = add nsw i32 %44, 1
store i32 %45, i32* %6
br label %17
46: ; preds = %17
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%ld\00"
@.str.1 = [4 x i8] c"%s\0A\00"
@stderr = global i32 0
@.str.2 = [50 x i8] c"Couldn't parse argument \22%s\22 as decimal integer.\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i64
%4 = alloca [128 x i8]
%5 = bitcast i64* %3 to i8*
%6 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
%7 = icmp slt i32 %0, 2
br i1 %7, label %8, label %11
8: ; preds = %2
%9 = load i8*, i8** %1
%10 = tail call i32 @usage(i8* %9)
br label %30
11: ; preds = %2
%12 = zext i32 %0 to i64
br label %13
13: ; preds = %11, %27
%14 = phi i64 [ 1, %11 ], [ %28, %27 ]
%15 = getelementptr inbounds i8*, i8** %1, i64 %14
%16 = load i8*, i8** %15
%17 = call i32 @sscanf(i8* %16, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64* %3)
%18 = icmp eq i32 %17, 1
br i1 %18, label %19, label %23
19: ; preds = %13
%20 = load i64, i64* %3
%21 = call i8* @ulong_to_binary_string(i64 %20, i8* %6)
%22 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %21)
br label %27
23: ; preds = %13
%24 = load i32, i32* @stderr
%25 = load i8*, i8** %15
%26 = call i32 @fprintf(i32 %24, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.2, i64 0, i64 0), i8* %25)
br label %27
27: ; preds = %19, %23
%28 = add nuw nsw i64 %14, 1
%29 = icmp eq i64 %28, %12
br i1 %29, label %30, label %13
30: ; preds = %27, %8
ret i32 0
}