#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 *, int, ...);
void statistics(int *cycles, int *regread, int *zeroread, int *cnt,
                int *count) {
  printf("average CPI = %.1lf\n", (double)*cycles / *count);
  printf("average register reads per instruction = %.1lf\n",
         (double)*regread / *count);
  if (regread != 0) {
    printf("fraction of reads that read zero register = %.1lf%%\n",
           100.0 * *zeroread / *regread);
  }
  int i;
  for (i = 0; i < 6 - 1; i++) {
    printf("number of inputs produced %d instructions ahead: %d\n", i + 1,
           cnt[i]);
  }
}


x86 assembly (clang, -O0):
<statistics>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    -0x8(%rbp),%rax
cvtsi2sdl (%rax),%xmm0
mov    -0x28(%rbp),%rax
cvtsi2sdl (%rax),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%esi
lea    0xebd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
cvtsi2sdl (%rax),%xmm0
mov    -0x28(%rbp),%rax
cvtsi2sdl (%rax),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%esi
lea    0xeac(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpq   $0x0,-0x10(%rbp)
je     11b5 <statistics+0xa5>
mov    -0x18(%rbp),%rax
cvtsi2sdl (%rax),%xmm1
movsd  0xe6d(%rip),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
cvtsi2sdl (%rax),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%esi
lea    0xe9f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x2c(%rbp)
cmpl   $0x5,-0x2c(%rbp)
jge    11f3 <statistics+0xe3>
mov    -0x2c(%rbp),%esi
add    $0x1,%esi
mov    -0x20(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
lea    0xea4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    11bc <statistics+0xac>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<statistics>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %r8,%rbx
cvtsi2sdl (%rdi),%xmm0
cvtsi2sdl (%r8),%xmm1
mov    %rcx,%r15
mov    %rdx,%r14
mov    %rsi,%r12
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%esi
lea    0xecc(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xorps  %xmm0,%xmm0
cvtsi2sdl (%r12),%xmm0
xorps  %xmm1,%xmm1
cvtsi2sdl (%rbx),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%esi
lea    0xebb(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xorps  %xmm0,%xmm0
cvtsi2sdl (%r14),%xmm0
mulsd  0xe87(%rip),%xmm0
xorps  %xmm1,%xmm1
cvtsi2sdl (%r12),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%esi
lea    0xebc(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    (%r15),%edx
lea    0xee0(%rip),%r14
mov    %r14,%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x4(%r15),%edx
mov    %r14,%rdi
mov    $0x2,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x8(%r15),%edx
mov    %r14,%rdi
mov    $0x3,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0xc(%r15),%edx
mov    %r14,%rdi
mov    $0x4,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x10(%r15),%edx
mov    %r14,%rdi
mov    $0x5,%esi
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [21 x i8] c"average CPI = %.1lf\0A\00"
@.str.1 = [48 x i8] c"average register reads per instruction = %.1lf\0A\00"
@.str.2 = [53 x i8] c"fraction of reads that read zero register = %.1lf%%\0A\00"
@.str.3 = [53 x i8] c"number of inputs produced %d instructions ahead: %d\0A\00"
define void @statistics(i32* %0, i32* %1, i32* %2, i32* %3, i32* %4) {
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca i32*
%10 = alloca i32*
%11 = alloca i32
store i32* %0, i32** %6
store i32* %1, i32** %7
store i32* %2, i32** %8
store i32* %3, i32** %9
store i32* %4, i32** %10
%12 = load i32*, i32** %6
%13 = load i32, i32* %12
%14 = sitofp i32 %13 to double
%15 = load i32*, i32** %10
%16 = load i32, i32* %15
%17 = sitofp i32 %16 to double
%18 = fdiv double %14, %17
%19 = fptosi double %18 to i32
%20 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 %19)
%21 = load i32*, i32** %7
%22 = load i32, i32* %21
%23 = sitofp i32 %22 to double
%24 = load i32*, i32** %10
%25 = load i32, i32* %24
%26 = sitofp i32 %25 to double
%27 = fdiv double %23, %26
%28 = fptosi double %27 to i32
%29 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.1, i64 0, i64 0), i32 %28)
%30 = load i32*, i32** %7
%31 = icmp ne i32* %30, null
br i1 %31, label %32, label %43
32: ; preds = %5
%33 = load i32*, i32** %8
%34 = load i32, i32* %33
%35 = sitofp i32 %34 to double
%36 = fmul double 1.000000e+02, %35
%37 = load i32*, i32** %7
%38 = load i32, i32* %37
%39 = sitofp i32 %38 to double
%40 = fdiv double %36, %39
%41 = fptosi double %40 to i32
%42 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.2, i64 0, i64 0), i32 %41)
br label %43
43: ; preds = %32, %5
store i32 0, i32* %11
br label %44
44: ; preds = %56, %43
%45 = load i32, i32* %11
%46 = icmp slt i32 %45, 5
br i1 %46, label %47, label %59
47: ; preds = %44
%48 = load i32, i32* %11
%49 = add nsw i32 %48, 1
%50 = load i32*, i32** %9
%51 = load i32, i32* %11
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds i32, i32* %50, i64 %52
%54 = load i32, i32* %53
%55 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.3, i64 0, i64 0), i32 %49, i32 %54)
br label %56
56: ; preds = %47
%57 = load i32, i32* %11
%58 = add nsw i32 %57, 1
store i32 %58, i32* %11
br label %44
59: ; preds = %44
ret void
}

