#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 */
char *calloc(int, int);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, char *);
int main(void) {
  int i;
  int n = 10;
  char c = "dfdsfsfc";
  for (i = 0; i < n; i++) {
    char *s;
    int j;
    s = calloc(i + 2, 1);
    if (!s) {
      perror("calloc");
      break;
    }
    for (j = 0; j < i + 1; j++) {
      s[j] = c;
    }
    printf("%s\n", s);
    free(s);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0xa,-0xc(%rbp)
lea    0xea3(%rip),%rax
mov    %al,-0xd(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11fe <main+0xbe>
mov    -0x8(%rbp),%edi
add    $0x2,%edi
mov    $0x1,%esi
call   1050 <calloc@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11a3 <main+0x63>
lea    0xe70(%rip),%rdi
call   1060 <perror@plt>
jmp    11fe <main+0xbe>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    -0x8(%rbp),%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
jge    11d7 <main+0x97>
mov    -0xd(%rbp),%dl
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11aa <main+0x6a>
mov    -0x18(%rbp),%rsi
lea    0xe2e(%rip),%rdi
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1167 <main+0x27>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    $0x2,%edi
mov    $0x1,%esi
call   1050 <calloc@plt>
test   %rax,%rax
je     13fc <main+0x2bc>
mov    %rax,%rbx
lea    0xe9a(%rip),%rax
mov    %al,(%rbx)
lea    0xea1(%rip),%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    $0x3,%edi
mov    $0x1,%esi
call   1050 <calloc@plt>
test   %rax,%rax
je     13fc <main+0x2bc>
mov    %rax,%rbx
lea    0xe5f(%rip),%rax
movzbl %al,%eax
mov    %eax,%ecx
shl    $0x8,%ecx
or     %eax,%ecx
mov    %cx,(%rbx)
lea    0xe5b(%rip),%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    $0x4,%edi
mov    $0x1,%esi
call   1050 <calloc@plt>
test   %rax,%rax
je     13fc <main+0x2bc>
mov    %rax,%rbx
lea    0xe19(%rip),%rax
mov    %al,0x2(%rbx)
movzbl %al,%eax
mov    %eax,%ecx
shl    $0x8,%ecx
or     %eax,%ecx
mov    %cx,(%rbx)
lea    0xe12(%rip),%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    $0x5,%edi
mov    $0x1,%esi
call   1050 <calloc@plt>
test   %rax,%rax
je     13fc <main+0x2bc>
mov    %rax,%rbx
lea    0xdd0(%rip),%rax
movzbl %al,%eax
imul   $0x1010101,%eax,%eax
mov    %eax,(%rbx)
lea    0xdce(%rip),%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    $0x6,%edi
mov    $0x1,%esi
call   1050 <calloc@plt>
test   %rax,%rax
je     13fc <main+0x2bc>
mov    %rax,%rbx
lea    0xd8c(%rip),%rax
movzbl %al,%eax
imul   $0x1010101,%eax,%eax
mov    %eax,(%rbx)
mov    %al,0x4(%rbx)
lea    0xd87(%rip),%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    $0x7,%edi
mov    $0x1,%esi
call   1050 <calloc@plt>
test   %rax,%rax
je     13fc <main+0x2bc>
mov    %rax,%rbx
lea    0xd45(%rip),%rax
movzbl %al,%eax
imul   $0x1010101,%eax,%eax
mov    %eax,(%rbx)
mov    %ax,0x4(%rbx)
lea    0xd3f(%rip),%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    $0x8,%edi
mov    $0x1,%esi
call   1050 <calloc@plt>
test   %rax,%rax
je     13fc <main+0x2bc>
mov    %rax,%rbx
lea    0xcfd(%rip),%rax
movzbl %al,%eax
imul   $0x1010101,%eax,%eax
mov    %eax,0x3(%rbx)
mov    %eax,(%rbx)
lea    0xcf8(%rip),%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    $0x9,%edi
mov    $0x1,%esi
call   1050 <calloc@plt>
test   %rax,%rax
je     13fc <main+0x2bc>
mov    %rax,%rbx
lea    0xcb6(%rip),%rax
movzbl %al,%eax
movabs $0x101010101010101,%r14
01 01 01
imul   %r14,%rax
mov    %rax,(%rbx)
lea    0xcab(%rip),%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    $0xa,%edi
mov    $0x1,%esi
call   1050 <calloc@plt>
test   %rax,%rax
je     13fc <main+0x2bc>
mov    %rax,%rbx
lea    0xc6d(%rip),%rax
movzbl %al,%eax
imul   %r14,%rax
mov    %rax,(%rbx)
mov    %al,0x8(%rbx)
lea    0xc69(%rip),%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    $0xb,%edi
mov    $0x1,%esi
call   1050 <calloc@plt>
test   %rax,%rax
je     13fc <main+0x2bc>
mov    %rax,%rbx
lea    0xc2b(%rip),%rax
movzbl %al,%eax
imul   %r14,%rax
mov    %rax,(%rbx)
mov    %ax,0x8(%rbx)
lea    0xc26(%rip),%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
jmp    1408 <main+0x2c8>
lea    0xc06(%rip),%rdi
call   1060 <perror@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
@.str = [9 x i8] c"dfdsfsfc\00"
@.str.1 = [7 x i8] c"calloc\00"
@.str.2 = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = tail call dereferenceable_or_null(2) i8* @calloc(i32 2, i32 1)
%2 = icmp eq i8* %1, null
br i1 %2, label %51, label %3
3: ; preds = %0
%4 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %1)
%5 = tail call i32 @free(i8* %1)
%6 = tail call dereferenceable_or_null(3) i8* @calloc(i32 3, i32 1)
%7 = icmp eq i8* %6, null
br i1 %7, label %51, label %8
8: ; preds = %3
%9 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %6)
%10 = tail call i32 @free(i8* %6)
%11 = tail call dereferenceable_or_null(4) i8* @calloc(i32 4, i32 1)
%12 = icmp eq i8* %11, null
br i1 %12, label %51, label %13
13: ; preds = %8
%14 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %11)
%15 = tail call i32 @free(i8* %11)
%16 = tail call dereferenceable_or_null(5) i8* @calloc(i32 5, i32 1)
%17 = icmp eq i8* %16, null
br i1 %17, label %51, label %18
18: ; preds = %13
%19 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %16)
%20 = tail call i32 @free(i8* %16)
%21 = tail call dereferenceable_or_null(6) i8* @calloc(i32 6, i32 1)
%22 = icmp eq i8* %21, null
br i1 %22, label %51, label %23
23: ; preds = %18
%24 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %21)
%25 = tail call i32 @free(i8* %21)
%26 = tail call dereferenceable_or_null(7) i8* @calloc(i32 7, i32 1)
%27 = icmp eq i8* %26, null
br i1 %27, label %51, label %28
28: ; preds = %23
%29 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %26)
%30 = tail call i32 @free(i8* %26)
%31 = tail call dereferenceable_or_null(8) i8* @calloc(i32 8, i32 1)
%32 = icmp eq i8* %31, null
br i1 %32, label %51, label %33
33: ; preds = %28
%34 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %31)
%35 = tail call i32 @free(i8* %31)
%36 = tail call dereferenceable_or_null(9) i8* @calloc(i32 9, i32 1)
%37 = icmp eq i8* %36, null
br i1 %37, label %51, label %38
38: ; preds = %33
%39 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %36)
%40 = tail call i32 @free(i8* %36)
%41 = tail call dereferenceable_or_null(10) i8* @calloc(i32 10, i32 1)
%42 = icmp eq i8* %41, null
br i1 %42, label %51, label %43
43: ; preds = %38
%44 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %41)
%45 = tail call i32 @free(i8* %41)
%46 = tail call dereferenceable_or_null(11) i8* @calloc(i32 11, i32 1)
%47 = icmp eq i8* %46, null
br i1 %47, label %51, label %48
48: ; preds = %43
%49 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %46)
%50 = tail call i32 @free(i8* %46)
br label %53
51: ; preds = %43, %38, %33, %28, %23, %18, %13, %8, %3, %0
%52 = tail call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
br label %53
53: ; preds = %48, %51
ret i32 0
}