#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 decimal_to_binary(int number) {
  int weight = 256;
  int counter = 0;
  while (counter != 9) {
    if (number >= weight) {
      printf("1");
      counter++;
      number = number - weight;
    } else {
      printf("0");
      counter++;
    }
    weight = weight / 2;
  }
  return 0;
}


x86 assembly (clang, -O0):
<decimal_to_binary>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x100,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x9,-0xc(%rbp)
je     118a <decimal_to_binary+0x7a>
mov    -0x4(%rbp),%eax
cmp    -0x8(%rbp),%eax
jl     1162 <decimal_to_binary+0x52>
lea    0xeba(%rip),%rdi
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x4(%rbp),%eax
sub    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1177 <decimal_to_binary+0x67>
lea    0xe99(%rip),%rdi
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
jmp    1129 <decimal_to_binary+0x19>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<decimal_to_binary>:
push   %rbx
mov    %edi,%ebx
cmp    $0x100,%edi
jge    11cb <decimal_to_binary+0xbb>
mov    $0x30,%edi
call   1030 <putchar@plt>
cmp    $0x80,%ebx
jl     11e7 <decimal_to_binary+0xd7>
mov    $0x31,%edi
call   1030 <putchar@plt>
add    $0xffffff80,%ebx
cmp    $0x40,%ebx
jl     11fa <decimal_to_binary+0xea>
mov    $0x31,%edi
call   1030 <putchar@plt>
add    $0xffffffc0,%ebx
cmp    $0x20,%ebx
jl     120d <decimal_to_binary+0xfd>
mov    $0x31,%edi
call   1030 <putchar@plt>
add    $0xffffffe0,%ebx
cmp    $0x10,%ebx
jl     1220 <decimal_to_binary+0x110>
mov    $0x31,%edi
call   1030 <putchar@plt>
add    $0xfffffff0,%ebx
cmp    $0x8,%ebx
jl     1233 <decimal_to_binary+0x123>
mov    $0x31,%edi
call   1030 <putchar@plt>
add    $0xfffffff8,%ebx
cmp    $0x4,%ebx
jl     1246 <decimal_to_binary+0x136>
mov    $0x31,%edi
call   1030 <putchar@plt>
add    $0xfffffffc,%ebx
cmp    $0x2,%ebx
jl     1259 <decimal_to_binary+0x149>
mov    $0x31,%edi
call   1030 <putchar@plt>
add    $0xfffffffe,%ebx
jmp    1263 <decimal_to_binary+0x153>
mov    $0x31,%edi
call   1030 <putchar@plt>
add    $0xffffff00,%ebx
cmp    $0x80,%ebx
jge    1135 <decimal_to_binary+0x25>
mov    $0x30,%edi
call   1030 <putchar@plt>
cmp    $0x40,%ebx
jge    114b <decimal_to_binary+0x3b>
mov    $0x30,%edi
call   1030 <putchar@plt>
cmp    $0x20,%ebx
jge    1161 <decimal_to_binary+0x51>
mov    $0x30,%edi
call   1030 <putchar@plt>
cmp    $0x10,%ebx
jge    1177 <decimal_to_binary+0x67>
mov    $0x30,%edi
call   1030 <putchar@plt>
cmp    $0x8,%ebx
jge    118d <decimal_to_binary+0x7d>
mov    $0x30,%edi
call   1030 <putchar@plt>
cmp    $0x4,%ebx
jge    11a3 <decimal_to_binary+0x93>
mov    $0x30,%edi
call   1030 <putchar@plt>
cmp    $0x2,%ebx
jge    11b9 <decimal_to_binary+0xa9>
mov    $0x30,%edi
call   1030 <putchar@plt>
xor    %edi,%edi
test   %ebx,%ebx
setle  %dil
xor    $0x31,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [2 x i8] c"1\00"
@.str.1 = [2 x i8] c"0\00"
define i32 @decimal_to_binary(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %2
store i32 256, i32* %3
store i32 0, i32* %4
br label %5
5: ; preds = %23, %1
%6 = load i32, i32* %4
%7 = icmp ne i32 %6, 9
br i1 %7, label %8, label %26
8: ; preds = %5
%9 = load i32, i32* %2
%10 = load i32, i32* %3
%11 = icmp sge i32 %9, %10
br i1 %11, label %12, label %19
12: ; preds = %8
%13 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%14 = load i32, i32* %4
%15 = add nsw i32 %14, 1
store i32 %15, i32* %4
%16 = load i32, i32* %2
%17 = load i32, i32* %3
%18 = sub nsw i32 %16, %17
store i32 %18, i32* %2
br label %23
19: ; preds = %8
%20 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%21 = load i32, i32* %4
%22 = add nsw i32 %21, 1
store i32 %22, i32* %4
br label %23
23: ; preds = %19, %12
%24 = load i32, i32* %3
%25 = sdiv i32 %24, 2
store i32 %25, i32* %3
br label %5
26: ; preds = %5
ret i32 0
}

