#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 exp(double);
void mtsp(void) {
  double xsav, rndx, wtry, rndw;
  double ranf();
  extern int iseed, icpt;
  extern double x, b, wt;
  xsav = x;
  rndx = ranf();
  x = x + 2 * b * (rndx - 0.5);
  if ((x < 0) || (x > 1)) {
    x = xsav;
  } else {
    wtry = (exp(x * x) - 1);
    rndw = ranf();
    if (wtry > (wt * rndw)) {
      wt = wtry;
      icpt = icpt + 1;
    } else {
      x = xsav;
    }
  }
}


x86 assembly (clang, -O0):
<mtsp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    0x2ea1(%rip),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x8(%rbp)
mov    $0x0,%al
call   1030 <ranf@plt>
movsd  %xmm0,-0x10(%rbp)
mov    0x2e85(%rip),%rax
movsd  (%rax),%xmm1
movsd  0xeb1(%rip),%xmm0
mov    0x2e6a(%rip),%rax
mulsd  (%rax),%xmm0
movsd  -0x10(%rbp),%xmm2
movsd  0xe91(%rip),%xmm3
subsd  %xmm3,%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    0x2e4e(%rip),%rax
movsd  %xmm0,(%rax)
xorps  %xmm0,%xmm0
mov    0x2e40(%rip),%rax
ucomisd (%rax),%xmm0
ja     11b7 <mtsp+0x97>
mov    0x2e2f(%rip),%rax
movsd  (%rax),%xmm0
movsd  0xe63(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    11cc <mtsp+0xac>
movsd  -0x8(%rbp),%xmm0
mov    0x2e0d(%rip),%rax
movsd  %xmm0,(%rax)
jmp    125d <mtsp+0x13d>
mov    0x2dfd(%rip),%rax
movsd  (%rax),%xmm0
mov    0x2df2(%rip),%rax
mulsd  (%rax),%xmm0
call   1040 <exp@plt>
sub    $0x1,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    $0x0,%al
call   1030 <ranf@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
mov    0x2ddd(%rip),%rax
movsd  (%rax),%xmm1
mulsd  -0x20(%rbp),%xmm1
ucomisd %xmm1,%xmm0
jbe    1248 <mtsp+0x128>
movsd  -0x18(%rbp),%xmm0
mov    0x2dbe(%rip),%rax
movsd  %xmm0,(%rax)
mov    0x2da3(%rip),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    0x2d97(%rip),%rax
mov    %ecx,(%rax)
jmp    1258 <mtsp+0x138>
movsd  -0x8(%rbp),%xmm0
mov    0x2d7c(%rip),%rax
movsd  %xmm0,(%rax)
jmp    125d <mtsp+0x13d>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mtsp>:
push   %rbx
sub    $0x10,%rsp
mov    0x2ea4(%rip),%rbx
movsd  (%rbx),%xmm0
movsd  %xmm0,(%rsp)
xor    %eax,%eax
call   1030 <ranf@plt>
mov    0x2e85(%rip),%rax
movsd  (%rax),%xmm1
addsd  0xeb1(%rip),%xmm0
addsd  %xmm1,%xmm1
mulsd  %xmm1,%xmm0
addsd  (%rbx),%xmm0
movsd  %xmm0,(%rbx)
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
ja     11be <mtsp+0x9e>
ucomisd 0xe97(%rip),%xmm0
ja     11be <mtsp+0x9e>
mulsd  %xmm0,%xmm0
call   1040 <exp@plt>
add    $0xffffffff,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  %xmm0,0x8(%rsp)
xor    %eax,%eax
call   1030 <ranf@plt>
mov    0x2e4e(%rip),%rax
mulsd  (%rax),%xmm0
movsd  0x8(%rsp),%xmm1
ucomisd %xmm0,%xmm1
jbe    11be <mtsp+0x9e>
movapd %xmm1,%xmm0
movsd  %xmm1,(%rax)
mov    0x2e1f(%rip),%rax
addl   $0x1,(%rax)
jmp    11c7 <mtsp+0xa7>
movsd  (%rsp),%xmm0
movsd  %xmm0,(%rbx)
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@x = external global double
@b = external global double
@wt = external global double
@icpt = external global i32
define void @mtsp() {
%1 = alloca double
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = load double, double* @x
store double %5, double* %1
%6 = call double (...) @ranf()
store double %6, double* %2
%7 = load double, double* @x
%8 = load double, double* @b
%9 = fmul double 2.000000e+00, %8
%10 = load double, double* %2
%11 = fsub double %10, 5.000000e-01
%12 = call double @llvm.fmuladd.f64(double %9, double %11, double %7)
store double %12, double* @x
%13 = load double, double* @x
%14 = fcmp olt double %13, 0.000000e+00
br i1 %14, label %18, label %15
15: ; preds = %0
%16 = load double, double* @x
%17 = fcmp ogt double %16, 1.000000e+00
br i1 %17, label %18, label %20
18: ; preds = %15, %0
%19 = load double, double* %1
store double %19, double* @x
br label %40
20: ; preds = %15
%21 = load double, double* @x
%22 = load double, double* @x
%23 = fmul double %21, %22
%24 = call i32 @exp(double %23)
%25 = sub nsw i32 %24, 1
%26 = sitofp i32 %25 to double
store double %26, double* %3
%27 = call double (...) @ranf()
store double %27, double* %4
%28 = load double, double* %3
%29 = load double, double* @wt
%30 = load double, double* %4
%31 = fmul double %29, %30
%32 = fcmp ogt double %28, %31
br i1 %32, label %33, label %37
33: ; preds = %20
%34 = load double, double* %3
store double %34, double* @wt
%35 = load i32, i32* @icpt
%36 = add nsw i32 %35, 1
store i32 %36, i32* @icpt
br label %39
37: ; preds = %20
%38 = load double, double* %1
store double %38, double* @x
br label %39
39: ; preds = %37, %33
br label %40
40: ; preds = %39, %18
ret void
}

LLVM IR (-O2):
@x = external global double
@b = external global double
@wt = external global double
@icpt = external global i32
define void @mtsp() {
%1 = load double, double* @x
%2 = tail call double (...) @ranf()
%3 = load double, double* @x
%4 = load double, double* @b
%5 = fmul double %4, 2.000000e+00
%6 = fadd double %2, -5.000000e-01
%7 = tail call double @llvm.fmuladd.f64(double %5, double %6, double %3)
store double %7, double* @x
%8 = fcmp olt double %7, 0.000000e+00
%9 = fcmp ogt double %7, 1.000000e+00
%10 = or i1 %8, %9
br i1 %10, label %11, label %12
11: ; preds = %0
store double %1, double* @x
br label %25
12: ; preds = %0
%13 = fmul double %7, %7
%14 = tail call i32 @exp(double %13)
%15 = add nsw i32 %14, -1
%16 = sitofp i32 %15 to double
%17 = tail call double (...) @ranf()
%18 = load double, double* @wt
%19 = fmul double %17, %18
%20 = fcmp olt double %19, %16
br i1 %20, label %21, label %24
21: ; preds = %12
store double %16, double* @wt
%22 = load i32, i32* @icpt
%23 = add nsw i32 %22, 1
store i32 %23, i32* @icpt
br label %25
24: ; preds = %12
store double %1, double* @x
br label %25
25: ; preds = %21, %24, %11
ret void
}