#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 */
double exp(float);
double signx(float);
void logsig(float *x, float N, float *y) {
  int i;
  for (i = 0; i < N; ++i) {
    y[i] = (1.0 / (1.0 + exp(-x[i])));
    if (y[i] != y[i]) {
      y[i] = signx(x[i]) * 0.5 + 0.5;
    }
  }
}


x86 assembly (clang, -O0):
<logsig>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movss  %xmm0,-0xc(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
cvtsi2ssl -0x1c(%rbp),%xmm1
movss  -0xc(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jbe    1207 <logsig+0xe7>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
call   1040 <exp@plt>
movsd  0xe8a(%rip),%xmm1
addsd  %xmm0,%xmm1
movsd  0xe7e(%rip),%xmm0
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
ucomiss (%rax,%rcx,4),%xmm0
jne    11c1 <logsig+0xa1>
jp     11c1 <logsig+0xa1>
jmp    11f4 <logsig+0xd4>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
call   1030 <signx@plt>
movsd  0xe2d(%rip),%xmm1
mulsd  %xmm1,%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
jmp    11f9 <logsig+0xd9>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    113c <logsig+0x1c>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<logsig>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
xorps  %xmm1,%xmm1
movss  %xmm0,0xc(%rsp)
ucomiss %xmm1,%xmm0
jbe    11b4 <logsig+0x94>
mov    %rsi,%r14
mov    %rdi,%r15
xor    %ebx,%ebx
nop
movss  (%r15,%rbx,4),%xmm0
xorpd  0xeb2(%rip),%xmm0
call   1040 <exp@plt>
movsd  0xeb5(%rip),%xmm1
addsd  %xmm1,%xmm0
divsd  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtsd2ss %xmm1,%xmm0
movss  %xmm0,(%r14,%rbx,4)
ucomiss %xmm0,%xmm0
jp     118d <logsig+0x6d>
add    $0x1,%rbx
xorps  %xmm0,%xmm0
cvtsi2ss %ebx,%xmm0
movss  0xc(%rsp),%xmm1
ucomiss %xmm0,%xmm1
ja     1140 <logsig+0x20>
jmp    11b4 <logsig+0x94>
movss  (%r15,%rbx,4),%xmm0
call   1030 <signx@plt>
movsd  0xe78(%rip),%xmm1
mulsd  %xmm1,%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,(%r14,%rbx,4)
jmp    1175 <logsig+0x55>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @logsig(float* %0, float %1, float* %2) {
%4 = alloca float*
%5 = alloca float
%6 = alloca float*
%7 = alloca i32
store float* %0, float** %4
store float %1, float* %5
store float* %2, float** %6
store i32 0, i32* %7
br label %8
8: ; preds = %53, %3
%9 = load i32, i32* %7
%10 = sitofp i32 %9 to float
%11 = load float, float* %5
%12 = fcmp olt float %10, %11
br i1 %12, label %13, label %56
13: ; preds = %8
%14 = load float*, float** %4
%15 = load i32, i32* %7
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds float, float* %14, i64 %16
%18 = load float, float* %17
%19 = fneg float %18
%20 = call double @exp(float %19)
%21 = fadd double 1.000000e+00, %20
%22 = fdiv double 1.000000e+00, %21
%23 = fptrunc double %22 to float
%24 = load float*, float** %6
%25 = load i32, i32* %7
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds float, float* %24, i64 %26
store float %23, float* %27
%28 = load float*, float** %6
%29 = load i32, i32* %7
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds float, float* %28, i64 %30
%32 = load float, float* %31
%33 = load float*, float** %6
%34 = load i32, i32* %7
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds float, float* %33, i64 %35
%37 = load float, float* %36
%38 = fcmp une float %32, %37
br i1 %38, label %39, label %52
39: ; preds = %13
%40 = load float*, float** %4
%41 = load i32, i32* %7
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds float, float* %40, i64 %42
%44 = load float, float* %43
%45 = call double @signx(float %44)
%46 = call double @llvm.fmuladd.f64(double %45, double 5.000000e-01, double 5.000000e-01)
%47 = fptrunc double %46 to float
%48 = load float*, float** %6
%49 = load i32, i32* %7
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds float, float* %48, i64 %50
store float %47, float* %51
br label %52
52: ; preds = %39, %13
br label %53
53: ; preds = %52
%54 = load i32, i32* %7
%55 = add nsw i32 %54, 1
store i32 %55, i32* %7
br label %8
56: ; preds = %8
ret void
}

LLVM IR (-O2):
define void @logsig(float* nocapture %0, float %1, float* nocapture writeonly %2) {
%4 = fcmp ogt float %1, 0.000000e+00
br i1 %4, label %5, label %26
5: ; preds = %3, %21
%6 = phi i64 [ %22, %21 ], [ 0, %3 ]
%7 = getelementptr inbounds float, float* %0, i64 %6
%8 = load float, float* %7
%9 = fneg float %8
%10 = tail call double @exp(float %9)
%11 = fadd double %10, 1.000000e+00
%12 = fdiv double 1.000000e+00, %11
%13 = fptrunc double %12 to float
%14 = getelementptr inbounds float, float* %2, i64 %6
store float %13, float* %14
%15 = fcmp uno float %13, 0.000000e+00
br i1 %15, label %16, label %21
16: ; preds = %5
%17 = load float, float* %7
%18 = tail call double @signx(float %17)
%19 = tail call double @llvm.fmuladd.f64(double %18, double 5.000000e-01, double 5.000000e-01)
%20 = fptrunc double %19 to float
store float %20, float* %14
br label %21
21: ; preds = %5, %16
%22 = add nuw i64 %6, 1
%23 = trunc i64 %22 to i32
%24 = sitofp i32 %23 to float
%25 = fcmp olt float %24, %1
br i1 %25, label %5, label %26
26: ; preds = %21, %3
ret void
}