LLVM IR (-O2):
define i32 @decimal_to_binary(i32 %0) {
%2 = icmp slt i32 %0, 256
br i1 %2, label %6, label %3
3: ; preds = %1
%4 = tail call i32 @putchar(i32 49)
%5 = add nsw i32 %0, -256
br label %8
6: ; preds = %1
%7 = tail call i32 @putchar(i32 48)
br label %8
8: ; preds = %6, %3
%9 = phi i32 [ %5, %3 ], [ %0, %6 ]
%10 = icmp slt i32 %9, 128
br i1 %10, label %14, label %11
11: ; preds = %8
%12 = tail call i32 @putchar(i32 49)
%13 = add nsw i32 %9, -128
br label %16
14: ; preds = %8
%15 = tail call i32 @putchar(i32 48)
br label %16
16: ; preds = %14, %11
%17 = phi i32 [ %13, %11 ], [ %9, %14 ]
%18 = icmp slt i32 %17, 64
br i1 %18, label %22, label %19
19: ; preds = %16
%20 = tail call i32 @putchar(i32 49)
%21 = add nsw i32 %17, -64
br label %24
22: ; preds = %16
%23 = tail call i32 @putchar(i32 48)
br label %24
24: ; preds = %22, %19
%25 = phi i32 [ %21, %19 ], [ %17, %22 ]
%26 = icmp slt i32 %25, 32
br i1 %26, label %30, label %27
27: ; preds = %24
%28 = tail call i32 @putchar(i32 49)
%29 = add nsw i32 %25, -32
br label %32
30: ; preds = %24
%31 = tail call i32 @putchar(i32 48)
br label %32
32: ; preds = %30, %27
%33 = phi i32 [ %29, %27 ], [ %25, %30 ]
%34 = icmp slt i32 %33, 16
br i1 %34, label %38, label %35
35: ; preds = %32
%36 = tail call i32 @putchar(i32 49)
%37 = add nsw i32 %33, -16
br label %40
38: ; preds = %32
%39 = tail call i32 @putchar(i32 48)
br label %40
40: ; preds = %38, %35
%41 = phi i32 [ %37, %35 ], [ %33, %38 ]
%42 = icmp slt i32 %41, 8
br i1 %42, label %46, label %43
43: ; preds = %40
%44 = tail call i32 @putchar(i32 49)
%45 = add nsw i32 %41, -8
br label %48
46: ; preds = %40
%47 = tail call i32 @putchar(i32 48)
br label %48
48: ; preds = %46, %43
%49 = phi i32 [ %45, %43 ], [ %41, %46 ]
%50 = icmp slt i32 %49, 4
br i1 %50, label %54, label %51
51: ; preds = %48
%52 = tail call i32 @putchar(i32 49)
%53 = add nsw i32 %49, -4
br label %56
54: ; preds = %48
%55 = tail call i32 @putchar(i32 48)
br label %56
56: ; preds = %54, %51
%57 = phi i32 [ %53, %51 ], [ %49, %54 ]
%58 = icmp slt i32 %57, 2
br i1 %58, label %62, label %59
59: ; preds = %56
%60 = tail call i32 @putchar(i32 49)
%61 = add nsw i32 %57, -2
br label %64
62: ; preds = %56
%63 = tail call i32 @putchar(i32 48)
br label %64
64: ; preds = %62, %59
%65 = phi i32 [ %61, %59 ], [ %57, %62 ]
%66 = icmp slt i32 %65, 1
%67 = select i1 %66, i32 48, i32 49
%68 = tail call i32 @putchar(i32 %67)
ret i32 0
}