#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*/ convert_to_binary(int, char *, int *);
int /*<<< orphan*/ get_input(int *);
int /*<<< orphan*/ printf(char *, ...);
int main(void) {
  int decimal, i;
  int bit_sig = 15;
  char binary[16];
  for (i = 0; i < 15; i++)
    binary[i] = '0';
  binary[bit_sig--] = '\0';
  printf("\n");
  get_input(&decimal);
  convert_to_binary(decimal, binary, &bit_sig);
  printf("The binary form of %d is %s\n\n", decimal, binary);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0xf,-0x10(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0xf,-0xc(%rbp)
jge    116e <main+0x3e>
movslq -0xc(%rbp),%rax
movb   $0x30,-0x20(%rbp,%rax,1)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    114d <main+0x1d>
mov    -0x10(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x10(%rbp)
cltq
movb   $0x0,-0x20(%rbp,%rax,1)
lea    0xe95(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x8(%rbp),%rdi
call   1050 <get_input@plt>
mov    -0x8(%rbp),%edi
lea    -0x20(%rbp),%rsi
lea    -0x10(%rbp),%rdx
call   1030 <convert_to_binary@plt>
mov    -0x8(%rbp),%esi
lea    -0x20(%rbp),%rdx
lea    0xe4b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
movabs $0x3030303030303030,%rax
30 30 30
mov    %rax,0x17(%rsp)
mov    %rax,0x10(%rsp)
movl   $0xe,0xc(%rsp)
movb   $0x0,0x1f(%rsp)
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0x8(%rsp),%rdi
call   1060 <get_input@plt>
mov    0x8(%rsp),%edi
lea    0x10(%rsp),%rbx
lea    0xc(%rsp),%rdx
mov    %rbx,%rsi
call   1040 <convert_to_binary@plt>
mov    0x8(%rsp),%esi
lea    0xe65(%rip),%rdi
mov    %rbx,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [2 x i8] c"\0A\00"
@.str.1 = [30 x i8] c"The binary form of %d is %s\0A\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca [16 x i8]
store i32 0, i32* %1
store i32 15, i32* %4
store i32 0, i32* %3
br label %6
6: ; preds = %13, %0
%7 = load i32, i32* %3
%8 = icmp slt i32 %7, 15
br i1 %8, label %9, label %16
9: ; preds = %6
%10 = load i32, i32* %3
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds [16 x i8], [16 x i8]* %5, i64 0, i64 %11
store i8 48, i8* %12
br label %13
13: ; preds = %9
%14 = load i32, i32* %3
%15 = add nsw i32 %14, 1
store i32 %15, i32* %3
br label %6
16: ; preds = %6
%17 = load i32, i32* %4
%18 = add nsw i32 %17, -1
store i32 %18, i32* %4
%19 = sext i32 %17 to i64
%20 = getelementptr inbounds [16 x i8], [16 x i8]* %5, i64 0, i64 %19
store i8 0, i8* %20
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%22 = call i32 @get_input(i32* %2)
%23 = load i32, i32* %2
%24 = getelementptr inbounds [16 x i8], [16 x i8]* %5, i64 0, i64 0
%25 = call i32 @convert_to_binary(i32 %23, i8* %24, i32* %4)
%26 = load i32, i32* %2
%27 = getelementptr inbounds [16 x i8], [16 x i8]* %5, i64 0, i64 0
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i32 %26, i8* %27)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [30 x i8] c"The binary form of %d is %s\0A\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [16 x i8]
%4 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 0
%5 = bitcast i32* %1 to i8*
%6 = bitcast i32* %2 to i8*
%7 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 0
store i32 14, i32* %2
%8 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 15
store i8 0, i8* %8
%9 = tail call i32 @putchar(i32 10)
%10 = call i32 @get_input(i32* %1)
%11 = load i32, i32* %1
%12 = call i32 @convert_to_binary(i32 %11, i8* %7, i32* %2)
%13 = load i32, i32* %1
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i32 %13, i8* %7)
ret i32 0
}