#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 printSubArray(int grades[][4], size_t pupils, size_t tests) {
  size_t i;
  size_t j;
  printf("%s", "                [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]);
    }
  }
}


x86 assembly (clang, -O0):
<printSubArray>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
lea    0xed5(%rip),%rdi
lea    0xed1(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    11c2 <printSubArray+0xb2>
mov    -0x20(%rbp),%rsi
lea    0xecc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movq   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    11ac <printSubArray+0x9c>
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%rcx
shl    $0x4,%rcx
add    %rcx,%rax
mov    -0x28(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xea6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    1169 <printSubArray+0x59>
jmp    11b1 <printSubArray+0xa1>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1141 <printSubArray+0x31>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printSubArray>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r15
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xed5(%rip),%rdi
lea    0xed1(%rip),%rsi
xor    %eax,%eax
call   1030 <printf@plt>
test   %r14,%r14
je     1199 <printSubArray+0x89>
lea    0xef5(%rip),%r13
xor    %ebp,%ebp
jmp    115d <printSubArray+0x4d>
nopl   0x0(%rax)
add    $0x1,%rbp
add    $0x10,%rbx
cmp    %r14,%rbp
je     1199 <printSubArray+0x89>
lea    0xec2(%rip),%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
test   %r15,%r15
je     1150 <printSubArray+0x40>
xor    %r12d,%r12d
cs nopw 0x0(%rax,%rax,1)
mov    (%rbx,%r12,4),%esi
mov    %r13,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x1,%r12
cmp    %r12,%r15
jne    1180 <printSubArray+0x70>
jmp    1150 <printSubArray+0x40>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@.str.1 = [35 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"
define void @printSubArray([4 x i32]* nocapture %0, i64 %1, i64 %2) {
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0))
%5 = icmp eq i64 %1, 0
br i1 %5, label %21, label %6
6: ; preds = %3
%7 = icmp eq i64 %2, 0
br label %8
8: ; preds = %6, %18
%9 = phi i64 [ 0, %6 ], [ %19, %18 ]
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i64 %9)
br i1 %7, label %18, label %11
11: ; preds = %8, %11
%12 = phi i64 [ %16, %11 ], [ 0, %8 ]
%13 = getelementptr inbounds [4 x i32], [4 x i32]* %0, i64 %9, i64 %12
%14 = load i32, i32* %13
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %14)
%16 = add nuw i64 %12, 1
%17 = icmp eq i64 %16, %2
br i1 %17, label %18, label %11
18: ; preds = %11, %8
%19 = add nuw i64 %9, 1
%20 = icmp eq i64 %19, %1
br i1 %20, label %21, label %8
21: ; preds = %18, %3
ret void
}