#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 PDQ_CreateMultiNode(int, char *, int, int);
int PDQ_CreateNode(char *, int, int);
int PDQ_CreateOpen(char *, double);
int /*<<< orphan*/ PDQ_Init(char *);
int /*<<< orphan*/ PDQ_Report();
int /*<<< orphan*/ PDQ_SetDemand(char *, char *, double);
int /*<<< orphan*/ PDQ_SetTUnit(char *);
int /*<<< orphan*/ PDQ_SetWUnit(char *);
int /*<<< orphan*/ PDQ_Solve(int);
int main(void) {
  int nodes;
  int streams;
  double stimeSelect = 0.5;
  double stimeClaims = 6.0;
  double stimePolicy = 20.0;
  double callRateIncoming = 35.0 / 60;
  double callRateClaim;
  double callRatePolicy;
  double routeSelectClaim = 0.55;
  double routeSelectPolicy = 0.45;
  double routePolicyClaim = 0.01;
  double routeClaimPolicy = 0.02;
  double vSelect;
  double vClaims;
  double vPolicy;
  callRateClaim = (routeSelectClaim + routePolicyClaim * routeSelectPolicy) *
                  callRateIncoming / (1 - routePolicyClaim * routeSelectPolicy);
  callRatePolicy =
      routeSelectPolicy * callRateIncoming + routeClaimPolicy * callRateClaim;
  vSelect = 1.0;
  vClaims = callRateClaim / callRateIncoming;
  vPolicy = callRatePolicy / callRateIncoming;
  PDQ_Init("G&H Example 4.2");
  streams = PDQ_CreateOpen("Customers", callRateIncoming);
  PDQ_SetWUnit("Calls");
  PDQ_SetTUnit("Mins");
  nodes = PDQ_CreateNode("Select", 4, 8);
  nodes = PDQ_CreateMultiNode(3, "Claims", 4, 8);
  nodes = PDQ_CreateMultiNode(7, "Policy", 4, 8);
  PDQ_SetDemand("Select", "Customers", vSelect * stimeSelect);
  PDQ_SetDemand("Claims", "Customers", vClaims * stimeClaims);
  PDQ_SetDemand("Policy", "Customers", vPolicy * stimePolicy);
  PDQ_Solve(16);
  PDQ_Report();
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movsd  0xea0(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  0xe8b(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xe76(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xe61(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xe4c(%rip),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  0xe37(%rip),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  0xe22(%rip),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  0xe0d(%rip),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x40(%rbp),%xmm1
movsd  -0x50(%rbp),%xmm0
movsd  -0x48(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mulsd  -0x28(%rbp),%xmm0
movsd  -0x50(%rbp),%xmm1
movsd  -0x48(%rbp),%xmm2
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm1
movsd  0xdb7(%rip),%xmm2
addsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm2
movsd  -0x58(%rbp),%xmm1
mulsd  -0x30(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  0xd81(%rip),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x30(%rbp),%xmm0
divsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x38(%rbp),%xmm0
divsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
lea    0xd9f(%rip),%rdi
call   10a0 <PDQ_Init@plt>
movsd  -0x28(%rbp),%xmm0
lea    0xd9e(%rip),%rdi
call   1080 <PDQ_CreateOpen@plt>
mov    %eax,-0x8(%rbp)
lea    0xd99(%rip),%rdi
call   10b0 <PDQ_SetWUnit@plt>
lea    0xd93(%rip),%rdi
call   1090 <PDQ_SetTUnit@plt>
lea    0xd8c(%rip),%rdi
mov    $0x4,%esi
mov    $0x8,%edx
call   1040 <PDQ_CreateNode@plt>
mov    %eax,-0x4(%rbp)
mov    $0x3,%edi
lea    0xd75(%rip),%rsi
mov    $0x4,%edx
mov    $0x8,%ecx
call   1070 <PDQ_CreateMultiNode@plt>
mov    %eax,-0x4(%rbp)
mov    $0x7,%edi
lea    0xd5e(%rip),%rsi
mov    $0x4,%edx
mov    $0x8,%ecx
call   1070 <PDQ_CreateMultiNode@plt>
mov    %eax,-0x4(%rbp)
movsd  -0x60(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
lea    0xd2d(%rip),%rdi
lea    0xd11(%rip),%rsi
call   1050 <PDQ_SetDemand@plt>
movsd  -0x68(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
lea    0xd17(%rip),%rdi
lea    0xcf4(%rip),%rsi
call   1050 <PDQ_SetDemand@plt>
movsd  -0x70(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
lea    0xd01(%rip),%rdi
lea    0xcd7(%rip),%rsi
call   1050 <PDQ_SetDemand@plt>
mov    $0x10,%edi
call   1060 <PDQ_Solve@plt>
mov    $0x0,%al
call   1030 <PDQ_Report@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
lea    0xe81(%rip),%rdi
call   10a0 <PDQ_Init@plt>
lea    0xe85(%rip),%r12
movsd  0xe4d(%rip),%xmm0
mov    %r12,%rdi
call   1080 <PDQ_CreateOpen@plt>
lea    0xe78(%rip),%rdi
call   10b0 <PDQ_SetWUnit@plt>
lea    0xe72(%rip),%rdi
call   1090 <PDQ_SetTUnit@plt>
lea    0xe6b(%rip),%r14
mov    %r14,%rdi
mov    $0x4,%esi
mov    $0x8,%edx
call   1040 <PDQ_CreateNode@plt>
lea    0xe59(%rip),%r15
mov    $0x3,%edi
mov    %r15,%rsi
mov    $0x4,%edx
mov    $0x8,%ecx
call   1070 <PDQ_CreateMultiNode@plt>
lea    0xe42(%rip),%rbx
mov    $0x7,%edi
mov    %rbx,%rsi
mov    $0x4,%edx
mov    $0x8,%ecx
call   1070 <PDQ_CreateMultiNode@plt>
movsd  0xdd8(%rip),%xmm0
mov    %r14,%rdi
mov    %r12,%rsi
call   1050 <PDQ_SetDemand@plt>
movsd  0xdcd(%rip),%xmm0
mov    %r15,%rdi
mov    %r12,%rsi
call   1050 <PDQ_SetDemand@plt>
movsd  0xdc2(%rip),%xmm0
mov    %rbx,%rdi
mov    %r12,%rsi
call   1050 <PDQ_SetDemand@plt>
mov    $0x10,%edi
call   1060 <PDQ_Solve@plt>
xor    %eax,%eax
call   1030 <PDQ_Report@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [16 x i8] c"G&H Example 4.2\00"
@.str.1 = [10 x i8] c"Customers\00"
@.str.2 = [6 x i8] c"Calls\00"
@.str.3 = [5 x i8] c"Mins\00"
@.str.4 = [7 x i8] c"Select\00"
@.str.5 = [7 x i8] c"Claims\00"
@.str.6 = [7 x i8] c"Policy\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca double
store double 5.000000e-01, double* %3
store double 6.000000e+00, double* %4
store double 2.000000e+01, double* %5
store double 0x3FE2AAAAAAAAAAAB, double* %6
store double 5.500000e-01, double* %9
store double 4.500000e-01, double* %10
store double 1.000000e-02, double* %11
store double 2.000000e-02, double* %12
%16 = load double, double* %9
%17 = load double, double* %11
%18 = load double, double* %10
%19 = call double @llvm.fmuladd.f64(double %17, double %18, double %16)
%20 = load double, double* %6
%21 = fmul double %19, %20
%22 = load double, double* %11
%23 = load double, double* %10
%24 = fneg double %22
%25 = call double @llvm.fmuladd.f64(double %24, double %23, double 1.000000e+00)
%26 = fdiv double %21, %25
store double %26, double* %7
%27 = load double, double* %10
%28 = load double, double* %6
%29 = load double, double* %12
%30 = load double, double* %7
%31 = fmul double %29, %30
%32 = call double @llvm.fmuladd.f64(double %27, double %28, double %31)
store double %32, double* %8
store double 1.000000e+00, double* %13
%33 = load double, double* %7
%34 = load double, double* %6
%35 = fdiv double %33, %34
store double %35, double* %14
%36 = load double, double* %8
%37 = load double, double* %6
%38 = fdiv double %36, %37
store double %38, double* %15
%39 = call i32 @PDQ_Init(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%40 = load double, double* %6
%41 = call i32 @PDQ_CreateOpen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), double %40)
store i32 %41, i32* %2
%42 = call i32 @PDQ_SetWUnit(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%43 = call i32 @PDQ_SetTUnit(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%44 = call i32 @PDQ_CreateNode(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i32 4, i32 8)
store i32 %44, i32* %1
%45 = call i32 @PDQ_CreateMultiNode(i32 3, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i32 4, i32 8)
store i32 %45, i32* %1
%46 = call i32 @PDQ_CreateMultiNode(i32 7, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i32 4, i32 8)
store i32 %46, i32* %1
%47 = load double, double* %13
%48 = load double, double* %3
%49 = fmul double %47, %48
%50 = call i32 @PDQ_SetDemand(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), double %49)
%51 = load double, double* %14
%52 = load double, double* %4
%53 = fmul double %51, %52
%54 = call i32 @PDQ_SetDemand(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), double %53)
%55 = load double, double* %15
%56 = load double, double* %5
%57 = fmul double %55, %56
%58 = call i32 @PDQ_SetDemand(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), double %57)
%59 = call i32 @PDQ_Solve(i32 16)
%60 = call i32 (...) @PDQ_Report()
ret i32 0
}

LLVM IR (-O2):
@.str = [16 x i8] c"G&H Example 4.2\00"
@.str.1 = [10 x i8] c"Customers\00"
@.str.2 = [6 x i8] c"Calls\00"
@.str.3 = [5 x i8] c"Mins\00"
@.str.4 = [7 x i8] c"Select\00"
@.str.5 = [7 x i8] c"Claims\00"
@.str.6 = [7 x i8] c"Policy\00"
define i32 @main() {
%1 = tail call i32 @PDQ_Init(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%2 = tail call i32 @PDQ_CreateOpen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), double 0x3FE2AAAAAAAAAAAB)
%3 = tail call i32 @PDQ_SetWUnit(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%4 = tail call i32 @PDQ_SetTUnit(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%5 = tail call i32 @PDQ_CreateNode(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i32 4, i32 8)
%6 = tail call i32 @PDQ_CreateMultiNode(i32 3, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i32 4, i32 8)
%7 = tail call i32 @PDQ_CreateMultiNode(i32 7, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i32 4, i32 8)
%8 = tail call i32 @PDQ_SetDemand(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), double 5.000000e-01)
%9 = tail call i32 @PDQ_SetDemand(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), double 0x400ABC7F09210B71)
%10 = tail call i32 @PDQ_SetDemand(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), double 0x402272132F15E253)
%11 = tail call i32 @PDQ_Solve(i32 16)
%12 = tail call i32 (...) @PDQ_Report()
ret i32 0
}