#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 */
int CHAR_BIT;
int /*<<< orphan*/ hsfc3d(unsigned int *, unsigned int *, unsigned int *);
void HSFC3d(double coord[], unsigned *nkey, unsigned key[]) {
  const unsigned imax =
      ((unsigned)(((sizeof(unsigned) * CHAR_BIT) <= 32)
                      ? ~(0u)
                      : (0xffffffff << ((sizeof(unsigned) * CHAR_BIT) - 32))));
  const double c0 = (coord[0] <= 0) ? 0 : imax * coord[0];
  const double c1 = (coord[1] <= 0) ? 0 : imax * coord[1];
  const double c2 = (coord[2] <= 0) ? 0 : imax * coord[2];
  unsigned c[3];
  c[0] = (unsigned)((imax < c0) ? imax : c0);
  c[1] = (unsigned)((imax < c1) ? imax : c1);
  c[2] = (unsigned)((imax < c2) ? imax : c2);
  hsfc3d(c, nkey, key);
}


x86 assembly (clang, -O0):
<HSFC3d>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    0x2eb2(%rip),%rax
movslq (%rax),%rax
shl    $0x2,%rax
cmp    $0x20,%rax
ja     114c <HSFC3d+0x3c>
mov    $0xffffffff,%eax
mov    %eax,-0x48(%rbp)
jmp    116a <HSFC3d+0x5a>
mov    0x2e8d(%rip),%rax
movslq (%rax),%rax
shl    $0x2,%rax
sub    $0x20,%rax
mov    %eax,%ecx
mov    $0xffffffff,%eax
shl    %cl,%eax
mov    %eax,-0x48(%rbp)
mov    -0x48(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
ucomisd (%rax),%xmm0
jb     118e <HSFC3d+0x7e>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x50(%rbp)
jmp    11a3 <HSFC3d+0x93>
mov    -0x1c(%rbp),%eax
cvtsi2sd %rax,%xmm0
mov    -0x8(%rbp),%rax
mulsd  (%rax),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
ucomisd 0x8(%rax),%xmm0
jb     11cc <HSFC3d+0xbc>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x58(%rbp)
jmp    11e2 <HSFC3d+0xd2>
mov    -0x1c(%rbp),%eax
cvtsi2sd %rax,%xmm0
mov    -0x8(%rbp),%rax
mulsd  0x8(%rax),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
ucomisd 0x10(%rax),%xmm0
jb     120b <HSFC3d+0xfb>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x60(%rbp)
jmp    1221 <HSFC3d+0x111>
mov    -0x1c(%rbp),%eax
cvtsi2sd %rax,%xmm0
mov    -0x8(%rbp),%rax
mulsd  0x10(%rax),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x60(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x1c(%rbp),%eax
cvtsi2sd %rax,%xmm1
movsd  -0x28(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    1254 <HSFC3d+0x144>
mov    -0x1c(%rbp),%eax
cvtsi2sd %rax,%xmm0
movsd  %xmm0,-0x68(%rbp)
jmp    125e <HSFC3d+0x14e>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x68(%rbp),%xmm0
cvttsd2si %xmm0,%rax
mov    %eax,-0x44(%rbp)
mov    -0x1c(%rbp),%eax
cvtsi2sd %rax,%xmm1
movsd  -0x30(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    1294 <HSFC3d+0x184>
mov    -0x1c(%rbp),%eax
cvtsi2sd %rax,%xmm0
movsd  %xmm0,-0x70(%rbp)
jmp    129e <HSFC3d+0x18e>
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x70(%rbp),%xmm0
cvttsd2si %xmm0,%rax
mov    %eax,-0x40(%rbp)
mov    -0x1c(%rbp),%eax
cvtsi2sd %rax,%xmm1
movsd  -0x38(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    12d4 <HSFC3d+0x1c4>
mov    -0x1c(%rbp),%eax
cvtsi2sd %rax,%xmm0
movsd  %xmm0,-0x78(%rbp)
jmp    12de <HSFC3d+0x1ce>
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  -0x78(%rbp),%xmm0
cvttsd2si %xmm0,%rax
mov    %eax,-0x3c(%rbp)
lea    -0x44(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1030 <hsfc3d@plt>
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<HSFC3d>:
sub    $0x18,%rsp
mov    0x2ec5(%rip),%rax
movslq (%rax),%rcx
shl    $0x2,%rcx
mov    $0xffffffff,%eax
shl    %cl,%eax
cmp    $0x21,%rcx
jb     1136 <HSFC3d+0x26>
cvtsi2sd %rax,%xmm0
jmp    113e <HSFC3d+0x2e>
movsd  0xec2(%rip),%xmm0
movsd  (%rdi),%xmm1
movsd  0x8(%rdi),%xmm2
movapd %xmm1,%xmm3
mulsd  %xmm0,%xmm3
xorpd  %xmm4,%xmm4
cmpnlesd %xmm4,%xmm1
andpd  %xmm3,%xmm1
movapd %xmm2,%xmm3
mulsd  %xmm0,%xmm3
cmpnlesd %xmm4,%xmm2
andpd  %xmm3,%xmm2
movsd  0x10(%rdi),%xmm3
movapd %xmm3,%xmm5
mulsd  %xmm0,%xmm5
cmpnlesd %xmm4,%xmm3
andpd  %xmm5,%xmm3
movapd %xmm0,%xmm4
minsd  %xmm1,%xmm4
cvttsd2si %xmm4,%rax
mov    %eax,0xc(%rsp)
movapd %xmm0,%xmm1
minsd  %xmm2,%xmm1
cvttsd2si %xmm1,%rax
mov    %eax,0x10(%rsp)
minsd  %xmm3,%xmm0
cvttsd2si %xmm0,%rax
mov    %eax,0x14(%rsp)
lea    0xc(%rsp),%rdi
call   1030 <hsfc3d@plt>
add    $0x18,%rsp
ret

LLVM IR (-O0):
@CHAR_BIT = global i32 0
define void @HSFC3d(double* %0, i32* %1, i32* %2) {
%4 = alloca double*
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca [3 x i32]
store double* %0, double** %4
store i32* %1, i32** %5
store i32* %2, i32** %6
%12 = load i32, i32* @CHAR_BIT
%13 = sext i32 %12 to i64
%14 = mul i64 4, %13
%15 = icmp ule i64 %14, 32
br i1 %15, label %16, label %17
16: ; preds = %3
br label %24
17: ; preds = %3
%18 = load i32, i32* @CHAR_BIT
%19 = sext i32 %18 to i64
%20 = mul i64 4, %19
%21 = sub i64 %20, 32
%22 = trunc i64 %21 to i32
%23 = shl i32 -1, %22
br label %24
24: ; preds = %17, %16
%25 = phi i32 [ -1, %16 ], [ %23, %17 ]
store i32 %25, i32* %7
%26 = load double*, double** %4
%27 = getelementptr inbounds double, double* %26, i64 0
%28 = load double, double* %27
%29 = fcmp ole double %28, 0.000000e+00
br i1 %29, label %30, label %31
30: ; preds = %24
br label %38
31: ; preds = %24
%32 = load i32, i32* %7
%33 = uitofp i32 %32 to double
%34 = load double*, double** %4
%35 = getelementptr inbounds double, double* %34, i64 0
%36 = load double, double* %35
%37 = fmul double %33, %36
br label %38
38: ; preds = %31, %30
%39 = phi double [ 0.000000e+00, %30 ], [ %37, %31 ]
store double %39, double* %8
%40 = load double*, double** %4
%41 = getelementptr inbounds double, double* %40, i64 1
%42 = load double, double* %41
%43 = fcmp ole double %42, 0.000000e+00
br i1 %43, label %44, label %45
44: ; preds = %38
br label %52
45: ; preds = %38
%46 = load i32, i32* %7
%47 = uitofp i32 %46 to double
%48 = load double*, double** %4
%49 = getelementptr inbounds double, double* %48, i64 1
%50 = load double, double* %49
%51 = fmul double %47, %50
br label %52
52: ; preds = %45, %44
%53 = phi double [ 0.000000e+00, %44 ], [ %51, %45 ]
store double %53, double* %9
%54 = load double*, double** %4
%55 = getelementptr inbounds double, double* %54, i64 2
%56 = load double, double* %55
%57 = fcmp ole double %56, 0.000000e+00
br i1 %57, label %58, label %59
58: ; preds = %52
br label %66
59: ; preds = %52
%60 = load i32, i32* %7
%61 = uitofp i32 %60 to double
%62 = load double*, double** %4
%63 = getelementptr inbounds double, double* %62, i64 2
%64 = load double, double* %63
%65 = fmul double %61, %64
br label %66
66: ; preds = %59, %58
%67 = phi double [ 0.000000e+00, %58 ], [ %65, %59 ]
store double %67, double* %10
%68 = load i32, i32* %7
%69 = uitofp i32 %68 to double
%70 = load double, double* %8
%71 = fcmp olt double %69, %70
br i1 %71, label %72, label %75
72: ; preds = %66
%73 = load i32, i32* %7
%74 = uitofp i32 %73 to double
br label %77
75: ; preds = %66
%76 = load double, double* %8
br label %77
77: ; preds = %75, %72
%78 = phi double [ %74, %72 ], [ %76, %75 ]
%79 = fptoui double %78 to i32
%80 = getelementptr inbounds [3 x i32], [3 x i32]* %11, i64 0, i64 0
store i32 %79, i32* %80
%81 = load i32, i32* %7
%82 = uitofp i32 %81 to double
%83 = load double, double* %9
%84 = fcmp olt double %82, %83
br i1 %84, label %85, label %88
85: ; preds = %77
%86 = load i32, i32* %7
%87 = uitofp i32 %86 to double
br label %90
88: ; preds = %77
%89 = load double, double* %9
br label %90
90: ; preds = %88, %85
%91 = phi double [ %87, %85 ], [ %89, %88 ]
%92 = fptoui double %91 to i32
%93 = getelementptr inbounds [3 x i32], [3 x i32]* %11, i64 0, i64 1
store i32 %92, i32* %93
%94 = load i32, i32* %7
%95 = uitofp i32 %94 to double
%96 = load double, double* %10
%97 = fcmp olt double %95, %96
br i1 %97, label %98, label %101
98: ; preds = %90
%99 = load i32, i32* %7
%100 = uitofp i32 %99 to double
br label %103
101: ; preds = %90
%102 = load double, double* %10
br label %103
103: ; preds = %101, %98
%104 = phi double [ %100, %98 ], [ %102, %101 ]
%105 = fptoui double %104 to i32
%106 = getelementptr inbounds [3 x i32], [3 x i32]* %11, i64 0, i64 2
store i32 %105, i32* %106
%107 = getelementptr inbounds [3 x i32], [3 x i32]* %11, i64 0, i64 0
%108 = load i32*, i32** %5
%109 = load i32*, i32** %6
%110 = call i32 @hsfc3d(i32* %107, i32* %108, i32* %109)
ret void
}

LLVM IR (-O2):
@CHAR_BIT = global i32 0
define void @HSFC3d(double* nocapture %0, i32* %1, i32* %2) {
%4 = alloca [3 x i32]
%5 = load i32, i32* @CHAR_BIT
%6 = sext i32 %5 to i64
%7 = shl nsw i64 %6, 2
%8 = icmp ult i64 %7, 33
%9 = trunc i64 %7 to i32
%10 = add i32 %9, -32
%11 = shl nsw i32 -1, %10
%12 = load double, double* %0
%13 = fcmp ugt double %12, 0.000000e+00
%14 = uitofp i32 %11 to double
%15 = select i1 %8, double 0x41EFFFFFFFE00000, double %14
%16 = fmul double %12, %15
%17 = select i1 %13, double %16, double 0.000000e+00
%18 = getelementptr inbounds double, double* %0, i64 1
%19 = load double, double* %18
%20 = fcmp ugt double %19, 0.000000e+00
%21 = fmul double %19, %15
%22 = select i1 %20, double %21, double 0.000000e+00
%23 = getelementptr inbounds double, double* %0, i64 2
%24 = load double, double* %23
%25 = fcmp ugt double %24, 0.000000e+00
%26 = fmul double %24, %15
%27 = select i1 %25, double %26, double 0.000000e+00
%28 = bitcast [3 x i32]* %4 to i8*
%29 = fcmp ogt double %17, %15
%30 = select i1 %29, double %15, double %17
%31 = fptoui double %30 to i32
%32 = getelementptr inbounds [3 x i32], [3 x i32]* %4, i64 0, i64 0
store i32 %31, i32* %32
%33 = fcmp ogt double %22, %15
%34 = select i1 %33, double %15, double %22
%35 = fptoui double %34 to i32
%36 = getelementptr inbounds [3 x i32], [3 x i32]* %4, i64 0, i64 1
store i32 %35, i32* %36
%37 = fcmp ogt double %27, %15
%38 = select i1 %37, double %15, double %27
%39 = fptoui double %38 to i32
%40 = getelementptr inbounds [3 x i32], [3 x i32]* %4, i64 0, i64 2
store i32 %39, i32* %40
%41 = call i32 @hsfc3d(i32* %32, i32* %1, i32* %2)
ret void
}