#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*/ scanf(char *, int *);
int /*<<< orphan*/ system(char *);
int /*<<< orphan*/ troca2(int, int);
int 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 n;
  scanf("%d", &n);
  v = malloc(n * sizeof(int));
  for (i = 0; i < n; i++)
    v[i] = i;
  for (i = 0; i < n; i++)
    printf("%d ", v[i]);
  putchar('\n');
  system("pause");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x21,-0x8(%rbp)
movl   $0x4d,-0xc(%rbp)
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xe76(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1080 <troca2@plt>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xe6a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe6f(%rip),%rdi
lea    -0x20(%rbp),%rsi
call   1070 <scanf@plt>
movslq -0x20(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    1202 <main+0xa2>
mov    -0x1c(%rbp),%edx
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11da <main+0x7a>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    123c <main+0xdc>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe02(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1209 <main+0xa9>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xde0(%rip),%rdi
call   1040 <system@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xf20(%rip),%rdi
mov    $0x21,%esi
mov    $0x4d,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x21,%edi
mov    $0x4d,%esi
call   1080 <troca2@plt>
lea    0xf0c(%rip),%rdi
mov    $0x21,%esi
mov    $0x4d,%edx
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xf07(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1070 <scanf@plt>
mov    0xc(%rsp),%r14d
lea    0x0(,%r14,4),%edi
call   1060 <malloc@plt>
test   %r14d,%r14d
jle    138c <main+0x22c>
mov    %rax,%r15
cmp    $0x8,%r14d
jae    11e4 <main+0x84>
xor    %eax,%eax
jmp    1350 <main+0x1f0>
mov    %r14d,%eax
and    $0xfffffff8,%eax
lea    -0x8(%rax),%rsi
mov    %rsi,%rdx
shr    $0x3,%rdx
add    $0x1,%rdx
mov    %edx,%ecx
and    $0x3,%ecx
cmp    $0x18,%rsi
jae    1213 <main+0xb3>
movdqa 0xdf4(%rip),%xmm0
xor    %esi,%esi
jmp    12f0 <main+0x190>
and    $0xfffffffffffffffc,%rdx
movdqa 0xde1(%rip),%xmm0
xor    %esi,%esi
movdqa 0xde6(%rip),%xmm8
movdqa 0xded(%rip),%xmm9
movdqa 0xdf4(%rip),%xmm10
movdqa 0xdfc(%rip),%xmm4
movdqa 0xe04(%rip),%xmm5
movdqa 0xe0c(%rip),%xmm6
movdqa 0xe14(%rip),%xmm7
movdqa 0xe1c(%rip),%xmm1
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movdqa %xmm0,%xmm2
paddd  %xmm8,%xmm2
movdqu %xmm0,(%r15,%rsi,4)
movdqu %xmm2,0x10(%r15,%rsi,4)
movdqa %xmm0,%xmm2
paddd  %xmm9,%xmm2
movdqa %xmm0,%xmm3
paddd  %xmm10,%xmm3
movdqu %xmm2,0x20(%r15,%rsi,4)
movdqu %xmm3,0x30(%r15,%rsi,4)
movdqa %xmm0,%xmm2
paddd  %xmm4,%xmm2
movdqa %xmm0,%xmm3
paddd  %xmm5,%xmm3
movdqu %xmm2,0x40(%r15,%rsi,4)
movdqu %xmm3,0x50(%r15,%rsi,4)
movdqa %xmm0,%xmm2
paddd  %xmm6,%xmm2
movdqa %xmm0,%xmm3
paddd  %xmm7,%xmm3
movdqu %xmm2,0x60(%r15,%rsi,4)
movdqu %xmm3,0x70(%r15,%rsi,4)
add    $0x20,%rsi
paddd  %xmm1,%xmm0
add    $0xfffffffffffffffc,%rdx
jne    1270 <main+0x110>
test   %rcx,%rcx
je     1340 <main+0x1e0>
lea    (%r15,%rsi,4),%rdx
add    $0x10,%rdx
shl    $0x5,%rcx
xor    %esi,%esi
movdqa 0xd05(%rip),%xmm1
movdqa 0xd0d(%rip),%xmm2
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movdqa %xmm0,%xmm3
paddd  %xmm1,%xmm3
movdqu %xmm0,-0x10(%rdx,%rsi,1)
movdqu %xmm3,(%rdx,%rsi,1)
paddd  %xmm2,%xmm0
add    $0x20,%rsi
cmp    %rsi,%rcx
jne    1320 <main+0x1c0>
cmp    %r14,%rax
je     135d <main+0x1fd>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %eax,(%r15,%rax,4)
add    $0x1,%rax
cmp    %rax,%r14
jne    1350 <main+0x1f0>
test   %r14d,%r14d
jle    138c <main+0x22c>
lea    0xd50(%rip),%r14
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
mov    (%r15,%rbx,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbx
movslq 0xc(%rsp),%rax
cmp    %rax,%rbx
jl     1370 <main+0x210>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xd20(%rip),%rdi
call   1040 <system@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [19 x i8] c"Antes a=%d, b=%d\0A\00"
@.str.1 = [19 x i8] c"Depois a=%d, b=%d\0A\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [4 x i8] c"%d \00"
@.str.4 = [6 x i8] c"pause\00"
define i32 @main() {
%1 = alloca i32
%2 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 33, i32 77)
%3 = tail call i32 @troca2(i32 33, i32 77)
%4 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 33, i32 77)
%5 = bitcast i32* %1 to i8*
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%7 = load i32, i32* %1
%8 = shl i32 %7, 2
%9 = call i32* @malloc(i32 %8)
%10 = icmp sgt i32 %7, 0
br i1 %10, label %11, label %94
11: ; preds = %0
%12 = zext i32 %7 to i64
%13 = icmp ult i32 %7, 8
br i1 %13, label %76, label %14
14: ; preds = %11
%15 = and i64 %12, 4294967288
%16 = add nsw i64 %15, -8
%17 = lshr exact i64 %16, 3
%18 = add nuw nsw i64 %17, 1
%19 = and i64 %18, 3
%20 = icmp ult i64 %16, 24
br i1 %20, label %57, label %21
21: ; preds = %14
%22 = and i64 %18, 4611686018427387900
br label %23
23: ; preds = %23, %21
%24 = phi i64 [ 0, %21 ], [ %53, %23 ]
%25 = phi <4 x i32> [ <i32 0, i32 1, i32 2, i32 3>, %21 ], [ %54, %23 ]
%26 = phi i64 [ 0, %21 ], [ %55, %23 ]
%27 = add <4 x i32> %25, <i32 4, i32 4, i32 4, i32 4>
%28 = getelementptr inbounds i32, i32* %9, i64 %24
%29 = bitcast i32* %28 to <4 x i32>*
store <4 x i32> %25, <4 x i32>* %29
%30 = getelementptr inbounds i32, i32* %28, i64 4
%31 = bitcast i32* %30 to <4 x i32>*
store <4 x i32> %27, <4 x i32>* %31
%32 = or i64 %24, 8
%33 = add <4 x i32> %25, <i32 8, i32 8, i32 8, i32 8>
%34 = add <4 x i32> %25, <i32 12, i32 12, i32 12, i32 12>
%35 = getelementptr inbounds i32, i32* %9, i64 %32
%36 = bitcast i32* %35 to <4 x i32>*
store <4 x i32> %33, <4 x i32>* %36
%37 = getelementptr inbounds i32, i32* %35, i64 4
%38 = bitcast i32* %37 to <4 x i32>*
store <4 x i32> %34, <4 x i32>* %38
%39 = or i64 %24, 16
%40 = add <4 x i32> %25, <i32 16, i32 16, i32 16, i32 16>
%41 = add <4 x i32> %25, <i32 20, i32 20, i32 20, i32 20>
%42 = getelementptr inbounds i32, i32* %9, i64 %39
%43 = bitcast i32* %42 to <4 x i32>*
store <4 x i32> %40, <4 x i32>* %43
%44 = getelementptr inbounds i32, i32* %42, i64 4
%45 = bitcast i32* %44 to <4 x i32>*
store <4 x i32> %41, <4 x i32>* %45
%46 = or i64 %24, 24
%47 = add <4 x i32> %25, <i32 24, i32 24, i32 24, i32 24>
%48 = add <4 x i32> %25, <i32 28, i32 28, i32 28, i32 28>
%49 = getelementptr inbounds i32, i32* %9, i64 %46
%50 = bitcast i32* %49 to <4 x i32>*
store <4 x i32> %47, <4 x i32>* %50
%51 = getelementptr inbounds i32, i32* %49, i64 4
%52 = bitcast i32* %51 to <4 x i32>*
store <4 x i32> %48, <4 x i32>* %52
%53 = add nuw i64 %24, 32
%54 = add <4 x i32> %25, <i32 32, i32 32, i32 32, i32 32>
%55 = add i64 %26, 4
%56 = icmp eq i64 %55, %22
br i1 %56, label %57, label %23
57: ; preds = %23, %14
%58 = phi i64 [ 0, %14 ], [ %53, %23 ]
%59 = phi <4 x i32> [ <i32 0, i32 1, i32 2, i32 3>, %14 ], [ %54, %23 ]
%60 = icmp eq i64 %19, 0
br i1 %60, label %74, label %61
61: ; preds = %57, %61
%62 = phi i64 [ %70, %61 ], [ %58, %57 ]
%63 = phi <4 x i32> [ %71, %61 ], [ %59, %57 ]
%64 = phi i64 [ %72, %61 ], [ 0, %57 ]
%65 = add <4 x i32> %63, <i32 4, i32 4, i32 4, i32 4>
%66 = getelementptr inbounds i32, i32* %9, i64 %62
%67 = bitcast i32* %66 to <4 x i32>*
store <4 x i32> %63, <4 x i32>* %67
%68 = getelementptr inbounds i32, i32* %66, i64 4
%69 = bitcast i32* %68 to <4 x i32>*
store <4 x i32> %65, <4 x i32>* %69
%70 = add nuw i64 %62, 8
%71 = add <4 x i32> %63, <i32 8, i32 8, i32 8, i32 8>
%72 = add i64 %64, 1
%73 = icmp eq i64 %72, %19
br i1 %73, label %74, label %61
74: ; preds = %61, %57
%75 = icmp eq i64 %15, %12
br i1 %75, label %78, label %76
76: ; preds = %11, %74
%77 = phi i64 [ 0, %11 ], [ %15, %74 ]
br label %79
78: ; preds = %79, %74
br i1 %10, label %85, label %94
79: ; preds = %76, %79
%80 = phi i64 [ %83, %79 ], [ %77, %76 ]
%81 = getelementptr inbounds i32, i32* %9, i64 %80
%82 = trunc i64 %80 to i32
store i32 %82, i32* %81
%83 = add nuw nsw i64 %80, 1
%84 = icmp eq i64 %83, %12
br i1 %84, label %78, label %79
85: ; preds = %78, %85
%86 = phi i64 [ %90, %85 ], [ 0, %78 ]
%87 = getelementptr inbounds i32, i32* %9, i64 %86
%88 = load i32, i32* %87
%89 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %88)
%90 = add nuw nsw i64 %86, 1
%91 = load i32, i32* %1
%92 = sext i32 %91 to i64
%93 = icmp slt i64 %90, %92
br i1 %93, label %85, label %94
94: ; preds = %85, %0, %78
%95 = call i32 @putchar(i8 signext 10)
%96 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
ret i32 0
}