#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 */
double avg2darr(double **, int);
double avgarr(double *, int);
double max2darr(double **, int);
int /*<<< orphan*/ printf(char *, ...);
void showres(double ar[][5], int n) {
  printf("Average of each set:\n");
  for (int i = 0; i < n; i++)
    printf("%d\t%g\n", i + 1, avgarr(ar[i], 5));
  printf("\nAverage of all: %g\n", avg2darr(ar, n));
  printf("\nMax of all: %g\n", max2darr(ar, n));
}


x86 assembly (clang, -O0):
<showres>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11b1 <showres+0x71>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
movslq -0x10(%rbp),%rax
imul   $0x28,%rax,%rax
add    %rax,%rdi
mov    $0x5,%esi
call   1030 <avgarr@plt>
mov    -0x14(%rbp),%esi
lea    0xe7a(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1164 <showres+0x24>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1060 <avg2darr@plt>
lea    0xe59(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1040 <max2darr@plt>
lea    0xe54(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<showres>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,%r15d
mov    %rdi,%r14
lea    0xec5(%rip),%rdi
call   1050 <puts@plt>
test   %r15d,%r15d
jle    11b6 <showres+0x66>
mov    %r15d,%r13d
xor    %ebx,%ebx
lea    0xe82(%rip),%r12
mov    %r14,%rbp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x1,%rbx
mov    %rbp,%rdi
mov    $0x5,%esi
call   1030 <avgarr@plt>
mov    %r12,%rdi
mov    %ebx,%esi
mov    $0x1,%al
call   1060 <printf@plt>
add    $0x28,%rbp
cmp    %rbx,%r13
jne    1190 <showres+0x40>
mov    %r14,%rdi
mov    %r15d,%esi
call   1070 <avg2darr@plt>
lea    0xe3f(%rip),%rdi
mov    $0x1,%al
call   1060 <printf@plt>
mov    %r14,%rdi
mov    %r15d,%esi
call   1040 <max2darr@plt>
lea    0xe3b(%rip),%rdi
mov    $0x1,%al
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1060 <printf@plt>

LLVM IR (-O0):
@.str = [22 x i8] c"Average of each set:\0A\00"
@.str.1 = [7 x i8] c"%d\09%g\0A\00"
@.str.2 = [21 x i8] c"\0AAverage of all: %g\0A\00"
@.str.3 = [17 x i8] c"\0AMax of all: %g\0A\00"
define void @showres([5 x double]* %0, i32 %1) {
%3 = alloca [5 x double]*
%4 = alloca i32
%5 = alloca i32
store [5 x double]* %0, [5 x double]** %3
store i32 %1, i32* %4
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %5
br label %7
7: ; preds = %21, %2
%8 = load i32, i32* %5
%9 = load i32, i32* %4
%10 = icmp slt i32 %8, %9
br i1 %10, label %11, label %24
11: ; preds = %7
%12 = load i32, i32* %5
%13 = add nsw i32 %12, 1
%14 = load [5 x double]*, [5 x double]** %3
%15 = load i32, i32* %5
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [5 x double], [5 x double]* %14, i64 %16
%18 = getelementptr inbounds [5 x double], [5 x double]* %17, i64 0, i64 0
%19 = call double @avgarr(double* %18, i32 5)
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %13, double %19)
br label %21
21: ; preds = %11
%22 = load i32, i32* %5
%23 = add nsw i32 %22, 1
store i32 %23, i32* %5
br label %7
24: ; preds = %7
%25 = load [5 x double]*, [5 x double]** %3
%26 = bitcast [5 x double]* %25 to double**
%27 = load i32, i32* %4
%28 = call double @avg2darr(double** %26, i32 %27)
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), double %28)
%30 = load [5 x double]*, [5 x double]** %3
%31 = bitcast [5 x double]* %30 to double**
%32 = load i32, i32* %4
%33 = call double @max2darr(double** %31, i32 %32)
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), double %33)
ret void
}

LLVM IR (-O2):
@.str.1 = [7 x i8] c"%d\09%g\0A\00"
@.str.2 = [21 x i8] c"\0AAverage of all: %g\0A\00"
@.str.3 = [17 x i8] c"\0AMax of all: %g\0A\00"
@str = [21 x i8] c"Average of each set:\00"
define void @showres([5 x double]* %0, i32 %1) {
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0))
%4 = icmp sgt i32 %1, 0
br i1 %4, label %5, label %7
5: ; preds = %2
%6 = zext i32 %1 to i64
br label %13
7: ; preds = %13, %2
%8 = bitcast [5 x double]* %0 to double**
%9 = tail call double @avg2darr(double** %8, i32 %1)
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), double %9)
%11 = tail call double @max2darr(double** %8, i32 %1)
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), double %11)
ret void
13: ; preds = %5, %13
%14 = phi i64 [ 0, %5 ], [ %15, %13 ]
%15 = add nuw nsw i64 %14, 1
%16 = getelementptr inbounds [5 x double], [5 x double]* %0, i64 %14, i64 0
%17 = tail call double @avgarr(double* %16, i32 5)
%18 = trunc i64 %15 to i32
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %18, double %17)
%20 = icmp eq i64 %15, %6
br i1 %20, label %7, label %13
}