#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 */
char *malloc(int);
int /*<<< orphan*/ sprintf(char *, char *, int);
int /*<<< orphan*/ strrev(char *);
char *getBinaryEquivalent(int number) {
  char *binaryEquivalent_rev_temp = malloc(100);
  char *binaryEquivalent_temp = binaryEquivalent_rev_temp;
  int count = 0;
  do {
    sprintf(binaryEquivalent_rev_temp, "%d", number % 2);
    binaryEquivalent_rev_temp++;
    number = number / 2;
    count++;
  } while (number != 0);
  strrev(binaryEquivalent_temp);
  return binaryEquivalent_temp;
}


x86 assembly (clang, -O0):
<getBinaryEquivalent>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    $0x64,%edi
call   1030 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x4(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
lea    0xe92(%rip),%rsi
call   1050 <sprintf@plt>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x4(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x4(%rbp)
jne    1158 <getBinaryEquivalent+0x28>
mov    -0x18(%rbp),%rdi
call   1040 <strrev@plt>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getBinaryEquivalent>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edi,%ebx
mov    $0x64,%edi
call   1030 <malloc@plt>
mov    %rax,%r14
lea    0xeb2(%rip),%r15
mov    %rax,%r12
mov    %ebx,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
shr    $0x1f,%ebp
add    %ebx,%ebp
mov    %ebp,%eax
and    $0xfffffffe,%eax
mov    %ebx,%edx
sub    %eax,%edx
mov    %r12,%rdi
mov    %r15,%rsi
call   1050 <sprintf@plt>
add    $0x1,%r12
sar    %ebp
add    $0x1,%ebx
cmp    $0x2,%ebx
mov    %ebp,%ebx
ja     1160 <getBinaryEquivalent+0x30>
mov    %r14,%rdi
call   1040 <strrev@plt>
mov    %r14,%rax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
define i8* @getBinaryEquivalent(i32 %0) {
%2 = tail call dereferenceable_or_null(100) i8* @malloc(i32 100)
br label %3
3: ; preds = %3, %1
%4 = phi i8* [ %2, %1 ], [ %8, %3 ]
%5 = phi i32 [ %0, %1 ], [ %9, %3 ]
%6 = srem i32 %5, 2
%7 = tail call i32 @sprintf(i8* dereferenceable(1) %4, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %6)
%8 = getelementptr inbounds i8, i8* %4, i64 1
%9 = sdiv i32 %5, 2
%10 = add i32 %5, 1
%11 = icmp ult i32 %10, 3
br i1 %11, label %12, label %3
12: ; preds = %3
%13 = tail call i32 @strrev(i8* %2)
ret i8* %2
}