#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 THSFC3d(double coord[], unsigned add_step, 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);
  unsigned nk = (*nkey - 1);
  key[2] = add_step;
  unsigned tempkey[nk];
  int i;
  for (i = 0; i < nk; i++)
    tempkey[i] = key[i];
  hsfc3d(c, &nk, tempkey);
  for (i = 0; i < nk; i++)
    key[i] = tempkey[i];
}


x86 assembly (clang, -O0):
<THSFC3d>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    0x2eaf(%rip),%rax
movslq (%rax),%rax
shl    $0x2,%rax
cmp    $0x20,%rax
ja     114f <THSFC3d+0x3f>
mov    $0xffffffff,%eax
mov    %eax,-0x68(%rbp)
jmp    116d <THSFC3d+0x5d>
mov    0x2e8a(%rip),%rax
movslq (%rax),%rax
shl    $0x2,%rax
sub    $0x20,%rax
mov    %eax,%ecx
mov    $0xffffffff,%eax
shl    %cl,%eax
mov    %eax,-0x68(%rbp)
mov    -0x68(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
ucomisd (%rax),%xmm0
jb     1191 <THSFC3d+0x81>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x70(%rbp)
jmp    11a6 <THSFC3d+0x96>
mov    -0x24(%rbp),%eax
cvtsi2sd %rax,%xmm0
mov    -0x8(%rbp),%rax
mulsd  (%rax),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x70(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
ucomisd 0x8(%rax),%xmm0
jb     11cf <THSFC3d+0xbf>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x78(%rbp)
jmp    11e5 <THSFC3d+0xd5>
mov    -0x24(%rbp),%eax
cvtsi2sd %rax,%xmm0
mov    -0x8(%rbp),%rax
mulsd  0x8(%rax),%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  -0x78(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
ucomisd 0x10(%rax),%xmm0
jb     120e <THSFC3d+0xfe>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x80(%rbp)
jmp    1224 <THSFC3d+0x114>
mov    -0x24(%rbp),%eax
cvtsi2sd %rax,%xmm0
mov    -0x8(%rbp),%rax
mulsd  0x10(%rax),%xmm0
movsd  %xmm0,-0x80(%rbp)
movsd  -0x80(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x24(%rbp),%eax
cvtsi2sd %rax,%xmm1
movsd  -0x30(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    125a <THSFC3d+0x14a>
mov    -0x24(%rbp),%eax
cvtsi2sd %rax,%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
jmp    1267 <THSFC3d+0x157>
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
movsd  -0x88(%rbp),%xmm0
ff
cvttsd2si %xmm0,%rax
mov    %eax,-0x4c(%rbp)
mov    -0x24(%rbp),%eax
cvtsi2sd %rax,%xmm1
movsd  -0x38(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    12a3 <THSFC3d+0x193>
mov    -0x24(%rbp),%eax
cvtsi2sd %rax,%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
jmp    12b0 <THSFC3d+0x1a0>
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
movsd  -0x90(%rbp),%xmm0
ff
cvttsd2si %xmm0,%rax
mov    %eax,-0x48(%rbp)
mov    -0x24(%rbp),%eax
cvtsi2sd %rax,%xmm1
movsd  -0x40(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    12ec <THSFC3d+0x1dc>
mov    -0x24(%rbp),%eax
cvtsi2sd %rax,%xmm0
movsd  %xmm0,-0x98(%rbp)
ff
jmp    12f9 <THSFC3d+0x1e9>
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x98(%rbp)
ff
movsd  -0x98(%rbp),%xmm0
cvttsd2si %xmm0,%rax
mov    %eax,-0x44(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
add    $0xffffffff,%eax
mov    %eax,-0x50(%rbp)
mov    -0xc(%rbp),%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,0x8(%rax)
mov    -0x50(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x58(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0xa0(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x60(%rbp)
movl   $0x0,-0x64(%rbp)
mov    -0x64(%rbp),%eax
cmp    -0x50(%rbp),%eax
jae    1383 <THSFC3d+0x273>
mov    -0xa0(%rbp),%rax
mov    -0x20(%rbp),%rcx
movslq -0x64(%rbp),%rdx
mov    (%rcx,%rdx,4),%edx
movslq -0x64(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
jmp    1350 <THSFC3d+0x240>
mov    -0xa0(%rbp),%rdx
lea    -0x4c(%rbp),%rdi
lea    -0x50(%rbp),%rsi
call   1030 <hsfc3d@plt>
movl   $0x0,-0x64(%rbp)
mov    -0x64(%rbp),%eax
cmp    -0x50(%rbp),%eax
jae    13d1 <THSFC3d+0x2c1>
mov    -0xa0(%rbp),%rax
movslq -0x64(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
mov    -0x20(%rbp),%rax
movslq -0x64(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
jmp    139e <THSFC3d+0x28e>
mov    -0x58(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<THSFC3d>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rcx,%r14
mov    0x2ea9(%rip),%rax
movslq (%rax),%rcx
shl    $0x2,%rcx
mov    $0xffffffff,%eax
shl    %cl,%eax
cmp    $0x21,%rcx
jb     1152 <THSFC3d+0x32>
cvtsi2sd %rax,%xmm0
jmp    115a <THSFC3d+0x3a>
movsd  0xea6(%rip),%xmm0
mov    %rsp,%r15
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,-0x28(%rbp)
movapd %xmm0,%xmm1
minsd  %xmm2,%xmm1
cvttsd2si %xmm1,%rax
mov    %eax,-0x24(%rbp)
minsd  %xmm3,%xmm0
cvttsd2si %xmm0,%rax
mov    %eax,-0x20(%rbp)
mov    (%rdx),%eax
add    $0xffffffff,%eax
mov    %eax,-0x1c(%rbp)
mov    %esi,0x8(%r14)
mov    %rsp,%rbx
lea    0xf(,%rax,4),%rcx
and    $0xfffffffffffffff0,%rcx
sub    %rcx,%rbx
mov    %rbx,%rsp
test   %eax,%eax
je     1206 <THSFC3d+0xe6>
lea    0x0(,%rax,4),%rdx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <memcpy@plt>
lea    -0x28(%rbp),%rdi
lea    -0x1c(%rbp),%rsi
mov    %rbx,%rdx
call   1030 <hsfc3d@plt>
mov    -0x1c(%rbp),%edx
test   %rdx,%rdx
je     122d <THSFC3d+0x10d>
shl    $0x2,%rdx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <memcpy@plt>
mov    %r15,%rsp
lea    -0x18(%rbp),%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@CHAR_BIT = global i32 0
define void @THSFC3d(double* %0, i32 %1, i32* %2, i32* %3) {
%5 = alloca double*
%6 = alloca i32
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca i32
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca [3 x i32]
%14 = alloca i32
%15 = alloca i8*
%16 = alloca i64
%17 = alloca i32
store double* %0, double** %5
store i32 %1, i32* %6
store i32* %2, i32** %7
store i32* %3, i32** %8
%18 = load i32, i32* @CHAR_BIT
%19 = sext i32 %18 to i64
%20 = mul i64 4, %19
%21 = icmp ule i64 %20, 32
br i1 %21, label %22, label %23
22: ; preds = %4
br label %30
23: ; preds = %4
%24 = load i32, i32* @CHAR_BIT
%25 = sext i32 %24 to i64
%26 = mul i64 4, %25
%27 = sub i64 %26, 32
%28 = trunc i64 %27 to i32
%29 = shl i32 -1, %28
br label %30
30: ; preds = %23, %22
%31 = phi i32 [ -1, %22 ], [ %29, %23 ]
store i32 %31, i32* %9
%32 = load double*, double** %5
%33 = getelementptr inbounds double, double* %32, i64 0
%34 = load double, double* %33
%35 = fcmp ole double %34, 0.000000e+00
br i1 %35, label %36, label %37
36: ; preds = %30
br label %44
37: ; preds = %30
%38 = load i32, i32* %9
%39 = uitofp i32 %38 to double
%40 = load double*, double** %5
%41 = getelementptr inbounds double, double* %40, i64 0
%42 = load double, double* %41
%43 = fmul double %39, %42
br label %44
44: ; preds = %37, %36
%45 = phi double [ 0.000000e+00, %36 ], [ %43, %37 ]
store double %45, double* %10
%46 = load double*, double** %5
%47 = getelementptr inbounds double, double* %46, i64 1
%48 = load double, double* %47
%49 = fcmp ole double %48, 0.000000e+00
br i1 %49, label %50, label %51
50: ; preds = %44
br label %58
51: ; preds = %44
%52 = load i32, i32* %9
%53 = uitofp i32 %52 to double
%54 = load double*, double** %5
%55 = getelementptr inbounds double, double* %54, i64 1
%56 = load double, double* %55
%57 = fmul double %53, %56
br label %58
58: ; preds = %51, %50
%59 = phi double [ 0.000000e+00, %50 ], [ %57, %51 ]
store double %59, double* %11
%60 = load double*, double** %5
%61 = getelementptr inbounds double, double* %60, i64 2
%62 = load double, double* %61
%63 = fcmp ole double %62, 0.000000e+00
br i1 %63, label %64, label %65
64: ; preds = %58
br label %72
65: ; preds = %58
%66 = load i32, i32* %9
%67 = uitofp i32 %66 to double
%68 = load double*, double** %5
%69 = getelementptr inbounds double, double* %68, i64 2
%70 = load double, double* %69
%71 = fmul double %67, %70
br label %72
72: ; preds = %65, %64
%73 = phi double [ 0.000000e+00, %64 ], [ %71, %65 ]
store double %73, double* %12
%74 = load i32, i32* %9
%75 = uitofp i32 %74 to double
%76 = load double, double* %10
%77 = fcmp olt double %75, %76
br i1 %77, label %78, label %81
78: ; preds = %72
%79 = load i32, i32* %9
%80 = uitofp i32 %79 to double
br label %83
81: ; preds = %72
%82 = load double, double* %10
br label %83
83: ; preds = %81, %78
%84 = phi double [ %80, %78 ], [ %82, %81 ]
%85 = fptoui double %84 to i32
%86 = getelementptr inbounds [3 x i32], [3 x i32]* %13, i64 0, i64 0
store i32 %85, i32* %86
%87 = load i32, i32* %9
%88 = uitofp i32 %87 to double
%89 = load double, double* %11
%90 = fcmp olt double %88, %89
br i1 %90, label %91, label %94
91: ; preds = %83
%92 = load i32, i32* %9
%93 = uitofp i32 %92 to double
br label %96
94: ; preds = %83
%95 = load double, double* %11
br label %96
96: ; preds = %94, %91
%97 = phi double [ %93, %91 ], [ %95, %94 ]
%98 = fptoui double %97 to i32
%99 = getelementptr inbounds [3 x i32], [3 x i32]* %13, i64 0, i64 1
store i32 %98, i32* %99
%100 = load i32, i32* %9
%101 = uitofp i32 %100 to double
%102 = load double, double* %12
%103 = fcmp olt double %101, %102
br i1 %103, label %104, label %107
104: ; preds = %96
%105 = load i32, i32* %9
%106 = uitofp i32 %105 to double
br label %109
107: ; preds = %96
%108 = load double, double* %12
br label %109
109: ; preds = %107, %104
%110 = phi double [ %106, %104 ], [ %108, %107 ]
%111 = fptoui double %110 to i32
%112 = getelementptr inbounds [3 x i32], [3 x i32]* %13, i64 0, i64 2
store i32 %111, i32* %112
%113 = load i32*, i32** %7
%114 = load i32, i32* %113
%115 = sub i32 %114, 1
store i32 %115, i32* %14
%116 = load i32, i32* %6
%117 = load i32*, i32** %8
%118 = getelementptr inbounds i32, i32* %117, i64 2
store i32 %116, i32* %118
%119 = load i32, i32* %14
%120 = zext i32 %119 to i64
%121 = call i8* @llvm.stacksave()
store i8* %121, i8** %15
%122 = alloca i32, i64 %120
store i64 %120, i64* %16
store i32 0, i32* %17
br label %123
123: ; preds = %136, %109
%124 = load i32, i32* %17
%125 = load i32, i32* %14
%126 = icmp ult i32 %124, %125
br i1 %126, label %127, label %139
127: ; preds = %123
%128 = load i32*, i32** %8
%129 = load i32, i32* %17
%130 = sext i32 %129 to i64
%131 = getelementptr inbounds i32, i32* %128, i64 %130
%132 = load i32, i32* %131
%133 = load i32, i32* %17
%134 = sext i32 %133 to i64
%135 = getelementptr inbounds i32, i32* %122, i64 %134
store i32 %132, i32* %135
br label %136
136: ; preds = %127
%137 = load i32, i32* %17
%138 = add nsw i32 %137, 1
store i32 %138, i32* %17
br label %123
139: ; preds = %123
%140 = getelementptr inbounds [3 x i32], [3 x i32]* %13, i64 0, i64 0
%141 = call i32 @hsfc3d(i32* %140, i32* %14, i32* %122)
store i32 0, i32* %17
br label %142
142: ; preds = %155, %139
%143 = load i32, i32* %17
%144 = load i32, i32* %14
%145 = icmp ult i32 %143, %144
br i1 %145, label %146, label %158
146: ; preds = %142
%147 = load i32, i32* %17
%148 = sext i32 %147 to i64
%149 = getelementptr inbounds i32, i32* %122, i64 %148
%150 = load i32, i32* %149
%151 = load i32*, i32** %8
%152 = load i32, i32* %17
%153 = sext i32 %152 to i64
%154 = getelementptr inbounds i32, i32* %151, i64 %153
store i32 %150, i32* %154
br label %155
155: ; preds = %146
%156 = load i32, i32* %17
%157 = add nsw i32 %156, 1
store i32 %157, i32* %17
br label %142
158: ; preds = %142
%159 = load i8*, i8** %15
ret void
}

LLVM IR (-O2):
@CHAR_BIT = global i32 0
define void @THSFC3d(double* nocapture %0, i32 %1, i32* nocapture %2, i32* nocapture %3) {
%5 = bitcast i32* %3 to i8*
%6 = alloca [3 x i32]
%7 = alloca i32
%8 = load i32, i32* @CHAR_BIT
%9 = sext i32 %8 to i64
%10 = shl nsw i64 %9, 2
%11 = icmp ult i64 %10, 33
%12 = trunc i64 %10 to i32
%13 = add i32 %12, -32
%14 = shl nsw i32 -1, %13
%15 = load double, double* %0
%16 = fcmp ugt double %15, 0.000000e+00
%17 = uitofp i32 %14 to double
%18 = select i1 %11, double 0x41EFFFFFFFE00000, double %17
%19 = fmul double %15, %18
%20 = select i1 %16, double %19, double 0.000000e+00
%21 = getelementptr inbounds double, double* %0, i64 1
%22 = load double, double* %21
%23 = fcmp ugt double %22, 0.000000e+00
%24 = fmul double %22, %18
%25 = select i1 %23, double %24, double 0.000000e+00
%26 = getelementptr inbounds double, double* %0, i64 2
%27 = load double, double* %26
%28 = fcmp ugt double %27, 0.000000e+00
%29 = fmul double %27, %18
%30 = select i1 %28, double %29, double 0.000000e+00
%31 = bitcast [3 x i32]* %6 to i8*
%32 = fcmp ogt double %20, %18
%33 = select i1 %32, double %18, double %20
%34 = fptoui double %33 to i32
%35 = getelementptr inbounds [3 x i32], [3 x i32]* %6, i64 0, i64 0
store i32 %34, i32* %35
%36 = fcmp ogt double %25, %18
%37 = select i1 %36, double %18, double %25
%38 = fptoui double %37 to i32
%39 = getelementptr inbounds [3 x i32], [3 x i32]* %6, i64 0, i64 1
store i32 %38, i32* %39
%40 = fcmp ogt double %30, %18
%41 = select i1 %40, double %18, double %30
%42 = fptoui double %41 to i32
%43 = getelementptr inbounds [3 x i32], [3 x i32]* %6, i64 0, i64 2
store i32 %42, i32* %43
%44 = bitcast i32* %7 to i8*
%45 = load i32, i32* %2
%46 = add i32 %45, -1
store i32 %46, i32* %7
%47 = getelementptr inbounds i32, i32* %3, i64 2
store i32 %1, i32* %47
%48 = zext i32 %46 to i64
%49 = tail call i8* @llvm.stacksave()
%50 = alloca i32, i64 %48
%51 = bitcast i32* %50 to i8*
%52 = icmp eq i32 %46, 0
br i1 %52, label %55, label %53
53: ; preds = %4
%54 = shl nuw nsw i64 %48, 2
br label %55
55: ; preds = %53, %4
%56 = call i32 @hsfc3d(i32* %35, i32* %7, i32* %50)
%57 = load i32, i32* %7
%58 = icmp eq i32 %57, 0
br i1 %58, label %62, label %59
59: ; preds = %55
%60 = zext i32 %57 to i64
%61 = shl nuw nsw i64 %60, 2
br label %62
62: ; preds = %59, %55
ret void
}