#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*/ display_array(int, int *);
int /*<<< orphan*/ free(int *);
int /*<<< orphan*/ printf(char *, ...);
int main(void) {
  int i = 0;
  int *array = NULL;
  array = (int *)calloc(10, sizeof(int));
  printf("Size of an int      : %lu\n", sizeof(int));
  printf("Address of array    : %p\n", array);
  printf("Address of array[0] : %p\n", &array[0]);
  printf("\n");
  display_array(10, array);
  for (i = 0; i < 10; ++i) {
    array[i] = i;
  }
  printf("\n");
  display_array(10, array);
  if (array) {
    free(array);
  }
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
mov    $0xa,%edi
mov    $0x4,%esi
call   1060 <calloc@plt>
mov    %rax,-0x10(%rbp)
lea    0xe88(%rip),%rdi
mov    $0x4,%esi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x10(%rbp),%rsi
lea    0xe8c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x10(%rbp),%rsi
lea    0xe94(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe84(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x10(%rbp),%rsi
mov    $0xa,%edi
call   1040 <display_array@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0xa,-0x8(%rbp)
jge    11f1 <main+0xb1>
mov    -0x8(%rbp),%edx
mov    -0x10(%rbp),%rax
movslq -0x8(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11cb <main+0x8b>
lea    0xe3b(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x10(%rbp),%rsi
mov    $0xa,%edi
call   1040 <display_array@plt>
cmpq   $0x0,-0x10(%rbp)
je     1221 <main+0xe1>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    $0xa,%edi
mov    $0x4,%esi
call   1070 <calloc@plt>
mov    %rax,%rbx
lea    0xeb6(%rip),%rdi
mov    $0x4,%esi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xebe(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xec7(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
mov    $0xa,%edi
mov    %rbx,%rsi
call   1050 <display_array@plt>
movaps 0xe4a(%rip),%xmm0
movups %xmm0,(%rbx)
movaps 0xe50(%rip),%xmm0
movups %xmm0,0x10(%rbx)
movabs $0x900000008,%rax
mov    %rax,0x20(%rbx)
mov    $0xa,%edi
call   1040 <putchar@plt>
mov    $0xa,%edi
mov    %rbx,%rsi
call   1050 <display_array@plt>
test   %rbx,%rbx
je     11f6 <main+0xa6>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [27 x i8] c"Size of an int : %lu\0A\00"
@.str.1 = [26 x i8] c"Address of array : %p\0A\00"
@.str.2 = [26 x i8] c"Address of array[0] : %p\0A\00"
@.str.3 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32*
store i32 0, i32* %1
store i32 0, i32* %2
store i32* null, i32** %3
%4 = call i64 @calloc(i32 10, i32 4)
%5 = inttoptr i64 %4 to i32*
store i32* %5, i32** %3
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i64 4)
%7 = load i32*, i32** %3
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i32* %7)
%9 = load i32*, i32** %3
%10 = getelementptr inbounds i32, i32* %9, i64 0
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i32* %10)
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%13 = load i32*, i32** %3
%14 = call i32 @display_array(i32 10, i32* %13)
store i32 0, i32* %2
br label %15
15: ; preds = %24, %0
%16 = load i32, i32* %2
%17 = icmp slt i32 %16, 10
br i1 %17, label %18, label %27
18: ; preds = %15
%19 = load i32, i32* %2
%20 = load i32*, i32** %3
%21 = load i32, i32* %2
%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* %2
%26 = add nsw i32 %25, 1
store i32 %26, i32* %2
br label %15
27: ; preds = %15
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%29 = load i32*, i32** %3
%30 = call i32 @display_array(i32 10, i32* %29)
%31 = load i32*, i32** %3
%32 = icmp ne i32* %31, null
br i1 %32, label %33, label %36
33: ; preds = %27
%34 = load i32*, i32** %3
%35 = call i32 @free(i32* %34)
br label %36
36: ; preds = %33, %27
ret i32 0
}

LLVM IR (-O2):
@.str = [27 x i8] c"Size of an int : %lu\0A\00"
@.str.1 = [26 x i8] c"Address of array : %p\0A\00"
@.str.2 = [26 x i8] c"Address of array[0] : %p\0A\00"
define i32 @main() {
%1 = tail call i64 @calloc(i32 10, i32 4)
%2 = inttoptr i64 %1 to i32*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i64 4)
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i32* %2)
%6 = tail call i32 @putchar(i32 10)
%7 = tail call i32 @display_array(i32 10, i32* %2)
%8 = inttoptr i64 %1 to <4 x i32>*
store <4 x i32> <i32 0, i32 1, i32 2, i32 3>, <4 x i32>* %8
%9 = getelementptr inbounds i32, i32* %2, i64 4
%10 = bitcast i32* %9 to <4 x i32>*
store <4 x i32> <i32 4, i32 5, i32 6, i32 7>, <4 x i32>* %10
%11 = getelementptr inbounds i32, i32* %2, i64 8
store i32 8, i32* %11
%12 = getelementptr inbounds i32, i32* %2, i64 9
store i32 9, i32* %12
%13 = tail call i32 @putchar(i32 10)
%14 = tail call i32 @display_array(i32 10, i32* %2)
%15 = icmp eq i64 %1, 0
br i1 %15, label %18, label %16
16: ; preds = %0
%17 = tail call i32 @free(i32* %2)
br label %18
18: ; preds = %16, %0
ret i32 0
}