#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*/ getchar();
int /*<<< orphan*/ printf(char *, int);
int main() {
  int *head, *p;
  head = (int *)calloc(10, sizeof(int));
  for (p = head; p < head + 10; p++)
    *p = p - head + 1;
  for (p = head; p < head + 10; p++)
    printf("%3d", *p);
  getchar();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0xa,%edi
mov    $0x4,%esi
call   1040 <calloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x10(%rbp),%rcx
add    $0x28,%rcx
cmp    %rcx,%rax
jae    119b <main+0x6b>
mov    -0x18(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    %rcx,%rax
sar    $0x2,%rax
add    $0x1,%rax
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x18(%rbp)
jmp    115a <main+0x2a>
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x10(%rbp),%rcx
add    $0x28,%rcx
cmp    %rcx,%rax
jae    11db <main+0xab>
mov    -0x18(%rbp),%rax
mov    (%rax),%esi
lea    0xe3b(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x18(%rbp)
jmp    11a3 <main+0x73>
mov    $0x0,%al
call   1050 <getchar@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    $0xa,%edi
mov    $0x4,%esi
call   1040 <calloc@plt>
mov    %rax,%rbx
movabs $0x200000001,%rax
mov    %rax,(%rbx)
movabs $0x400000003,%rax
mov    %rax,0x8(%rbx)
movabs $0x600000005,%rax
mov    %rax,0x10(%rbx)
movabs $0x800000007,%rax
mov    %rax,0x18(%rbx)
movabs $0xa00000009,%rax
mov    %rax,0x20(%rbx)
lea    0xe6e(%rip),%r14
mov    %r14,%rdi
mov    $0x1,%esi
call   1030 <printf@plt>
mov    0x4(%rbx),%esi
mov    %r14,%rdi
call   1030 <printf@plt>
mov    0x8(%rbx),%esi
mov    %r14,%rdi
call   1030 <printf@plt>
mov    0xc(%rbx),%esi
mov    %r14,%rdi
call   1030 <printf@plt>
mov    0x10(%rbx),%esi
mov    %r14,%rdi
call   1030 <printf@plt>
mov    0x14(%rbx),%esi
mov    %r14,%rdi
call   1030 <printf@plt>
mov    0x18(%rbx),%esi
mov    %r14,%rdi
call   1030 <printf@plt>
mov    0x1c(%rbx),%esi
mov    %r14,%rdi
call   1030 <printf@plt>
mov    0x20(%rbx),%esi
mov    %r14,%rdi
call   1030 <printf@plt>
mov    0x24(%rbx),%esi
mov    %r14,%rdi
call   1030 <printf@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

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