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


x86 assembly (clang, -O0):
<showres>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    -0x8(%rbp),%eax
mov    %rax,-0x20(%rbp)
lea    0xea0(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11c1 <showres+0x81>
mov    -0x20(%rbp),%rcx
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
movslq -0x14(%rbp),%rax
imul   %rcx,%rax
shl    $0x3,%rax
add    %rax,%rsi
call   1030 <avgarr@plt>
mov    -0x24(%rbp),%esi
lea    0xe6a(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    116e <showres+0x2e>
mov    -0x8(%rbp),%edi
mov    -0x4(%rbp),%esi
mov    -0x10(%rbp),%rdx
call   1060 <avg2darr@plt>
lea    0xe46(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    -0x8(%rbp),%edi
mov    -0x4(%rbp),%esi
mov    -0x10(%rbp),%rdx
call   1040 <max2darr@plt>
lea    0xe3e(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<showres>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdx,0x10(%rsp)
mov    %esi,%r13d
mov    %edi,%ebx
lea    0xebe(%rip),%rdi
call   1050 <puts@plt>
mov    %ebx,0xc(%rsp)
test   %ebx,%ebx
jle    11c3 <showres+0x73>
mov    %r13d,%r14d
mov    0xc(%rsp),%r15d
shl    $0x3,%r14
xor    %ebp,%ebp
lea    0xe6f(%rip),%r12
mov    0x10(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%rbp
mov    %r13d,%edi
mov    %rbx,%rsi
call   1030 <avgarr@plt>
mov    %r12,%rdi
mov    %ebp,%esi
mov    $0x1,%al
call   1060 <printf@plt>
add    %r14,%rbx
cmp    %rbp,%r15
jne    11a0 <showres+0x50>
mov    %r13d,%edi
mov    0xc(%rsp),%ebp
mov    %ebp,%esi
mov    0x10(%rsp),%rbx
mov    %rbx,%rdx
call   1070 <avg2darr@plt>
lea    0xe27(%rip),%rdi
mov    $0x1,%al
call   1060 <printf@plt>
mov    %r13d,%edi
mov    %ebp,%esi
mov    %rbx,%rdx
call   1040 <max2darr@plt>
lea    0xe21(%rip),%rdi
mov    $0x1,%al
add    $0x18,%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(i32 %0, i32 %1, double* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca double*
%7 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store double* %2, double** %6
%8 = load i32, i32* %4
%9 = zext i32 %8 to i64
%10 = load i32, i32* %5
%11 = zext i32 %10 to i64
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %7
br label %13
13: ; preds = %28, %3
%14 = load i32, i32* %7
%15 = load i32, i32* %4
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %31
17: ; preds = %13
%18 = load i32, i32* %7
%19 = add nsw i32 %18, 1
%20 = load i32, i32* %5
%21 = load double*, double** %6
%22 = load i32, i32* %7
%23 = sext i32 %22 to i64
%24 = mul nsw i64 %23, %11
%25 = getelementptr inbounds double, double* %21, i64 %24
%26 = call double @avgarr(i32 %20, double* %25)
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %19, double %26)
br label %28
28: ; preds = %17
%29 = load i32, i32* %7
%30 = add nsw i32 %29, 1
store i32 %30, i32* %7
br label %13
31: ; preds = %13
%32 = load i32, i32* %5
%33 = load i32, i32* %4
%34 = load double*, double** %6
%35 = bitcast double* %34 to double**
%36 = call double @avg2darr(i32 %32, i32 %33, double** %35)
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), double %36)
%38 = load i32, i32* %5
%39 = load i32, i32* %4
%40 = load double*, double** %6
%41 = bitcast double* %40 to double**
%42 = call double @max2darr(i32 %38, i32 %39, double** %41)
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), double %42)
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(i32 %0, i32 %1, double* %2) {
%4 = zext i32 %1 to i64
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0))
%6 = icmp sgt i32 %0, 0
br i1 %6, label %7, label %9
7: ; preds = %3
%8 = zext i32 %0 to i64
br label %15
9: ; preds = %15, %3
%10 = bitcast double* %2 to double**
%11 = tail call double @avg2darr(i32 %1, i32 %0, double** %10)
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), double %11)
%13 = tail call double @max2darr(i32 %1, i32 %0, double** %10)
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), double %13)
ret void
15: ; preds = %7, %15
%16 = phi i64 [ 0, %7 ], [ %17, %15 ]
%17 = add nuw nsw i64 %16, 1
%18 = mul nuw nsw i64 %16, %4
%19 = getelementptr inbounds double, double* %2, i64 %18
%20 = tail call double @avgarr(i32 %1, double* %19)
%21 = trunc i64 %17 to i32
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %21, double %20)
%23 = icmp eq i64 %17, %8
br i1 %23, label %9, label %15
}