#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*/ putchar(char);
int scanf(char *, unsigned long *);
int /*<<< orphan*/ to_binary(unsigned long);
int main(void) {
  unsigned long number;
  printf("Enter an integer (q to quit):\n");
  while (scanf("%lu", &number) == 1) {
    printf("Binary equivalent: ");
    to_binary(number);
    putchar('\n');
    printf("Enter an integer (q to quit):\n");
  }
  printf("Done.\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
call   1050 <printf@plt>
lea    0xebd(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1060 <scanf@plt>
cmp    $0x1,%eax
jne    11a4 <main+0x64>
lea    0xea8(%rip),%rdi
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1040 <to_binary@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xe66(%rip),%rdi
call   1050 <printf@plt>
jmp    115b <main+0x1b>
lea    0xe8c(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
lea    0xebf(%rip),%rdi
call   1040 <puts@plt>
lea    0xe95(%rip),%rdi
mov    %rsp,%rsi
call   1070 <scanf@plt>
cmp    $0x1,%eax
jne    11c3 <main+0x73>
lea    0xe85(%rip),%r14
lea    0xe98(%rip),%r15
lea    0xe73(%rip),%r12
mov    %rsp,%rbx
mov    %r14,%rdi
call   1060 <printf@plt>
mov    (%rsp),%rdi
call   1050 <to_binary@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r15,%rdi
call   1040 <puts@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1070 <scanf@plt>
cmp    $0x1,%eax
je     1190 <main+0x40>
lea    0xe4e(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [31 x i8] c"Enter an integer (q to quit):\0A\00"
@.str.1 = [4 x i8] c"%lu\00"
@.str.2 = [20 x i8] c"Binary equivalent: \00"
@.str.3 = [7 x i8] c"Done.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
store i32 0, i32* %1
%3 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
br label %4
4: ; preds = %7, %0
%5 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64* %2)
%6 = icmp eq i32 %5, 1
br i1 %6, label %7, label %13
7: ; preds = %4
%8 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%9 = load i64, i64* %2
%10 = call i32 @to_binary(i64 %9)
%11 = call i32 @putchar(i8 signext 10)
%12 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
br label %4
13: ; preds = %4
%14 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [4 x i8] c"%lu\00"
@.str.2 = [20 x i8] c"Binary equivalent: \00"
@str.4 = [6 x i8] c"Done.\00"
@str.5 = [30 x i8] c"Enter an integer (q to quit):\00"
define i32 @main() {
%1 = alloca i64
%2 = bitcast i64* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str.5, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64* %1)
%5 = icmp eq i32 %4, 1
br i1 %5, label %6, label %14
6: ; preds = %0, %6
%7 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%8 = load i64, i64* %1
%9 = call i32 @to_binary(i64 %8)
%10 = call i32 @putchar(i8 signext 10)
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str.5, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64* %1)
%13 = icmp eq i32 %12, 1
br i1 %13, label %6, label %14
14: ; preds = %6, %0
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str.4, i64 0, i64 0))
ret i32 0
}