#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 *, ...);
void dec2bin(int decimal) {
  int remainder[32];
  int quocient = decimal, i = 0;
  while (quocient >= 2) {
    remainder[i] = quocient % 2;
    quocient = quocient / 2;
    i++;
  }
  remainder[i] = quocient;
  printf("The decimal number %d in binary is: ", decimal);
  while (i >= 0) {
    printf("%d", remainder[i]);
    i--;
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<dec2bin>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x94(%rbp)
movl   $0x0,-0x98(%rbp)
cmpl   $0x2,-0x94(%rbp)
jl     1182 <dec2bin+0x72>
mov    -0x94(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
movslq -0x98(%rbp),%rax
mov    %edx,-0x90(%rbp,%rax,4)
mov    -0x94(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x94(%rbp)
mov    -0x98(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x98(%rbp)
jmp    1131 <dec2bin+0x21>
mov    -0x94(%rbp),%ecx
movslq -0x98(%rbp),%rax
mov    %ecx,-0x90(%rbp,%rax,4)
mov    -0x4(%rbp),%esi
lea    0xe60(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x0,-0x98(%rbp)
jl     11e4 <dec2bin+0xd4>
movslq -0x98(%rbp),%rax
mov    -0x90(%rbp,%rax,4),%esi
lea    0xe5c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x98(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x98(%rbp)
jmp    11a7 <dec2bin+0x97>
lea    0xe3d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dec2bin>:
push   %rbp
push   %r14
push   %rbx
sub    $0x80,%rsp
mov    %edi,%r14d
cmp    $0x2,%edi
jl     1173 <dec2bin+0x53>
xor    %ebx,%ebx
mov    %r14d,%ebp
nopl   0x0(%rax,%rax,1)
mov    %ebp,%eax
mov    %ebp,%ecx
and    $0x1,%ecx
mov    %ecx,(%rsp,%rbx,4)
shr    %ebp
add    $0x1,%rbx
cmp    $0x3,%eax
ja     1140 <dec2bin+0x20>
mov    %ebp,(%rsp,%rbx,4)
lea    0xea1(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
test   $0x80000000,%ebx
je     118d <dec2bin+0x6d>
jmp    11c8 <dec2bin+0xa8>
mov    %r14d,(%rsp)
lea    0xe82(%rip),%rdi
xor    %ebx,%ebx
mov    %r14d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14d,%ebp
lea    0xe91(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
test   %rbx,%rbx
je     11c8 <dec2bin+0xa8>
add    $0x1,%rbx
lea    0xe78(%rip),%rbp
nopl   (%rax)
mov    -0x8(%rsp,%rbx,4),%esi
mov    %rbp,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0xffffffffffffffff,%rbx
cmp    $0x1,%rbx
jg     11b0 <dec2bin+0x90>
mov    $0xa,%edi
add    $0x80,%rsp
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@.str = [37 x i8] c"The decimal number %d in binary is: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [2 x i8] c"\0A\00"
define void @dec2bin(i32 %0) {
%2 = alloca i32
%3 = alloca [32 x i32]
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %2
%6 = load i32, i32* %2
store i32 %6, i32* %4
store i32 0, i32* %5
br label %7
7: ; preds = %10, %1
%8 = load i32, i32* %4
%9 = icmp sge i32 %8, 2
br i1 %9, label %10, label %20
10: ; preds = %7
%11 = load i32, i32* %4
%12 = srem i32 %11, 2
%13 = load i32, i32* %5
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds [32 x i32], [32 x i32]* %3, i64 0, i64 %14
store i32 %12, i32* %15
%16 = load i32, i32* %4
%17 = sdiv i32 %16, 2
store i32 %17, i32* %4
%18 = load i32, i32* %5
%19 = add nsw i32 %18, 1
store i32 %19, i32* %5
br label %7
20: ; preds = %7
%21 = load i32, i32* %4
%22 = load i32, i32* %5
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [32 x i32], [32 x i32]* %3, i64 0, i64 %23
store i32 %21, i32* %24
%25 = load i32, i32* %2
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i32 %25)
br label %27
27: ; preds = %30, %20
%28 = load i32, i32* %5
%29 = icmp sge i32 %28, 0
br i1 %29, label %30, label %38
30: ; preds = %27
%31 = load i32, i32* %5
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [32 x i32], [32 x i32]* %3, 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)
%36 = load i32, i32* %5
%37 = add nsw i32 %36, -1
store i32 %37, i32* %5
br label %27
38: ; preds = %27
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [37 x i8] c"The decimal number %d in binary is: \00"
@.str.1 = [3 x i8] c"%d\00"
define void @dec2bin(i32 %0) {
%2 = alloca [32 x i32]
%3 = bitcast [32 x i32]* %2 to i8*
%4 = icmp sgt i32 %0, 1
br i1 %4, label %8, label %5
5: ; preds = %1
%6 = getelementptr inbounds [32 x i32], [32 x i32]* %2, i64 0, i64 0
store i32 %0, i32* %6
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i32 %0)
br label %22
8: ; preds = %1, %8
%9 = phi i64 [ %14, %8 ], [ 0, %1 ]
%10 = phi i32 [ %13, %8 ], [ %0, %1 ]
%11 = and i32 %10, 1
%12 = getelementptr inbounds [32 x i32], [32 x i32]* %2, i64 0, i64 %9
store i32 %11, i32* %12
%13 = lshr i32 %10, 1
%14 = add nuw nsw i64 %9, 1
%15 = icmp ugt i32 %10, 3
br i1 %15, label %8, label %16
16: ; preds = %8
%17 = and i64 %14, 4294967295
%18 = getelementptr inbounds [32 x i32], [32 x i32]* %2, i64 0, i64 %17
store i32 %13, i32* %18
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i32 %0)
%20 = and i64 %14, 2147483648
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %34
22: ; preds = %5, %16
%23 = phi i64 [ 0, %5 ], [ %17, %16 ]
%24 = phi i32 [ %0, %5 ], [ %13, %16 ]
%25 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %24)
%26 = icmp eq i64 %23, 0
br i1 %26, label %34, label %27
27: ; preds = %22, %27
%28 = phi i64 [ %29, %27 ], [ %23, %22 ]
%29 = add nsw i64 %28, -1
%30 = getelementptr inbounds [32 x i32], [32 x i32]* %2, i64 0, i64 %29
%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 = icmp sgt i64 %28, 1
br i1 %33, label %27, label %34
34: ; preds = %27, %22, %16
%35 = tail call i32 @putchar(i32 10)
ret void
}