#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 fabs(double);
double get_rand_double(double, double);
int DiffLocMetropolisTest(double value_last, double value_new, double exp_last,
                          double exp_new, int reverse_comparison) {
  if (reverse_comparison) {
    double temp = value_last;
    value_last = value_new;
    value_new = temp;
    temp = exp_last;
    exp_last = exp_new;
    exp_new = temp;
  }
  double prob;
  if (fabs(exp_last) < 1.0e-300)
    return (1);
  if (fabs(exp_new) < 1.0e-300)
    return (0);
  if (value_new > value_last)
    return (1);
  if ((prob = get_rand_double(0.0, 1.0)) < exp_new / exp_last)
    return (1);
  else
    return (0);
}


x86 assembly (clang, -O0):
<DiffLocMetropolisTest>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
movsd  %xmm3,-0x28(%rbp)
mov    %edi,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
je     1175 <DiffLocMetropolisTest+0x65>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm1
movaps 0xe8f(%rip),%xmm0
pand   %xmm0,%xmm1
movsd  0xe73(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    11a3 <DiffLocMetropolisTest+0x93>
movl   $0x1,-0x4(%rbp)
jmp    122c <DiffLocMetropolisTest+0x11c>
movsd  -0x28(%rbp),%xmm1
movaps 0xe61(%rip),%xmm0
pand   %xmm0,%xmm1
movsd  0xe45(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    11d1 <DiffLocMetropolisTest+0xc1>
movl   $0x0,-0x4(%rbp)
jmp    122c <DiffLocMetropolisTest+0x11c>
movsd  -0x18(%rbp),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    11ed <DiffLocMetropolisTest+0xdd>
movl   $0x1,-0x4(%rbp)
jmp    122c <DiffLocMetropolisTest+0x11c>
xorps  %xmm0,%xmm0
movsd  0xe10(%rip),%xmm1
call   1030 <get_rand_double@plt>
movaps %xmm0,%xmm1
movsd  %xmm1,-0x40(%rbp)
movsd  -0x28(%rbp),%xmm0
divsd  -0x20(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    1225 <DiffLocMetropolisTest+0x115>
movl   $0x1,-0x4(%rbp)
jmp    122c <DiffLocMetropolisTest+0x11c>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<DiffLocMetropolisTest>:
test   %edi,%edi
je     111e <DiffLocMetropolisTest+0xe>
movapd %xmm3,%xmm5
movapd %xmm0,%xmm4
jmp    112e <DiffLocMetropolisTest+0x1e>
movapd %xmm2,%xmm5
movapd %xmm3,%xmm2
movapd %xmm1,%xmm4
movapd %xmm0,%xmm1
sub    $0x28,%rsp
movapd 0xec6(%rip),%xmm3
andpd  %xmm5,%xmm3
mov    $0x1,%eax
movsd  0xec5(%rip),%xmm0
ucomisd %xmm3,%xmm0
ja     11a0 <DiffLocMetropolisTest+0x90>
movapd 0xea7(%rip),%xmm3
andpd  %xmm2,%xmm3
xor    %eax,%eax
ucomisd %xmm3,%xmm0
ja     11a0 <DiffLocMetropolisTest+0x90>
ucomisd %xmm1,%xmm4
mov    $0x1,%eax
ja     11a0 <DiffLocMetropolisTest+0x90>
movsd  0xea0(%rip),%xmm1
xorpd  %xmm0,%xmm0
movapd %xmm2,(%rsp)
movapd %xmm5,0x10(%rsp)
call   1030 <get_rand_double@plt>
movapd (%rsp),%xmm1
divsd  0x10(%rsp),%xmm1
xor    %eax,%eax
ucomisd %xmm0,%xmm1
seta   %al
add    $0x28,%rsp
ret

LLVM IR (-O0):
define i32 @DiffLocMetropolisTest(double %0, double %1, double %2, double %3, i32 %4) {
%6 = alloca i32
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca i32
%12 = alloca double
%13 = alloca double
store double %0, double* %7
store double %1, double* %8
store double %2, double* %9
store double %3, double* %10
store i32 %4, i32* %11
%14 = load i32, i32* %11
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %23
16: ; preds = %5
%17 = load double, double* %7
store double %17, double* %12
%18 = load double, double* %8
store double %18, double* %7
%19 = load double, double* %12
store double %19, double* %8
%20 = load double, double* %9
store double %20, double* %12
%21 = load double, double* %10
store double %21, double* %9
%22 = load double, double* %12
store double %22, double* %10
br label %23
23: ; preds = %16, %5
%24 = load double, double* %9
%25 = call double @llvm.fabs.f64(double %24)
%26 = fcmp olt double %25, 1.000000e-300
br i1 %26, label %27, label %28
27: ; preds = %23
store i32 1, i32* %6
br label %46
28: ; preds = %23
%29 = load double, double* %10
%30 = call double @llvm.fabs.f64(double %29)
%31 = fcmp olt double %30, 1.000000e-300
br i1 %31, label %32, label %33
32: ; preds = %28
store i32 0, i32* %6
br label %46
33: ; preds = %28
%34 = load double, double* %8
%35 = load double, double* %7
%36 = fcmp ogt double %34, %35
br i1 %36, label %37, label %38
37: ; preds = %33
store i32 1, i32* %6
br label %46
38: ; preds = %33
%39 = call double @get_rand_double(double 0.000000e+00, double 1.000000e+00)
store double %39, double* %13
%40 = load double, double* %10
%41 = load double, double* %9
%42 = fdiv double %40, %41
%43 = fcmp olt double %39, %42
br i1 %43, label %44, label %45
44: ; preds = %38
store i32 1, i32* %6
br label %46
45: ; preds = %38
store i32 0, i32* %6
br label %46
46: ; preds = %45, %44, %37, %32, %27
%47 = load i32, i32* %6
ret i32 %47
}

LLVM IR (-O2):
define i32 @DiffLocMetropolisTest(double %0, double %1, double %2, double %3, i32 %4) {
%6 = icmp eq i32 %4, 0
br i1 %6, label %8, label %7
7: ; preds = %5
br label %8
8: ; preds = %7, %5
%9 = phi double [ %3, %7 ], [ %2, %5 ]
%10 = phi double [ %2, %7 ], [ %3, %5 ]
%11 = phi double [ %0, %7 ], [ %1, %5 ]
%12 = phi double [ %1, %7 ], [ %0, %5 ]
%13 = tail call double @llvm.fabs.f64(double %9)
%14 = fcmp olt double %13, 1.000000e-300
br i1 %14, label %25, label %15
15: ; preds = %8
%16 = tail call double @llvm.fabs.f64(double %10)
%17 = fcmp olt double %16, 1.000000e-300
br i1 %17, label %25, label %18
18: ; preds = %15
%19 = fcmp ogt double %11, %12
br i1 %19, label %25, label %20
20: ; preds = %18
%21 = tail call double @get_rand_double(double 0.000000e+00, double 1.000000e+00)
%22 = fdiv double %10, %9
%23 = fcmp olt double %21, %22
%24 = zext i1 %23 to i32
br label %25
25: ; preds = %20, %18, %15, %8
%26 = phi i32 [ 1, %8 ], [ 0, %15 ], [ 1, %18 ], [ %24, %20 ]
ret i32 %26
}