#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 */
float pow(int, float);
double sqrt(double);
float psy2_spread_func(int i, int j) {
  float tmp;
  float tmpx, tmpy, tmpz;
  float spread_val;
  if (j >= i)
    tmpx = 3 * (j - i);
  else
    tmpx = 1.5 * (j - i);
  if (tmpx > 0.5 && tmpx < 2.5) {
    tmp = tmpx - 0.5;
    tmpz = 8 * (tmp * tmp - 2 * tmp);
  } else {
    tmpz = 0;
  }
  tmpy = 15.811389 + 7.5 * (tmpx + 0.474) -
         17.5 * sqrt(1.0 + (tmpx + 0.474) * (tmpx + 0.474));
  if (tmpy < -100)
    spread_val = 0;
  else
    spread_val = pow(10, (tmpz + tmpy) / 10.);
  return spread_val;
}


x86 assembly (clang, -O0):
<psy2_spread_func>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x4(%rbp),%eax
jl     1151 <psy2_spread_func+0x31>
mov    -0x8(%rbp),%eax
sub    -0x4(%rbp),%eax
imul   $0x3,%eax,%eax
cvtsi2ss %eax,%xmm0
movss  %xmm0,-0x10(%rbp)
jmp    1170 <psy2_spread_func+0x50>
mov    -0x8(%rbp),%eax
sub    -0x4(%rbp),%eax
cvtsi2sd %eax,%xmm1
movsd  0xe9d(%rip),%xmm0
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe87(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1206 <psy2_spread_func+0xe6>
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xe74(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    1206 <psy2_spread_func+0xe6>
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe51(%rip),%xmm1
subsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0xc(%rbp),%xmm1
movss  -0xc(%rbp),%xmm2
movss  0xe76(%rip),%xmm0
mulss  -0xc(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
mulss  %xmm2,%xmm1
addss  %xmm0,%xmm1
movss  0xe50(%rip),%xmm0
mulss  %xmm1,%xmm0
movss  %xmm0,-0x18(%rbp)
jmp    120e <psy2_spread_func+0xee>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe09(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  0xe05(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe01(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xdd7(%rip),%xmm1
addsd  %xmm1,%xmm0
movss  -0x10(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
movsd  0xdc2(%rip),%xmm2
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  0xdaa(%rip),%xmm1
addsd  %xmm1,%xmm0
call   1040 <sqrt@plt>
movsd  -0x28(%rbp),%xmm1
movsd  0xd8c(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x14(%rbp)
movss  0xdab(%rip),%xmm0
ucomiss -0x14(%rbp),%xmm0
jbe    12bc <psy2_spread_func+0x19c>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x1c(%rbp)
jmp    12e9 <psy2_spread_func+0x1c9>
movss  -0x18(%rbp),%xmm0
addss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xd6e(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
mov    $0xa,%edi
call   1030 <pow@plt>
movss  %xmm0,-0x1c(%rbp)
movss  -0x1c(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<psy2_spread_func>:
sub    $0x18,%rsp
sub    %edi,%esi
jge    113a <psy2_spread_func+0x1a>
cvtsi2sd %esi,%xmm0
mulsd  0xecc(%rip),%xmm0
cvtsd2ss %xmm0,%xmm1
jmp    1141 <psy2_spread_func+0x21>
lea    (%rsi,%rsi,2),%eax
cvtsi2ss %eax,%xmm1
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
ucomiss 0xee1(%rip),%xmm1
xorps  %xmm3,%xmm3
jbe    1183 <psy2_spread_func+0x63>
movss  0xed8(%rip),%xmm2
ucomiss %xmm1,%xmm2
jbe    1183 <psy2_spread_func+0x63>
addss  0xecf(%rip),%xmm1
movaps %xmm1,%xmm2
addss  %xmm1,%xmm2
mulss  %xmm1,%xmm1
subss  %xmm2,%xmm1
mulss  0xebc(%rip),%xmm1
movaps %xmm1,%xmm3
addsd  0xe7d(%rip),%xmm0
movsd  0xe7d(%rip),%xmm2
mulsd  %xmm0,%xmm2
addsd  0xe79(%rip),%xmm2
mulsd  %xmm0,%xmm0
addsd  0xe75(%rip),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     11ba <psy2_spread_func+0x9a>
sqrtsd %xmm0,%xmm0
jmp    11d7 <psy2_spread_func+0xb7>
movss  %xmm3,0xc(%rsp)
movsd  %xmm2,0x10(%rsp)
call   1040 <sqrt@plt>
movsd  0x10(%rsp),%xmm2
movss  0xc(%rsp),%xmm3
mulsd  0xe49(%rip),%xmm0
addsd  %xmm2,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  0xe51(%rip),%xmm1
ucomiss %xmm0,%xmm1
jbe    11fc <psy2_spread_func+0xdc>
xorps  %xmm0,%xmm0
add    $0x18,%rsp
ret
addss  %xmm0,%xmm3
divss  0xe3c(%rip),%xmm3
mov    $0xa,%edi
movaps %xmm3,%xmm0
add    $0x18,%rsp
jmp    1030 <pow@plt>

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

LLVM IR (-O2):
define float @psy2_spread_func(i32 %0, i32 %1) {
%3 = icmp slt i32 %1, %0
%4 = sub nsw i32 %1, %0
br i1 %3, label %8, label %5
5: ; preds = %2
%6 = mul nsw i32 %4, 3
%7 = sitofp i32 %6 to float
br label %12
8: ; preds = %2
%9 = sitofp i32 %4 to double
%10 = fmul double %9, 1.500000e+00
%11 = fptrunc double %10 to float
br label %12
12: ; preds = %8, %5
%13 = phi float [ %7, %5 ], [ %11, %8 ]
%14 = fpext float %13 to double
%15 = fcmp ogt float %13, 5.000000e-01
%16 = fcmp olt float %13, 2.500000e+00
%17 = and i1 %15, %16
br i1 %17, label %18, label %23
18: ; preds = %12
%19 = fadd float %13, -5.000000e-01
%20 = fmul float %19, -2.000000e+00
%21 = tail call float @llvm.fmuladd.f32(float %19, float %19, float %20)
%22 = fmul float %21, 8.000000e+00
br label %23
23: ; preds = %12, %18
%24 = phi float [ %22, %18 ], [ 0.000000e+00, %12 ]
%25 = fadd double %14, 4.740000e-01
%26 = tail call double @llvm.fmuladd.f64(double %25, double 7.500000e+00, double 0x402F9F6E6106AB15)
%27 = tail call double @llvm.fmuladd.f64(double %25, double %25, double 1.000000e+00)
%28 = tail call double @sqrt(double %27)
%29 = tail call double @llvm.fmuladd.f64(double %28, double -1.750000e+01, double %26)
%30 = fptrunc double %29 to float
%31 = fcmp olt float %30, -1.000000e+02
br i1 %31, label %36, label %32
32: ; preds = %23
%33 = fadd float %24, %30
%34 = fdiv float %33, 1.000000e+01
%35 = tail call float @pow(i32 10, float %34)
br label %36
36: ; preds = %23, %32
%37 = phi float [ %35, %32 ], [ 0.000000e+00, %23 ]
ret float %37
}