#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*/ a;

/* Variables and functions */
int emPilha(int);
int /*<<< orphan*/ getchar();
int /*<<< orphan*/ printBinary(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int a = 0;
  printf("Entre com o inteiro a ser invertido e pressione <Enter>: ");
  scanf("%d", &a);
  getchar();
  printf("Anterior à inversão:\n");
  printf("\tO binário (%lubits) de %010u é: ", 8 * sizeof(a), a);
  printBinary(a);
  printf("Após a inversão:\n");
  a = emPilha(a);
  printf("\tO binário (%lubits) de %010u é: ", 8 * sizeof(a), a);
  printBinary(a);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
lea    0xe93(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xebf(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1060 <scanf@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
lea    0xeab(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%edx
lea    0xeb2(%rip),%rdi
mov    $0x20,%esi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%edi
call   1040 <printBinary@plt>
lea    0xebb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%edi
call   1070 <emPilha@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edx
lea    0xe7b(%rip),%rdi
mov    $0x20,%esi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%edi
call   1040 <printBinary@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
movl   $0x0,0xc(%rsp)
lea    0xe8c(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeb8(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1070 <scanf@plt>
xor    %eax,%eax
call   1060 <getchar@plt>
lea    0xec7(%rip),%rdi
call   1030 <puts@plt>
mov    0xc(%rsp),%edx
lea    0xe93(%rip),%rbx
mov    $0x20,%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0xc(%rsp),%edi
call   1050 <printBinary@plt>
lea    0xeaf(%rip),%rdi
call   1030 <puts@plt>
mov    0xc(%rsp),%edi
call   1080 <emPilha@plt>
mov    %eax,0xc(%rsp)
mov    $0x20,%esi
mov    %rbx,%rdi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    0xc(%rsp),%edi
call   1050 <printBinary@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [58 x i8] c"Entre com o inteiro a ser invertido e pressione <Enter>: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [24 x i8] c"Anterior \C3\A0 invers\C3\A3o:\0A\00"
@.str.3 = [36 x i8] c"\09O bin\C3\A1rio (%lubits) de %010u \C3\A9: \00"
@.str.4 = [20 x i8] c"Ap\C3\B3s a invers\C3\A3o:\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
%3 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%5 = call i32 (...) @getchar()
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%7 = load i32, i32* %2
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0), i64 32, i32 %7)
%9 = load i32, i32* %2
%10 = call i32 @printBinary(i32 %9)
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0))
%12 = load i32, i32* %2
%13 = call i32 @emPilha(i32 %12)
store i32 %13, i32* %2
%14 = load i32, i32* %2
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0), i64 32, i32 %14)
%16 = load i32, i32* %2
%17 = call i32 @printBinary(i32 %16)
ret i32 0
}

LLVM IR (-O2):
@.str = [58 x i8] c"Entre com o inteiro a ser invertido e pressione <Enter>: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.3 = [36 x i8] c"\09O bin\C3\A1rio (%lubits) de %010u \C3\A9: \00"
@str = [23 x i8] c"Anterior \C3\A0 invers\C3\A3o:\00"
@str.5 = [19 x i8] c"Ap\C3\B3s a invers\C3\A3o:\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([58 x i8], [58 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%5 = call i32 (...) @getchar()
%6 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0))
%7 = load i32, i32* %1
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0), i64 32, i32 %7)
%9 = load i32, i32* %1
%10 = call i32 @printBinary(i32 %9)
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.5, i64 0, i64 0))
%12 = load i32, i32* %1
%13 = call i32 @emPilha(i32 %12)
store i32 %13, i32* %1
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0), i64 32, i32 %13)
%15 = load i32, i32* %1
%16 = call i32 @printBinary(i32 %15)
ret i32 0
}