#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*/ avg_course(double **, double *);
int /*<<< orphan*/ avg_student(double **, double *);
int /*<<< orphan*/ input_scores(double **);
int *max_score(double **);
int /*<<< orphan*/ print_averages(double *, int);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  double student_scores[10][5];
  double averages_stu[10];
  double averages_course[5];
  int *max_pos;
  input_scores(student_scores);
  avg_student(student_scores, averages_stu);
  avg_course(student_scores, averages_course);
  printf("Average score for each student: ");
  print_averages(averages_stu, 10);
  printf("Average score for each course: ");
  print_averages(averages_course, 5);
  max_pos = max_score(student_scores);
  printf("The maximum is in the position (%d, %d)\n", max_pos[0] + 1,
         max_pos[1] + 1);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x230,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x1a0(%rbp),%rdi
call   1050 <input_scores@plt>
lea    -0x1a0(%rbp),%rdi
lea    -0x1f0(%rbp),%rsi
call   1080 <avg_student@plt>
lea    -0x1a0(%rbp),%rdi
lea    -0x220(%rbp),%rsi
call   1040 <avg_course@plt>
lea    0xe55(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0x1f0(%rbp),%rdi
mov    $0xa,%esi
call   1030 <print_averages@plt>
lea    0xe57(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0x220(%rbp),%rdi
mov    $0x5,%esi
call   1030 <print_averages@plt>
lea    -0x1a0(%rbp),%rdi
call   1070 <max_score@plt>
mov    %rax,-0x228(%rbp)
mov    -0x228(%rbp),%rax
mov    (%rax),%esi
add    $0x1,%esi
mov    -0x228(%rbp),%rax
mov    0x4(%rax),%edx
add    $0x1,%edx
lea    0xe2c(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x230,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x210,%rsp
lea    0x80(%rsp),%rbx
mov    %rbx,%rdi
call   1050 <input_scores@plt>
lea    0x30(%rsp),%r14
mov    %rbx,%rdi
mov    %r14,%rsi
call   1080 <avg_student@plt>
mov    %rsp,%r15
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <avg_course@plt>
lea    0xe5f(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r14,%rdi
mov    $0xa,%esi
call   1030 <print_averages@plt>
lea    0xe65(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r15,%rdi
mov    $0x5,%esi
call   1030 <print_averages@plt>
mov    %rbx,%rdi
call   1070 <max_score@plt>
mov    (%rax),%esi
mov    0x4(%rax),%edx
add    $0x1,%esi
add    $0x1,%edx
lea    0xe57(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x210,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [33 x i8] c"Average score for each student: \00"
@.str.1 = [32 x i8] c"Average score for each course: \00"
@.str.2 = [41 x i8] c"The maximum is in the position (%d, %d)\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [10 x [5 x double]]
%3 = alloca [10 x double]
%4 = alloca [5 x double]
%5 = alloca i32*
store i32 0, i32* %1
%6 = getelementptr inbounds [10 x [5 x double]], [10 x [5 x double]]* %2, i64 0, i64 0
%7 = bitcast [5 x double]* %6 to double**
%8 = call i32 @input_scores(double** %7)
%9 = getelementptr inbounds [10 x [5 x double]], [10 x [5 x double]]* %2, i64 0, i64 0
%10 = bitcast [5 x double]* %9 to double**
%11 = getelementptr inbounds [10 x double], [10 x double]* %3, i64 0, i64 0
%12 = call i32 @avg_student(double** %10, double* %11)
%13 = getelementptr inbounds [10 x [5 x double]], [10 x [5 x double]]* %2, i64 0, i64 0
%14 = bitcast [5 x double]* %13 to double**
%15 = getelementptr inbounds [5 x double], [5 x double]* %4, i64 0, i64 0
%16 = call i32 @avg_course(double** %14, double* %15)
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%18 = getelementptr inbounds [10 x double], [10 x double]* %3, i64 0, i64 0
%19 = call i32 @print_averages(double* %18, i32 10)
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0))
%21 = getelementptr inbounds [5 x double], [5 x double]* %4, i64 0, i64 0
%22 = call i32 @print_averages(double* %21, i32 5)
%23 = getelementptr inbounds [10 x [5 x double]], [10 x [5 x double]]* %2, i64 0, i64 0
%24 = bitcast [5 x double]* %23 to double**
%25 = call i32* @max_score(double** %24)
store i32* %25, i32** %5
%26 = load i32*, i32** %5
%27 = getelementptr inbounds i32, i32* %26, i64 0
%28 = load i32, i32* %27
%29 = add nsw i32 %28, 1
%30 = load i32*, i32** %5
%31 = getelementptr inbounds i32, i32* %30, i64 1
%32 = load i32, i32* %31
%33 = add nsw i32 %32, 1
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0), i32 %29, i32 %33)
ret i32 0
}

LLVM IR (-O2):
@.str = [33 x i8] c"Average score for each student: \00"
@.str.1 = [32 x i8] c"Average score for each course: \00"
@.str.2 = [41 x i8] c"The maximum is in the position (%d, %d)\0A\00"
define i32 @main() {
%1 = alloca [10 x [5 x double]]
%2 = alloca [10 x double]
%3 = alloca [5 x double]
%4 = bitcast [10 x [5 x double]]* %1 to i8*
%5 = bitcast [10 x double]* %2 to i8*
%6 = bitcast [5 x double]* %3 to i8*
%7 = bitcast [10 x [5 x double]]* %1 to double**
%8 = call i32 @input_scores(double** %7)
%9 = getelementptr inbounds [10 x double], [10 x double]* %2, i64 0, i64 0
%10 = call i32 @avg_student(double** %7, double* %9)
%11 = getelementptr inbounds [5 x double], [5 x double]* %3, i64 0, i64 0
%12 = call i32 @avg_course(double** %7, double* %11)
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%14 = call i32 @print_averages(double* %9, i32 10)
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0))
%16 = call i32 @print_averages(double* %11, i32 5)
%17 = call i32* @max_score(double** %7)
%18 = load i32, i32* %17
%19 = add nsw i32 %18, 1
%20 = getelementptr inbounds i32, i32* %17, i64 1
%21 = load i32, i32* %20
%22 = add nsw i32 %21, 1
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0), i32 %19, i32 %22)
ret i32 0
}