#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 *, ...);
void throughput(const int arg, const int value) {
  static int duration;
  if (arg == -1) {
    if (value) {
      printf("%10s\t", "Throughput (kB/s)");
    } else {
      printf("%10s\t", "Duration");
    }
    return;
  }
  if (!arg) {
    duration = value;
    printf("%10d\t", value);
  } else {
    printf("%10.2f", ((8 * ((double)value)) / ((double)duration)) * 1000000.0 /
                         1024.0 / 1024.0);
  }
}


x86 assembly (clang, -O0):
<throughput>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
cmpl   $0xffffffff,-0x4(%rbp)
jne    1166 <throughput+0x56>
cmpl   $0x0,-0x8(%rbp)
je     114c <throughput+0x3c>
lea    0xedf(%rip),%rdi
lea    0xede(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1161 <throughput+0x51>
lea    0xec5(%rip),%rdi
lea    0xed6(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11de <throughput+0xce>
cmpl   $0x0,-0x4(%rbp)
jne    118f <throughput+0x7f>
mov    -0x8(%rbp),%eax
mov    %eax,0x2eb3(%rip)
mov    -0x8(%rbp),%esi
lea    0xeb6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11de <throughput+0xce>
cvtsi2sdl -0x8(%rbp),%xmm1
movsd  0xe74(%rip),%xmm0
mulsd  %xmm1,%xmm0
cvtsi2sdl 0x2e84(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  0xe54(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe40(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  0xe34(%rip),%xmm1
divsd  %xmm1,%xmm0
lea    0xe68(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<throughput>:
test   %edi,%edi
je     1132 <throughput+0x22>
cmp    $0xffffffff,%edi
jne    1146 <throughput+0x36>
lea    0xef8(%rip),%rdi
test   %esi,%esi
je     1184 <throughput+0x74>
lea    0xef3(%rip),%rsi
xor    %eax,%eax
jmp    1030 <printf@plt>
mov    %esi,0x2ef4(%rip)
lea    0xefa(%rip),%rdi
xor    %eax,%eax
jmp    1030 <printf@plt>
cvtsi2sd %esi,%xmm0
mulsd  0xeae(%rip),%xmm0
cvtsi2sdl 0x2ed2(%rip),%xmm1
divsd  %xmm1,%xmm0
mulsd  0xea2(%rip),%xmm0
movsd  0xea2(%rip),%xmm1
mulsd  %xmm1,%xmm0
mulsd  %xmm1,%xmm0
lea    0xec2(%rip),%rdi
mov    $0x1,%al
jmp    1030 <printf@plt>
lea    0xea5(%rip),%rsi
xor    %eax,%eax
jmp    1030 <printf@plt>

LLVM IR (-O0):
@throughput.duration = internal global i32 0
@.str = [6 x i8] c"%10s\09\00"
@.str.1 = [18 x i8] c"Throughput (kB/s)\00"
@.str.2 = [9 x i8] c"Duration\00"
@.str.3 = [6 x i8] c"%10d\09\00"
@.str.4 = [7 x i8] c"%10.2f\00"
define void @throughput(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%5 = load i32, i32* %3
%6 = icmp eq i32 %5, -1
br i1 %6, label %7, label %15
7: ; preds = %2
%8 = load i32, i32* %4
%9 = icmp ne i32 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %7
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
br label %14
12: ; preds = %7
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
br label %14
14: ; preds = %12, %10
br label %33
15: ; preds = %2
%16 = load i32, i32* %3
%17 = icmp ne i32 %16, 0
br i1 %17, label %22, label %18
18: ; preds = %15
%19 = load i32, i32* %4
store i32 %19, i32* @throughput.duration
%20 = load i32, i32* %4
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 %20)
br label %33
22: ; preds = %15
%23 = load i32, i32* %4
%24 = sitofp i32 %23 to double
%25 = fmul double 8.000000e+00, %24
%26 = load i32, i32* @throughput.duration
%27 = sitofp i32 %26 to double
%28 = fdiv double %25, %27
%29 = fmul double %28, 1.000000e+06
%30 = fdiv double %29, 1.024000e+03
%31 = fdiv double %30, 1.024000e+03
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), double %31)
br label %33
33: ; preds = %14, %22, %18
ret void
}

LLVM IR (-O2):
@throughput.duration = internal unnamed_addr global i32 0
@.str = [6 x i8] c"%10s\09\00"
@.str.1 = [18 x i8] c"Throughput (kB/s)\00"
@.str.2 = [9 x i8] c"Duration\00"
@.str.3 = [6 x i8] c"%10d\09\00"
@.str.4 = [7 x i8] c"%10.2f\00"
define void @throughput(i32 %0, i32 %1) {
switch i32 %0, label %11 [
i32 -1, label %3
i32 0, label %9
]
3: ; preds = %2
%4 = icmp eq i32 %1, 0
br i1 %4, label %7, label %5
5: ; preds = %3
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
br label %21
7: ; preds = %3
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
br label %21
9: ; preds = %2
store i32 %1, i32* @throughput.duration
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 %1)
br label %21
11: ; preds = %2
%12 = sitofp i32 %1 to double
%13 = fmul double %12, 8.000000e+00
%14 = load i32, i32* @throughput.duration
%15 = sitofp i32 %14 to double
%16 = fdiv double %13, %15
%17 = fmul double %16, 1.000000e+06
%18 = fmul double %17, 0x3F50000000000000
%19 = fmul double %18, 0x3F50000000000000
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), double %19)
br label %21
21: ; preds = %5, %7, %11, %9
ret void
}