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


x86 assembly (clang, -O0):
<clogsigma>:
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    11b6 <clogsigma+0x96>
movss  0x2ec1(%rip),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  0x2eb4(%rip),%xmm0
call   1030 <exp@plt>
cvtsi2sd %rax,%xmm1
movsd  0xe6e(%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)
jmp    11ee <clogsigma+0xce>
movss  0x2e76(%rip),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
call   1030 <exp@plt>
mov    %rax,%rdi
add    $0x1,%rdi
call   1040 <log@plt>
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<clogsigma>:
sub    $0x18,%rsp
subss  %xmm0,%xmm2
mulss  %xmm1,%xmm2
xorps  %xmm0,%xmm0
ucomiss %xmm2,%xmm0
jbe    1164 <clogsigma+0x44>
movaps %xmm2,%xmm0
movaps %xmm2,(%rsp)
call   1030 <exp@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  0xec0(%rip),%xmm0
cvttsd2si %xmm0,%rdi
call   1040 <log@plt>
movaps (%rsp),%xmm1
subss  %xmm0,%xmm1
jmp    1186 <clogsigma+0x66>
xorps  0xe95(%rip),%xmm2
movaps %xmm2,%xmm0
call   1030 <exp@plt>
lea    0x1(%rax),%rdi
call   1040 <log@plt>
movaps %xmm0,%xmm1
xorps  0xe7a(%rip),%xmm1
movaps %xmm1,%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
@clogsigma.y = internal global float 0.000000e+00
define float @clogsigma(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* @clogsigma.y
%13 = load float, float* @clogsigma.y
%14 = fpext float %13 to double
%15 = fcmp olt double %14, 0.000000e+00
br i1 %15, label %16, label %25
16: ; preds = %3
%17 = load float, float* @clogsigma.y
%18 = load float, float* @clogsigma.y
%19 = call i64 @exp(float %18)
%20 = sitofp i64 %19 to double
%21 = fadd double 1.000000e+00, %20
%22 = fptosi double %21 to i64
%23 = call float @log(i64 %22)
%24 = fsub float %17, %23
store float %24, float* %4
br label %32
25: ; preds = %3
%26 = load float, float* @clogsigma.y
%27 = fneg float %26
%28 = call i64 @exp(float %27)
%29 = add nsw i64 1, %28
%30 = call float @log(i64 %29)
%31 = fneg float %30
store float %31, float* %4
br label %32
32: ; preds = %25, %16
%33 = load float, float* %4
ret float %33
}

LLVM IR (-O2):
define float @clogsigma(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 = fsub float %5, %12
br label %20
14: ; preds = %3
%15 = fneg float %5
%16 = tail call i64 @exp(float %15)
%17 = add nsw i64 %16, 1
%18 = tail call float @log(i64 %17)
%19 = fneg float %18
br label %20
20: ; preds = %14, %7
%21 = phi float [ %13, %7 ], [ %19, %14 ]
ret float %21
}