#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 */
typedef int /*<<< orphan*/ result;

/* Variables and functions */
scalar_t__ odd(unsigned int);
int /*<<< orphan*/ printf(char *, char);
void binary(unsigned int number) {
  int index;
  char result[4];
  for (index = sizeof(result) - 1; index >= 0; index--) {
    result[index] = (char)odd(number);
    number = number / 2;
  }
  for (index = 0; index < sizeof(result); index++) {
    printf("%d", result[index]);
  }
}


x86 assembly (clang, -O0):
<binary>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x3,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jl     1165 <binary+0x45>
mov    -0x4(%rbp),%edi
call   1040 <odd@plt>
mov    %al,%cl
movslq -0x8(%rbp),%rax
mov    %cl,-0xc(%rbp,%rax,1)
mov    -0x4(%rbp),%eax
shr    $0x1,%eax
mov    %eax,-0x4(%rbp)
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
jmp    1132 <binary+0x12>
movl   $0x0,-0x8(%rbp)
movslq -0x8(%rbp),%rax
cmp    $0x4,%rax
jae    119d <binary+0x7d>
movslq -0x8(%rbp),%rax
lea    0xe7b(%rip),%rdi
movsbl -0xc(%rbp,%rax,1),%esi
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    116c <binary+0x4c>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<binary>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edi,%ebp
call   1040 <odd@plt>
mov    %rax,%r14
mov    %ebp,%edi
shr    %edi
call   1040 <odd@plt>
mov    %rax,%r15
mov    %ebp,%edi
shr    $0x2,%edi
call   1040 <odd@plt>
mov    %rax,%rbx
shr    $0x3,%ebp
mov    %ebp,%edi
call   1040 <odd@plt>
movsbl %al,%esi
lea    0xea2(%rip),%rbp
mov    %rbp,%rdi
call   1030 <printf@plt>
movsbl %bl,%esi
mov    %rbp,%rdi
call   1030 <printf@plt>
movsbl %r15b,%esi
mov    %rbp,%rdi
call   1030 <printf@plt>
movsbl %r14b,%esi
mov    %rbp,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
define void @binary(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca [4 x i8]
store i32 %0, i32* %2
store i32 3, i32* %3
br label %5
5: ; preds = %17, %1
%6 = load i32, i32* %3
%7 = icmp sge i32 %6, 0
br i1 %7, label %8, label %20
8: ; preds = %5
%9 = load i32, i32* %2
%10 = call i64 @odd(i32 %9)
%11 = trunc i64 %10 to i8
%12 = load i32, i32* %3
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 %13
store i8 %11, i8* %14
%15 = load i32, i32* %2
%16 = udiv i32 %15, 2
store i32 %16, i32* %2
br label %17
17: ; preds = %8
%18 = load i32, i32* %3
%19 = add nsw i32 %18, -1
store i32 %19, i32* %3
br label %5
20: ; preds = %5
store i32 0, i32* %3
br label %21
21: ; preds = %31, %20
%22 = load i32, i32* %3
%23 = sext i32 %22 to i64
%24 = icmp ult i64 %23, 4
br i1 %24, label %25, label %34
25: ; preds = %21
%26 = load i32, i32* %3
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 %27
%29 = load i8, i8* %28
%30 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %29)
br label %31
31: ; preds = %25
%32 = load i32, i32* %3
%33 = add nsw i32 %32, 1
store i32 %33, i32* %3
br label %21
34: ; preds = %21
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
define void @binary(i32 %0) {
%2 = tail call i64 @odd(i32 %0)
%3 = trunc i64 %2 to i8
%4 = lshr i32 %0, 1
%5 = tail call i64 @odd(i32 %4)
%6 = trunc i64 %5 to i8
%7 = lshr i32 %0, 2
%8 = tail call i64 @odd(i32 %7)
%9 = trunc i64 %8 to i8
%10 = lshr i32 %0, 3
%11 = tail call i64 @odd(i32 %10)
%12 = trunc i64 %11 to i8
%13 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %12)
%14 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %9)
%15 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %6)
%16 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %3)
ret void
}