#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 /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ system(char *);
int main() {
  int pilha[32];
  int n;
  int t = 0;
  printf("digite o numero a ser convertido: ");
  scanf("%d", &n);
  while (n != 0) {
    pilha[t++] = n % 2;
    n = n / 2;
  }
  while (t != 0) {
    printf("%d", pilha[--t]);
  }
  printf("\n");
  system("pause");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x98(%rbp)
lea    0xead(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xec2(%rip),%rdi
lea    -0x94(%rbp),%rsi
call   1050 <scanf@plt>
cmpl   $0x0,-0x94(%rbp)
je     11bb <main+0x8b>
mov    -0x94(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    -0x98(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x98(%rbp)
cltq
mov    %edx,-0x90(%rbp,%rax,4)
mov    -0x94(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x94(%rbp)
jmp    116d <main+0x3d>
jmp    11c0 <main+0x90>
cmpl   $0x0,-0x98(%rbp)
je     11f8 <main+0xc8>
mov    -0x98(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x98(%rbp)
cltq
mov    -0x90(%rbp,%rax,4),%esi
lea    0xe37(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11c0 <main+0x90>
lea    0xe27(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe1b(%rip),%rdi
call   1030 <system@plt>
mov    -0x4(%rbp),%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x98,%rsp
lea    0xeab(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xec0(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1060 <scanf@plt>
mov    0xc(%rsp),%eax
test   %eax,%eax
je     11dd <main+0x9d>
xor    %r12d,%r12d
nopl   0x0(%rax,%rax,1)
mov    %eax,%ecx
shr    $0x1f,%eax
add    %ecx,%eax
mov    %eax,%edx
and    $0xfffffffe,%edx
mov    %ecx,%esi
sub    %edx,%esi
mov    %esi,0x10(%rsp,%r12,4)
add    $0x1,%r12
sar    %eax
add    $0x1,%ecx
cmp    $0x3,%ecx
jae    1180 <main+0x40>
mov    %eax,0xc(%rsp)
test   %r12d,%r12d
je     11dd <main+0x9d>
movslq %r12d,%rax
lea    (%rsp,%rax,4),%r15
add    $0xc,%r15
lea    0xe65(%rip),%r14
xor    %ebx,%ebx
mov    (%r15,%rbx,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    -0x1(%rbx),%rax
add    %r12d,%ebx
cmp    $0x1,%ebx
mov    %rax,%rbx
jne    11c0 <main+0x80>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xe38(%rip),%rdi
call   1040 <system@plt>
xor    %eax,%eax
add    $0x98,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [35 x i8] c"digite o numero a ser convertido: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [6 x i8] c"pause\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [32 x i32]
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %4
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
br label %7
7: ; preds = %10, %0
%8 = load i32, i32* %3
%9 = icmp ne i32 %8, 0
br i1 %9, label %10, label %19
10: ; preds = %7
%11 = load i32, i32* %3
%12 = srem i32 %11, 2
%13 = load i32, i32* %4
%14 = add nsw i32 %13, 1
store i32 %14, i32* %4
%15 = sext i32 %13 to i64
%16 = getelementptr inbounds [32 x i32], [32 x i32]* %2, i64 0, i64 %15
store i32 %12, i32* %16
%17 = load i32, i32* %3
%18 = sdiv i32 %17, 2
store i32 %18, i32* %3
br label %7
19: ; preds = %7
br label %20
20: ; preds = %23, %19
%21 = load i32, i32* %4
%22 = icmp ne i32 %21, 0
br i1 %22, label %23, label %30
23: ; preds = %20
%24 = load i32, i32* %4
%25 = add nsw i32 %24, -1
store i32 %25, i32* %4
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [32 x i32], [32 x i32]* %2, i64 0, i64 %26
%28 = load i32, i32* %27
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %28)
br label %20
30: ; preds = %20
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%32 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%33 = load i32, i32* %1
ret i32 %33
}

LLVM IR (-O2):
@.str = [35 x i8] c"digite o numero a ser convertido: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.3 = [6 x i8] c"pause\00"
define i32 @main() {
%1 = alloca [32 x i32]
%2 = alloca i32
%3 = bitcast [32 x i32]* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%7 = load i32, i32* %2
%8 = icmp eq i32 %7, 0
br i1 %8, label %32, label %15
9: ; preds = %15
%10 = trunc i64 %19 to i32
store i32 %21, i32* %2
%11 = icmp eq i32 %10, 0
br i1 %11, label %32, label %12
12: ; preds = %9
%13 = shl i64 %19, 32
%14 = ashr exact i64 %13, 32
br label %24
15: ; preds = %0, %15
%16 = phi i64 [ %19, %15 ], [ 0, %0 ]
%17 = phi i32 [ %21, %15 ], [ %7, %0 ]
%18 = srem i32 %17, 2
%19 = add nuw i64 %16, 1
%20 = getelementptr inbounds [32 x i32], [32 x i32]* %1, i64 0, i64 %16
store i32 %18, i32* %20
%21 = sdiv i32 %17, 2
%22 = add i32 %17, 1
%23 = icmp ult i32 %22, 3
br i1 %23, label %9, label %15
24: ; preds = %12, %24
%25 = phi i64 [ %14, %12 ], [ %26, %24 ]
%26 = add nsw i64 %25, -1
%27 = getelementptr inbounds [32 x i32], [32 x i32]* %1, i64 0, i64 %26
%28 = load i32, i32* %27
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %28)
%30 = trunc i64 %26 to i32
%31 = icmp eq i32 %30, 0
br i1 %31, label %32, label %24
32: ; preds = %24, %0, %9
%33 = call i32 @putchar(i32 10)
%34 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
ret i32 0
}