#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*/ EXIT_FAILURE;
int /*<<< orphan*/ EXIT_SUCCESS;
int *calloc(int const, int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ printf(char *, void *, int);
int /*<<< orphan*/ stderr;
int main(void) {
  int i;
  const int tot_elem = 10;
  int *ptr;
  if ((ptr = calloc(tot_elem, sizeof(int))) == NULL) {
    fprintf(stderr, "Err.(line:%d) calloc()\n", 31 - 1);
    exit(EXIT_FAILURE);
  }
  for (i = 0; i < tot_elem; i++)
    printf("%p = %d\n", (void *)&ptr[i], ptr[i]);
  exit(EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0xa,-0xc(%rbp)
mov    $0xa,%edi
mov    $0x4,%esi
call   1040 <calloc@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    119b <main+0x5b>
mov    0x2e66(%rip),%rax
mov    (%rax),%edi
lea    0xe7d(%rip),%rsi
mov    $0x1e,%edx
call   1050 <fprintf@plt>
mov    0x2e44(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0xa,-0x8(%rbp)
jge    11e0 <main+0xa0>
mov    -0x18(%rbp),%rsi
movslq -0x8(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
mov    -0x18(%rbp),%rax
movslq -0x8(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
lea    0xe4b(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11a2 <main+0x62>
mov    0x2de9(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    $0xa,%edi
mov    $0x4,%esi
call   1040 <calloc@plt>
test   %rax,%rax
jne    1180 <main+0x40>
mov    0x2e81(%rip),%rax
mov    (%rax),%edi
lea    0xe98(%rip),%rsi
mov    $0x1e,%edx
call   1050 <fprintf@plt>
mov    0x2e5f(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
mov    %rax,%rbx
mov    (%rax),%edx
lea    0xe8c(%rip),%r14
mov    %r14,%rdi
mov    %rax,%rsi
call   1030 <printf@plt>
lea    0x4(%rbx),%rsi
mov    0x4(%rbx),%edx
mov    %r14,%rdi
call   1030 <printf@plt>
lea    0x8(%rbx),%rsi
mov    0x8(%rbx),%edx
mov    %r14,%rdi
call   1030 <printf@plt>
lea    0xc(%rbx),%rsi
mov    0xc(%rbx),%edx
mov    %r14,%rdi
call   1030 <printf@plt>
lea    0x10(%rbx),%rsi
mov    0x10(%rbx),%edx
mov    %r14,%rdi
call   1030 <printf@plt>
lea    0x14(%rbx),%rsi
mov    0x14(%rbx),%edx
mov    %r14,%rdi
call   1030 <printf@plt>
lea    0x18(%rbx),%rsi
mov    0x18(%rbx),%edx
mov    %r14,%rdi
call   1030 <printf@plt>
lea    0x1c(%rbx),%rsi
mov    0x1c(%rbx),%edx
mov    %r14,%rdi
call   1030 <printf@plt>
lea    0x20(%rbx),%rsi
mov    0x20(%rbx),%edx
mov    %r14,%rdi
call   1030 <printf@plt>
mov    %rbx,%rsi
add    $0x24,%rsi
mov    0x24(%rbx),%edx
mov    %r14,%rdi
call   1030 <printf@plt>
mov    0x2da8(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [24 x i8] c"Err.(line:%d) calloc()\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [9 x i8] c"%p = %d\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32*
store i32 0, i32* %1
store i32 10, i32* %3
%5 = call i32* @calloc(i32 10, i32 4)
store i32* %5, i32** %4
%6 = icmp eq i32* %5, null
br i1 %6, label %7, label %12
7: ; preds = %0
%8 = load i32, i32* @stderr
%9 = call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 30)
%10 = load i32, i32* @EXIT_FAILURE
%11 = call i32 @exit(i32 %10)
unreachable
12: ; preds = %0
store i32 0, i32* %2
br label %13
13: ; preds = %28, %12
%14 = load i32, i32* %2
%15 = icmp slt i32 %14, 10
br i1 %15, label %16, label %31
16: ; preds = %13
%17 = load i32*, i32** %4
%18 = load i32, i32* %2
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i32, i32* %17, i64 %19
%21 = bitcast i32* %20 to i8*
%22 = load i32*, i32** %4
%23 = load i32, i32* %2
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i32, i32* %22, i64 %24
%26 = load i32, i32* %25
%27 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* %21, i32 %26)
br label %28
28: ; preds = %16
%29 = load i32, i32* %2
%30 = add nsw i32 %29, 1
store i32 %30, i32* %2
br label %13
31: ; preds = %13
%32 = load i32, i32* @EXIT_SUCCESS
%33 = call i32 @exit(i32 %32)
unreachable
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [24 x i8] c"Err.(line:%d) calloc()\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [9 x i8] c"%p = %d\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = tail call i32* @calloc(i32 10, i32 4)
%2 = icmp eq i32* %1, null
br i1 %2, label %45, label %3
3: ; preds = %0
%4 = bitcast i32* %1 to i8*
%5 = load i32, i32* %1
%6 = tail call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* %4, i32 %5)
%7 = getelementptr inbounds i32, i32* %1, i64 1
%8 = bitcast i32* %7 to i8*
%9 = load i32, i32* %7
%10 = tail call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* %8, i32 %9)
%11 = getelementptr inbounds i32, i32* %1, i64 2
%12 = bitcast i32* %11 to i8*
%13 = load i32, i32* %11
%14 = tail call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* %12, i32 %13)
%15 = getelementptr inbounds i32, i32* %1, i64 3
%16 = bitcast i32* %15 to i8*
%17 = load i32, i32* %15
%18 = tail call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* %16, i32 %17)
%19 = getelementptr inbounds i32, i32* %1, i64 4
%20 = bitcast i32* %19 to i8*
%21 = load i32, i32* %19
%22 = tail call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* %20, i32 %21)
%23 = getelementptr inbounds i32, i32* %1, i64 5
%24 = bitcast i32* %23 to i8*
%25 = load i32, i32* %23
%26 = tail call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* %24, i32 %25)
%27 = getelementptr inbounds i32, i32* %1, i64 6
%28 = bitcast i32* %27 to i8*
%29 = load i32, i32* %27
%30 = tail call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* %28, i32 %29)
%31 = getelementptr inbounds i32, i32* %1, i64 7
%32 = bitcast i32* %31 to i8*
%33 = load i32, i32* %31
%34 = tail call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* %32, i32 %33)
%35 = getelementptr inbounds i32, i32* %1, i64 8
%36 = bitcast i32* %35 to i8*
%37 = load i32, i32* %35
%38 = tail call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* %36, i32 %37)
%39 = getelementptr inbounds i32, i32* %1, i64 9
%40 = bitcast i32* %39 to i8*
%41 = load i32, i32* %39
%42 = tail call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* %40, i32 %41)
%43 = load i32, i32* @EXIT_SUCCESS
%44 = tail call i32 @exit(i32 %43)
unreachable
45: ; preds = %0
%46 = load i32, i32* @stderr
%47 = tail call i32 @fprintf(i32 %46, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 30)
%48 = load i32, i32* @EXIT_FAILURE
%49 = tail call i32 @exit(i32 %48)
unreachable
}