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


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0xa,%edi
mov    $0x1,%esi
call   1040 <my_calloc@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0xa,-0x14(%rbp)
jge    1189 <main+0x59>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
lea    0xe8e(%rip),%rdi
movsbl (%rax,%rcx,1),%esi
call   1050 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1159 <main+0x29>
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    $0xa,%edi
mov    $0x1,%esi
call   1040 <my_calloc@plt>
mov    %rax,%rbx
movsbl (%rax),%esi
lea    0xeb0(%rip),%r14
mov    %r14,%rdi
call   1050 <printf@plt>
movsbl 0x1(%rbx),%esi
mov    %r14,%rdi
call   1050 <printf@plt>
movsbl 0x2(%rbx),%esi
mov    %r14,%rdi
call   1050 <printf@plt>
movsbl 0x3(%rbx),%esi
mov    %r14,%rdi
call   1050 <printf@plt>
movsbl 0x4(%rbx),%esi
mov    %r14,%rdi
call   1050 <printf@plt>
movsbl 0x5(%rbx),%esi
mov    %r14,%rdi
call   1050 <printf@plt>
movsbl 0x6(%rbx),%esi
mov    %r14,%rdi
call   1050 <printf@plt>
movsbl 0x7(%rbx),%esi
mov    %r14,%rdi
call   1050 <printf@plt>
movsbl 0x8(%rbx),%esi
mov    %r14,%rdi
call   1050 <printf@plt>
movsbl 0x9(%rbx),%esi
mov    %r14,%rdi
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
@.str = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = tail call i64 @my_calloc(i32 10, i32 1)
%2 = inttoptr i64 %1 to i8*
%3 = load i8, i8* %2
%4 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8 signext %3)
%5 = getelementptr inbounds i8, i8* %2, i64 1
%6 = load i8, i8* %5
%7 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8 signext %6)
%8 = getelementptr inbounds i8, i8* %2, i64 2
%9 = load i8, i8* %8
%10 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8 signext %9)
%11 = getelementptr inbounds i8, i8* %2, i64 3
%12 = load i8, i8* %11
%13 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8 signext %12)
%14 = getelementptr inbounds i8, i8* %2, i64 4
%15 = load i8, i8* %14
%16 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8 signext %15)
%17 = getelementptr inbounds i8, i8* %2, i64 5
%18 = load i8, i8* %17
%19 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8 signext %18)
%20 = getelementptr inbounds i8, i8* %2, i64 6
%21 = load i8, i8* %20
%22 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8 signext %21)
%23 = getelementptr inbounds i8, i8* %2, i64 7
%24 = load i8, i8* %23
%25 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8 signext %24)
%26 = getelementptr inbounds i8, i8* %2, i64 8
%27 = load i8, i8* %26
%28 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8 signext %27)
%29 = getelementptr inbounds i8, i8* %2, i64 9
%30 = load i8, i8* %29
%31 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8 signext %30)
%32 = tail call i32 @free(i8* %2)
ret i32 0
}