#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);
void raw_sigmoid_bulk_apply_function(int n, float *ptr) {
  int i;
  for (i = 0; i < n; i++) {
    ptr[i] = 1.0 / (1.0 + exp(-ptr[i]));
  }
}


x86 assembly (clang, -O0):
<raw_sigmoid_bulk_apply_function>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1188 <raw_sigmoid_bulk_apply_function+0x78>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
call   1030 <exp@plt>
movsd  0xea7(%rip),%xmm1
addsd  %xmm0,%xmm1
movsd  0xe9b(%rip),%xmm0
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1126 <raw_sigmoid_bulk_apply_function+0x16>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<raw_sigmoid_bulk_apply_function>:
push   %r15
push   %r14
push   %rbx
test   %edi,%edi
jle    1169 <raw_sigmoid_bulk_apply_function+0x59>
mov    %rsi,%r15
mov    %edi,%r14d
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movss  (%r15,%rbx,4),%xmm0
xorpd  0xec2(%rip),%xmm0
call   1030 <exp@plt>
movsd  0xec5(%rip),%xmm1
addsd  %xmm1,%xmm0
divsd  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtsd2ss %xmm1,%xmm0
movss  %xmm0,(%r15,%rbx,4)
add    $0x1,%rbx
cmp    %rbx,%r14
jne    1130 <raw_sigmoid_bulk_apply_function+0x20>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @raw_sigmoid_bulk_apply_function(i32 %0, float* %1) {
%3 = alloca i32
%4 = alloca float*
%5 = alloca i32
store i32 %0, i32* %3
store float* %1, float** %4
store i32 0, i32* %5
br label %6
6: ; preds = %25, %2
%7 = load i32, i32* %5
%8 = load i32, i32* %3
%9 = icmp slt i32 %7, %8
br i1 %9, label %10, label %28
10: ; preds = %6
%11 = load float*, float** %4
%12 = load i32, i32* %5
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds float, float* %11, i64 %13
%15 = load float, float* %14
%16 = fneg float %15
%17 = call double @exp(float %16)
%18 = fadd double 1.000000e+00, %17
%19 = fdiv double 1.000000e+00, %18
%20 = fptrunc double %19 to float
%21 = load float*, float** %4
%22 = load i32, i32* %5
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds float, float* %21, i64 %23
store float %20, float* %24
br label %25
25: ; preds = %10
%26 = load i32, i32* %5
%27 = add nsw i32 %26, 1
store i32 %27, i32* %5
br label %6
28: ; preds = %6
ret void
}

LLVM IR (-O2):
define void @raw_sigmoid_bulk_apply_function(i32 %0, float* nocapture %1) {
%3 = icmp sgt i32 %0, 0
br i1 %3, label %4, label %17
4: ; preds = %2
%5 = zext i32 %0 to i64
br label %6
6: ; preds = %4, %6
%7 = phi i64 [ 0, %4 ], [ %15, %6 ]
%8 = getelementptr inbounds float, float* %1, i64 %7
%9 = load float, float* %8
%10 = fneg float %9
%11 = tail call double @exp(float %10)
%12 = fadd double %11, 1.000000e+00
%13 = fdiv double 1.000000e+00, %12
%14 = fptrunc double %13 to float
store float %14, float* %8
%15 = add nuw nsw i64 %7, 1
%16 = icmp eq i64 %15, %5
br i1 %16, label %17, label %6
17: ; preds = %6, %2
ret void
}