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

/* Variables and functions */
int /*<<< orphan*/ memset(int *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, ...);
void binary(int a) {
  int c, i = 12, bol[13] = {0};
  c = a;
  while (a != 0) {
    bol[i] = a % 2;
    a = a / 2;
    i--;
  }
  if (c == 0) {
    printf("0000000000000");
  } else {
    for (i = 0; i < 13; i++) {
      printf("%d", bol[i]);
    }
  }
  memset(bol, 0, sizeof(bol));
}


x86 assembly (clang, -O0):
<binary>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
movl   $0xc,-0xc(%rbp)
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x34,%edx
call   1040 <memset@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x4(%rbp)
je     1181 <binary+0x61>
mov    -0x4(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
movslq -0xc(%rbp),%rax
mov    %edx,-0x40(%rbp,%rax,4)
mov    -0x4(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x4(%rbp)
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
jmp    1148 <binary+0x28>
cmpl   $0x0,-0x8(%rbp)
jne    119e <binary+0x7e>
lea    0xe6e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11d8 <binary+0xb8>
movl   $0x0,-0xc(%rbp)
cmpl   $0xd,-0xc(%rbp)
jge    11d3 <binary+0xb3>
movslq -0xc(%rbp),%rax
mov    -0x40(%rbp,%rax,4),%esi
lea    0xe50(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11a5 <binary+0x85>
jmp    11d8 <binary+0xb8>
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x34,%edx
call   1040 <memset@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<binary>:
push   %rbx
sub    $0x40,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
movl   $0x0,0x30(%rsp)
test   %edi,%edi
je     122e <binary+0x10e>
lea    0x30(%rsp),%rax
mov    %edi,%ecx
nopl   (%rax)
shr    $0x1f,%ecx
add    %edi,%ecx
mov    %ecx,%edx
and    $0xfffffffe,%edx
mov    %edi,%esi
sub    %edx,%esi
mov    %esi,(%rax)
sar    %ecx
add    $0x1,%edi
add    $0xfffffffffffffffc,%rax
cmp    $0x2,%edi
mov    %ecx,%edi
ja     1150 <binary+0x30>
mov    (%rsp),%esi
lea    0xe94(%rip),%rbx
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x4(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x8(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0xc(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x10(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x14(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x18(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x1c(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x20(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x24(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x28(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x2c(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x30(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    123c <binary+0x11c>
lea    0xdcb(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rsp,%rdi
xor    %esi,%esi
mov    $0x34,%edx
call   1040 <memset@plt>
add    $0x40,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [14 x i8] c"0000000000000\00"
@.str.1 = [3 x i8] c"%d\00"
define void @binary(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca [13 x i32]
store i32 %0, i32* %2
store i32 12, i32* %4
%6 = bitcast [13 x i32]* %5 to i8*
%7 = load i32, i32* %2
store i32 %7, i32* %3
br label %8
8: ; preds = %11, %1
%9 = load i32, i32* %2
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %21
11: ; preds = %8
%12 = load i32, i32* %2
%13 = srem i32 %12, 2
%14 = load i32, i32* %4
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [13 x i32], [13 x i32]* %5, i64 0, i64 %15
store i32 %13, i32* %16
%17 = load i32, i32* %2
%18 = sdiv i32 %17, 2
store i32 %18, i32* %2
%19 = load i32, i32* %4
%20 = add nsw i32 %19, -1
store i32 %20, i32* %4
br label %8
21: ; preds = %8
%22 = load i32, i32* %3
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %21
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
br label %40
26: ; preds = %21
store i32 0, i32* %4
br label %27
27: ; preds = %36, %26
%28 = load i32, i32* %4
%29 = icmp slt i32 %28, 13
br i1 %29, label %30, label %39
30: ; preds = %27
%31 = load i32, i32* %4
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [13 x i32], [13 x i32]* %5, i64 0, i64 %32
%34 = load i32, i32* %33
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %34)
br label %36
36: ; preds = %30
%37 = load i32, i32* %4
%38 = add nsw i32 %37, 1
store i32 %38, i32* %4
br label %27
39: ; preds = %27
br label %40
40: ; preds = %39, %24
%41 = getelementptr inbounds [13 x i32], [13 x i32]* %5, i64 0, i64 0
%42 = call i32 @memset(i32* %41, i32 0, i32 52)
ret void
}

LLVM IR (-O2):
@.str = [14 x i8] c"0000000000000\00"
@.str.1 = [3 x i8] c"%d\00"
define void @binary(i32 %0) {
%2 = alloca [13 x i32]
%3 = bitcast [13 x i32]* %2 to i8*
%4 = icmp eq i32 %0, 0
br i1 %4, label %54, label %5
5: ; preds = %1, %5
%6 = phi i64 [ %11, %5 ], [ 12, %1 ]
%7 = phi i32 [ %10, %5 ], [ %0, %1 ]
%8 = srem i32 %7, 2
%9 = getelementptr inbounds [13 x i32], [13 x i32]* %2, i64 0, i64 %6
store i32 %8, i32* %9
%10 = sdiv i32 %7, 2
%11 = add i64 %6, -1
%12 = add i32 %7, 1
%13 = icmp ult i32 %12, 3
br i1 %13, label %14, label %5
14: ; preds = %5
%15 = getelementptr inbounds [13 x i32], [13 x i32]* %2, i64 0, i64 0
%16 = load i32, i32* %15
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %16)
%18 = getelementptr inbounds [13 x i32], [13 x i32]* %2, i64 0, i64 1
%19 = load i32, i32* %18
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %19)
%21 = getelementptr inbounds [13 x i32], [13 x i32]* %2, i64 0, i64 2
%22 = load i32, i32* %21
%23 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %22)
%24 = getelementptr inbounds [13 x i32], [13 x i32]* %2, i64 0, i64 3
%25 = load i32, i32* %24
%26 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %25)
%27 = getelementptr inbounds [13 x i32], [13 x i32]* %2, i64 0, i64 4
%28 = load i32, i32* %27
%29 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %28)
%30 = getelementptr inbounds [13 x i32], [13 x i32]* %2, i64 0, i64 5
%31 = load i32, i32* %30
%32 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %31)
%33 = getelementptr inbounds [13 x i32], [13 x i32]* %2, i64 0, i64 6
%34 = load i32, i32* %33
%35 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %34)
%36 = getelementptr inbounds [13 x i32], [13 x i32]* %2, i64 0, i64 7
%37 = load i32, i32* %36
%38 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %37)
%39 = getelementptr inbounds [13 x i32], [13 x i32]* %2, i64 0, i64 8
%40 = load i32, i32* %39
%41 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %40)
%42 = getelementptr inbounds [13 x i32], [13 x i32]* %2, i64 0, i64 9
%43 = load i32, i32* %42
%44 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %43)
%45 = getelementptr inbounds [13 x i32], [13 x i32]* %2, i64 0, i64 10
%46 = load i32, i32* %45
%47 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %46)
%48 = getelementptr inbounds [13 x i32], [13 x i32]* %2, i64 0, i64 11
%49 = load i32, i32* %48
%50 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %49)
%51 = getelementptr inbounds [13 x i32], [13 x i32]* %2, i64 0, i64 12
%52 = load i32, i32* %51
%53 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %52)
br label %56
54: ; preds = %1
%55 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
br label %56
56: ; preds = %14, %54
%57 = getelementptr inbounds [13 x i32], [13 x i32]* %2, i64 0, i64 0
%58 = call i32 @memset(i32* %57, i32 0, i32 52)
ret void
}