#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*/ free(int *);
int *malloc(int);
int /*<<< orphan*/ printf(char *, int, int);
int main() {
  int *vetor = malloc(sizeof(int) * 10);
  for (int i = 0; i < 10; i++) {
    vetor[i] = i + 1;
    printf("vetor[%d]=%d\n", i, vetor[i]);
  }
  free(vetor);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x28,%edi
call   1050 <malloc@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0xa,-0x14(%rbp)
jge    1197 <main+0x67>
mov    -0x14(%rbp),%edx
add    $0x1,%edx
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x14(%rbp),%esi
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
lea    0xe7c(%rip),%rdi
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1154 <main+0x24>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    $0x28,%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
lea    0xed8(%rip),%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x1,%edx
call   1040 <printf@plt>
mov    %r14,%rdi
mov    $0x1,%esi
mov    $0x2,%edx
call   1040 <printf@plt>
mov    %r14,%rdi
mov    $0x2,%esi
mov    $0x3,%edx
call   1040 <printf@plt>
movaps 0xe7e(%rip),%xmm0
movups %xmm0,(%rbx)
mov    %r14,%rdi
mov    $0x3,%esi
mov    $0x4,%edx
call   1040 <printf@plt>
mov    %r14,%rdi
mov    $0x4,%esi
mov    $0x5,%edx
call   1040 <printf@plt>
mov    %r14,%rdi
mov    $0x5,%esi
mov    $0x6,%edx
call   1040 <printf@plt>
mov    %r14,%rdi
mov    $0x6,%esi
mov    $0x7,%edx
call   1040 <printf@plt>
movaps 0xe3c(%rip),%xmm0
movups %xmm0,0x10(%rbx)
mov    %r14,%rdi
mov    $0x7,%esi
mov    $0x8,%edx
call   1040 <printf@plt>
movl   $0x9,0x20(%rbx)
mov    %r14,%rdi
mov    $0x8,%esi
mov    $0x9,%edx
call   1040 <printf@plt>
movl   $0xa,0x24(%rbx)
mov    %r14,%rdi
mov    $0x9,%esi
mov    $0xa,%edx
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [14 x i8] c"vetor[%d]=%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32* @malloc(i32 40)
store i32* %4, i32** %2
store i32 0, i32* %3
br label %5
5: ; preds = %22, %0
%6 = load i32, i32* %3
%7 = icmp slt i32 %6, 10
br i1 %7, label %8, label %25
8: ; preds = %5
%9 = load i32, i32* %3
%10 = add nsw i32 %9, 1
%11 = load i32*, i32** %2
%12 = load i32, i32* %3
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i32, i32* %11, i64 %13
store i32 %10, i32* %14
%15 = load i32, i32* %3
%16 = load i32*, i32** %2
%17 = load i32, i32* %3
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i32, i32* %16, i64 %18
%20 = load i32, i32* %19
%21 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 %15, i32 %20)
br label %22
22: ; preds = %8
%23 = load i32, i32* %3
%24 = add nsw i32 %23, 1
store i32 %24, i32* %3
br label %5
25: ; preds = %5
%26 = load i32*, i32** %2
%27 = call i32 @free(i32* %26)
ret i32 0
}

LLVM IR (-O2):
@.str = [14 x i8] c"vetor[%d]=%d\0A\00"
define i32 @main() {
%1 = tail call i32* @malloc(i32 40)
%2 = tail call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 0, i32 1)
%3 = tail call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 1, i32 2)
%4 = tail call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 2, i32 3)
%5 = bitcast i32* %1 to <4 x i32>*
store <4 x i32> <i32 1, i32 2, i32 3, i32 4>, <4 x i32>* %5
%6 = tail call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 3, i32 4)
%7 = getelementptr inbounds i32, i32* %1, i64 4
%8 = tail call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 4, i32 5)
%9 = tail call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 5, i32 6)
%10 = tail call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 6, i32 7)
%11 = bitcast i32* %7 to <4 x i32>*
store <4 x i32> <i32 5, i32 6, i32 7, i32 8>, <4 x i32>* %11
%12 = tail call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 7, i32 8)
%13 = getelementptr inbounds i32, i32* %1, i64 8
store i32 9, i32* %13
%14 = tail call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 8, i32 9)
%15 = getelementptr inbounds i32, i32* %1, i64 9
store i32 10, i32* %15
%16 = tail call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 9, i32 10)
%17 = tail call i32 @free(i32* %1)
ret i32 0
}