double CriticalPart3(int id, double I, double t1, double T2, double v) {
  double result;
  double z1, z2;
  const double vT2_t1 = v * sqrt(T2 - t1);
  const double p2v = ((v) * (v));
  const double logI = log(I);
  if (id == 1) {
    z1 = (logI + p2v / 2.0 * (T2 - t1)) / vT2_t1;
    z2 = (logI - p2v / 2.0 * (T2 - t1)) / vT2_t1;
    result = I * cnd(z1) - cnd(z2);
  } else if (id == 2) {
    z1 = (-logI + ((v) * (v)) / 2.0 * (T2 - t1)) / vT2_t1;
    z2 = (-logI - ((v) * (v)) / 2.0 * (T2 - t1)) / vT2_t1;
    result = cnd(z1) - I * cnd(z2);
  } else
    abort();
  return result;
}


x86 assembly (clang, -O0):
<CriticalPart3>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %edi,-0x4(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
movsd  %xmm3,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x20(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
call   1060 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x60(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x28(%rbp),%xmm0
mulsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1040 <log@plt>
movsd  %xmm0,-0x58(%rbp)
cmpl   $0x1,-0x4(%rbp)
jne    1291 <CriticalPart3+0x151>
movsd  -0x58(%rbp),%xmm1
movsd  -0x50(%rbp),%xmm0
movsd  0xe3a(%rip),%xmm2
divsd  %xmm2,%xmm0
movsd  -0x20(%rbp),%xmm2
subsd  -0x18(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
divsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x58(%rbp),%xmm1
movsd  -0x50(%rbp),%xmm0
movsd  0xe08(%rip),%xmm2
divsd  %xmm2,%xmm0
movsd  -0x20(%rbp),%xmm2
subsd  -0x18(%rbp),%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
divsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x38(%rbp),%xmm0
mov    $0x1,%al
call   1050 <cnd@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x40(%rbp),%xmm0
mov    $0x1,%al
call   1050 <cnd@plt>
movsd  -0x70(%rbp),%xmm0
movsd  -0x68(%rbp),%xmm2
cvtsi2sd %eax,%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
jmp    13ba <CriticalPart3+0x27a>
cmpl   $0x2,-0x4(%rbp)
jne    13b0 <CriticalPart3+0x270>
movsd  -0x58(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
movsd  -0x28(%rbp),%xmm0
mulsd  -0x28(%rbp),%xmm0
movsd  0xd37(%rip),%xmm2
divsd  %xmm2,%xmm0
movsd  -0x20(%rbp),%xmm2
subsd  -0x18(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
divsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x58(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
movsd  -0x28(%rbp),%xmm0
mulsd  -0x28(%rbp),%xmm0
movsd  0xce9(%rip),%xmm2
divsd  %xmm2,%xmm0
movsd  -0x20(%rbp),%xmm2
subsd  -0x18(%rbp),%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
divsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x38(%rbp),%xmm0
mov    $0x1,%al
call   1050 <cnd@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x80(%rbp)
movsd  -0x40(%rbp),%xmm0
mov    $0x1,%al
call   1050 <cnd@plt>
movsd  -0x80(%rbp),%xmm0
movsd  -0x78(%rbp),%xmm1
cvtsi2sd %eax,%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
jmp    13b5 <CriticalPart3+0x275>
call   1030 <abort@plt>
jmp    13ba <CriticalPart3+0x27a>
movsd  -0x30(%rbp),%xmm0
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CriticalPart3>:
push   %rbx
sub    $0x40,%rsp
movapd %xmm0,%xmm4
mov    %edi,%ebx
subsd  %xmm1,%xmm2
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm2
movapd %xmm4,0x30(%rsp)
movsd  %xmm2,0x20(%rsp)
jb     116e <CriticalPart3+0x2e>
xorps  %xmm0,%xmm0
sqrtsd %xmm2,%xmm0
jmp    1186 <CriticalPart3+0x46>
movapd %xmm2,%xmm0
movaps %xmm3,(%rsp)
call   1060 <sqrt@plt>
movapd (%rsp),%xmm3
movapd 0x30(%rsp),%xmm4
mulsd  %xmm3,%xmm0
movsd  %xmm0,0x18(%rsp)
mulsd  %xmm3,%xmm3
movapd %xmm3,(%rsp)
movapd %xmm4,%xmm0
call   1040 <log@plt>
movapd %xmm0,%xmm3
cmp    $0x2,%ebx
je     1216 <CriticalPart3+0xd6>
movsd  0x18(%rsp),%xmm2
movapd (%rsp),%xmm1
cmp    $0x1,%ebx
movsd  0x20(%rsp),%xmm0
jne    12a2 <CriticalPart3+0x162>
mulsd  0xe33(%rip),%xmm1
mulsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
addsd  %xmm3,%xmm0
divsd  %xmm2,%xmm0
subsd  %xmm1,%xmm3
divsd  %xmm2,%xmm3
movsd  %xmm3,(%rsp)
mov    $0x1,%al
call   1050 <cnd@plt>
mov    %eax,%ebx
movsd  (%rsp),%xmm0
mov    $0x1,%al
call   1050 <cnd@plt>
xorps  %xmm2,%xmm2
cvtsi2sd %eax,%xmm2
xorpd  0xe02(%rip),%xmm2
movapd 0x30(%rsp),%xmm1
jmp    128d <CriticalPart3+0x14d>
movapd (%rsp),%xmm2
mulsd  0xddd(%rip),%xmm2
movapd %xmm2,%xmm0
movsd  0x20(%rsp),%xmm1
mulsd  %xmm1,%xmm0
subsd  %xmm3,%xmm0
movsd  0x18(%rsp),%xmm4
divsd  %xmm4,%xmm0
xorpd  0xdc9(%rip),%xmm2
mulsd  %xmm1,%xmm2
subsd  %xmm3,%xmm2
divsd  %xmm4,%xmm2
movapd %xmm2,(%rsp)
mov    $0x1,%al
call   1050 <cnd@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movapd %xmm0,0x20(%rsp)
movaps (%rsp),%xmm0
mov    $0x1,%al
call   1050 <cnd@plt>
movapd 0x20(%rsp),%xmm2
mov    %eax,%ebx
movapd 0x30(%rsp),%xmm1
xorpd  0xd83(%rip),%xmm1
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
mulsd  %xmm1,%xmm0
addsd  %xmm2,%xmm0
add    $0x40,%rsp
pop    %rbx
ret
call   1030 <abort@plt>

LLVM IR (-O0):
define double @CriticalPart3(i32 %0, double %1, double %2, double %3, double %4) {
%6 = alloca i32
%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
%16 = alloca double
store i32 %0, i32* %6
store double %1, double* %7
store double %2, double* %8
store double %3, double* %9
store double %4, double* %10
%17 = load double, double* %10
%18 = load double, double* %9
%19 = load double, double* %8
%20 = fsub double %18, %19
%21 = call double @sqrt(double %20)
%22 = fmul double %17, %21
store double %22, double* %14
%23 = load double, double* %10
%24 = load double, double* %10
%25 = fmul double %23, %24
store double %25, double* %15
%26 = load double, double* %7
%27 = call double @log(double %26)
store double %27, double* %16
%28 = load i32, i32* %6
%29 = icmp eq i32 %28, 1
br i1 %29, label %30, label %59
30: ; preds = %5
%31 = load double, double* %16
%32 = load double, double* %15
%33 = fdiv double %32, 2.000000e+00
%34 = load double, double* %9
%35 = load double, double* %8
%36 = fsub double %34, %35
%37 = call double @llvm.fmuladd.f64(double %33, double %36, double %31)
%38 = load double, double* %14
%39 = fdiv double %37, %38
store double %39, double* %12
%40 = load double, double* %16
%41 = load double, double* %15
%42 = fdiv double %41, 2.000000e+00
%43 = load double, double* %9
%44 = load double, double* %8
%45 = fsub double %43, %44
%46 = fneg double %42
%47 = call double @llvm.fmuladd.f64(double %46, double %45, double %40)
%48 = load double, double* %14
%49 = fdiv double %47, %48
store double %49, double* %13
%50 = load double, double* %7
%51 = load double, double* %12
%52 = call i32 (double, ...) bitcast (i32 (...)* @cnd to i32 (double, ...)*)(double %51)
%53 = sitofp i32 %52 to double
%54 = load double, double* %13
%55 = call i32 (double, ...) bitcast (i32 (...)* @cnd to i32 (double, ...)*)(double %54)
%56 = sitofp i32 %55 to double
%57 = fneg double %56
%58 = call double @llvm.fmuladd.f64(double %50, double %53, double %57)
store double %58, double* %11
br label %99
59: ; preds = %5
%60 = load i32, i32* %6
%61 = icmp eq i32 %60, 2
br i1 %61, label %62, label %97
62: ; preds = %59
%63 = load double, double* %16
%64 = fneg double %63
%65 = load double, double* %10
%66 = load double, double* %10
%67 = fmul double %65, %66
%68 = fdiv double %67, 2.000000e+00
%69 = load double, double* %9
%70 = load double, double* %8
%71 = fsub double %69, %70
%72 = call double @llvm.fmuladd.f64(double %68, double %71, double %64)
%73 = load double, double* %14
%74 = fdiv double %72, %73
store double %74, double* %12
%75 = load double, double* %16
%76 = fneg double %75
%77 = load double, double* %10
%78 = load double, double* %10
%79 = fmul double %77, %78
%80 = fdiv double %79, 2.000000e+00
%81 = load double, double* %9
%82 = load double, double* %8
%83 = fsub double %81, %82
%84 = fneg double %80
%85 = call double @llvm.fmuladd.f64(double %84, double %83, double %76)
%86 = load double, double* %14
%87 = fdiv double %85, %86
store double %87, double* %13
%88 = load double, double* %12
%89 = call i32 (double, ...) bitcast (i32 (...)* @cnd to i32 (double, ...)*)(double %88)
%90 = sitofp i32 %89 to double
%91 = load double, double* %7
%92 = load double, double* %13
%93 = call i32 (double, ...) bitcast (i32 (...)* @cnd to i32 (double, ...)*)(double %92)
%94 = sitofp i32 %93 to double
%95 = fneg double %91
%96 = call double @llvm.fmuladd.f64(double %95, double %94, double %90)
store double %96, double* %11
br label %98
97: ; preds = %59
unreachable
98: ; preds = %62
br label %99
99: ; preds = %98, %30
%100 = load double, double* %11
ret double %100
}

LLVM IR (-O2):
define double @CriticalPart3(i32 %0, double %1, double %2, double %3, double %4) {
%6 = fsub double %3, %2
%7 = tail call double @sqrt(double %6)
%8 = fmul double %7, %4
%9 = fmul double %4, %4
%10 = tail call double @log(double %1)
switch i32 %0, label %34 [
i32 1, label %11
i32 2, label %22
]
11: ; preds = %5
%12 = fmul double %9, 5.000000e-01
%13 = tail call double @llvm.fmuladd.f64(double %12, double %6, double %10)
%14 = fdiv double %13, %8
%15 = fneg double %12
%16 = tail call double @llvm.fmuladd.f64(double %15, double %6, double %10)
%17 = fdiv double %16, %8
%18 = tail call i32 (double, ...) bitcast (i32 (...)* @cnd to i32 (double, ...)*)(double %14)
%19 = tail call i32 (double, ...) bitcast (i32 (...)* @cnd to i32 (double, ...)*)(double %17)
%20 = sitofp i32 %19 to double
%21 = fneg double %20
br label %35
22: ; preds = %5
%23 = fneg double %10
%24 = fmul double %9, 5.000000e-01
%25 = tail call double @llvm.fmuladd.f64(double %24, double %6, double %23)
%26 = fdiv double %25, %8
%27 = fneg double %24
%28 = tail call double @llvm.fmuladd.f64(double %27, double %6, double %23)
%29 = fdiv double %28, %8
%30 = tail call i32 (double, ...) bitcast (i32 (...)* @cnd to i32 (double, ...)*)(double %26)
%31 = sitofp i32 %30 to double
%32 = tail call i32 (double, ...) bitcast (i32 (...)* @cnd to i32 (double, ...)*)(double %29)
%33 = fneg double %1
br label %35
34: ; preds = %5
tail call void @abort()
unreachable
35: ; preds = %22, %11
%36 = phi double [ %31, %22 ], [ %21, %11 ]
%37 = phi i32 [ %32, %22 ], [ %18, %11 ]
%38 = phi double [ %33, %22 ], [ %1, %11 ]
%39 = sitofp i32 %37 to double
%40 = tail call double @llvm.fmuladd.f64(double %38, double %39, double %36)
ret double %40
}