#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 cwndtime(const int arg, const int value) {
  static int SndLimTimeRwin, SndLimTimeSender;
  if (arg == -1) {
    if (value == 0) {
      printf("%10s\t", "Duration");
    } else if (value == 3) {
      printf("%10s\t", "CwndTime (%% of total time)");
    }
    return;
  }
  if (arg == 0) {
    printf("%10d\t", value);
  } else if (arg == 1) {
    SndLimTimeRwin = value;
  } else if (arg == 2) {
    SndLimTimeSender = value;
  } else {
    printf("%10.2f",
           ((double)value) / (((double)SndLimTimeRwin) +
                              ((double)SndLimTimeSender) + ((double)value)));
  }
}


x86 assembly (clang, -O0):
<cwndtime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
cmpl   $0xffffffff,-0x4(%rbp)
jne    1175 <cwndtime+0x65>
cmpl   $0x0,-0x8(%rbp)
jne    114c <cwndtime+0x3c>
lea    0xec7(%rip),%rdi
lea    0xec6(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1170 <cwndtime+0x60>
cmpl   $0x3,-0x8(%rbp)
jne    116b <cwndtime+0x5b>
lea    0xea3(%rip),%rdi
lea    0xeab(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1170 <cwndtime+0x60>
jmp    1203 <cwndtime+0xf3>
cmpl   $0x0,-0x4(%rbp)
jne    1195 <cwndtime+0x85>
mov    -0x8(%rbp),%esi
lea    0xea2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1203 <cwndtime+0xf3>
cmpl   $0x1,-0x4(%rbp)
jne    11ad <cwndtime+0x9d>
mov    -0x8(%rbp),%eax
mov    %eax,0x2e84(%rip)
jmp    11fe <cwndtime+0xee>
cmpl   $0x2,-0x4(%rbp)
jne    11c5 <cwndtime+0xb5>
mov    -0x8(%rbp),%eax
mov    %eax,0x2e70(%rip)
jmp    11f9 <cwndtime+0xe9>
cvtsi2sdl -0x8(%rbp),%xmm0
cvtsi2sdl 0x2e5a(%rip),%xmm1
cvtsi2sdl 0x2e56(%rip),%xmm2
addsd  %xmm2,%xmm1
cvtsi2sdl -0x8(%rbp),%xmm2
addsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
lea    0xe3f(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    11fe <cwndtime+0xee>
jmp    1203 <cwndtime+0xf3>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cwndtime>:
add    $0x1,%edi
cmp    $0x3,%edi
ja     114d <cwndtime+0x3d>
lea    0xee1(%rip),%rax
movslq (%rax,%rdi,4),%rcx
add    %rax,%rcx
jmp    *%rcx
cmp    $0x3,%esi
je     1190 <cwndtime+0x80>
test   %esi,%esi
jne    114c <cwndtime+0x3c>
lea    0xed8(%rip),%rdi
lea    0xed7(%rip),%rsi
xor    %eax,%eax
jmp    1030 <printf@plt>
mov    %esi,0x2ee0(%rip)
ret
cvtsi2sd %esi,%xmm0
cvtsi2sdl 0x2ed3(%rip),%xmm1
cvtsi2sdl 0x2ecf(%rip),%xmm2
addsd  %xmm1,%xmm2
addsd  %xmm0,%xmm2
divsd  %xmm2,%xmm0
lea    0xecd(%rip),%rdi
mov    $0x1,%al
jmp    1030 <printf@plt>
lea    0xeb9(%rip),%rdi
xor    %eax,%eax
jmp    1030 <printf@plt>
mov    %esi,0x2ea1(%rip)
ret
lea    0xe79(%rip),%rdi
lea    0xe81(%rip),%rsi
xor    %eax,%eax
jmp    1030 <printf@plt>

LLVM IR (-O0):
@cwndtime.SndLimTimeRwin = internal global i32 0
@cwndtime.SndLimTimeSender = internal global i32 0
@.str = [6 x i8] c"%10s\09\00"
@.str.1 = [9 x i8] c"Duration\00"
@.str.2 = [28 x i8] c"CwndTime (%% of total time)\00"
@.str.3 = [6 x i8] c"%10d\09\00"
@.str.4 = [7 x i8] c"%10.2f\00"
define void @cwndtime(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 %19
7: ; preds = %2
%8 = load i32, i32* %4
%9 = icmp eq 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 ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
br label %18
12: ; preds = %7
%13 = load i32, i32* %4
%14 = icmp eq i32 %13, 3
br i1 %14, label %15, label %17
15: ; preds = %12
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
br label %17
17: ; preds = %15, %12
br label %18
18: ; preds = %17, %10
br label %50
19: ; preds = %2
%20 = load i32, i32* %3
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %25
22: ; preds = %19
%23 = load i32, i32* %4
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 %23)
br label %50
25: ; preds = %19
%26 = load i32, i32* %3
%27 = icmp eq i32 %26, 1
br i1 %27, label %28, label %30
28: ; preds = %25
%29 = load i32, i32* %4
store i32 %29, i32* @cwndtime.SndLimTimeRwin
br label %49
30: ; preds = %25
%31 = load i32, i32* %3
%32 = icmp eq i32 %31, 2
br i1 %32, label %33, label %35
33: ; preds = %30
%34 = load i32, i32* %4
store i32 %34, i32* @cwndtime.SndLimTimeSender
br label %48
35: ; preds = %30
%36 = load i32, i32* %4
%37 = sitofp i32 %36 to double
%38 = load i32, i32* @cwndtime.SndLimTimeRwin
%39 = sitofp i32 %38 to double
%40 = load i32, i32* @cwndtime.SndLimTimeSender
%41 = sitofp i32 %40 to double
%42 = fadd double %39, %41
%43 = load i32, i32* %4
%44 = sitofp i32 %43 to double
%45 = fadd double %42, %44
%46 = fdiv double %37, %45
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), double %46)
br label %48
48: ; preds = %35, %33
br label %49
49: ; preds = %48, %28
br label %50
50: ; preds = %18, %49, %22
ret void
}

