#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 */
typedef int /*<<< orphan*/ int16_t;

/* Variables and functions */
int fabs(float);
scalar_t__ floor(double);
int /*<<< orphan*/ mjpeg_info(char *, float);
int16_t cubic_spline(float x, unsigned int multiplicative) {
  const float B = 1.0 / 3.0;
  const float C = 1.0 / 3.0;
  if (fabs(x) < 1)
    return ((int16_t)floor(
        0.5 +
        (((12.0 - 9.0 * B - 6.0 * C) * fabs(x) * fabs(x) * fabs(x) +
          (-18.0 + 12.0 * B + 6.0 * C) * fabs(x) * fabs(x) + (6.0 - 2.0 * B)) /
         6.0) *
            multiplicative));
  if (fabs(x) <= 2)
    return ((int16_t)floor(
        0.5 + (((-B - 6.0 * C) * fabs(x) * fabs(x) * fabs(x) +
                (6.0 * B + 30.0 * C) * fabs(x) * fabs(x) +
                (-12.0 * B - 48.0 * C) * fabs(x) + (8.0 * B + 24.0 * C)) /
               6.0) *
                  multiplicative));
  if (fabs(x) <= 3)
    return (0);
  mjpeg_info("In function cubic_spline: x=%f >3", x);
  return (0);
}


