#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 */
scalar_t__ calloc(int, int);
int /*<<< orphan*/ free(int *);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char const *argv[]) {
  int *p, i;
  p = (int *)calloc(20, sizeof(int));
  if (!p)
    printf("Memoria insuficiente\n");
  else {
    for (i = 0; i < 20; i++)
      *(p + i) = i;
    for (i = 0; i < 20; i++)
      printf("%d \t", p[i]);
    printf("\n\n\n");
    free(p);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x14,%edi
mov    $0x4,%esi
call   1050 <calloc@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1177 <main+0x47>
lea    0xe95(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11f3 <main+0xc3>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x14,-0x1c(%rbp)
jge    11a4 <main+0x74>
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    117e <main+0x4e>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x14,-0x1c(%rbp)
jge    11dc <main+0xac>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe4f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11ab <main+0x7b>
lea    0xe38(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    $0x14,%edi
mov    $0x4,%esi
call   1060 <calloc@plt>
test   %rax,%rax
je     12b5 <main+0x175>
mov    %rax,%rbx
movaps 0xe9a(%rip),%xmm0
movups %xmm0,(%rax)
movaps 0xea0(%rip),%xmm0
movups %xmm0,0x10(%rax)
movaps 0xea5(%rip),%xmm0
movups %xmm0,0x20(%rax)
movaps 0xeaa(%rip),%xmm0
movups %xmm0,0x30(%rax)
movaps 0xeaf(%rip),%xmm0
movups %xmm0,0x40(%rax)
lea    0xeb4(%rip),%r14
mov    %r14,%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x4(%rbx),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x8(%rbx),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0xc(%rbx),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x10(%rbx),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x14(%rbx),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x18(%rbx),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x1c(%rbx),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x20(%rbx),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x24(%rbx),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x28(%rbx),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x2c(%rbx),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x30(%rbx),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x34(%rbx),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x38(%rbx),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x3c(%rbx),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x40(%rbx),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x44(%rbx),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x48(%rbx),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x4c(%rbx),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xdc4(%rip),%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
jmp    12c1 <main+0x181>
lea    0xd99(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
@.str.1 = [5 x i8] c"%d \09\00"
@str = [21 x i8] c"Memoria insuficiente\00"
@str.3 = [3 x i8] c"\0A\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i64 @calloc(i32 20, i32 4)
%4 = inttoptr i64 %3 to i32*
%5 = icmp eq i64 %3, 0
br i1 %5, label %72, label %6
6: ; preds = %2
%7 = getelementptr inbounds i32, i32* %4, i64 1
%8 = getelementptr inbounds i32, i32* %4, i64 2
%9 = getelementptr inbounds i32, i32* %4, i64 3
%10 = inttoptr i64 %3 to <4 x i32>*
store <4 x i32> <i32 0, i32 1, i32 2, i32 3>, <4 x i32>* %10
%11 = getelementptr inbounds i32, i32* %4, i64 4
%12 = getelementptr inbounds i32, i32* %4, i64 5
%13 = getelementptr inbounds i32, i32* %4, i64 6
%14 = getelementptr inbounds i32, i32* %4, i64 7
%15 = bitcast i32* %11 to <4 x i32>*
store <4 x i32> <i32 4, i32 5, i32 6, i32 7>, <4 x i32>* %15
%16 = getelementptr inbounds i32, i32* %4, i64 8
%17 = getelementptr inbounds i32, i32* %4, i64 9
%18 = getelementptr inbounds i32, i32* %4, i64 10
%19 = getelementptr inbounds i32, i32* %4, i64 11
%20 = bitcast i32* %16 to <4 x i32>*
store <4 x i32> <i32 8, i32 9, i32 10, i32 11>, <4 x i32>* %20
%21 = getelementptr inbounds i32, i32* %4, i64 12
%22 = getelementptr inbounds i32, i32* %4, i64 13
%23 = getelementptr inbounds i32, i32* %4, i64 14
%24 = getelementptr inbounds i32, i32* %4, i64 15
%25 = bitcast i32* %21 to <4 x i32>*
store <4 x i32> <i32 12, i32 13, i32 14, i32 15>, <4 x i32>* %25
%26 = getelementptr inbounds i32, i32* %4, i64 16
%27 = getelementptr inbounds i32, i32* %4, i64 17
%28 = getelementptr inbounds i32, i32* %4, i64 18
%29 = getelementptr inbounds i32, i32* %4, i64 19
%30 = bitcast i32* %26 to <4 x i32>*
store <4 x i32> <i32 16, i32 17, i32 18, i32 19>, <4 x i32>* %30
%31 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 0)
%32 = load i32, i32* %7
%33 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %32)
%34 = load i32, i32* %8
%35 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %34)
%36 = load i32, i32* %9
%37 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %36)
%38 = load i32, i32* %11
%39 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %38)
%40 = load i32, i32* %12
%41 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %40)
%42 = load i32, i32* %13
%43 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %42)
%44 = load i32, i32* %14
%45 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %44)
%46 = load i32, i32* %16
%47 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %46)
%48 = load i32, i32* %17
%49 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %48)
%50 = load i32, i32* %18
%51 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %50)
%52 = load i32, i32* %19
%53 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %52)
%54 = load i32, i32* %21
%55 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %54)
%56 = load i32, i32* %22
%57 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %56)
%58 = load i32, i32* %23
%59 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %58)
%60 = load i32, i32* %24
%61 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %60)
%62 = load i32, i32* %26
%63 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %62)
%64 = load i32, i32* %27
%65 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %64)
%66 = load i32, i32* %28
%67 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %66)
%68 = load i32, i32* %29
%69 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %68)
%70 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @str.3, i64 0, i64 0))
%71 = tail call i32 @free(i32* %4)
br label %74
72: ; preds = %2
%73 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0))
br label %74
74: ; preds = %6, %72
ret i32 0
}