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


x86 assembly (clang, -O0):
<raw_tanh_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    1193 <raw_tanh_bulk_apply_function+0x83>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movss  0xece(%rip),%xmm0
mulss  (%rax,%rcx,4),%xmm0
cvttss2si %xmm0,%edi
call   1030 <exp@plt>
movsd  0xea8(%rip),%xmm1
addsd  %xmm0,%xmm1
movsd  0xea4(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  0xe90(%rip),%xmm1
subsd  %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_tanh_bulk_apply_function+0x16>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<raw_tanh_bulk_apply_function>:
push   %r15
push   %r14
push   %rbx
test   %edi,%edi
jle    1179 <raw_tanh_bulk_apply_function+0x69>
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
mulss  0xec2(%rip),%xmm0
cvttss2si %xmm0,%edi
call   1030 <exp@plt>
addsd  0xeb9(%rip),%xmm0
movsd  0xeb9(%rip),%xmm1
divsd  %xmm0,%xmm1
addsd  0xeb5(%rip),%xmm1
xorps  %xmm0,%xmm0
cvtsd2ss %xmm1,%xmm0
movss  %xmm0,(%r15,%rbx,4)
add    $0x1,%rbx
cmp    %rbx,%r14
jne    1130 <raw_tanh_bulk_apply_function+0x20>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @raw_tanh_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 = %27, %2
%7 = load i32, i32* %5
%8 = load i32, i32* %3
%9 = icmp slt i32 %7, %8
br i1 %9, label %10, label %30
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 = fmul float -2.000000e+00, %15
%17 = fptosi float %16 to i32
%18 = call double @exp(i32 %17)
%19 = fadd double 1.000000e+00, %18
%20 = fdiv double 2.000000e+00, %19
%21 = fsub double %20, 1.000000e+00
%22 = fptrunc double %21 to float
%23 = load float*, float** %4
%24 = load i32, i32* %5
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds float, float* %23, i64 %25
store float %22, float* %26
br label %27
27: ; preds = %10
%28 = load i32, i32* %5
%29 = add nsw i32 %28, 1
store i32 %29, i32* %5
br label %6
30: ; preds = %6
ret void
}

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