#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 EXIT_SUCCESS;
int /*<<< orphan*/ checkIntInput(long *);
int decimalToBbinary(long, char *);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  long decimal;
  char binary[50];
  printf("Enter decimal number: ");
  checkIntInput(&decimal);
  if (decimal) {
    int startBit = decimalToBbinary(decimal, binary);
    printf("decimal %ld is in binary %s", decimal, (binary + startBit));
  } else {
    printf("decimal %lu is in binary 0", decimal);
  }
  return (EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x10(%rbp),%rdi
call   1030 <checkIntInput@plt>
cmpq   $0x0,-0x10(%rbp)
je     1193 <main+0x63>
mov    -0x10(%rbp),%rdi
lea    -0x50(%rbp),%rsi
call   1050 <decimalToBbinary@plt>
mov    %eax,-0x54(%rbp)
mov    -0x10(%rbp),%rsi
lea    -0x50(%rbp),%rdx
movslq -0x54(%rbp),%rax
add    %rax,%rdx
lea    0xe90(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11a5 <main+0x75>
mov    -0x10(%rbp),%rsi
lea    0xe95(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2e34(%rip),%rax
mov    (%rax),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x48,%rsp
lea    0xec5(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x8(%rsp),%rdi
call   1030 <checkIntInput@plt>
mov    0x8(%rsp),%rdi
test   %rdi,%rdi
je     117f <main+0x4f>
lea    0x10(%rsp),%rsi
call   1050 <decimalToBbinary@plt>
mov    0x8(%rsp),%rsi
cltq
lea    (%rsp,%rax,1),%rdx
add    $0x10,%rdx
lea    0xea1(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    118f <main+0x5f>
lea    0xead(%rip),%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2e4a(%rip),%rax
mov    (%rax),%eax
add    $0x48,%rsp
ret

LLVM IR (-O0):
@.str = [23 x i8] c"Enter decimal number: \00"
@.str.1 = [28 x i8] c"decimal %ld is in binary %s\00"
@.str.2 = [27 x i8] c"decimal %lu is in binary 0\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca [50 x i8]
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @checkIntInput(i64* %2)
%7 = load i64, i64* %2
%8 = icmp ne i64 %7, 0
br i1 %8, label %9, label %19
9: ; preds = %0
%10 = load i64, i64* %2
%11 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%12 = call i32 @decimalToBbinary(i64 %10, i8* %11)
store i32 %12, i32* %4
%13 = load i64, i64* %2
%14 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%15 = load i32, i32* %4
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8, i8* %14, i64 %16
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i64 %13, i8* %17)
br label %22
19: ; preds = %0
%20 = load i64, i64* %2
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i64 %20)
br label %22
22: ; preds = %19, %9
%23 = load i32, i32* @EXIT_SUCCESS
ret i32 %23
}

LLVM IR (-O2):
@.str = [23 x i8] c"Enter decimal number: \00"
@.str.1 = [28 x i8] c"decimal %ld is in binary %s\00"
@.str.2 = [27 x i8] c"decimal %lu is in binary 0\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i64
%2 = alloca [50 x i8]
%3 = bitcast i64* %1 to i8*
%4 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @checkIntInput(i64* %1)
%7 = load i64, i64* %1
%8 = icmp eq i64 %7, 0
br i1 %8, label %15, label %9
9: ; preds = %0
%10 = call i32 @decimalToBbinary(i64 %7, i8* %4)
%11 = load i64, i64* %1
%12 = sext i32 %10 to i64
%13 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 %12
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i64 %11, i8* %13)
br label %17
15: ; preds = %0
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i64 0)
br label %17
17: ; preds = %15, %9
%18 = load i32, i32* @EXIT_SUCCESS
ret i32 %18
}