#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 /*<<< orphan*/ assert(int);
float floorf(float);
float nvWrapf(float a, float min, float max) {
  assert(max > min);
  float d = max - min;
  float s = a - min;
  float q = s / d;
  float m = q - floorf(q);
  return m * d + min;
}


x86 assembly (clang, -O0):
<nvWrapf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movss  %xmm0,-0x4(%rbp)
movss  %xmm1,-0x8(%rbp)
movss  %xmm2,-0xc(%rbp)
movss  -0xc(%rbp),%xmm0
ucomiss -0x8(%rbp),%xmm0
seta   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
movss  -0xc(%rbp),%xmm0
subss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x4(%rbp),%xmm0
subss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
divss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x18(%rbp),%xmm0
movss  %xmm0,-0x20(%rbp)
movss  -0x18(%rbp),%xmm0
call   1030 <floorf@plt>
movaps %xmm0,%xmm1
movss  -0x20(%rbp),%xmm0
subss  %xmm1,%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x1c(%rbp),%xmm0
movss  -0x10(%rbp),%xmm2
movss  -0x8(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nvWrapf>:
sub    $0x18,%rsp
movss  %xmm2,0xc(%rsp)
movss  %xmm1,0x14(%rsp)
movss  %xmm0,0x10(%rsp)
xor    %edi,%edi
ucomiss %xmm1,%xmm2
seta   %dil
call   1040 <assert@plt>
movss  0x14(%rsp),%xmm2
movss  0xc(%rsp),%xmm1
subss  %xmm2,%xmm1
movss  %xmm1,0xc(%rsp)
movss  0x10(%rsp),%xmm0
subss  %xmm2,%xmm0
divss  %xmm1,%xmm0
movss  %xmm0,0x10(%rsp)
call   1030 <floorf@plt>
movss  0x10(%rsp),%xmm1
subss  %xmm0,%xmm1
mulss  0xc(%rsp),%xmm1
addss  0x14(%rsp),%xmm1
movaps %xmm1,%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
define float @nvWrapf(float %0, float %1, float %2) {
%4 = alloca float
%5 = alloca float
%6 = alloca float
%7 = alloca float
%8 = alloca float
%9 = alloca float
%10 = alloca float
store float %0, float* %4
store float %1, float* %5
store float %2, float* %6
%11 = load float, float* %6
%12 = load float, float* %5
%13 = fcmp ogt float %11, %12
%14 = zext i1 %13 to i32
%15 = call i32 @assert(i32 %14)
%16 = load float, float* %6
%17 = load float, float* %5
%18 = fsub float %16, %17
store float %18, float* %7
%19 = load float, float* %4
%20 = load float, float* %5
%21 = fsub float %19, %20
store float %21, float* %8
%22 = load float, float* %8
%23 = load float, float* %7
%24 = fdiv float %22, %23
store float %24, float* %9
%25 = load float, float* %9
%26 = load float, float* %9
%27 = call float @llvm.floor.f32(float %26)
%28 = fsub float %25, %27
store float %28, float* %10
%29 = load float, float* %10
%30 = load float, float* %7
%31 = load float, float* %5
%32 = call float @llvm.fmuladd.f32(float %29, float %30, float %31)
ret float %32
}

LLVM IR (-O2):
define float @nvWrapf(float %0, float %1, float %2) {
%4 = fcmp ogt float %2, %1
%5 = zext i1 %4 to i32
%6 = tail call i32 @assert(i32 %5)
%7 = fsub float %2, %1
%8 = fsub float %0, %1
%9 = fdiv float %8, %7
%10 = tail call float @llvm.floor.f32(float %9)
%11 = fsub float %9, %10
%12 = tail call float @llvm.fmuladd.f32(float %11, float %7, float %1)
ret float %12
}