#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*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, long long *);
int main() {
  printf("Please enter an integer number to convert to binary: ");
  long long n;
  scanf("%lld", &n);
  int binary[65];
  int i = 0;
  while (n > 0) {
    int currentDigit = n % 2;
    binary[i] = currentDigit;
    n /= 2;
    i++;
  }
  if (n == 0) {
    printf("0");
  }
  for (i = i - 1; i >= 0; i--) {
    printf("%d", binary[i]);
  }
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xec7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeef(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x0,-0x124(%rbp)
cmpq   $0x0,-0x10(%rbp)
jle    11b5 <main+0x95>
mov    -0x10(%rbp),%rax
mov    $0x2,%ecx
cqto
idiv   %rcx
mov    %edx,%eax
mov    %eax,-0x128(%rbp)
mov    -0x128(%rbp),%ecx
movslq -0x124(%rbp),%rax
mov    %ecx,-0x120(%rbp,%rax,4)
mov    -0x10(%rbp),%rax
mov    $0x2,%ecx
cqto
idiv   %rcx
mov    %rax,-0x10(%rbp)
mov    -0x124(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x124(%rbp)
jmp    115a <main+0x3a>
cmpq   $0x0,-0x10(%rbp)
jne    11ce <main+0xae>
lea    0xe74(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x124(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x124(%rbp)
cmpl   $0x0,-0x124(%rbp)
jl     121a <main+0xfa>
movslq -0x124(%rbp),%rax
mov    -0x120(%rbp,%rax,4),%esi
lea    0xe3e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x124(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x124(%rbp)
jmp    11dd <main+0xbd>
lea    0xe1f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x118,%rsp
lea    0xebf(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xee5(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x8(%rsp),%rax
test   %rax,%rax
jle    118e <main+0x5e>
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
mov    %rax,%rcx
mov    %ecx,%edx
and    $0x1,%edx
mov    %edx,0x10(%rsp,%rbx,4)
shr    %rax
add    $0x1,%rbx
cmp    $0x1,%rcx
ja     1170 <main+0x40>
mov    %rax,0x8(%rsp)
test   %rax,%rax
je     1199 <main+0x69>
test   %ebx,%ebx
jg     11a7 <main+0x77>
jmp    11d8 <main+0xa8>
mov    $0x30,%edi
call   1030 <putchar@plt>
test   %ebx,%ebx
jle    11d8 <main+0xa8>
mov    %ebx,%ebx
add    $0x1,%rbx
lea    0xe87(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    0x8(%rsp,%rbx,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0xffffffffffffffff,%rbx
cmp    $0x1,%rbx
ja     11c0 <main+0x90>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x118,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [54 x i8] c"Please enter an integer number to convert to binary: \00"
@.str.1 = [5 x i8] c"%lld\00"
@.str.2 = [2 x i8] c"0\00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca [65 x i32]
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64* %2)
store i32 0, i32* %4
br label %8
8: ; preds = %11, %0
%9 = load i64, i64* %2
%10 = icmp sgt i64 %9, 0
br i1 %10, label %11, label %23
11: ; preds = %8
%12 = load i64, i64* %2
%13 = srem i64 %12, 2
%14 = trunc i64 %13 to i32
store i32 %14, i32* %5
%15 = load i32, i32* %5
%16 = load i32, i32* %4
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [65 x i32], [65 x i32]* %3, i64 0, i64 %17
store i32 %15, i32* %18
%19 = load i64, i64* %2
%20 = sdiv i64 %19, 2
store i64 %20, i64* %2
%21 = load i32, i32* %4
%22 = add nsw i32 %21, 1
store i32 %22, i32* %4
br label %8
23: ; preds = %8
%24 = load i64, i64* %2
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %28
26: ; preds = %23
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %28
28: ; preds = %26, %23
%29 = load i32, i32* %4
%30 = sub nsw i32 %29, 1
store i32 %30, i32* %4
br label %31
31: ; preds = %40, %28
%32 = load i32, i32* %4
%33 = icmp sge i32 %32, 0
br i1 %33, label %34, label %43
34: ; preds = %31
%35 = load i32, i32* %4
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [65 x i32], [65 x i32]* %3, i64 0, i64 %36
%38 = load i32, i32* %37
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %38)
br label %40
40: ; preds = %34
%41 = load i32, i32* %4
%42 = add nsw i32 %41, -1
store i32 %42, i32* %4
br label %31
43: ; preds = %31
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [54 x i8] c"Please enter an integer number to convert to binary: \00"
@.str.1 = [5 x i8] c"%lld\00"
@.str.3 = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca i64
%2 = alloca [65 x i32]
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0))
%4 = bitcast i64* %1 to i8*
%5 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64* %1)
%6 = bitcast [65 x i32]* %2 to i8*
%7 = load i64, i64* %1
%8 = icmp sgt i64 %7, 0
br i1 %8, label %9, label %20
9: ; preds = %0, %9
%10 = phi i64 [ %16, %9 ], [ 0, %0 ]
%11 = phi i64 [ %15, %9 ], [ %7, %0 ]
%12 = trunc i64 %11 to i32
%13 = and i32 %12, 1
%14 = getelementptr inbounds [65 x i32], [65 x i32]* %2, i64 0, i64 %10
store i32 %13, i32* %14
%15 = lshr i64 %11, 1
%16 = add nuw nsw i64 %10, 1
%17 = icmp ult i64 %11, 2
br i1 %17, label %18, label %9
18: ; preds = %9
%19 = trunc i64 %16 to i32
store i64 %15, i64* %1
br label %20
20: ; preds = %18, %0
%21 = phi i64 [ %15, %18 ], [ %7, %0 ]
%22 = phi i32 [ %19, %18 ], [ 0, %0 ]
%23 = icmp eq i64 %21, 0
br i1 %23, label %24, label %26
24: ; preds = %20
%25 = call i32 @putchar(i32 48)
br label %26
26: ; preds = %24, %20
%27 = icmp sgt i32 %22, 0
br i1 %27, label %28, label %37
28: ; preds = %26
%29 = zext i32 %22 to i64
br label %30
30: ; preds = %28, %30
%31 = phi i64 [ %29, %28 ], [ %32, %30 ]
%32 = add nsw i64 %31, -1
%33 = getelementptr inbounds [65 x i32], [65 x i32]* %2, i64 0, i64 %32
%34 = load i32, i32* %33
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %34)
%36 = icmp ugt i64 %31, 1
br i1 %36, label %30, label %37
37: ; preds = %30, %26
%38 = call i32 @putchar(i32 10)
ret i32 0
}