#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 *malloc(int);
int /*<<< orphan*/ printf(char *, int, ...);
int /*<<< orphan*/ putchar(char);
int /*<<< orphan*/ system(char *);
int /*<<< orphan*/ troca2(int, int);
void main(void) {
  int a = 33, b = 77;
  printf("Antes a = %d, b = %d \n ", a, b);
  troca2(a, b);
  printf("Depois a = %d , b = %d \n", a, b);
  int *v;
  int i;
  int f = 100;
  v = malloc(10 * sizeof(int));
  for (i = 0; i < 10; i++) {
    v[i] = f;
    f = f + 10;
  }
  for (i = 0; i < 10; i++)
    printf("%d ", v[i]);
  putchar('\n');
  system("pause");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x21,-0x4(%rbp)
movl   $0x4d,-0x8(%rbp)
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
lea    0xe8d(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1070 <troca2@plt>
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
lea    0xe86(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x64,-0x18(%rbp)
mov    $0x28,%edi
call   1060 <malloc@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0xa,-0x14(%rbp)
jge    11e4 <main+0x94>
mov    -0x18(%rbp),%edx
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x18(%rbp),%eax
add    $0xa,%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11b5 <main+0x65>
movl   $0x0,-0x14(%rbp)
cmpl   $0xa,-0x14(%rbp)
jge    121c <main+0xcc>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe2a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11eb <main+0x9b>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xe08(%rip),%rdi
call   1040 <system@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xea8(%rip),%rdi
mov    $0x21,%esi
mov    $0x4d,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x21,%edi
mov    $0x4d,%esi
call   1070 <troca2@plt>
lea    0xe99(%rip),%rdi
mov    $0x21,%esi
mov    $0x4d,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x28,%edi
call   1060 <malloc@plt>
lea    0xe90(%rip),%rbx
mov    %rbx,%rdi
mov    $0x64,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    $0x6e,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    $0x78,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    $0x82,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    $0x8c,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    $0x96,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    $0xa0,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    $0xaa,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    $0xb4,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    $0xbe,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xded(%rip),%rdi
pop    %rbx
jmp    1040 <system@plt>

LLVM IR (-O0):
@.str = [24 x i8] c"Antes a = %d, b = %d \0A \00"
@.str.1 = [25 x i8] c"Depois a = %d , b = %d \0A\00"
@.str.2 = [4 x i8] c"%d \00"
@.str.3 = [6 x i8] c"pause\00"
define void @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
store i32 33, i32* %1
store i32 77, i32* %2
%6 = load i32, i32* %1
%7 = load i32, i32* %2
%8 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 %6, i32 %7)
%9 = load i32, i32* %1
%10 = load i32, i32* %2
%11 = call i32 @troca2(i32 %9, i32 %10)
%12 = load i32, i32* %1
%13 = load i32, i32* %2
%14 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i32 %12, i32 %13)
store i32 100, i32* %5
%15 = call i32* @malloc(i32 40)
store i32* %15, i32** %3
store i32 0, i32* %4
br label %16
16: ; preds = %27, %0
%17 = load i32, i32* %4
%18 = icmp slt i32 %17, 10
br i1 %18, label %19, label %30
19: ; preds = %16
%20 = load i32, i32* %5
%21 = load i32*, i32** %3
%22 = load i32, i32* %4
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i32, i32* %21, i64 %23
store i32 %20, i32* %24
%25 = load i32, i32* %5
%26 = add nsw i32 %25, 10
store i32 %26, i32* %5
br label %27
27: ; preds = %19
%28 = load i32, i32* %4
%29 = add nsw i32 %28, 1
store i32 %29, i32* %4
br label %16
30: ; preds = %16
store i32 0, i32* %4
br label %31
31: ; preds = %41, %30
%32 = load i32, i32* %4
%33 = icmp slt i32 %32, 10
br i1 %33, label %34, label %44
34: ; preds = %31
%35 = load i32*, i32** %3
%36 = load i32, i32* %4
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i32, i32* %35, i64 %37
%39 = load i32, i32* %38
%40 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %39)
br label %41
41: ; preds = %34
%42 = load i32, i32* %4
%43 = add nsw i32 %42, 1
store i32 %43, i32* %4
br label %31
44: ; preds = %31
%45 = call i32 @putchar(i8 signext 10)
%46 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [24 x i8] c"Antes a = %d, b = %d \0A \00"
@.str.1 = [25 x i8] c"Depois a = %d , b = %d \0A\00"
@.str.2 = [4 x i8] c"%d \00"
@.str.3 = [6 x i8] c"pause\00"
define void @main() {
%1 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 33, i32 77)
%2 = tail call i32 @troca2(i32 33, i32 77)
%3 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i32 33, i32 77)
%4 = tail call i32* @malloc(i32 40)
%5 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 100)
%6 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 110)
%7 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 120)
%8 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 130)
%9 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 140)
%10 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 150)
%11 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 160)
%12 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 170)
%13 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 180)
%14 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 190)
%15 = tail call i32 @putchar(i8 signext 10)
%16 = tail call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
ret void
}