#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 */
typedef int /*<<< orphan*/ __m256;

/* Variables and functions */
float acosf(float const);
__m256 inv_cosine(const __m256 X) {
  union cos {
    __m256 m;
    float x[8];
  };
  union cos union_costheta;
  union cos union_returnvalue;
  union_costheta.m = X;
  const float minus_one = (float)-1.0;
  const float one = (float)1.0;
  const float zero = (float)0.0;
  for (int ii = 0; ii < 8; ii++) {
    const float costheta = union_costheta.x[ii];
    if (costheta < minus_one) {
      union_returnvalue.x[ii] = 3.14159265358979323846264338327950288;
    } else if (costheta > one) {
      union_returnvalue.x[ii] = zero;
    } else {
      union_returnvalue.x[ii] = acosf(costheta);
    }
  }
  return union_returnvalue.m;
}


x86 assembly (clang, -O0):
<inv_cosine>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x28(%rbp)
movss  0xedb(%rip),%xmm0
movss  %xmm0,-0x4c(%rbp)
movss  0xeca(%rip),%xmm0
movss  %xmm0,-0x50(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x54(%rbp)
movl   $0x0,-0x58(%rbp)
cmpl   $0x8,-0x58(%rbp)
jge    11e0 <inv_cosine+0xd0>
movslq -0x58(%rbp),%rax
movss  -0x28(%rbp,%rax,4),%xmm0
movss  %xmm0,-0x5c(%rbp)
movss  0xe99(%rip),%xmm0
ucomiss -0x5c(%rbp),%xmm0
jbe    118c <inv_cosine+0x7c>
movslq -0x58(%rbp),%rax
movss  0xe87(%rip),%xmm0
movss  %xmm0,-0x48(%rbp,%rax,4)
jmp    11cd <inv_cosine+0xbd>
movss  -0x5c(%rbp),%xmm0
movss  0xe67(%rip),%xmm1
ucomiss %xmm1,%xmm0
jbe    11b4 <inv_cosine+0xa4>
movslq -0x58(%rbp),%rax
xorps  %xmm0,%xmm0
movss  %xmm0,-0x48(%rbp,%rax,4)
jmp    11c8 <inv_cosine+0xb8>
movss  -0x5c(%rbp),%xmm0
call   1030 <acosf@plt>
movslq -0x58(%rbp),%rax
movss  %xmm0,-0x48(%rbp,%rax,4)
jmp    11cd <inv_cosine+0xbd>
jmp    11d2 <inv_cosine+0xc2>
mov    -0x58(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x58(%rbp)
jmp    114a <inv_cosine+0x3a>
mov    -0x48(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<inv_cosine>:
push   %rbx
movd   %edi,%xmm0
mov    $0x40490fdb,%ebx
movss  0xede(%rip),%xmm1
ucomiss %xmm0,%xmm1
ja     113b <inv_cosine+0x2b>
xor    %ebx,%ebx
ucomiss 0xed4(%rip),%xmm0
ja     113b <inv_cosine+0x2b>
call   1030 <acosf@plt>
movd   %xmm0,%ebx
call   1030 <acosf@plt>
call   1030 <acosf@plt>
call   1030 <acosf@plt>
call   1030 <acosf@plt>
call   1030 <acosf@plt>
call   1030 <acosf@plt>
call   1030 <acosf@plt>
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
%union.cos = type { [8 x float] }
define i32 @inv_cosine(i32 %0) {
%2 = alloca i32
%3 = alloca %union.cos
%4 = alloca %union.cos
%5 = alloca float
%6 = alloca float
%7 = alloca float
%8 = alloca i32
%9 = alloca float
store i32 %0, i32* %2
%10 = load i32, i32* %2
%11 = bitcast %union.cos* %3 to i32*
store i32 %10, i32* %11
store float -1.000000e+00, float* %5
store float 1.000000e+00, float* %6
store float 0.000000e+00, float* %7
store i32 0, i32* %8
br label %12
12: ; preds = %45, %1
%13 = load i32, i32* %8
%14 = icmp slt i32 %13, 8
br i1 %14, label %15, label %48
15: ; preds = %12
%16 = bitcast %union.cos* %3 to [8 x float]*
%17 = load i32, i32* %8
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [8 x float], [8 x float]* %16, i64 0, i64 %18
%20 = load float, float* %19
store float %20, float* %9
%21 = load float, float* %9
%22 = fcmp olt float %21, -1.000000e+00
br i1 %22, label %23, label %28
23: ; preds = %15
%24 = bitcast %union.cos* %4 to [8 x float]*
%25 = load i32, i32* %8
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [8 x float], [8 x float]* %24, i64 0, i64 %26
store float 0x400921FB60000000, float* %27
br label %44
28: ; preds = %15
%29 = load float, float* %9
%30 = fcmp ogt float %29, 1.000000e+00
br i1 %30, label %31, label %36
31: ; preds = %28
%32 = bitcast %union.cos* %4 to [8 x float]*
%33 = load i32, i32* %8
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [8 x float], [8 x float]* %32, i64 0, i64 %34
store float 0.000000e+00, float* %35
br label %43
36: ; preds = %28
%37 = load float, float* %9
%38 = call float @acosf(float %37)
%39 = bitcast %union.cos* %4 to [8 x float]*
%40 = load i32, i32* %8
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds [8 x float], [8 x float]* %39, i64 0, i64 %41
store float %38, float* %42
br label %43
43: ; preds = %36, %31
br label %44
44: ; preds = %43, %23
br label %45
45: ; preds = %44
%46 = load i32, i32* %8
%47 = add nsw i32 %46, 1
store i32 %47, i32* %8
br label %12
48: ; preds = %12
%49 = bitcast %union.cos* %4 to i32*
%50 = load i32, i32* %49
ret i32 %50
}

LLVM IR (-O2):
define i32 @inv_cosine(i32 %0) {
%2 = bitcast i32 %0 to float
%3 = fcmp olt float %2, -1.000000e+00
br i1 %3, label %9, label %4
4: ; preds = %1
%5 = fcmp ogt float %2, 1.000000e+00
br i1 %5, label %9, label %6
6: ; preds = %4
%7 = tail call float @acosf(float %2)
%8 = bitcast float %7 to i32
br label %9
9: ; preds = %6, %1, %4
%10 = phi i32 [ %8, %6 ], [ 1078530011, %1 ], [ 0, %4 ]
%11 = tail call float @acosf(float undef)
%12 = tail call float @acosf(float undef)
%13 = tail call float @acosf(float undef)
%14 = tail call float @acosf(float undef)
%15 = tail call float @acosf(float undef)
%16 = tail call float @acosf(float undef)
%17 = tail call float @acosf(float undef)
ret i32 %10
}