#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);
void transformarBinario(int n) {
  int binario[8];
  int i = 7, resto = 0;
  while (n > 0) {
    resto = n % 2;
    if (resto == 0)
      binario[i] = 0;
    else
      binario[i] = 1;
    i--;
    n = n / 2;
  }
  while (i >= 0) {
    binario[i] = 0;
    i--;
  }
  for (i = 0; i < 8; i++)
    printf("%d", binario[i]);
}


x86 assembly (clang, -O0):
<transformarBinario>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x7,-0x34(%rbp)
movl   $0x0,-0x38(%rbp)
cmpl   $0x0,-0x4(%rbp)
jle    1184 <transformarBinario+0x74>
mov    -0x4(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %edx,-0x38(%rbp)
cmpl   $0x0,-0x38(%rbp)
jne    115c <transformarBinario+0x4c>
movslq -0x34(%rbp),%rax
movl   $0x0,-0x30(%rbp,%rax,4)
jmp    1168 <transformarBinario+0x58>
movslq -0x34(%rbp),%rax
movl   $0x1,-0x30(%rbp,%rax,4)
mov    -0x34(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x34(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x4(%rbp)
jmp    1129 <transformarBinario+0x19>
jmp    1189 <transformarBinario+0x79>
cmpl   $0x0,-0x34(%rbp)
jl     11ad <transformarBinario+0x9d>
movslq -0x34(%rbp),%rax
movl   $0x0,-0x30(%rbp,%rax,4)
mov    -0x34(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x34(%rbp)
jmp    1189 <transformarBinario+0x79>
movl   $0x0,-0x34(%rbp)
cmpl   $0x8,-0x34(%rbp)
jge    11e0 <transformarBinario+0xd0>
movslq -0x34(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%esi
lea    0xe33(%rip),%rdi
call   1030 <printf@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    11b4 <transformarBinario+0xa4>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<transformarBinario>:
push   %rbx
sub    $0x20,%rsp
mov    $0x7,%eax
test   %edi,%edi
jle    114c <transformarBinario+0x2c>
mov    %edi,%ecx
mov    %edi,%edx
and    $0x1,%edx
mov    %edx,(%rsp,%rax,4)
add    $0xffffffffffffffff,%rax
shr    %ecx
cmp    $0x2,%edi
mov    %ecx,%edi
jae    1130 <transformarBinario+0x10>
test   $0x80000000,%eax
jne    1160 <transformarBinario+0x40>
mov    %eax,%eax
lea    0x4(,%rax,4),%rdx
mov    %rsp,%rdi
xor    %esi,%esi
call   1040 <memset@plt>
mov    (%rsp),%esi
lea    0xe96(%rip),%rbx
mov    %rbx,%rdi
call   1030 <printf@plt>
mov    0x4(%rsp),%esi
mov    %rbx,%rdi
call   1030 <printf@plt>
mov    0x8(%rsp),%esi
mov    %rbx,%rdi
call   1030 <printf@plt>
mov    0xc(%rsp),%esi
mov    %rbx,%rdi
call   1030 <printf@plt>
mov    0x10(%rsp),%esi
mov    %rbx,%rdi
call   1030 <printf@plt>
mov    0x14(%rsp),%esi
mov    %rbx,%rdi
call   1030 <printf@plt>
mov    0x18(%rsp),%esi
mov    %rbx,%rdi
call   1030 <printf@plt>
mov    0x1c(%rsp),%esi
mov    %rbx,%rdi
add    $0x20,%rsp
pop    %rbx
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
define void @transformarBinario(i32 %0) {
%2 = alloca i32
%3 = alloca [8 x i32]
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %2
store i32 7, i32* %4
store i32 0, i32* %5
br label %6
6: ; preds = %22, %1
%7 = load i32, i32* %2
%8 = icmp sgt i32 %7, 0
br i1 %8, label %9, label %27
9: ; preds = %6
%10 = load i32, i32* %2
%11 = srem i32 %10, 2
store i32 %11, i32* %5
%12 = load i32, i32* %5
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %18
14: ; preds = %9
%15 = load i32, i32* %4
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [8 x i32], [8 x i32]* %3, i64 0, i64 %16
store i32 0, i32* %17
br label %22
18: ; preds = %9
%19 = load i32, i32* %4
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [8 x i32], [8 x i32]* %3, i64 0, i64 %20
store i32 1, i32* %21
br label %22
22: ; preds = %18, %14
%23 = load i32, i32* %4
%24 = add nsw i32 %23, -1
store i32 %24, i32* %4
%25 = load i32, i32* %2
%26 = sdiv i32 %25, 2
store i32 %26, i32* %2
br label %6
27: ; preds = %6
br label %28
28: ; preds = %31, %27
%29 = load i32, i32* %4
%30 = icmp sge i32 %29, 0
br i1 %30, label %31, label %37
31: ; preds = %28
%32 = load i32, i32* %4
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [8 x i32], [8 x i32]* %3, i64 0, i64 %33
store i32 0, i32* %34
%35 = load i32, i32* %4
%36 = add nsw i32 %35, -1
store i32 %36, i32* %4
br label %28
37: ; preds = %28
store i32 0, i32* %4
br label %38
38: ; preds = %47, %37
%39 = load i32, i32* %4
%40 = icmp slt i32 %39, 8
br i1 %40, label %41, label %50
41: ; preds = %38
%42 = load i32, i32* %4
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds [8 x i32], [8 x i32]* %3, i64 0, i64 %43
%45 = load i32, i32* %44
%46 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %45)
br label %47
47: ; preds = %41
%48 = load i32, i32* %4
%49 = add nsw i32 %48, 1
store i32 %49, i32* %4
br label %38
50: ; preds = %38
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
define void @transformarBinario(i32 %0) {
%2 = alloca [8 x i32]
%3 = bitcast [8 x i32]* %2 to i8*
%4 = icmp sgt i32 %0, 0
br i1 %4, label %13, label %8
5: ; preds = %13
%6 = and i64 %18, 2147483648
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %21
8: ; preds = %1, %5
%9 = phi i64 [ %18, %5 ], [ 7, %1 ]
%10 = shl i64 %9, 2
%11 = and i64 %10, 17179869180
%12 = add nuw nsw i64 %11, 4
br label %21
13: ; preds = %1, %13
%14 = phi i64 [ %18, %13 ], [ 7, %1 ]
%15 = phi i32 [ %19, %13 ], [ %0, %1 ]
%16 = and i32 %15, 1
%17 = getelementptr inbounds [8 x i32], [8 x i32]* %2, i64 0, i64 %14
store i32 %16, i32* %17
%18 = add nsw i64 %14, -1
%19 = lshr i32 %15, 1
%20 = icmp ult i32 %15, 2
br i1 %20, label %5, label %13
21: ; preds = %8, %5
%22 = getelementptr inbounds [8 x i32], [8 x i32]* %2, i64 0, i64 0
%23 = load i32, i32* %22
%24 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %23)
%25 = getelementptr inbounds [8 x i32], [8 x i32]* %2, i64 0, i64 1
%26 = load i32, i32* %25
%27 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %26)
%28 = getelementptr inbounds [8 x i32], [8 x i32]* %2, i64 0, i64 2
%29 = load i32, i32* %28
%30 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %29)
%31 = getelementptr inbounds [8 x i32], [8 x i32]* %2, i64 0, i64 3
%32 = load i32, i32* %31
%33 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %32)
%34 = getelementptr inbounds [8 x i32], [8 x i32]* %2, i64 0, i64 4
%35 = load i32, i32* %34
%36 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %35)
%37 = getelementptr inbounds [8 x i32], [8 x i32]* %2, i64 0, i64 5
%38 = load i32, i32* %37
%39 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %38)
%40 = getelementptr inbounds [8 x i32], [8 x i32]* %2, i64 0, i64 6
%41 = load i32, i32* %40
%42 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %41)
%43 = getelementptr inbounds [8 x i32], [8 x i32]* %2, i64 0, i64 7
%44 = load i32, i32* %43
%45 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %44)
ret void
}