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


x86 assembly (clang, -O0):
<CriticalPart2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %edi,-0x4(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
movsd  %xmm3,-0x28(%rbp)
cmpl   $0x1,-0x4(%rbp)
jne    11f0 <CriticalPart2+0xb0>
movsd  -0x10(%rbp),%xmm0
call   1040 <log@plt>
movaps %xmm0,%xmm1
movsd  -0x28(%rbp),%xmm0
mulsd  -0x28(%rbp),%xmm0
movsd  0xe78(%rip),%xmm2
divsd  %xmm2,%xmm0
movsd  -0x20(%rbp),%xmm2
subsd  -0x18(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x20(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
call   1060 <sqrt@plt>
movsd  -0x50(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x48(%rbp),%xmm0
mulsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
mov    $0x1,%al
call   1050 <cnd@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x30(%rbp)
jmp    12bc <CriticalPart2+0x17c>
cmpl   $0x2,-0x4(%rbp)
jne    12b2 <CriticalPart2+0x172>
movsd  -0x10(%rbp),%xmm0
call   1040 <log@plt>
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
movsd  -0x28(%rbp),%xmm0
mulsd  -0x28(%rbp),%xmm0
movsd  0xdd3(%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
movsd  %xmm0,-0x58(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x20(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
call   1060 <sqrt@plt>
movsd  -0x60(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x58(%rbp),%xmm0
mulsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
mov    $0x1,%al
call   1050 <cnd@plt>
mov    %eax,%ecx
xor    %eax,%eax
sub    %ecx,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x30(%rbp)
jmp    12b7 <CriticalPart2+0x177>
call   1030 <abort@plt>
jmp    12bc <CriticalPart2+0x17c>
movsd  -0x30(%rbp),%xmm0
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CriticalPart2>:
sub    $0x18,%rsp
movsd  %xmm3,0x8(%rsp)
cmp    $0x2,%edi
movsd  %xmm2,(%rsp)
movsd  %xmm1,0x10(%rsp)
je     11a4 <CriticalPart2+0x64>
cmp    $0x1,%edi
jne    124d <CriticalPart2+0x10d>
call   1040 <log@plt>
movsd  0x8(%rsp),%xmm1
movapd %xmm1,%xmm3
mulsd  %xmm1,%xmm3
mulsd  0xe8a(%rip),%xmm3
movsd  (%rsp),%xmm2
subsd  0x10(%rsp),%xmm2
mulsd  %xmm2,%xmm3
addsd  %xmm0,%xmm3
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm2
jb     11e5 <CriticalPart2+0xa5>
xorps  %xmm0,%xmm0
sqrtsd %xmm2,%xmm0
jmp    11fe <CriticalPart2+0xbe>
call   1040 <log@plt>
movsd  (%rsp),%xmm2
movsd  0x8(%rsp),%xmm1
movapd %xmm1,%xmm3
mulsd  %xmm1,%xmm3
subsd  0x10(%rsp),%xmm2
mulsd  0xe36(%rip),%xmm3
mulsd  %xmm2,%xmm3
subsd  %xmm0,%xmm3
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm2
jb     1213 <CriticalPart2+0xd3>
xorps  %xmm0,%xmm0
sqrtsd %xmm2,%xmm0
jmp    122c <CriticalPart2+0xec>
movapd %xmm2,%xmm0
movsd  %xmm3,(%rsp)
call   1060 <sqrt@plt>
movsd  (%rsp),%xmm3
movsd  0x8(%rsp),%xmm1
mulsd  %xmm1,%xmm0
divsd  %xmm0,%xmm3
movapd %xmm3,%xmm0
mov    $0x1,%al
call   1050 <cnd@plt>
jmp    1241 <CriticalPart2+0x101>
movapd %xmm2,%xmm0
movsd  %xmm3,(%rsp)
call   1060 <sqrt@plt>
movsd  (%rsp),%xmm3
movsd  0x8(%rsp),%xmm1
mulsd  %xmm1,%xmm0
divsd  %xmm0,%xmm3
movapd %xmm3,%xmm0
mov    $0x1,%al
call   1050 <cnd@plt>
neg    %eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
add    $0x18,%rsp
ret
call   1030 <abort@plt>

LLVM IR (-O0):
define double @CriticalPart2(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
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
%14 = load i32, i32* %6
%15 = icmp eq i32 %14, 1
br i1 %15, label %16, label %37
16: ; preds = %5
%17 = load double, double* %7
%18 = call double @log(double %17)
%19 = load double, double* %10
%20 = load double, double* %10
%21 = fmul double %19, %20
%22 = fdiv double %21, 2.000000e+00
%23 = load double, double* %9
%24 = load double, double* %8
%25 = fsub double %23, %24
%26 = call double @llvm.fmuladd.f64(double %22, double %25, double %18)
%27 = load double, double* %10
%28 = load double, double* %9
%29 = load double, double* %8
%30 = fsub double %28, %29
%31 = call double @sqrt(double %30)
%32 = fmul double %27, %31
%33 = fdiv double %26, %32
store double %33, double* %12
%34 = load double, double* %12
%35 = call i32 (double, ...) bitcast (i32 (...)* @cnd to i32 (double, ...)*)(double %34)
%36 = sitofp i32 %35 to double
store double %36, double* %11
br label %66
37: ; preds = %5
%38 = load i32, i32* %6
%39 = icmp eq i32 %38, 2
br i1 %39, label %40, label %64
40: ; preds = %37
%41 = load double, double* %7
%42 = call double @log(double %41)
%43 = fneg double %42
%44 = load double, double* %10
%45 = load double, double* %10
%46 = fmul double %44, %45
%47 = fdiv double %46, 2.000000e+00
%48 = load double, double* %9
%49 = load double, double* %8
%50 = fsub double %48, %49
%51 = fneg double %47
%52 = call double @llvm.fmuladd.f64(double %51, double %50, double %43)
%53 = load double, double* %10
%54 = load double, double* %9
%55 = load double, double* %8
%56 = fsub double %54, %55
%57 = call double @sqrt(double %56)
%58 = fmul double %53, %57
%59 = fdiv double %52, %58
store double %59, double* %13
%60 = load double, double* %13
%61 = call i32 (double, ...) bitcast (i32 (...)* @cnd to i32 (double, ...)*)(double %60)
%62 = sub nsw i32 0, %61
%63 = sitofp i32 %62 to double
store double %63, double* %11
br label %65
64: ; preds = %37
unreachable
65: ; preds = %40
br label %66
66: ; preds = %65, %16
%67 = load double, double* %11
ret double %67
}

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