LLVM IR (-O2):
@cwndtime.SndLimTimeRwin = internal unnamed_addr global i32 0
@cwndtime.SndLimTimeSender = internal unnamed_addr global i32 0
@.str = [6 x i8] c"%10s\09\00"
@.str.1 = [9 x i8] c"Duration\00"
@.str.2 = [28 x i8] c"CwndTime (%% of total time)\00"
@.str.3 = [6 x i8] c"%10d\09\00"
@.str.4 = [7 x i8] c"%10.2f\00"
define void @cwndtime(i32 %0, i32 %1) {
switch i32 %0, label %12 [
i32 -1, label %3
i32 0, label %8
i32 1, label %10
i32 2, label %11
]
3: ; preds = %2
switch i32 %1, label %22 [
i32 0, label %4
i32 3, label %6
]
4: ; preds = %3
%5 = 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.1, i64 0, i64 0))
br label %22
6: ; preds = %3
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
br label %22
8: ; preds = %2
%9 = 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 %22
10: ; preds = %2
store i32 %1, i32* @cwndtime.SndLimTimeRwin
br label %22
11: ; preds = %2
store i32 %1, i32* @cwndtime.SndLimTimeSender
br label %22
12: ; preds = %2
%13 = sitofp i32 %1 to double
%14 = load i32, i32* @cwndtime.SndLimTimeRwin
%15 = sitofp i32 %14 to double
%16 = load i32, i32* @cwndtime.SndLimTimeSender
%17 = sitofp i32 %16 to double
%18 = fadd double %15, %17
%19 = fadd double %18, %13
%20 = fdiv double %13, %19
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), double %20)
br label %22
22: ; preds = %3, %10, %12, %11, %4, %6, %8
ret void
}