#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*/ comm_mpi();
int /*<<< orphan*/ comm_rank();
scalar_t__ comm_size();
unsigned long mpi_add_ulong(int /*<<< orphan*/, unsigned int);
unsigned int mpi_max_unsigned(int /*<<< orphan*/, unsigned int);
unsigned int mpi_min_unsigned(int /*<<< orphan*/, unsigned int);
int /*<<< orphan*/ print(char *, char const *, unsigned int, unsigned int,
                         unsigned long, double, double);
void print_value_stats(char const *name, unsigned ln) {
  unsigned long tn;
  unsigned maxn;
  unsigned minn;
  double avg;
  tn = mpi_add_ulong(comm_mpi(), ln);
  maxn = mpi_max_unsigned(comm_mpi(), ln);
  minn = mpi_min_unsigned(comm_mpi(), ln);
  avg = ((double)tn) / ((double)(comm_size()));
  if (!comm_rank())
    print("%s max %u min %u total %lu avg %f imb %f\n", name, maxn, minn, tn,
          avg, ((double)maxn) / avg);
}


x86 assembly (clang, -O0):
<print_value_stats>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
xor    %eax,%eax
mov    %al,-0x31(%rbp)
call   1060 <comm_mpi@plt>
mov    %eax,%edi
mov    -0xc(%rbp),%esi
call   1090 <mpi_add_ulong@plt>
mov    %rax,%rcx
mov    -0x31(%rbp),%al
mov    %rcx,-0x18(%rbp)
call   1060 <comm_mpi@plt>
mov    %eax,%edi
mov    -0xc(%rbp),%esi
call   1040 <mpi_max_unsigned@plt>
mov    %eax,%ecx
mov    -0x31(%rbp),%al
mov    %ecx,-0x1c(%rbp)
call   1060 <comm_mpi@plt>
mov    %eax,%edi
mov    -0xc(%rbp),%esi
call   1080 <mpi_min_unsigned@plt>
mov    %eax,-0x20(%rbp)
movaps 0xe33(%rip),%xmm1
movq   -0x18(%rbp),%xmm0
punpckldq %xmm1,%xmm0
movapd 0xe32(%rip),%xmm1
subpd  %xmm1,%xmm0
movaps %xmm0,%xmm1
unpckhpd %xmm0,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    $0x0,%al
call   1030 <comm_size@plt>
movsd  -0x30(%rbp),%xmm0
cvtsi2sd %rax,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    $0x0,%al
call   1070 <comm_rank@plt>
cmp    $0x0,%eax
jne    1247 <print_value_stats+0xd7>
mov    -0x8(%rbp),%rsi
mov    -0x1c(%rbp),%eax
mov    %eax,%edx
mov    -0x20(%rbp),%ecx
mov    -0x18(%rbp),%r8
movsd  -0x28(%rbp),%xmm0
cvtsi2sd %rax,%xmm1
divsd  -0x28(%rbp),%xmm1
lea    0xdde(%rip),%rdi
call   1050 <print@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_value_stats>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %esi,%ebx
mov    %rdi,%r14
xor    %eax,%eax
call   1060 <comm_mpi@plt>
mov    %eax,%edi
mov    %ebx,%esi
call   1090 <mpi_add_ulong@plt>
mov    %rax,%r15
xor    %eax,%eax
call   1060 <comm_mpi@plt>
mov    %eax,%edi
mov    %ebx,%esi
call   1040 <mpi_max_unsigned@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   1060 <comm_mpi@plt>
mov    %eax,%edi
mov    %ebx,%esi
call   1080 <mpi_min_unsigned@plt>
mov    %eax,%r12d
xor    %eax,%eax
call   1030 <comm_size@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1070 <comm_rank@plt>
test   %eax,%eax
je     11d3 <print_value_stats+0x63>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
movq   %r15,%xmm1
punpckldq 0xe20(%rip),%xmm1
subpd  0xe28(%rip),%xmm1
movapd %xmm1,%xmm0
unpckhpd %xmm1,%xmm0
addsd  %xmm1,%xmm0
xorps  %xmm1,%xmm1
cvtsi2sd %rbx,%xmm1
divsd  %xmm1,%xmm0
mov    %ebp,%eax
xorps  %xmm1,%xmm1
cvtsi2sd %rax,%xmm1
divsd  %xmm0,%xmm1
lea    0xe0b(%rip),%rdi
mov    %r14,%rsi
mov    %ebp,%edx
mov    %r12d,%ecx
mov    %r15,%r8
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <print@plt>

LLVM IR (-O0):
@.str = [42 x i8] c"%s max %u min %u total %lu avg %f imb %f\0A\00"
define void @print_value_stats(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i64
%6 = alloca i32
%7 = alloca i32
%8 = alloca double
store i8* %0, i8** %3
store i32 %1, i32* %4
%9 = call i32 (...) @comm_mpi()
%10 = load i32, i32* %4
%11 = call i64 @mpi_add_ulong(i32 %9, i32 %10)
store i64 %11, i64* %5
%12 = call i32 (...) @comm_mpi()
%13 = load i32, i32* %4
%14 = call i32 @mpi_max_unsigned(i32 %12, i32 %13)
store i32 %14, i32* %6
%15 = call i32 (...) @comm_mpi()
%16 = load i32, i32* %4
%17 = call i32 @mpi_min_unsigned(i32 %15, i32 %16)
store i32 %17, i32* %7
%18 = load i64, i64* %5
%19 = uitofp i64 %18 to double
%20 = call i64 (...) @comm_size()
%21 = sitofp i64 %20 to double
%22 = fdiv double %19, %21
store double %22, double* %8
%23 = call i32 (...) @comm_rank()
%24 = icmp ne i32 %23, 0
br i1 %24, label %36, label %25
25: ; preds = %2
%26 = load i8*, i8** %3
%27 = load i32, i32* %6
%28 = load i32, i32* %7
%29 = load i64, i64* %5
%30 = load double, double* %8
%31 = load i32, i32* %6
%32 = uitofp i32 %31 to double
%33 = load double, double* %8
%34 = fdiv double %32, %33
%35 = call i32 @print(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0), i8* %26, i32 %27, i32 %28, i64 %29, double %30, double %34)
br label %36
36: ; preds = %25, %2
ret void
}

LLVM IR (-O2):
@.str = [42 x i8] c"%s max %u min %u total %lu avg %f imb %f\0A\00"
define void @print_value_stats(i8* %0, i32 %1) {
%3 = tail call i32 (...) @comm_mpi()
%4 = tail call i64 @mpi_add_ulong(i32 %3, i32 %1)
%5 = tail call i32 (...) @comm_mpi()
%6 = tail call i32 @mpi_max_unsigned(i32 %5, i32 %1)
%7 = tail call i32 (...) @comm_mpi()
%8 = tail call i32 @mpi_min_unsigned(i32 %7, i32 %1)
%9 = uitofp i64 %4 to double
%10 = tail call i64 (...) @comm_size()
%11 = sitofp i64 %10 to double
%12 = fdiv double %9, %11
%13 = tail call i32 (...) @comm_rank()
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %19
15: ; preds = %2
%16 = uitofp i32 %6 to double
%17 = fdiv double %16, %12
%18 = tail call i32 @print(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0), i8* %0, i32 %6, i32 %8, i64 %4, double %12, double %17)
br label %19
19: ; preds = %15, %2
ret void
}