#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*/ hsfc2d(unsigned int *, unsigned int *, unsigned int *);
void HSFC2d(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];
  unsigned c[2];
  c[0] = (unsigned)((imax < c0) ? imax : c0);
  c[1] = (unsigned)((imax < c1) ? imax : c1);
  hsfc2d(c, nkey, key);
}


x86 assembly (clang, -O0):
<HSFC2d>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    0x2eb5(%rip),%rax
movslq (%rax),%rax
shl    $0x2,%rax
cmp    $0x20,%rax
ja     1149 <HSFC2d+0x39>
mov    $0xffffffff,%eax
mov    %eax,-0x3c(%rbp)
jmp    1167 <HSFC2d+0x57>
mov    0x2e90(%rip),%rax
movslq (%rax),%rax
shl    $0x2,%rax
sub    $0x20,%rax
mov    %eax,%ecx
mov    $0xffffffff,%eax
shl    %cl,%eax
mov    %eax,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
ucomisd (%rax),%xmm0
jb     118b <HSFC2d+0x7b>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x48(%rbp)
jmp    11a0 <HSFC2d+0x90>
mov    -0x1c(%rbp),%eax
cvtsi2sd %rax,%xmm0
mov    -0x8(%rbp),%rax
mulsd  (%rax),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
ucomisd 0x8(%rax),%xmm0
jb     11c9 <HSFC2d+0xb9>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x50(%rbp)
jmp    11df <HSFC2d+0xcf>
mov    -0x1c(%rbp),%eax
cvtsi2sd %rax,%xmm0
mov    -0x8(%rbp),%rax
mulsd  0x8(%rax),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x1c(%rbp),%eax
cvtsi2sd %rax,%xmm1
movsd  -0x28(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    1212 <HSFC2d+0x102>
mov    -0x1c(%rbp),%eax
cvtsi2sd %rax,%xmm0
movsd  %xmm0,-0x58(%rbp)
jmp    121c <HSFC2d+0x10c>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x58(%rbp),%xmm0
cvttsd2si %xmm0,%rax
mov    %eax,-0x38(%rbp)
mov    -0x1c(%rbp),%eax
cvtsi2sd %rax,%xmm1
movsd  -0x30(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    1252 <HSFC2d+0x142>
mov    -0x1c(%rbp),%eax
cvtsi2sd %rax,%xmm0
movsd  %xmm0,-0x60(%rbp)
jmp    125c <HSFC2d+0x14c>
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x60(%rbp),%xmm0
cvttsd2si %xmm0,%rax
mov    %eax,-0x34(%rbp)
lea    -0x38(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1030 <hsfc2d@plt>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<HSFC2d>:
push   %rax
mov    0x2ec8(%rip),%rax
movslq (%rax),%rcx
shl    $0x2,%rcx
mov    $0xffffffff,%eax
shl    %cl,%eax
cmp    $0x21,%rcx
jb     1133 <HSFC2d+0x23>
cvtsi2sd %rax,%xmm0
jmp    113b <HSFC2d+0x2b>
movsd  0xec5(%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
movapd %xmm0,%xmm3
minsd  %xmm1,%xmm3
cvttsd2si %xmm3,%rax
mov    %eax,(%rsp)
minsd  %xmm2,%xmm0
cvttsd2si %xmm0,%rax
mov    %eax,0x4(%rsp)
mov    %rsp,%rdi
call   1030 <hsfc2d@plt>
pop    %rax
ret

LLVM IR (-O0):
@CHAR_BIT = global i32 0
define void @HSFC2d(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 [2 x i32]
store double* %0, double** %4
store i32* %1, i32** %5
store i32* %2, i32** %6
%11 = load i32, i32* @CHAR_BIT
%12 = sext i32 %11 to i64
%13 = mul i64 4, %12
%14 = icmp ule i64 %13, 32
br i1 %14, label %15, label %16
15: ; preds = %3
br label %23
16: ; preds = %3
%17 = load i32, i32* @CHAR_BIT
%18 = sext i32 %17 to i64
%19 = mul i64 4, %18
%20 = sub i64 %19, 32
%21 = trunc i64 %20 to i32
%22 = shl i32 -1, %21
br label %23
23: ; preds = %16, %15
%24 = phi i32 [ -1, %15 ], [ %22, %16 ]
store i32 %24, i32* %7
%25 = load double*, double** %4
%26 = getelementptr inbounds double, double* %25, i64 0
%27 = load double, double* %26
%28 = fcmp ole double %27, 0.000000e+00
br i1 %28, label %29, label %30
29: ; preds = %23
br label %37
30: ; preds = %23
%31 = load i32, i32* %7
%32 = uitofp i32 %31 to double
%33 = load double*, double** %4
%34 = getelementptr inbounds double, double* %33, i64 0
%35 = load double, double* %34
%36 = fmul double %32, %35
br label %37
37: ; preds = %30, %29
%38 = phi double [ 0.000000e+00, %29 ], [ %36, %30 ]
store double %38, double* %8
%39 = load double*, double** %4
%40 = getelementptr inbounds double, double* %39, i64 1
%41 = load double, double* %40
%42 = fcmp ole double %41, 0.000000e+00
br i1 %42, label %43, label %44
43: ; preds = %37
br label %51
44: ; preds = %37
%45 = load i32, i32* %7
%46 = uitofp i32 %45 to double
%47 = load double*, double** %4
%48 = getelementptr inbounds double, double* %47, i64 1
%49 = load double, double* %48
%50 = fmul double %46, %49
br label %51
51: ; preds = %44, %43
%52 = phi double [ 0.000000e+00, %43 ], [ %50, %44 ]
store double %52, double* %9
%53 = load i32, i32* %7
%54 = uitofp i32 %53 to double
%55 = load double, double* %8
%56 = fcmp olt double %54, %55
br i1 %56, label %57, label %60
57: ; preds = %51
%58 = load i32, i32* %7
%59 = uitofp i32 %58 to double
br label %62
60: ; preds = %51
%61 = load double, double* %8
br label %62
62: ; preds = %60, %57
%63 = phi double [ %59, %57 ], [ %61, %60 ]
%64 = fptoui double %63 to i32
%65 = getelementptr inbounds [2 x i32], [2 x i32]* %10, i64 0, i64 0
store i32 %64, i32* %65
%66 = load i32, i32* %7
%67 = uitofp i32 %66 to double
%68 = load double, double* %9
%69 = fcmp olt double %67, %68
br i1 %69, label %70, label %73
70: ; preds = %62
%71 = load i32, i32* %7
%72 = uitofp i32 %71 to double
br label %75
73: ; preds = %62
%74 = load double, double* %9
br label %75
75: ; preds = %73, %70
%76 = phi double [ %72, %70 ], [ %74, %73 ]
%77 = fptoui double %76 to i32
%78 = getelementptr inbounds [2 x i32], [2 x i32]* %10, i64 0, i64 1
store i32 %77, i32* %78
%79 = getelementptr inbounds [2 x i32], [2 x i32]* %10, i64 0, i64 0
%80 = load i32*, i32** %5
%81 = load i32*, i32** %6
%82 = call i32 @hsfc2d(i32* %79, i32* %80, i32* %81)
ret void
}

LLVM IR (-O2):
@CHAR_BIT = global i32 0
define void @HSFC2d(double* nocapture %0, i32* %1, i32* %2) {
%4 = alloca [2 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 = bitcast [2 x i32]* %4 to i8*
%24 = fcmp ogt double %17, %15
%25 = select i1 %24, double %15, double %17
%26 = fptoui double %25 to i32
%27 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 0
store i32 %26, i32* %27
%28 = fcmp ogt double %22, %15
%29 = select i1 %28, double %15, double %22
%30 = fptoui double %29 to i32
%31 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 1
store i32 %30, i32* %31
%32 = call i32 @hsfc2d(i32* %27, i32* %1, i32* %2)
ret void
}