#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 dobro(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ procedimento();
int /*<<< orphan*/ procedimentoEscopo(int);
int /*<<< orphan*/ procedimentoN(int);
int /*<<< orphan*/ procedimento_ref(int *, int);
int main() {
  int i, j;
  printf("Procedimentos:\n");
  procedimento();
  procedimentoN(2);
  i = 3;
  procedimentoN(i);
  printf("----\n");
  printf("Escopo:\n");
  printf("i=%d (main)\n", i);
  procedimentoEscopo(i);
  printf("i=%d (main)\n", i);
  printf("----\n");
  printf("Funcoes:\n");
  printf("i=%d, dobro=%d\n", i, dobro(i));
  i = dobro(i);
  printf("i=%d, dobro=%d\n", i, dobro(i));
  printf("----\n");
  i = 0;
  j = 0;
  printf("Passagem por referência:\n");
  printf("i=%d, j=%d\n", i, j);
  procedimento_ref(&i, j);
  printf("i=%d, j=%d\n", i, j);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe8a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1060 <procedimento@plt>
mov    $0x2,%edi
call   1070 <procedimentoN@plt>
movl   $0x3,-0x8(%rbp)
mov    -0x8(%rbp),%edi
call   1070 <procedimentoN@plt>
lea    0xe6c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe64(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%esi
lea    0xe5c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%edi
call   1080 <procedimentoEscopo@plt>
mov    -0x8(%rbp),%esi
lea    0xe43(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe26(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe34(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%edi
call   1050 <dobro@plt>
mov    -0x14(%rbp),%esi
mov    %eax,%edx
lea    0xe1d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%edi
call   1050 <dobro@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%edi
call   1050 <dobro@plt>
mov    -0x10(%rbp),%esi
mov    %eax,%edx
lea    0xdf1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xdbd(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
lea    0xdd7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xdde(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xc(%rbp),%esi
lea    -0x8(%rbp),%rdi
call   1030 <procedimento_ref@plt>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xdbe(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xeaa(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   1070 <procedimento@plt>
mov    $0x2,%edi
call   1080 <procedimentoN@plt>
mov    $0x3,%edi
call   1080 <procedimentoN@plt>
lea    0xea3(%rip),%r14
mov    %r14,%rdi
call   1040 <puts@plt>
lea    0xe83(%rip),%rdi
call   1040 <puts@plt>
lea    0xe3f(%rip),%rbx
mov    %rbx,%rdi
mov    $0x3,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x3,%edi
call   1090 <procedimentoEscopo@plt>
mov    %rbx,%rdi
mov    $0x3,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14,%rdi
call   1040 <puts@plt>
lea    0xe48(%rip),%rdi
call   1040 <puts@plt>
mov    $0x3,%edi
call   1060 <dobro@plt>
lea    0xdff(%rip),%rbx
mov    %rbx,%rdi
mov    $0x3,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x3,%edi
call   1060 <dobro@plt>
mov    %eax,%ebp
mov    %eax,%edi
call   1060 <dobro@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14,%rdi
call   1040 <puts@plt>
movl   $0x0,0xc(%rsp)
lea    0xdf7(%rip),%rdi
call   1040 <puts@plt>
lea    0xdba(%rip),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
xor    %edx,%edx
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xc(%rsp),%rdi
xor    %esi,%esi
call   1030 <procedimento_ref@plt>
mov    0xc(%rsp),%esi
mov    %rbx,%rdi
xor    %edx,%edx
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [16 x i8] c"Procedimentos:\0A\00"
@.str.1 = [6 x i8] c"----\0A\00"
@.str.2 = [9 x i8] c"Escopo:\0A\00"
@.str.3 = [13 x i8] c"i=%d (main)\0A\00"
@.str.4 = [10 x i8] c"Funcoes:\0A\00"
@.str.5 = [16 x i8] c"i=%d, dobro=%d\0A\00"
@.str.6 = [27 x i8] c"Passagem por refer\C3\AAncia:\0A\00"
@.str.7 = [12 x i8] c"i=%d, j=%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%5 = call i32 (...) @procedimento()
%6 = call i32 @procedimentoN(i32 2)
store i32 3, i32* %2
%7 = load i32, i32* %2
%8 = call i32 @procedimentoN(i32 %7)
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%11 = load i32, i32* %2
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i32 %11)
%13 = load i32, i32* %2
%14 = call i32 @procedimentoEscopo(i32 %13)
%15 = load i32, i32* %2
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i32 %15)
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
%19 = load i32, i32* %2
%20 = load i32, i32* %2
%21 = call i32 @dobro(i32 %20)
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0), i32 %19, i32 %21)
%23 = load i32, i32* %2
%24 = call i32 @dobro(i32 %23)
store i32 %24, i32* %2
%25 = load i32, i32* %2
%26 = load i32, i32* %2
%27 = call i32 @dobro(i32 %26)
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0), i32 %25, i32 %27)
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %2
store i32 0, i32* %3
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.6, i64 0, i64 0))
%31 = load i32, i32* %2
%32 = load i32, i32* %3
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0), i32 %31, i32 %32)
%34 = load i32, i32* %3
%35 = call i32 @procedimento_ref(i32* %2, i32 %34)
%36 = load i32, i32* %2
%37 = load i32, i32* %3
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0), i32 %36, i32 %37)
ret i32 0
}

LLVM IR (-O2):
@.str.3 = [13 x i8] c"i=%d (main)\0A\00"
@.str.5 = [16 x i8] c"i=%d, dobro=%d\0A\00"
@.str.7 = [12 x i8] c"i=%d, j=%d\0A\00"
@str = [15 x i8] c"Procedimentos:\00"
@str.9 = [8 x i8] c"Escopo:\00"
@str.11 = [9 x i8] c"Funcoes:\00"
@str.12 = [5 x i8] c"----\00"
@str.13 = [26 x i8] c"Passagem por refer\C3\AAncia:\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 (...) @procedimento()
%5 = tail call i32 @procedimentoN(i32 2)
%6 = tail call i32 @procedimentoN(i32 3)
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str.12, i64 0, i64 0))
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str.9, i64 0, i64 0))
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i32 3)
%10 = tail call i32 @procedimentoEscopo(i32 3)
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i32 3)
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str.12, i64 0, i64 0))
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.11, i64 0, i64 0))
%14 = tail call i32 @dobro(i32 3)
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0), i32 3, i32 %14)
%16 = tail call i32 @dobro(i32 3)
%17 = tail call i32 @dobro(i32 %16)
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0), i32 %16, i32 %17)
%19 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str.12, i64 0, i64 0))
store i32 0, i32* %1
%20 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str.13, i64 0, i64 0))
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0), i32 0, i32 0)
%22 = call i32 @procedimento_ref(i32* %1, i32 0)
%23 = load i32, i32* %1
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0), i32 %23, i32 0)
ret i32 0
}