#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 exp(double);
double get_rand_double();
int metrop(double de, double t) {
  double bolzman, rnd;
  bolzman = exp(-de / t);
  rnd = get_rand_double();
  if (de < 0.0)
    return (1);
  if ((-(de / t)) < -10000.0)
    return (0);
  else
    return (rnd < bolzman);
}


x86 assembly (clang, -O0):
<metrop>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
divsd  -0x18(%rbp),%xmm0
call   1030 <exp@plt>
movsd  %xmm0,-0x20(%rbp)
mov    $0x0,%al
call   1040 <get_rand_double@plt>
movsd  %xmm0,-0x28(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    1183 <metrop+0x63>
movl   $0x1,-0x4(%rbp)
jmp    11db <metrop+0xbb>
movsd  -0x10(%rbp),%xmm0
divsd  -0x18(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
movsd  0xe54(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    11c2 <metrop+0xa2>
movl   $0x0,-0x4(%rbp)
jmp    11db <metrop+0xbb>
movsd  -0x28(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm0
ucomisd %xmm1,%xmm0
seta   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<metrop>:
sub    $0x38,%rsp
movapd %xmm0,%xmm2
movapd %xmm0,0x20(%rsp)
movapd 0xeca(%rip),%xmm0
xorpd  %xmm2,%xmm0
divsd  %xmm1,%xmm0
movapd %xmm0,0x10(%rsp)
call   1030 <exp@plt>
movsd  %xmm0,0x8(%rsp)
xor    %eax,%eax
call   1040 <get_rand_double@plt>
mov    $0x1,%eax
xorpd  %xmm1,%xmm1
ucomisd 0x20(%rsp),%xmm1
ja     118b <metrop+0x6b>
movsd  0xea1(%rip),%xmm1
ucomisd 0x10(%rsp),%xmm1
mov    $0x0,%eax
ja     118b <metrop+0x6b>
xor    %eax,%eax
movsd  0x8(%rsp),%xmm1
ucomisd %xmm0,%xmm1
seta   %al
add    $0x38,%rsp
ret

LLVM IR (-O0):
define i32 @metrop(double %0, double %1) {
%3 = alloca i32
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
store double %0, double* %4
store double %1, double* %5
%8 = load double, double* %4
%9 = fneg double %8
%10 = load double, double* %5
%11 = fdiv double %9, %10
%12 = call double @exp(double %11)
store double %12, double* %6
%13 = call double (...) @get_rand_double()
store double %13, double* %7
%14 = load double, double* %4
%15 = fcmp olt double %14, 0.000000e+00
br i1 %15, label %16, label %17
16: ; preds = %2
store i32 1, i32* %3
br label %29
17: ; preds = %2
%18 = load double, double* %4
%19 = load double, double* %5
%20 = fdiv double %18, %19
%21 = fneg double %20
%22 = fcmp olt double %21, -1.000000e+04
br i1 %22, label %23, label %24
23: ; preds = %17
store i32 0, i32* %3
br label %29
24: ; preds = %17
%25 = load double, double* %7
%26 = load double, double* %6
%27 = fcmp olt double %25, %26
%28 = zext i1 %27 to i32
store i32 %28, i32* %3
br label %29
29: ; preds = %24, %23, %16
%30 = load i32, i32* %3
ret i32 %30
}

LLVM IR (-O2):
define i32 @metrop(double %0, double %1) {
%3 = fneg double %0
%4 = fdiv double %3, %1
%5 = tail call double @exp(double %4)
%6 = tail call double (...) @get_rand_double()
%7 = fcmp olt double %0, 0.000000e+00
br i1 %7, label %13, label %8
8: ; preds = %2
%9 = fcmp olt double %4, -1.000000e+04
br i1 %9, label %13, label %10
10: ; preds = %8
%11 = fcmp olt double %6, %5
%12 = zext i1 %11 to i32
br label %13
13: ; preds = %8, %2, %10
%14 = phi i32 [ %12, %10 ], [ 1, %2 ], [ 0, %8 ]
ret i32 %14
}