#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 */
float cos(double);
float sin(double);
float InTspline(float t, int n) {
  float sn, cs;
  sn = sin(0.5 * 3.14159265358979323846 * t);
  cs = cos(0.5 * 3.14159265358979323846 * t);
  switch (n) {
  case 1:
    return (0.5 * cs * (cs - 1));
  case 2:
    return (0.5 * sn * (sn + 1));
  case 3:
    return (0.5 * cs * (cs + 1));
  case 4:
    return (0.5 * sn * (sn - 1));
  }
  return t;
}


x86 assembly (clang, -O0):
<InTspline>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movss  %xmm0,-0x8(%rbp)
mov    %edi,-0xc(%rbp)
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xebf(%rip),%xmm1
movsd  %xmm1,-0x28(%rbp)
mulsd  %xmm1,%xmm0
call   1030 <sin@plt>
movsd  -0x28(%rbp),%xmm1
movss  %xmm0,-0x10(%rbp)
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
mulsd  %xmm1,%xmm0
call   1040 <cos@plt>
movss  %xmm0,-0x14(%rbp)
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0x3,%eax
ja     1281 <InTspline+0x161>
mov    -0x20(%rbp),%rax
lea    0xe84(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xe5e(%rip),%xmm0
mulsd  %xmm1,%xmm0
movss  -0x14(%rbp),%xmm1
movss  0xe55(%rip),%xmm2
subss  %xmm2,%xmm1
cvtss2sd %xmm1,%xmm1
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    128b <InTspline+0x16b>
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xe22(%rip),%xmm0
mulsd  %xmm1,%xmm0
movss  0xe1e(%rip),%xmm1
addss  -0x10(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    128b <InTspline+0x16b>
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xdea(%rip),%xmm0
mulsd  %xmm1,%xmm0
movss  0xde6(%rip),%xmm1
addss  -0x14(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    128b <InTspline+0x16b>
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xdb2(%rip),%xmm0
mulsd  %xmm1,%xmm0
movss  -0x10(%rbp),%xmm1
movss  0xda9(%rip),%xmm2
subss  %xmm2,%xmm1
cvtss2sd %xmm1,%xmm1
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    128b <InTspline+0x16b>
movss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<InTspline>:
push   %rbx
sub    $0x10,%rsp
mov    %edi,%ebx
movss  %xmm0,0x4(%rsp)
cvtss2sd %xmm0,%xmm0
mulsd  0xec7(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
call   1030 <sin@plt>
movss  %xmm0,(%rsp)
movsd  0x8(%rsp),%xmm0
call   1040 <cos@plt>
movss  0x4(%rsp),%xmm1
add    $0xffffffff,%ebx
cmp    $0x3,%ebx
ja     11fd <InTspline+0xdd>
lea    0xeab(%rip),%rax
movslq (%rax,%rbx,4),%rcx
add    %rax,%rcx
jmp    *%rcx
xorps  %xmm1,%xmm1
cvtss2sd %xmm0,%xmm1
mulsd  0xe83(%rip),%xmm1
addss  0xe83(%rip),%xmm0
jmp    11c4 <InTspline+0xa4>
movss  (%rsp),%xmm1
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
mulsd  0xe65(%rip),%xmm0
addss  0xe69(%rip),%xmm1
jmp    11f1 <InTspline+0xd1>
xorps  %xmm1,%xmm1
cvtss2sd %xmm0,%xmm1
mulsd  0xe4c(%rip),%xmm1
addss  0xe50(%rip),%xmm0
cvtss2sd %xmm0,%xmm0
mulsd  %xmm1,%xmm0
xorps  %xmm1,%xmm1
cvtsd2ss %xmm0,%xmm1
jmp    11fd <InTspline+0xdd>
movss  (%rsp),%xmm1
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
mulsd  0xe1f(%rip),%xmm0
addss  0xe1f(%rip),%xmm1
cvtss2sd %xmm1,%xmm1
mulsd  %xmm0,%xmm1
cvtsd2ss %xmm1,%xmm1
movaps %xmm1,%xmm0
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define float @InTspline(float %0, i32 %1) {
%3 = alloca float
%4 = alloca float
%5 = alloca i32
%6 = alloca float
%7 = alloca float
store float %0, float* %4
store i32 %1, i32* %5
%8 = load float, float* %4
%9 = fpext float %8 to double
%10 = fmul double 0x3FF921FB54442D18, %9
%11 = call float @sin(double %10)
store float %11, float* %6
%12 = load float, float* %4
%13 = fpext float %12 to double
%14 = fmul double 0x3FF921FB54442D18, %13
%15 = call float @cos(double %14)
store float %15, float* %7
%16 = load i32, i32* %5
switch i32 %16, label %53 [
i32 1, label %17
i32 2, label %26
i32 3, label %35
i32 4, label %44
]
17: ; preds = %2
%18 = load float, float* %7
%19 = fpext float %18 to double
%20 = fmul double 5.000000e-01, %19
%21 = load float, float* %7
%22 = fsub float %21, 1.000000e+00
%23 = fpext float %22 to double
%24 = fmul double %20, %23
%25 = fptrunc double %24 to float
store float %25, float* %3
br label %55
26: ; preds = %2
%27 = load float, float* %6
%28 = fpext float %27 to double
%29 = fmul double 5.000000e-01, %28
%30 = load float, float* %6
%31 = fadd float %30, 1.000000e+00
%32 = fpext float %31 to double
%33 = fmul double %29, %32
%34 = fptrunc double %33 to float
store float %34, float* %3
br label %55
35: ; preds = %2
%36 = load float, float* %7
%37 = fpext float %36 to double
%38 = fmul double 5.000000e-01, %37
%39 = load float, float* %7
%40 = fadd float %39, 1.000000e+00
%41 = fpext float %40 to double
%42 = fmul double %38, %41
%43 = fptrunc double %42 to float
store float %43, float* %3
br label %55
44: ; preds = %2
%45 = load float, float* %6
%46 = fpext float %45 to double
%47 = fmul double 5.000000e-01, %46
%48 = load float, float* %6
%49 = fsub float %48, 1.000000e+00
%50 = fpext float %49 to double
%51 = fmul double %47, %50
%52 = fptrunc double %51 to float
store float %52, float* %3
br label %55
53: ; preds = %2
%54 = load float, float* %4
store float %54, float* %3
br label %55
55: ; preds = %53, %44, %35, %26, %17
%56 = load float, float* %3
ret float %56
}

LLVM IR (-O2):
define float @InTspline(float %0, i32 %1) {
%3 = fpext float %0 to double
%4 = fmul double %3, 0x3FF921FB54442D18
%5 = tail call float @sin(double %4)
%6 = tail call float @cos(double %4)
switch i32 %1, label %35 [
i32 1, label %7
i32 2, label %14
i32 3, label %21
i32 4, label %28
]
7: ; preds = %2
%8 = fpext float %6 to double
%9 = fmul double %8, 5.000000e-01
%10 = fadd float %6, -1.000000e+00
%11 = fpext float %10 to double
%12 = fmul double %9, %11
%13 = fptrunc double %12 to float
br label %35
14: ; preds = %2
%15 = fpext float %5 to double
%16 = fmul double %15, 5.000000e-01
%17 = fadd float %5, 1.000000e+00
%18 = fpext float %17 to double
%19 = fmul double %16, %18
%20 = fptrunc double %19 to float
br label %35
21: ; preds = %2
%22 = fpext float %6 to double
%23 = fmul double %22, 5.000000e-01
%24 = fadd float %6, 1.000000e+00
%25 = fpext float %24 to double
%26 = fmul double %23, %25
%27 = fptrunc double %26 to float
br label %35
28: ; preds = %2
%29 = fpext float %5 to double
%30 = fmul double %29, 5.000000e-01
%31 = fadd float %5, -1.000000e+00
%32 = fpext float %31 to double
%33 = fmul double %30, %32
%34 = fptrunc double %33 to float
br label %35
35: ; preds = %2, %28, %21, %14, %7
%36 = phi float [ %34, %28 ], [ %27, %21 ], [ %20, %14 ], [ %13, %7 ], [ %0, %2 ]
ret float %36
}