#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 log(double);
double myrunif();
int pow(double, int);
double sqrt(double);
double myrgamma1(double alpha) {
  double accept;
  int test;
  double u, v, w, x, y, z, b, c;
  b = alpha - 1;
  c = 3 * alpha - 0.75;
  test = 0;
  while (test == 0) {
    u = myrunif();
    v = myrunif();
    w = u * (1 - u);
    y = sqrt(c / w) * (u - .5);
    x = b + y;
    if (x > 0) {
      z = 64 * pow(v, 2) * pow(w, 3);
      if (z <= (1 - (2 * pow(y, 2) / x))) {
        test = 1;
        accept = x;
      } else if ((2 * (b * log(x / b) - y)) >= log(z)) {
        test = 1;
        accept = x;
      } else {
        test = 0;
      }
    }
  }
  return accept;
}


x86 assembly (clang, -O0):
<myrgamma1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  0xeb3(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  0xe8d(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe89(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    1341 <myrgamma1+0x201>
mov    $0x0,%al
call   1030 <myrunif@plt>
movsd  %xmm0,-0x20(%rbp)
mov    $0x0,%al
call   1030 <myrunif@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  0xe52(%rip),%xmm1
subsd  -0x20(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x58(%rbp),%xmm0
divsd  -0x30(%rbp),%xmm0
call   1060 <sqrt@plt>
movsd  -0x20(%rbp),%xmm1
movsd  0xe30(%rip),%xmm2
subsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x50(%rbp),%xmm0
addsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    133c <myrgamma1+0x1fc>
movsd  -0x28(%rbp),%xmm0
mov    $0x2,%edi
call   1050 <pow@plt>
shl    $0x6,%eax
mov    %eax,-0x64(%rbp)
movsd  -0x30(%rbp),%xmm0
mov    $0x3,%edi
call   1050 <pow@plt>
mov    %eax,%ecx
mov    -0x64(%rbp),%eax
imul   %ecx,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x40(%rbp),%xmm0
mov    $0x2,%edi
call   1050 <pow@plt>
movsd  -0x60(%rbp),%xmm1
shl    $0x1,%eax
cvtsi2sd %eax,%xmm2
divsd  -0x38(%rbp),%xmm2
movsd  0xd93(%rip),%xmm0
subsd  %xmm2,%xmm0
ucomisd %xmm1,%xmm0
jb     12a1 <myrgamma1+0x161>
movl   $0x1,-0x14(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
jmp    1337 <myrgamma1+0x1f7>
movsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  -0x38(%rbp),%xmm0
divsd  -0x50(%rbp),%xmm0
call   1040 <log@plt>
movsd  -0x78(%rbp),%xmm1
cvtsi2sd %eax,%xmm2
movsd  -0x40(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  0xd31(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x48(%rbp),%xmm0
call   1040 <log@plt>
movsd  -0x70(%rbp),%xmm0
cvtsi2sd %eax,%xmm1
ucomisd %xmm1,%xmm0
jb     132b <myrgamma1+0x1eb>
movl   $0x1,-0x14(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
jmp    1332 <myrgamma1+0x1f2>
movl   $0x0,-0x14(%rbp)
jmp    1337 <myrgamma1+0x1f7>
jmp    133c <myrgamma1+0x1fc>
jmp    118f <myrgamma1+0x4f>
movsd  -0x10(%rbp),%xmm0
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<myrgamma1>:
push   %rbx
sub    $0x50,%rsp
movsd  0xeb3(%rip),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x18(%rsp)
mulsd  0xea9(%rip),%xmm0
addsd  0xea9(%rip),%xmm0
movsd  %xmm0,0x48(%rsp)
jmp    1178 <myrgamma1+0x38>
nop
test   %eax,%eax
jne    12f9 <myrgamma1+0x1b9>
xor    %eax,%eax
call   1030 <myrunif@plt>
movsd  %xmm0,0x8(%rsp)
xor    %eax,%eax
call   1030 <myrunif@plt>
movsd  0x8(%rsp),%xmm1
movaps %xmm0,%xmm3
movsd  0xe7b(%rip),%xmm2
subsd  %xmm1,%xmm2
mulsd  %xmm1,%xmm2
movsd  0x48(%rsp),%xmm0
movsd  %xmm2,0x10(%rsp)
divsd  %xmm2,%xmm0
ucomisd 0xe6b(%rip),%xmm0
jb     11d0 <myrgamma1+0x90>
sqrtsd %xmm0,%xmm0
jmp    11e7 <myrgamma1+0xa7>
cs nopw 0x0(%rax,%rax,1)
nop
movsd  %xmm3,0x20(%rsp)
call   1060 <sqrt@plt>
movsd  0x20(%rsp),%xmm3
movsd  0x8(%rsp),%xmm1
addsd  0xe31(%rip),%xmm1
mulsd  %xmm0,%xmm1
movsd  0x18(%rsp),%xmm2
addsd  %xmm1,%xmm2
xor    %eax,%eax
ucomisd 0xe21(%rip),%xmm2
jbe    1170 <myrgamma1+0x30>
movaps %xmm3,%xmm0
mov    $0x2,%edi
movsd  %xmm1,0x8(%rsp)
movapd %xmm2,0x20(%rsp)
call   1050 <pow@plt>
mov    %eax,%ebx
movsd  0x10(%rsp),%xmm0
mov    $0x3,%edi
call   1050 <pow@plt>
imul   %ebx,%eax
shl    $0x6,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  %xmm0,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
mov    $0x2,%edi
call   1050 <pow@plt>
movapd 0x20(%rsp),%xmm2
add    %eax,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
divsd  %xmm2,%xmm0
movsd  0xda2(%rip),%xmm1
subsd  %xmm0,%xmm1
ucomisd 0x10(%rsp),%xmm1
jae    12f3 <myrgamma1+0x1b3>
movapd %xmm2,%xmm0
divsd  0x18(%rsp),%xmm0
call   1040 <log@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0x18(%rsp),%xmm0
subsd  0x8(%rsp),%xmm0
addsd  %xmm0,%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x10(%rsp),%xmm0
call   1040 <log@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
xor    %eax,%eax
movsd  0x8(%rsp),%xmm1
ucomisd %xmm0,%xmm1
setae  %al
cmpnlesd %xmm1,%xmm0
movapd 0x30(%rsp),%xmm1
andpd  %xmm0,%xmm1
andnpd 0x20(%rsp),%xmm0
orpd   %xmm0,%xmm1
movapd %xmm1,0x30(%rsp)
jmp    1170 <myrgamma1+0x30>
movapd %xmm2,0x30(%rsp)
movaps 0x30(%rsp),%xmm0
add    $0x50,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define double @myrgamma1(double %0) {
%2 = alloca double
%3 = alloca double
%4 = alloca i32
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
store double %0, double* %2
%13 = load double, double* %2
%14 = fsub double %13, 1.000000e+00
store double %14, double* %11
%15 = load double, double* %2
%16 = call double @llvm.fmuladd.f64(double 3.000000e+00, double %15, double -7.500000e-01)
store double %16, double* %12
store i32 0, i32* %4
br label %17
17: ; preds = %78, %1
%18 = load i32, i32* %4
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %79
20: ; preds = %17
%21 = call double (...) @myrunif()
store double %21, double* %5
%22 = call double (...) @myrunif()
store double %22, double* %6
%23 = load double, double* %5
%24 = load double, double* %5
%25 = fsub double 1.000000e+00, %24
%26 = fmul double %23, %25
store double %26, double* %7
%27 = load double, double* %12
%28 = load double, double* %7
%29 = fdiv double %27, %28
%30 = call double @sqrt(double %29)
%31 = load double, double* %5
%32 = fsub double %31, 5.000000e-01
%33 = fmul double %30, %32
store double %33, double* %9
%34 = load double, double* %11
%35 = load double, double* %9
%36 = fadd double %34, %35
store double %36, double* %8
%37 = load double, double* %8
%38 = fcmp ogt double %37, 0.000000e+00
br i1 %38, label %39, label %78
39: ; preds = %20
%40 = load double, double* %6
%41 = call i32 @pow(double %40, i32 2)
%42 = mul nsw i32 64, %41
%43 = load double, double* %7
%44 = call i32 @pow(double %43, i32 3)
%45 = mul nsw i32 %42, %44
%46 = sitofp i32 %45 to double
store double %46, double* %10
%47 = load double, double* %10
%48 = load double, double* %9
%49 = call i32 @pow(double %48, i32 2)
%50 = mul nsw i32 2, %49
%51 = sitofp i32 %50 to double
%52 = load double, double* %8
%53 = fdiv double %51, %52
%54 = fsub double 1.000000e+00, %53
%55 = fcmp ole double %47, %54
br i1 %55, label %56, label %58
56: ; preds = %39
store i32 1, i32* %4
%57 = load double, double* %8
store double %57, double* %3
br label %77
58: ; preds = %39
%59 = load double, double* %11
%60 = load double, double* %8
%61 = load double, double* %11
%62 = fdiv double %60, %61
%63 = call i32 @log(double %62)
%64 = sitofp i32 %63 to double
%65 = load double, double* %9
%66 = fneg double %65
%67 = call double @llvm.fmuladd.f64(double %59, double %64, double %66)
%68 = fmul double 2.000000e+00, %67
%69 = load double, double* %10
%70 = call i32 @log(double %69)
%71 = sitofp i32 %70 to double
%72 = fcmp oge double %68, %71
br i1 %72, label %73, label %75
73: ; preds = %58
store i32 1, i32* %4
%74 = load double, double* %8
store double %74, double* %3
br label %76
75: ; preds = %58
store i32 0, i32* %4
br label %76
76: ; preds = %75, %73
br label %77
77: ; preds = %76, %56
br label %78
78: ; preds = %77, %20
br label %17
79: ; preds = %17
%80 = load double, double* %3
ret double %80
}

LLVM IR (-O2):
define double @myrgamma1(double %0) {
%2 = fadd double %0, -1.000000e+00
%3 = tail call double @llvm.fmuladd.f64(double %0, double 3.000000e+00, double -7.500000e-01)
br label %4
4: ; preds = %1, %41
%5 = phi double [ undef, %1 ], [ %43, %41 ]
%6 = tail call double (...) @myrunif()
%7 = tail call double (...) @myrunif()
%8 = fsub double 1.000000e+00, %6
%9 = fmul double %6, %8
%10 = fdiv double %3, %9
%11 = tail call double @sqrt(double %10)
%12 = fadd double %6, -5.000000e-01
%13 = fmul double %12, %11
%14 = fadd double %2, %13
%15 = fcmp ogt double %14, 0.000000e+00
br i1 %15, label %16, label %41
16: ; preds = %4
%17 = tail call i32 @pow(double %7, i32 2)
%18 = shl nsw i32 %17, 6
%19 = tail call i32 @pow(double %9, i32 3)
%20 = mul nsw i32 %18, %19
%21 = sitofp i32 %20 to double
%22 = tail call i32 @pow(double %13, i32 2)
%23 = shl nsw i32 %22, 1
%24 = sitofp i32 %23 to double
%25 = fdiv double %24, %14
%26 = fsub double 1.000000e+00, %25
%27 = fcmp ult double %26, %21
br i1 %27, label %28, label %45
28: ; preds = %16
%29 = fdiv double %14, %2
%30 = tail call i32 @log(double %29)
%31 = sitofp i32 %30 to double
%32 = fneg double %13
%33 = tail call double @llvm.fmuladd.f64(double %2, double %31, double %32)
%34 = fmul double %33, 2.000000e+00
%35 = tail call i32 @log(double %21)
%36 = sitofp i32 %35 to double
%37 = fcmp ult double %34, %36
%38 = xor i1 %37, true
%39 = zext i1 %38 to i32
%40 = select i1 %37, double %5, double %14
br label %41
41: ; preds = %28, %4
%42 = phi i32 [ 0, %4 ], [ %39, %28 ]
%43 = phi double [ %5, %4 ], [ %40, %28 ]
%44 = icmp eq i32 %42, 0
br i1 %44, label %4, label %45
45: ; preds = %16, %41
%46 = phi double [ %43, %41 ], [ %14, %16 ]
ret double %46
}