#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 */
scalar_t__ floor(float);
void stbir__calculate_sample_range_upsample(int n, float out_filter_radius,
                                            float scale_ratio, float out_shift,
                                            int *in_first_pixel,
                                            int *in_last_pixel,
                                            float *in_center_of_out) {
  float out_pixel_center = (float)n + 0.5f;
  float out_pixel_influence_lowerbound = out_pixel_center - out_filter_radius;
  float out_pixel_influence_upperbound = out_pixel_center + out_filter_radius;
  float in_pixel_influence_lowerbound =
      (out_pixel_influence_lowerbound + out_shift) / scale_ratio;
  float in_pixel_influence_upperbound =
      (out_pixel_influence_upperbound + out_shift) / scale_ratio;
  *in_center_of_out = (out_pixel_center + out_shift) / scale_ratio;
  *in_first_pixel = (int)(floor(in_pixel_influence_lowerbound + 0.5));
  *in_last_pixel = (int)(floor(in_pixel_influence_upperbound - 0.5));
}


x86 assembly (clang, -O0):
<stbir__calculate_sample_range_upsample>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
movss  %xmm0,-0x8(%rbp)
movss  %xmm1,-0xc(%rbp)
movss  %xmm2,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
cvtsi2ssl -0x4(%rbp),%xmm0
movss  0xec5(%rip),%xmm1
addss  %xmm1,%xmm0
movss  %xmm0,-0x2c(%rbp)
movss  -0x2c(%rbp),%xmm0
subss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x30(%rbp)
movss  -0x2c(%rbp),%xmm0
addss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x34(%rbp)
movss  -0x30(%rbp),%xmm0
addss  -0x10(%rbp),%xmm0
divss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x38(%rbp)
movss  -0x34(%rbp),%xmm0
addss  -0x10(%rbp),%xmm0
divss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x3c(%rbp)
movss  -0x2c(%rbp),%xmm0
addss  -0x10(%rbp),%xmm0
divss  -0xc(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movss  %xmm0,(%rax)
movss  -0x38(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe46(%rip),%xmm1
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
call   1030 <floor@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
movss  -0x3c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe20(%rip),%xmm1
subsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
call   1030 <floor@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<stbir__calculate_sample_range_upsample>:
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%rbx
movaps %xmm0,%xmm5
cvtsi2ss %edi,%xmm3
movss  0xed7(%rip),%xmm4
addss  %xmm4,%xmm3
movaps %xmm3,%xmm0
subss  %xmm5,%xmm0
addss  %xmm3,%xmm5
addss  %xmm2,%xmm0
divss  %xmm1,%xmm0
addss  %xmm2,%xmm5
divss  %xmm1,%xmm5
movss  %xmm5,0x4(%rsp)
addss  %xmm2,%xmm3
divss  %xmm1,%xmm3
movss  %xmm3,(%rcx)
addss  %xmm4,%xmm0
call   1030 <floor@plt>
mov    %eax,(%rbx)
movss  0x4(%rsp),%xmm0
addss  0xe91(%rip),%xmm0
call   1030 <floor@plt>
mov    %eax,(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @stbir__calculate_sample_range_upsample(i32 %0, float %1, float %2, float %3, i32* %4, i32* %5, float* %6) {
%8 = alloca i32
%9 = alloca float
%10 = alloca float
%11 = alloca float
%12 = alloca i32*
%13 = alloca i32*
%14 = alloca float*
%15 = alloca float
%16 = alloca float
%17 = alloca float
%18 = alloca float
%19 = alloca float
store i32 %0, i32* %8
store float %1, float* %9
store float %2, float* %10
store float %3, float* %11
store i32* %4, i32** %12
store i32* %5, i32** %13
store float* %6, float** %14
%20 = load i32, i32* %8
%21 = sitofp i32 %20 to float
%22 = fadd float %21, 5.000000e-01
store float %22, float* %15
%23 = load float, float* %15
%24 = load float, float* %9
%25 = fsub float %23, %24
store float %25, float* %16
%26 = load float, float* %15
%27 = load float, float* %9
%28 = fadd float %26, %27
store float %28, float* %17
%29 = load float, float* %16
%30 = load float, float* %11
%31 = fadd float %29, %30
%32 = load float, float* %10
%33 = fdiv float %31, %32
store float %33, float* %18
%34 = load float, float* %17
%35 = load float, float* %11
%36 = fadd float %34, %35
%37 = load float, float* %10
%38 = fdiv float %36, %37
store float %38, float* %19
%39 = load float, float* %15
%40 = load float, float* %11
%41 = fadd float %39, %40
%42 = load float, float* %10
%43 = fdiv float %41, %42
%44 = load float*, float** %14
store float %43, float* %44
%45 = load float, float* %18
%46 = fpext float %45 to double
%47 = fadd double %46, 5.000000e-01
%48 = fptrunc double %47 to float
%49 = call i64 @floor(float %48)
%50 = trunc i64 %49 to i32
%51 = load i32*, i32** %12
store i32 %50, i32* %51
%52 = load float, float* %19
%53 = fpext float %52 to double
%54 = fsub double %53, 5.000000e-01
%55 = fptrunc double %54 to float
%56 = call i64 @floor(float %55)
%57 = trunc i64 %56 to i32
%58 = load i32*, i32** %13
store i32 %57, i32* %58
ret void
}

LLVM IR (-O2):
define void @stbir__calculate_sample_range_upsample(i32 %0, float %1, float %2, float %3, i32* nocapture writeonly %4, i32* nocapture writeonly %5, float* nocapture writeonly %6) {
%8 = sitofp i32 %0 to float
%9 = fadd float %8, 5.000000e-01
%10 = fsub float %9, %1
%11 = fadd float %9, %1
%12 = fadd float %10, %3
%13 = fdiv float %12, %2
%14 = fadd float %11, %3
%15 = fdiv float %14, %2
%16 = fadd float %9, %3
%17 = fdiv float %16, %2
store float %17, float* %6
%18 = fadd float %13, 5.000000e-01
%19 = tail call i64 @floor(float %18)
%20 = trunc i64 %19 to i32
store i32 %20, i32* %4
%21 = fadd float %15, -5.000000e-01
%22 = tail call i64 @floor(float %21)
%23 = trunc i64 %22 to i32
store i32 %23, i32* %5
ret void
}