#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*/ printf(char *, ...);
void printArray(int grades[][4], int pupils, int tests) {
  int i;
  int j;
  printf("                [0]  [1]  [2]  [3]");
  for (i = 0; i < pupils; i++) {
    printf("\nstudentGrades[%d] ", i);
    for (j = 0; j < tests; j++) {
      printf("%-5d", grades[i][j]);
    }
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<printArray>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
lea    0xed7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11ac <printArray+0x9c>
mov    -0x14(%rbp),%esi
lea    0xed6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    1199 <printArray+0x89>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
shl    $0x4,%rcx
add    %rcx,%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xeb3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    115b <printArray+0x4b>
jmp    119e <printArray+0x8e>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1137 <printArray+0x27>
lea    0xe89(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printArray>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,0x4(%rsp)
mov    %esi,%ebp
mov    %rdi,%rbx
lea    0xec5(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
test   %ebp,%ebp
jle    11a9 <printArray+0x89>
mov    %ebp,%r13d
mov    0x4(%rsp),%r14d
lea    0xee2(%rip),%rbp
xor    %r12d,%r12d
jmp    116d <printArray+0x4d>
nopw   0x0(%rax,%rax,1)
add    $0x1,%r12
add    $0x10,%rbx
cmp    %r13,%r12
je     11a9 <printArray+0x89>
lea    0xeaf(%rip),%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
cmpl   $0x0,0x4(%rsp)
jle    1160 <printArray+0x40>
xor    %r15d,%r15d
nopl   0x0(%rax,%rax,1)
mov    (%rbx,%r15,4),%esi
mov    %rbp,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%r15
cmp    %r15,%r14
jne    1190 <printArray+0x70>
jmp    1160 <printArray+0x40>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>

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

LLVM IR (-O2):
@.str = [35 x i8] c" [0] [1] [2] [3]\00"
@.str.1 = [20 x i8] c"\0AstudentGrades[%d] \00"
@.str.2 = [5 x i8] c"%-5d\00"
define void @printArray([4 x i32]* nocapture %0, i32 %1, i32 %2) {
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
%5 = icmp sgt i32 %1, 0
br i1 %5, label %6, label %24
6: ; preds = %3
%7 = icmp sgt i32 %2, 0
%8 = zext i32 %1 to i64
%9 = zext i32 %2 to i64
br label %10
10: ; preds = %6, %21
%11 = phi i64 [ 0, %6 ], [ %22, %21 ]
%12 = trunc i64 %11 to i32
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i32 %12)
br i1 %7, label %14, label %21
14: ; preds = %10, %14
%15 = phi i64 [ %19, %14 ], [ 0, %10 ]
%16 = getelementptr inbounds [4 x i32], [4 x i32]* %0, i64 %11, i64 %15
%17 = load i32, i32* %16
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %17)
%19 = add nuw nsw i64 %15, 1
%20 = icmp eq i64 %19, %9
br i1 %20, label %21, label %14
21: ; preds = %14, %10
%22 = add nuw nsw i64 %11, 1
%23 = icmp eq i64 %22, %8
br i1 %23, label %24, label %10
24: ; preds = %21, %3
%25 = tail call i32 @putchar(i32 10)
ret void
}