#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 getfitsfloatcenter();
double tlp2i(double dp, double tlmin, double binsiz, int type) {
  double dval = getfitsfloatcenter();
  if ((binsiz == 1.0) || (binsiz <= 0.0)) {
    switch (type) {
    case 'B':
    case 'I':
    case 'U':
    case 'J':
    case 'K':
    case 'V':
    default:
      return ((dp - tlmin) + 1.0);
    case 'E':
    case 'D':
      return ((dp - tlmin) + dval);
    }
  } else {
    switch (type) {
    case 'B':
    case 'I':
    case 'U':
    case 'J':
    case 'K':
    case 'V':
    default:
      return ((dp - tlmin) / binsiz + 1.0);
    case 'E':
    case 'D':
      return ((dp - tlmin) / binsiz + dval);
    }
  }
}


x86 assembly (clang, -O0):
<tlp2i>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
mov    %edi,-0x24(%rbp)
mov    $0x0,%al
call   1030 <getfitsfloatcenter@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  0xebd(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    1158 <tlp2i+0x48>
jp     1158 <tlp2i+0x48>
jmp    1166 <tlp2i+0x56>
xorps  %xmm0,%xmm0
ucomisd -0x20(%rbp),%xmm0
jb     11f4 <tlp2i+0xe4>
mov    -0x24(%rbp),%eax
mov    %eax,-0x34(%rbp)
sub    $0x42,%eax
je     11b6 <tlp2i+0xa6>
jmp    117a <tlp2i+0x6a>
mov    -0x34(%rbp),%eax
add    $0xffffffbc,%eax
sub    $0x2,%eax
jb     11db <tlp2i+0xcb>
jmp    118e <tlp2i+0x7e>
mov    -0x34(%rbp),%eax
add    $0xffffffb7,%eax
sub    $0x3,%eax
jb     11b6 <tlp2i+0xa6>
jmp    11a2 <tlp2i+0x92>
mov    -0x34(%rbp),%eax
add    $0xffffffab,%eax
sub    $0x1,%eax
ja     11bb <tlp2i+0xab>
jmp    11b6 <tlp2i+0xa6>
jmp    11bb <tlp2i+0xab>
movsd  -0x10(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
movsd  0xe33(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1287 <tlp2i+0x177>
movsd  -0x10(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
addsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1287 <tlp2i+0x177>
mov    -0x24(%rbp),%eax
mov    %eax,-0x38(%rbp)
sub    $0x42,%eax
je     1244 <tlp2i+0x134>
jmp    1208 <tlp2i+0xf8>
mov    -0x38(%rbp),%eax
add    $0xffffffbc,%eax
sub    $0x2,%eax
jb     126e <tlp2i+0x15e>
jmp    121c <tlp2i+0x10c>
mov    -0x38(%rbp),%eax
add    $0xffffffb7,%eax
sub    $0x3,%eax
jb     1244 <tlp2i+0x134>
jmp    1230 <tlp2i+0x120>
mov    -0x38(%rbp),%eax
add    $0xffffffab,%eax
sub    $0x1,%eax
ja     1249 <tlp2i+0x139>
jmp    1244 <tlp2i+0x134>
jmp    1249 <tlp2i+0x139>
movsd  -0x10(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
divsd  -0x20(%rbp),%xmm0
movsd  0xda0(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1287 <tlp2i+0x177>
movsd  -0x10(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
divsd  -0x20(%rbp),%xmm0
addsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tlp2i>:
push   %rbx
sub    $0x20,%rsp
mov    %edi,%ebx
movsd  %xmm2,0x10(%rsp)
movsd  %xmm1,0x18(%rsp)
movsd  %xmm0,0x8(%rsp)
xor    %eax,%eax
call   1030 <getfitsfloatcenter@plt>
movsd  0x10(%rsp),%xmm3
movsd  0x8(%rsp),%xmm2
and    $0xfffffffe,%ebx
ucomisd 0xeb9(%rip),%xmm3
subsd  0x18(%rsp),%xmm2
jne    1151 <tlp2i+0x41>
jnp    116a <tlp2i+0x5a>
xorpd  %xmm1,%xmm1
ucomisd %xmm3,%xmm1
jae    116a <tlp2i+0x5a>
divsd  %xmm3,%xmm2
cmp    $0x44,%ebx
jne    116f <tlp2i+0x5f>
addsd  %xmm0,%xmm2
jmp    1177 <tlp2i+0x67>
cmp    $0x44,%ebx
je     1164 <tlp2i+0x54>
addsd  0xe89(%rip),%xmm2
movapd %xmm2,%xmm0
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define double @tlp2i(double %0, double %1, double %2, i32 %3) {
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca i32
%10 = alloca double
store double %0, double* %6
store double %1, double* %7
store double %2, double* %8
store i32 %3, i32* %9
%11 = call double (...) @getfitsfloatcenter()
store double %11, double* %10
%12 = load double, double* %8
%13 = fcmp oeq double %12, 1.000000e+00
br i1 %13, label %17, label %14
14: ; preds = %4
%15 = load double, double* %8
%16 = fcmp ole double %15, 0.000000e+00
br i1 %16, label %17, label %31
17: ; preds = %14, %4
%18 = load i32, i32* %9
switch i32 %18, label %20 [
i32 66, label %19
i32 73, label %19
i32 85, label %19
i32 74, label %19
i32 75, label %19
i32 86, label %19
i32 69, label %25
i32 68, label %25
]
19: ; preds = %17, %17, %17, %17, %17, %17
br label %20
20: ; preds = %17, %19
%21 = load double, double* %6
%22 = load double, double* %7
%23 = fsub double %21, %22
%24 = fadd double %23, 1.000000e+00
store double %24, double* %5
br label %49
25: ; preds = %17, %17
%26 = load double, double* %6
%27 = load double, double* %7
%28 = fsub double %26, %27
%29 = load double, double* %10
%30 = fadd double %28, %29
store double %30, double* %5
br label %49
31: ; preds = %14
%32 = load i32, i32* %9
switch i32 %32, label %34 [
i32 66, label %33
i32 73, label %33
i32 85, label %33
i32 74, label %33
i32 75, label %33
i32 86, label %33
i32 69, label %41
i32 68, label %41
]
33: ; preds = %31, %31, %31, %31, %31, %31
br label %34
34: ; preds = %31, %33
%35 = load double, double* %6
%36 = load double, double* %7
%37 = fsub double %35, %36
%38 = load double, double* %8
%39 = fdiv double %37, %38
%40 = fadd double %39, 1.000000e+00
store double %40, double* %5
br label %49
41: ; preds = %31, %31
%42 = load double, double* %6
%43 = load double, double* %7
%44 = fsub double %42, %43
%45 = load double, double* %8
%46 = fdiv double %44, %45
%47 = load double, double* %10
%48 = fadd double %46, %47
store double %48, double* %5
br label %49
49: ; preds = %41, %34, %25, %20
%50 = load double, double* %5
ret double %50
}

LLVM IR (-O2):
define double @tlp2i(double %0, double %1, double %2, i32 %3) {
%5 = tail call double (...) @getfitsfloatcenter()
%6 = fcmp oeq double %2, 1.000000e+00
%7 = fcmp ole double %2, 0.000000e+00
%8 = or i1 %6, %7
%9 = and i32 %3, -2
%10 = icmp eq i32 %9, 68
%11 = fsub double %0, %1
br i1 %8, label %12, label %17
12: ; preds = %4
br i1 %10, label %15, label %13
13: ; preds = %12
%14 = fadd double %11, 1.000000e+00
br label %23
15: ; preds = %12
%16 = fadd double %11, %5
br label %23
17: ; preds = %4
%18 = fdiv double %11, %2
br i1 %10, label %21, label %19
19: ; preds = %17
%20 = fadd double %18, 1.000000e+00
br label %23
21: ; preds = %17
%22 = fadd double %18, %5
br label %23
23: ; preds = %21, %19, %15, %13
%24 = phi double [ %14, %13 ], [ %16, %15 ], [ %20, %19 ], [ %22, %21 ]
ret double %24
}