#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(const int grades[][4], int pupils, int tests) {
  int i;
  int j;
  printf("The array is:\n");
  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>
lea    0xed8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11ba <printArray+0xaa>
mov    -0x14(%rbp),%esi
lea    0xed8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11a7 <printArray+0x97>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
shl    $0x4,%rcx
add    %rcx,%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xeb5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1169 <printArray+0x59>
jmp    11ac <printArray+0x9c>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1145 <printArray+0x35>
lea    0xe4c(%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    0xef2(%rip),%rdi
call   1040 <puts@plt>
lea    0xea9(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
test   %ebp,%ebp
jle    11c9 <printArray+0x99>
mov    %ebp,%r13d
mov    0x4(%rsp),%r14d
lea    0xec7(%rip),%rbp
xor    %r12d,%r12d
jmp    118d <printArray+0x5d>
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%r12
add    $0x10,%rbx
cmp    %r13,%r12
je     11c9 <printArray+0x99>
lea    0xe90(%rip),%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
cmpl   $0x0,0x4(%rsp)
jle    1180 <printArray+0x50>
xor    %r15d,%r15d
nopl   0x0(%rax,%rax,1)
mov    (%rbx,%r15,4),%esi
mov    %rbp,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%r15
cmp    %r15,%r14
jne    11b0 <printArray+0x80>
jmp    1180 <printArray+0x50>
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 = [15 x i8] c"The array is:\0A\00"
@.str.1 = [36 x i8] c" [0] [1] [2] [3]\00"
@.str.2 = [20 x i8] c"\0AstudentGrades[%d] \00"
@.str.3 = [5 x i8] c"%-5d\00"
@.str.4 = [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 ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %7
br label %11
11: ; preds = %36, %3
%12 = load i32, i32* %7
%13 = load i32, i32* %5
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %39
15: ; preds = %11
%16 = load i32, i32* %7
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i32 %16)
store i32 0, i32* %8
br label %18
18: ; preds = %32, %15
%19 = load i32, i32* %8
%20 = load i32, i32* %6
%21 = icmp slt i32 %19, %20
br i1 %21, label %22, label %35
22: ; preds = %18
%23 = load [4 x i32]*, [4 x i32]** %4
%24 = load i32, i32* %7
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [4 x i32], [4 x i32]* %23, i64 %25
%27 = load i32, i32* %8
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [4 x i32], [4 x i32]* %26, i64 0, i64 %28
%30 = load i32, i32* %29
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %30)
br label %32
32: ; preds = %22
%33 = load i32, i32* %8
%34 = add nsw i32 %33, 1
store i32 %34, i32* %8
br label %18
35: ; preds = %18
br label %36
36: ; preds = %35
%37 = load i32, i32* %7
%38 = add nsw i32 %37, 1
store i32 %38, i32* %7
br label %11
39: ; preds = %11
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
ret void
}

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