#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 */
scalar_t__ exp(float);
float log(scalar_t__);
float logsigma(float x, float beta, float Threshold) {
  static float y;
  y = beta * (Threshold - x);
  if (y < 0.0) {
    return -log(1.0 + exp(y));
  } else {
    return -y - log(1.0 + exp(-y));
  };
}


x86 assembly (clang, -O0):
<logsigma>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movss  %xmm0,-0x8(%rbp)
movss  %xmm1,-0xc(%rbp)
movss  %xmm2,-0x10(%rbp)
movss  -0xc(%rbp),%xmm0
movss  -0x10(%rbp),%xmm1
subss  -0x8(%rbp),%xmm1
mulss  %xmm1,%xmm0
movss  %xmm0,0x2ee2(%rip)
movss  0x2eda(%rip),%xmm0
cvtss2sd %xmm0,%xmm1
xorps  %xmm0,%xmm0
ucomisd %xmm1,%xmm0
jbe    11aa <logsigma+0x8a>
movss  0x2ec1(%rip),%xmm0
call   1030 <exp@plt>
cvtsi2sd %rax,%xmm1
movsd  0xe7b(%rip),%xmm0
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rdi
call   1040 <log@plt>
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    120a <logsigma+0xea>
movss  0x2e82(%rip),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  %xmm0,-0x14(%rbp)
movss  0x2e68(%rip),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
call   1030 <exp@plt>
cvtsi2sd %rax,%xmm1
movsd  0xe15(%rip),%xmm0
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rdi
call   1040 <log@plt>
movaps %xmm0,%xmm1
movss  -0x14(%rbp),%xmm0
subss  %xmm1,%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<logsigma>:
sub    $0x18,%rsp
subss  %xmm0,%xmm2
mulss  %xmm1,%xmm2
xorps  %xmm0,%xmm0
ucomiss %xmm2,%xmm0
jbe    1164 <logsigma+0x44>
movaps %xmm2,%xmm0
call   1030 <exp@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  0xec4(%rip),%xmm0
cvttsd2si %xmm0,%rdi
call   1040 <log@plt>
movapd %xmm0,%xmm1
xorpd  0xe9e(%rip),%xmm1
jmp    1199 <logsigma+0x79>
xorps  0xe95(%rip),%xmm2
movaps %xmm2,(%rsp)
movaps %xmm2,%xmm0
call   1030 <exp@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  0xe89(%rip),%xmm0
cvttsd2si %xmm0,%rdi
call   1040 <log@plt>
movaps (%rsp),%xmm1
subss  %xmm0,%xmm1
movaps %xmm1,%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
@logsigma.y = internal global float 0.000000e+00
define float @logsigma(float %0, float %1, float %2) {
%4 = alloca float
%5 = alloca float
%6 = alloca float
%7 = alloca float
store float %0, float* %5
store float %1, float* %6
store float %2, float* %7
%8 = load float, float* %6
%9 = load float, float* %7
%10 = load float, float* %5
%11 = fsub float %9, %10
%12 = fmul float %8, %11
store float %12, float* @logsigma.y
%13 = load float, float* @logsigma.y
%14 = fpext float %13 to double
%15 = fcmp olt double %14, 0.000000e+00
br i1 %15, label %16, label %24
16: ; preds = %3
%17 = load float, float* @logsigma.y
%18 = call i64 @exp(float %17)
%19 = sitofp i64 %18 to double
%20 = fadd double 1.000000e+00, %19
%21 = fptosi double %20 to i64
%22 = call float @log(i64 %21)
%23 = fneg float %22
store float %23, float* %4
br label %35
24: ; preds = %3
%25 = load float, float* @logsigma.y
%26 = fneg float %25
%27 = load float, float* @logsigma.y
%28 = fneg float %27
%29 = call i64 @exp(float %28)
%30 = sitofp i64 %29 to double
%31 = fadd double 1.000000e+00, %30
%32 = fptosi double %31 to i64
%33 = call float @log(i64 %32)
%34 = fsub float %26, %33
store float %34, float* %4
br label %35
35: ; preds = %24, %16
%36 = load float, float* %4
ret float %36
}

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