#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 */
double cos(int);
scalar_t__ isfinite(double);
int log(double);
double random_uniform();
double sin(int);
double sqrt(int);
double random_cauchy(void) {
  double x1 = random_uniform();
  double x2 = random_uniform();
  double y_1 =
      sqrt(-2 * log(x1)) * cos(2 * 3.14159265358979323846264338328 * x2);
  double y_2 =
      sqrt(-2 * log(x1)) * sin(2 * 3.14159265358979323846264338328 * x2);
  double r = y_1 / y_2;
  return isfinite(r) ? r : 0;
}


x86 assembly (clang, -O0):
<random_cauchy>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    $0x0,%al
call   1030 <random_uniform@plt>
movsd  %xmm0,-0x8(%rbp)
mov    $0x0,%al
call   1030 <random_uniform@plt>
movsd  %xmm0,-0x10(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1070 <log@plt>
imul   $0xfffffffe,%eax,%edi
call   1080 <sqrt@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  0xe5e(%rip),%xmm0
mulsd  -0x10(%rbp),%xmm0
cvttsd2si %xmm0,%edi
call   1060 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1070 <log@plt>
imul   $0xfffffffe,%eax,%edi
call   1080 <sqrt@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  0xe1d(%rip),%xmm0
mulsd  -0x10(%rbp),%xmm0
cvttsd2si %xmm0,%edi
call   1040 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
divsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
call   1050 <isfinite@plt>
cmp    $0x0,%rax
je     1234 <random_cauchy+0xd4>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
jmp    1241 <random_cauchy+0xe1>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x40(%rbp)
jmp    1241 <random_cauchy+0xe1>
movsd  -0x40(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<random_cauchy>:
push   %rbx
sub    $0x20,%rsp
xor    %eax,%eax
call   1030 <random_uniform@plt>
movsd  %xmm0,0x10(%rsp)
xor    %eax,%eax
call   1030 <random_uniform@plt>
movsd  %xmm0,0x8(%rsp)
movsd  0x10(%rsp),%xmm0
call   1070 <log@plt>
lea    (%rax,%rax,1),%edi
neg    %edi
call   1080 <sqrt@plt>
movsd  %xmm0,0x18(%rsp)
movsd  0x8(%rsp),%xmm0
mulsd  0xe58(%rip),%xmm0
cvttsd2si %xmm0,%ebx
mov    %ebx,%edi
call   1060 <cos@plt>
mulsd  0x18(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x10(%rsp),%xmm0
call   1070 <log@plt>
lea    (%rax,%rax,1),%edi
neg    %edi
call   1080 <sqrt@plt>
movsd  %xmm0,0x10(%rsp)
mov    %ebx,%edi
call   1040 <sin@plt>
mulsd  0x10(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
movapd %xmm1,%xmm0
call   1050 <isfinite@plt>
xorpd  %xmm0,%xmm0
test   %rax,%rax
je     120f <random_cauchy+0xaf>
movsd  0x8(%rsp),%xmm0
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define double @random_cauchy() {
%1 = alloca double
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = call double (...) @random_uniform()
store double %6, double* %1
%7 = call double (...) @random_uniform()
store double %7, double* %2
%8 = load double, double* %1
%9 = call i32 @log(double %8)
%10 = mul nsw i32 -2, %9
%11 = call double @sqrt(i32 %10)
%12 = load double, double* %2
%13 = fmul double 0x401921FB54442D18, %12
%14 = fptosi double %13 to i32
%15 = call double @cos(i32 %14)
%16 = fmul double %11, %15
store double %16, double* %3
%17 = load double, double* %1
%18 = call i32 @log(double %17)
%19 = mul nsw i32 -2, %18
%20 = call double @sqrt(i32 %19)
%21 = load double, double* %2
%22 = fmul double 0x401921FB54442D18, %21
%23 = fptosi double %22 to i32
%24 = call double @sin(i32 %23)
%25 = fmul double %20, %24
store double %25, double* %4
%26 = load double, double* %3
%27 = load double, double* %4
%28 = fdiv double %26, %27
store double %28, double* %5
%29 = load double, double* %5
%30 = call i64 @isfinite(double %29)
%31 = icmp ne i64 %30, 0
br i1 %31, label %32, label %34
32: ; preds = %0
%33 = load double, double* %5
br label %35
34: ; preds = %0
br label %35
35: ; preds = %34, %32
%36 = phi double [ %33, %32 ], [ 0.000000e+00, %34 ]
ret double %36
}

LLVM IR (-O2):
define double @random_cauchy() {
%1 = tail call double (...) @random_uniform()
%2 = tail call double (...) @random_uniform()
%3 = tail call i32 @log(double %1)
%4 = mul nsw i32 %3, -2
%5 = tail call double @sqrt(i32 %4)
%6 = fmul double %2, 0x401921FB54442D18
%7 = fptosi double %6 to i32
%8 = tail call double @cos(i32 %7)
%9 = fmul double %5, %8
%10 = tail call i32 @log(double %1)
%11 = mul nsw i32 %10, -2
%12 = tail call double @sqrt(i32 %11)
%13 = tail call double @sin(i32 %7)
%14 = fmul double %12, %13
%15 = fdiv double %9, %14
%16 = tail call i64 @isfinite(double %15)
%17 = icmp eq i64 %16, 0
%18 = select i1 %17, double 0.000000e+00, double %15
ret double %18
}