#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(float);
float sigmoid(float t, float start, float end) {
  if (t < start) {
    return 0;
  } else if (t > end) {
    return 1;
  } else {
    float tprime = -1.0 + 2.0 * (t - start) / (end - start);
    return 1.0 / (1 + exp(-tprime * 5));
  }
}


x86 assembly (clang, -O0):
<sigmoid>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movss  %xmm0,-0x8(%rbp)
movss  %xmm1,-0xc(%rbp)
movss  %xmm2,-0x10(%rbp)
movss  -0x8(%rbp),%xmm1
movss  -0xc(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jbe    1147 <sigmoid+0x37>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    11e8 <sigmoid+0xd8>
movss  -0x8(%rbp),%xmm0
ucomiss -0x10(%rbp),%xmm0
jbe    1168 <sigmoid+0x58>
movss  0xebe(%rip),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    11e8 <sigmoid+0xd8>
movss  -0x8(%rbp),%xmm0
subss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe92(%rip),%xmm1
mulsd  %xmm0,%xmm1
movss  -0x10(%rbp),%xmm0
subss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
divsd  %xmm0,%xmm1
movsd  0xe6c(%rip),%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  0xe55(%rip),%xmm1
mulss  %xmm1,%xmm0
call   1030 <exp@plt>
add    $0x1,%eax
cvtsi2sd %eax,%xmm1
movsd  0xe25(%rip),%xmm0
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sigmoid>:
push   %rax
xorps  %xmm3,%xmm3
ucomiss %xmm0,%xmm1
ja     1179 <sigmoid+0x69>
ucomiss %xmm2,%xmm0
jbe    1128 <sigmoid+0x18>
movss  0xeda(%rip),%xmm3
jmp    1179 <sigmoid+0x69>
subss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
addsd  %xmm0,%xmm0
subss  %xmm1,%xmm2
xorps  %xmm1,%xmm1
cvtss2sd %xmm2,%xmm1
divsd  %xmm1,%xmm0
addsd  0xebd(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
mulss  0xead(%rip),%xmm0
call   1030 <exp@plt>
add    $0x1,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  0xea2(%rip),%xmm1
divsd  %xmm0,%xmm1
xorps  %xmm3,%xmm3
cvtsd2ss %xmm1,%xmm3
movaps %xmm3,%xmm0
pop    %rax
ret

LLVM IR (-O0):
define float @sigmoid(float %0, float %1, float %2) {
%4 = alloca float
%5 = alloca float
%6 = alloca float
%7 = alloca float
%8 = alloca float
store float %0, float* %5
store float %1, float* %6
store float %2, float* %7
%9 = load float, float* %5
%10 = load float, float* %6
%11 = fcmp olt float %9, %10
br i1 %11, label %12, label %13
12: ; preds = %3
store float 0.000000e+00, float* %4
br label %39
13: ; preds = %3
%14 = load float, float* %5
%15 = load float, float* %7
%16 = fcmp ogt float %14, %15
br i1 %16, label %17, label %18
17: ; preds = %13
store float 1.000000e+00, float* %4
br label %39
18: ; preds = %13
%19 = load float, float* %5
%20 = load float, float* %6
%21 = fsub float %19, %20
%22 = fpext float %21 to double
%23 = fmul double 2.000000e+00, %22
%24 = load float, float* %7
%25 = load float, float* %6
%26 = fsub float %24, %25
%27 = fpext float %26 to double
%28 = fdiv double %23, %27
%29 = fadd double -1.000000e+00, %28
%30 = fptrunc double %29 to float
store float %30, float* %8
%31 = load float, float* %8
%32 = fneg float %31
%33 = fmul float %32, 5.000000e+00
%34 = call i32 @exp(float %33)
%35 = add nsw i32 1, %34
%36 = sitofp i32 %35 to double
%37 = fdiv double 1.000000e+00, %36
%38 = fptrunc double %37 to float
store float %38, float* %4
br label %39
39: ; preds = %18, %17, %12
%40 = load float, float* %4
ret float %40
}

LLVM IR (-O2):
define float @sigmoid(float %0, float %1, float %2) {
%4 = fcmp olt float %0, %1
br i1 %4, label %22, label %5
5: ; preds = %3
%6 = fcmp ogt float %0, %2
br i1 %6, label %22, label %7
7: ; preds = %5
%8 = fsub float %0, %1
%9 = fpext float %8 to double
%10 = fmul double %9, 2.000000e+00
%11 = fsub float %2, %1
%12 = fpext float %11 to double
%13 = fdiv double %10, %12
%14 = fadd double %13, -1.000000e+00
%15 = fptrunc double %14 to float
%16 = fmul float %15, -5.000000e+00
%17 = tail call i32 @exp(float %16)
%18 = add nsw i32 %17, 1
%19 = sitofp i32 %18 to double
%20 = fdiv double 1.000000e+00, %19
%21 = fptrunc double %20 to float
br label %22
22: ; preds = %5, %3, %7
%23 = phi float [ %21, %7 ], [ 0.000000e+00, %3 ], [ 1.000000e+00, %5 ]
ret float %23
}