#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 */
float expf(float);
void arraydiff_kernel_logistic_fwd_f32(size_t dim, const float *x, float *y) {
  for (size_t i = 0; i < dim; i++) {
    float x_i = x[i];
    float y_i = 1.0f / (1.0f + expf(-x_i));
    y[i] = y_i;
  }
}


x86 assembly (clang, -O0):
<arraydiff_kernel_logistic_fwd_f32>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x8(%rbp),%rax
jae    11a3 <arraydiff_kernel_logistic_fwd_f32+0x93>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
movss  %xmm0,-0x24(%rbp)
movss  -0x24(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
call   1030 <expf@plt>
movss  0xe95(%rip),%xmm1
addss  %xmm0,%xmm1
movss  0xe89(%rip),%xmm0
divss  %xmm1,%xmm0
movss  %xmm0,-0x28(%rbp)
movss  -0x28(%rbp),%xmm0
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    112c <arraydiff_kernel_logistic_fwd_f32+0x1c>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<arraydiff_kernel_logistic_fwd_f32>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
test   %rdi,%rdi
je     1161 <arraydiff_kernel_logistic_fwd_f32+0x51>
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%r12
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
movss  (%r15,%rbx,4),%xmm0
xorps  0xec3(%rip),%xmm0
call   1030 <expf@plt>
movss  0xec6(%rip),%xmm1
addss  %xmm1,%xmm0
divss  %xmm0,%xmm1
movss  %xmm1,(%r14,%rbx,4)
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1130 <arraydiff_kernel_logistic_fwd_f32+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

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