LLVM IR (-O2):
@.str = [21 x i8] c"average CPI = %.1lf\0A\00"
@.str.1 = [48 x i8] c"average register reads per instruction = %.1lf\0A\00"
@.str.2 = [53 x i8] c"fraction of reads that read zero register = %.1lf%%\0A\00"
@.str.3 = [53 x i8] c"number of inputs produced %d instructions ahead: %d\0A\00"
define void @statistics(i32* nocapture %0, i32* nocapture %1, i32* nocapture %2, i32* nocapture %3, i32* nocapture %4) {
%6 = load i32, i32* %0
%7 = sitofp i32 %6 to double
%8 = load i32, i32* %4
%9 = sitofp i32 %8 to double
%10 = fdiv double %7, %9
%11 = fptosi double %10 to i32
%12 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 %11)
%13 = load i32, i32* %1
%14 = sitofp i32 %13 to double
%15 = load i32, i32* %4
%16 = sitofp i32 %15 to double
%17 = fdiv double %14, %16
%18 = fptosi double %17 to i32
%19 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.1, i64 0, i64 0), i32 %18)
%20 = load i32, i32* %2
%21 = sitofp i32 %20 to double
%22 = fmul double %21, 1.000000e+02
%23 = load i32, i32* %1
%24 = sitofp i32 %23 to double
%25 = fdiv double %22, %24
%26 = fptosi double %25 to i32
%27 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.2, i64 0, i64 0), i32 %26)
%28 = load i32, i32* %3
%29 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.3, i64 0, i64 0), i32 1, i32 %28)
%30 = getelementptr inbounds i32, i32* %3, i64 1
%31 = load i32, i32* %30
%32 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.3, i64 0, i64 0), i32 2, i32 %31)
%33 = getelementptr inbounds i32, i32* %3, i64 2
%34 = load i32, i32* %33
%35 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.3, i64 0, i64 0), i32 3, i32 %34)
%36 = getelementptr inbounds i32, i32* %3, i64 3
%37 = load i32, i32* %36
%38 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.3, i64 0, i64 0), i32 4, i32 %37)
%39 = getelementptr inbounds i32, i32* %3, i64 4
%40 = load i32, i32* %39
%41 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.3, i64 0, i64 0), i32 5, i32 %40)
ret void
}