x86 assembly (clang, -O0):
<cubic_spline>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movss  %xmm0,-0x8(%rbp)
mov    %edi,-0xc(%rbp)
movss  0xeb8(%rip),%xmm0
movss  %xmm0,-0x10(%rbp)
movss  0xeab(%rip),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x8(%rbp),%xmm0
call   1030 <fabs@plt>
cmp    $0x1,%eax
jge    1240 <cubic_spline+0x110>
movss  -0x8(%rbp),%xmm0
call   1030 <fabs@plt>
cvtsi2sd %eax,%xmm0
movsd  0xeb5(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movss  -0x8(%rbp),%xmm0
call   1030 <fabs@plt>
movsd  -0x38(%rbp),%xmm0
cvtsi2sd %eax,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movss  -0x8(%rbp),%xmm0
call   1030 <fabs@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x20(%rbp)
movss  -0x8(%rbp),%xmm0
call   1030 <fabs@plt>
cvtsi2sd %eax,%xmm0
movsd  0xe6f(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movss  -0x8(%rbp),%xmm0
call   1030 <fabs@plt>
movsd  -0x30(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm2
cvtsi2sd %eax,%xmm3
mulsd  %xmm3,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  0xe3d(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  0xe19(%rip),%xmm1
divsd  %xmm1,%xmm0
mov    -0xc(%rbp),%eax
cvtsi2sd %rax,%xmm1
mulsd  %xmm1,%xmm0
movsd  0xdd9(%rip),%xmm1
addsd  %xmm1,%xmm0
call   1050 <floor@plt>
mov    %eax,-0x4(%rbp)
jmp    1385 <cubic_spline+0x255>
movss  -0x8(%rbp),%xmm0
call   1030 <fabs@plt>
cmp    $0x2,%eax
jg     134e <cubic_spline+0x21e>
movss  -0x8(%rbp),%xmm0
call   1030 <fabs@plt>
cvtsi2sd %eax,%xmm0
movsd  0xda7(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
movss  -0x8(%rbp),%xmm0
call   1030 <fabs@plt>
movsd  -0x60(%rbp),%xmm0
cvtsi2sd %eax,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movss  -0x8(%rbp),%xmm0
call   1030 <fabs@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x48(%rbp)
movss  -0x8(%rbp),%xmm0
call   1030 <fabs@plt>
cvtsi2sd %eax,%xmm0
movsd  0xd61(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
movss  -0x8(%rbp),%xmm0
call   1030 <fabs@plt>
movsd  -0x58(%rbp),%xmm1
movsd  -0x50(%rbp),%xmm0
movsd  -0x48(%rbp),%xmm2
cvtsi2sd %eax,%xmm3
mulsd  %xmm3,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movss  -0x8(%rbp),%xmm0
call   1030 <fabs@plt>
movsd  -0x40(%rbp),%xmm1
cvtsi2sd %eax,%xmm0
movsd  0xd17(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  0xd0f(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  0xd0b(%rip),%xmm1
divsd  %xmm1,%xmm0
mov    -0xc(%rbp),%eax
cvtsi2sd %rax,%xmm1
mulsd  %xmm1,%xmm0
movsd  0xccb(%rip),%xmm1
addsd  %xmm1,%xmm0
call   1050 <floor@plt>
mov    %eax,-0x4(%rbp)
jmp    1385 <cubic_spline+0x255>
movss  -0x8(%rbp),%xmm0
call   1030 <fabs@plt>
cmp    $0x3,%eax
jg     136d <cubic_spline+0x23d>
movl   $0x0,-0x4(%rbp)
jmp    1385 <cubic_spline+0x255>
movss  -0x8(%rbp),%xmm0
lea    0xcd7(%rip),%rdi
call   1040 <mjpeg_info@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cubic_spline>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %edi,%r14d
movss  %xmm0,0xc(%rsp)
call   1030 <fabs@plt>
mov    %eax,%ebx
movss  0xc(%rsp),%xmm0
call   1030 <fabs@plt>
mov    %eax,%ebp
test   %ebx,%ebx
jle    1230 <cubic_spline+0x100>
movss  0xc(%rsp),%xmm0
call   1030 <fabs@plt>
cmp    $0x2,%ebp
jg     12f6 <cubic_spline+0x1c6>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0xe80(%rip),%xmm0
movsd  %xmm0,0x10(%rsp)
movss  0xc(%rsp),%xmm0
call   1030 <fabs@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
movss  0xc(%rsp),%xmm0
call   1030 <fabs@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
movss  0xc(%rsp),%xmm0
call   1030 <fabs@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0xe2c(%rip),%xmm0
movsd  %xmm0,0x18(%rsp)
movss  0xc(%rsp),%xmm0
call   1030 <fabs@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0x18(%rsp),%xmm0
addsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
movss  0xc(%rsp),%xmm0
call   1030 <fabs@plt>
cvtsi2sd %eax,%xmm1
mulsd  0xdf3(%rip),%xmm1
addsd  0x10(%rsp),%xmm1
addsd  0xded(%rip),%xmm1
jmp    12c4 <cubic_spline+0x194>
xorps  %xmm0,%xmm0
cvtsi2sd %ebp,%xmm0
mulsd  0xdf1(%rip),%xmm0
movsd  %xmm0,0x10(%rsp)
movss  0xc(%rsp),%xmm0
call   1030 <fabs@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
movss  0xc(%rsp),%xmm0
call   1030 <fabs@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
movss  0xc(%rsp),%xmm0
call   1030 <fabs@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0xd9d(%rip),%xmm0
movsd  %xmm0,0x18(%rsp)
movss  0xc(%rsp),%xmm0
call   1030 <fabs@plt>
cvtsi2sd %eax,%xmm1
mulsd  0x18(%rsp),%xmm1
addsd  0x10(%rsp),%xmm1
addsd  0xd7c(%rip),%xmm1
divsd  0xd54(%rip),%xmm1
mov    %r14d,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
mulsd  %xmm1,%xmm0
addsd  0xd45(%rip),%xmm0
call   1050 <floor@plt>
mov    %rax,%rbx
mov    %ebx,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
movss  0xc(%rsp),%xmm0
xor    %ebx,%ebx
cmp    $0x4,%eax
jl     12eb <cubic_spline+0x1bb>
lea    0xd3e(%rip),%rdi
call   1040 <mjpeg_info@plt>
jmp    12eb <cubic_spline+0x1bb>

LLVM IR (-O0):
@.str = [34 x i8] c"In function cubic_spline: x=%f >3\00"
define i32 @cubic_spline(float %0, i32 %1) {
%3 = alloca i32
%4 = alloca float
%5 = alloca i32
%6 = alloca float
%7 = alloca float
store float %0, float* %4
store i32 %1, i32* %5
store float 0x3FD5555560000000, float* %6
store float 0x3FD5555560000000, float* %7
%8 = load float, float* %4
%9 = call i32 @fabs(float %8)
%10 = icmp slt i32 %9, 1
br i1 %10, label %11, label %39
11: ; preds = %2
%12 = load float, float* %4
%13 = call i32 @fabs(float %12)
%14 = sitofp i32 %13 to double
%15 = fmul double 0x401BFFFFF6000000, %14
%16 = load float, float* %4
%17 = call i32 @fabs(float %16)
%18 = sitofp i32 %17 to double
%19 = fmul double %15, %18
%20 = load float, float* %4
%21 = call i32 @fabs(float %20)
%22 = sitofp i32 %21 to double
%23 = load float, float* %4
%24 = call i32 @fabs(float %23)
%25 = sitofp i32 %24 to double
%26 = fmul double 0xC027FFFFFA000000, %25
%27 = load float, float* %4
%28 = call i32 @fabs(float %27)
%29 = sitofp i32 %28 to double
%30 = fmul double %26, %29
%31 = call double @llvm.fmuladd.f64(double %19, double %22, double %30)
%32 = fadd double %31, 0x4015555554000000
%33 = fdiv double %32, 6.000000e+00
%34 = load i32, i32* %5
%35 = uitofp i32 %34 to double
%36 = call double @llvm.fmuladd.f64(double %33, double %35, double 5.000000e-01)
%37 = call i64 @floor(double %36)
%38 = trunc i64 %37 to i32
store i32 %38, i32* %3
br label %83
39: ; preds = %2
%40 = load float, float* %4
%41 = call i32 @fabs(float %40)
%42 = icmp sle i32 %41, 2
br i1 %42, label %43, label %75
43: ; preds = %39
%44 = load float, float* %4
%45 = call i32 @fabs(float %44)
%46 = sitofp i32 %45 to double
%47 = fmul double 0xC002AAAAB4000000, %46
%48 = load float, float* %4
%49 = call i32 @fabs(float %48)
%50 = sitofp i32 %49 to double
%51 = fmul double %47, %50
%52 = load float, float* %4
%53 = call i32 @fabs(float %52)
%54 = sitofp i32 %53 to double
%55 = load float, float* %4
%56 = call i32 @fabs(float %55)
%57 = sitofp i32 %56 to double
%58 = fmul double 0x402800000C000000, %57
%59 = load float, float* %4
%60 = call i32 @fabs(float %59)
%61 = sitofp i32 %60 to double
%62 = fmul double %58, %61
%63 = call double @llvm.fmuladd.f64(double %51, double %54, double %62)
%64 = load float, float* %4
%65 = call i32 @fabs(float %64)
%66 = sitofp i32 %65 to double
%67 = call double @llvm.fmuladd.f64(double 0xC03400000A000000, double %66, double %63)
%68 = fadd double %67, 0x4025555560000000
%69 = fdiv double %68, 6.000000e+00
%70 = load i32, i32* %5
%71 = uitofp i32 %70 to double
%72 = call double @llvm.fmuladd.f64(double %69, double %71, double 5.000000e-01)
%73 = call i64 @floor(double %72)
%74 = trunc i64 %73 to i32
store i32 %74, i32* %3
br label %83
75: ; preds = %39
%76 = load float, float* %4
%77 = call i32 @fabs(float %76)
%78 = icmp sle i32 %77, 3
br i1 %78, label %79, label %80
79: ; preds = %75
store i32 0, i32* %3
br label %83
80: ; preds = %75
%81 = load float, float* %4
%82 = call i32 @mjpeg_info(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), float %81)
store i32 0, i32* %3
br label %83
83: ; preds = %80, %79, %43, %11
%84 = load i32, i32* %3
ret i32 %84
}

LLVM IR (-O2):
@.str = [34 x i8] c"In function cubic_spline: x=%f >3\00"
define i32 @cubic_spline(float %0, i32 %1) {
%3 = tail call i32 @fabs(float %0)
%4 = icmp slt i32 %3, 1
%5 = tail call i32 @fabs(float %0)
br i1 %4, label %6, label %27
6: ; preds = %2
%7 = sitofp i32 %5 to double
%8 = fmul double %7, 0x401BFFFFF6000000
%9 = tail call i32 @fabs(float %0)
%10 = sitofp i32 %9 to double
%11 = fmul double %8, %10
%12 = tail call i32 @fabs(float %0)
%13 = sitofp i32 %12 to double
%14 = tail call i32 @fabs(float %0)
%15 = sitofp i32 %14 to double
%16 = fmul double %15, 0xC027FFFFFA000000
%17 = tail call i32 @fabs(float %0)
%18 = sitofp i32 %17 to double
%19 = fmul double %16, %18
%20 = tail call double @llvm.fmuladd.f64(double %11, double %13, double %19)
%21 = fadd double %20, 0x4015555554000000
%22 = fdiv double %21, 6.000000e+00
%23 = uitofp i32 %1 to double
%24 = tail call double @llvm.fmuladd.f64(double %22, double %23, double 5.000000e-01)
%25 = tail call i64 @floor(double %24)
%26 = trunc i64 %25 to i32
br label %58
27: ; preds = %2
%28 = icmp slt i32 %5, 3
%29 = tail call i32 @fabs(float %0)
br i1 %28, label %30, label %54
30: ; preds = %27
%31 = sitofp i32 %29 to double
%32 = fmul double %31, 0xC002AAAAB4000000
%33 = tail call i32 @fabs(float %0)
%34 = sitofp i32 %33 to double
%35 = fmul double %32, %34
%36 = tail call i32 @fabs(float %0)
%37 = sitofp i32 %36 to double
%38 = tail call i32 @fabs(float %0)
%39 = sitofp i32 %38 to double
%40 = fmul double %39, 0x402800000C000000
%41 = tail call i32 @fabs(float %0)
%42 = sitofp i32 %41 to double
%43 = fmul double %40, %42
%44 = tail call double @llvm.fmuladd.f64(double %35, double %37, double %43)
%45 = tail call i32 @fabs(float %0)
%46 = sitofp i32 %45 to double
%47 = tail call double @llvm.fmuladd.f64(double %46, double 0xC03400000A000000, double %44)
%48 = fadd double %47, 0x4025555560000000
%49 = fdiv double %48, 6.000000e+00
%50 = uitofp i32 %1 to double
%51 = tail call double @llvm.fmuladd.f64(double %49, double %50, double 5.000000e-01)
%52 = tail call i64 @floor(double %51)
%53 = trunc i64 %52 to i32
br label %58
54: ; preds = %27
%55 = icmp slt i32 %29, 4
br i1 %55, label %58, label %56
56: ; preds = %54
%57 = tail call i32 @mjpeg_info(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), float %0)
br label %58
58: ; preds = %54, %56, %30, %6
%59 = phi i32 [ %26, %6 ], [ %53, %30 ], [ 0, %56 ], [ 0, %54 ]
ret i32 %59
}