#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(void *);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int main(void) {
  char i;
  char j;
  char(*a)[5];
  a = (char(*)[5])malloc(4 * 5 * sizeof(char));
  for (i = 0; i < 4; ++i) {
    for (j = 0; j < 5; ++j) {
      a[i][j] = i + j;
      printf("%2d", a[i][j]);
    }
    printf("\n");
  }
  free((void *)a);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x14,%edi
call   1050 <malloc@plt>
mov    %rax,-0x10(%rbp)
movb   $0x0,-0x5(%rbp)
movsbl -0x5(%rbp),%eax
cmp    $0x4,%eax
jge    11e2 <main+0xb2>
movb   $0x0,-0x6(%rbp)
movsbl -0x6(%rbp),%eax
cmp    $0x5,%eax
jge    11c7 <main+0x97>
movsbl -0x5(%rbp),%eax
movsbl -0x6(%rbp),%ecx
add    %ecx,%eax
mov    %al,%dl
mov    -0x10(%rbp),%rax
movsbq -0x5(%rbp),%rcx
imul   $0x5,%rcx,%rcx
add    %rcx,%rax
movsbq -0x6(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x10(%rbp),%rax
movsbq -0x5(%rbp),%rcx
imul   $0x5,%rcx,%rcx
add    %rcx,%rax
movsbq -0x6(%rbp),%rcx
movsbl (%rax,%rcx,1),%esi
lea    0xe4d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x6(%rbp),%al
add    $0x1,%al
mov    %al,-0x6(%rbp)
jmp    1162 <main+0x32>
lea    0xe36(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x5(%rbp),%al
add    $0x1,%al
mov    %al,-0x5(%rbp)
jmp    1151 <main+0x21>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    $0x14,%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
movb   $0x0,(%rax)
lea    0xea5(%rip),%r14
mov    %r14,%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1050 <printf@plt>
movb   $0x1,0x1(%rbx)
mov    %r14,%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1050 <printf@plt>
movb   $0x2,0x2(%rbx)
mov    %r14,%rdi
mov    $0x2,%esi
xor    %eax,%eax
call   1050 <printf@plt>
movb   $0x3,0x3(%rbx)
mov    %r14,%rdi
mov    $0x3,%esi
xor    %eax,%eax
call   1050 <printf@plt>
movb   $0x4,0x4(%rbx)
mov    %r14,%rdi
mov    $0x4,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
movb   $0x1,0x5(%rbx)
mov    %r14,%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1050 <printf@plt>
movb   $0x2,0x6(%rbx)
mov    %r14,%rdi
mov    $0x2,%esi
xor    %eax,%eax
call   1050 <printf@plt>
movb   $0x3,0x7(%rbx)
mov    %r14,%rdi
mov    $0x3,%esi
xor    %eax,%eax
call   1050 <printf@plt>
movb   $0x4,0x8(%rbx)
mov    %r14,%rdi
mov    $0x4,%esi
xor    %eax,%eax
call   1050 <printf@plt>
movb   $0x5,0x9(%rbx)
mov    %r14,%rdi
mov    $0x5,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
movb   $0x2,0xa(%rbx)
mov    %r14,%rdi
mov    $0x2,%esi
xor    %eax,%eax
call   1050 <printf@plt>
movb   $0x3,0xb(%rbx)
mov    %r14,%rdi
mov    $0x3,%esi
xor    %eax,%eax
call   1050 <printf@plt>
movb   $0x4,0xc(%rbx)
mov    %r14,%rdi
mov    $0x4,%esi
xor    %eax,%eax
call   1050 <printf@plt>
movb   $0x5,0xd(%rbx)
mov    %r14,%rdi
mov    $0x5,%esi
xor    %eax,%eax
call   1050 <printf@plt>
movb   $0x6,0xe(%rbx)
mov    %r14,%rdi
mov    $0x6,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
movb   $0x3,0xf(%rbx)
mov    %r14,%rdi
mov    $0x3,%esi
xor    %eax,%eax
call   1050 <printf@plt>
movb   $0x4,0x10(%rbx)
mov    %r14,%rdi
mov    $0x4,%esi
xor    %eax,%eax
call   1050 <printf@plt>
movb   $0x5,0x11(%rbx)
mov    %r14,%rdi
mov    $0x5,%esi
xor    %eax,%eax
call   1050 <printf@plt>
movb   $0x6,0x12(%rbx)
mov    %r14,%rdi
mov    $0x6,%esi
xor    %eax,%eax
call   1050 <printf@plt>
movb   $0x7,0x13(%rbx)
mov    %r14,%rdi
mov    $0x7,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1040 <putchar@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"%2d\00"
@.str.1 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca i8
%4 = alloca [5 x i8]*
store i32 0, i32* %1
%5 = call i64 @malloc(i32 20)
%6 = inttoptr i64 %5 to [5 x i8]*
store [5 x i8]* %6, [5 x i8]** %4
store i8 0, i8* %2
br label %7
7: ; preds = %45, %0
%8 = load i8, i8* %2
%9 = sext i8 %8 to i32
%10 = icmp slt i32 %9, 4
br i1 %10, label %11, label %48
11: ; preds = %7
store i8 0, i8* %3
br label %12
12: ; preds = %40, %11
%13 = load i8, i8* %3
%14 = sext i8 %13 to i32
%15 = icmp slt i32 %14, 5
br i1 %15, label %16, label %43
16: ; preds = %12
%17 = load i8, i8* %2
%18 = sext i8 %17 to i32
%19 = load i8, i8* %3
%20 = sext i8 %19 to i32
%21 = add nsw i32 %18, %20
%22 = trunc i32 %21 to i8
%23 = load [5 x i8]*, [5 x i8]** %4
%24 = load i8, i8* %2
%25 = sext i8 %24 to i64
%26 = getelementptr inbounds [5 x i8], [5 x i8]* %23, i64 %25
%27 = load i8, i8* %3
%28 = sext i8 %27 to i64
%29 = getelementptr inbounds [5 x i8], [5 x i8]* %26, i64 0, i64 %28
store i8 %22, i8* %29
%30 = load [5 x i8]*, [5 x i8]** %4
%31 = load i8, i8* %2
%32 = sext i8 %31 to i64
%33 = getelementptr inbounds [5 x i8], [5 x i8]* %30, i64 %32
%34 = load i8, i8* %3
%35 = sext i8 %34 to i64
%36 = getelementptr inbounds [5 x i8], [5 x i8]* %33, i64 0, i64 %35
%37 = load i8, i8* %36
%38 = sext i8 %37 to i32
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %38)
br label %40
40: ; preds = %16
%41 = load i8, i8* %3
%42 = add i8 %41, 1
store i8 %42, i8* %3
br label %12
43: ; preds = %12
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %45
45: ; preds = %43
%46 = load i8, i8* %2
%47 = add i8 %46, 1
store i8 %47, i8* %2
br label %7
48: ; preds = %7
%49 = load [5 x i8]*, [5 x i8]** %4
%50 = bitcast [5 x i8]* %49 to i8*
%51 = call i32 @free(i8* %50)
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%2d\00"
define i32 @main() {
%1 = tail call i64 @malloc(i32 20)
%2 = inttoptr i64 %1 to [5 x i8]*
%3 = getelementptr [5 x i8], [5 x i8]* %2, i64 0, i64 0
store i8 0, i8* %3
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 0)
%5 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 1
store i8 1, i8* %5
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 1)
%7 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 2
store i8 2, i8* %7
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 2)
%9 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 3
store i8 3, i8* %9
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 3)
%11 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 4
store i8 4, i8* %11
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 4)
%13 = tail call i32 @putchar(i32 10)
%14 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 1, i64 0
store i8 1, i8* %14
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 1)
%16 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 1, i64 1
store i8 2, i8* %16
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 2)
%18 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 1, i64 2
store i8 3, i8* %18
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 3)
%20 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 1, i64 3
store i8 4, i8* %20
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 4)
%22 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 1, i64 4
store i8 5, i8* %22
%23 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 5)
%24 = tail call i32 @putchar(i32 10)
%25 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 2, i64 0
store i8 2, i8* %25
%26 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 2)
%27 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 2, i64 1
store i8 3, i8* %27
%28 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 3)
%29 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 2, i64 2
store i8 4, i8* %29
%30 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 4)
%31 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 2, i64 3
store i8 5, i8* %31
%32 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 5)
%33 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 2, i64 4
store i8 6, i8* %33
%34 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 6)
%35 = tail call i32 @putchar(i32 10)
%36 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 3, i64 0
store i8 3, i8* %36
%37 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 3)
%38 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 3, i64 1
store i8 4, i8* %38
%39 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 4)
%40 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 3, i64 2
store i8 5, i8* %40
%41 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 5)
%42 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 3, i64 3
store i8 6, i8* %42
%43 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 6)
%44 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 3, i64 4
store i8 7, i8* %44
%45 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 7)
%46 = tail call i32 @putchar(i32 10)
%47 = tail call i32 @free(i8* %3)
ret i32 0
}