#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 incomplete_gamma(double, double, char const *);
double normal(double x, const char *prompt) {
  return x > 0   ? 0.5 * (1 + incomplete_gamma(0.5, x * x / 2, prompt))
         : x < 0 ? 0.5 * (1 - incomplete_gamma(0.5, x * x / 2, prompt))
                 : 0.5;
}


x86 assembly (clang, -O0):
<normal>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x8(%rbp)
mov    %rdi,-0x10(%rbp)
movsd  -0x8(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    1177 <normal+0x67>
movsd  -0x8(%rbp),%xmm1
mulsd  -0x8(%rbp),%xmm1
movsd  0xec3(%rip),%xmm0
divsd  %xmm0,%xmm1
mov    -0x10(%rbp),%rdi
movsd  0xeab(%rip),%xmm0
call   1030 <incomplete_gamma@plt>
add    $0x1,%eax
cvtsi2sd %eax,%xmm1
movsd  0xe97(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    11eb <normal+0xdb>
xorps  %xmm0,%xmm0
ucomisd -0x8(%rbp),%xmm0
jbe    11cf <normal+0xbf>
movsd  -0x8(%rbp),%xmm1
mulsd  -0x8(%rbp),%xmm1
movsd  0xe71(%rip),%xmm0
divsd  %xmm0,%xmm1
mov    -0x10(%rbp),%rdi
movsd  0xe59(%rip),%xmm0
call   1030 <incomplete_gamma@plt>
mov    %eax,%ecx
mov    $0x1,%eax
sub    %ecx,%eax
cvtsi2sd %eax,%xmm1
movsd  0xe3f(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    11e1 <normal+0xd1>
movsd  0xe29(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    11e1 <normal+0xd1>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<normal>:
push   %rax
movapd %xmm0,%xmm1
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm1
jbe    1140 <normal+0x30>
mulsd  %xmm1,%xmm1
movsd  0xed5(%rip),%xmm0
mulsd  %xmm0,%xmm1
call   1030 <incomplete_gamma@plt>
add    $0x1,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
jmp    1169 <normal+0x59>
ucomisd %xmm1,%xmm0
jbe    1173 <normal+0x63>
mulsd  %xmm1,%xmm1
movsd  0xeae(%rip),%xmm0
mulsd  %xmm0,%xmm1
call   1030 <incomplete_gamma@plt>
mov    $0x1,%ecx
sub    %eax,%ecx
xorps  %xmm0,%xmm0
cvtsi2sd %ecx,%xmm0
mulsd  0xe8f(%rip),%xmm0
pop    %rax
ret
movsd  0xe85(%rip),%xmm0
pop    %rax
ret

LLVM IR (-O0):
define double @normal(double %0, i8* %1) {
%3 = alloca double
%4 = alloca i8*
store double %0, double* %3
store i8* %1, i8** %4
%5 = load double, double* %3
%6 = fcmp ogt double %5, 0.000000e+00
br i1 %6, label %7, label %17
7: ; preds = %2
%8 = load double, double* %3
%9 = load double, double* %3
%10 = fmul double %8, %9
%11 = fdiv double %10, 2.000000e+00
%12 = load i8*, i8** %4
%13 = call i32 @incomplete_gamma(double 5.000000e-01, double %11, i8* %12)
%14 = add nsw i32 1, %13
%15 = sitofp i32 %14 to double
%16 = fmul double 5.000000e-01, %15
br label %33
17: ; preds = %2
%18 = load double, double* %3
%19 = fcmp olt double %18, 0.000000e+00
br i1 %19, label %20, label %30
20: ; preds = %17
%21 = load double, double* %3
%22 = load double, double* %3
%23 = fmul double %21, %22
%24 = fdiv double %23, 2.000000e+00
%25 = load i8*, i8** %4
%26 = call i32 @incomplete_gamma(double 5.000000e-01, double %24, i8* %25)
%27 = sub nsw i32 1, %26
%28 = sitofp i32 %27 to double
%29 = fmul double 5.000000e-01, %28
br label %31
30: ; preds = %17
br label %31
31: ; preds = %30, %20
%32 = phi double [ %29, %20 ], [ 5.000000e-01, %30 ]
br label %33
33: ; preds = %31, %7
%34 = phi double [ %16, %7 ], [ %32, %31 ]
ret double %34
}

LLVM IR (-O2):
define double @normal(double %0, i8* %1) {
%3 = fcmp ogt double %0, 0.000000e+00
br i1 %3, label %4, label %11
4: ; preds = %2
%5 = fmul double %0, %0
%6 = fmul double %5, 5.000000e-01
%7 = tail call i32 @incomplete_gamma(double 5.000000e-01, double %6, i8* %1)
%8 = add nsw i32 %7, 1
%9 = sitofp i32 %8 to double
%10 = fmul double %9, 5.000000e-01
br label %20
11: ; preds = %2
%12 = fcmp olt double %0, 0.000000e+00
br i1 %12, label %13, label %20
13: ; preds = %11
%14 = fmul double %0, %0
%15 = fmul double %14, 5.000000e-01
%16 = tail call i32 @incomplete_gamma(double 5.000000e-01, double %15, i8* %1)
%17 = sub nsw i32 1, %16
%18 = sitofp i32 %17 to double
%19 = fmul double %18, 5.000000e-01
br label %20
20: ; preds = %13, %11, %4
%21 = phi double [ %10, %4 ], [ %19, %13 ], [ 5.000000e-01, %11 ]
ret double %21
}