#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 abs(float);
float fmod(float, float);
float spb_fwrapf(float x, float y) {
  float wrapped;
  if (x >= 0 && y > 0) {
    wrapped = fmod(x, y);
  } else if (x < 0 && y > 0) {
    wrapped = y - abs(fmod(x, y));
  } else {
    wrapped = (0.f / 0.f);
  }
  return wrapped;
}


x86 assembly (clang, -O0):
<spb_fwrapf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movss  %xmm0,-0x4(%rbp)
movss  %xmm1,-0x8(%rbp)
movss  -0x4(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jb     116d <spb_fwrapf+0x4d>
movss  -0x8(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jbe    116d <spb_fwrapf+0x4d>
movss  -0x4(%rbp),%xmm0
movss  -0x8(%rbp),%xmm1
call   1040 <fmod@plt>
movss  %xmm0,-0xc(%rbp)
jmp    11d1 <spb_fwrapf+0xb1>
xorps  %xmm0,%xmm0
ucomiss -0x4(%rbp),%xmm0
jbe    11bf <spb_fwrapf+0x9f>
movss  -0x8(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jbe    11bf <spb_fwrapf+0x9f>
movss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x4(%rbp),%xmm0
movss  -0x8(%rbp),%xmm1
call   1040 <fmod@plt>
call   1030 <abs@plt>
movaps %xmm0,%xmm1
movss  -0x10(%rbp),%xmm0
subss  %xmm1,%xmm0
movss  %xmm0,-0xc(%rbp)
jmp    11cc <spb_fwrapf+0xac>
movss  0xe39(%rip),%xmm0
movss  %xmm0,-0xc(%rbp)
jmp    11d1 <spb_fwrapf+0xb1>
movss  -0xc(%rbp),%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<spb_fwrapf>:
xorps  %xmm2,%xmm2
ucomiss %xmm2,%xmm0
jb     1132 <spb_fwrapf+0x12>
ucomiss %xmm2,%xmm1
jbe    1132 <spb_fwrapf+0x12>
jmp    1040 <fmod@plt>
push   %rax
ucomiss %xmm0,%xmm2
movss  0xec2(%rip),%xmm3
jbe    1162 <spb_fwrapf+0x42>
xorps  %xmm2,%xmm2
ucomiss %xmm2,%xmm1
jbe    1162 <spb_fwrapf+0x42>
movss  %xmm1,0x4(%rsp)
call   1040 <fmod@plt>
call   1030 <abs@plt>
movss  0x4(%rsp),%xmm3
subss  %xmm0,%xmm3
movaps %xmm3,%xmm0
pop    %rax
ret

LLVM IR (-O0):
define float @spb_fwrapf(float %0, float %1) {
%3 = alloca float
%4 = alloca float
%5 = alloca float
store float %0, float* %3
store float %1, float* %4
%6 = load float, float* %3
%7 = fcmp oge float %6, 0.000000e+00
br i1 %7, label %8, label %15
8: ; preds = %2
%9 = load float, float* %4
%10 = fcmp ogt float %9, 0.000000e+00
br i1 %10, label %11, label %15
11: ; preds = %8
%12 = load float, float* %3
%13 = load float, float* %4
%14 = call float @fmod(float %12, float %13)
store float %14, float* %5
br label %30
15: ; preds = %8, %2
%16 = load float, float* %3
%17 = fcmp olt float %16, 0.000000e+00
br i1 %17, label %18, label %28
18: ; preds = %15
%19 = load float, float* %4
%20 = fcmp ogt float %19, 0.000000e+00
br i1 %20, label %21, label %28
21: ; preds = %18
%22 = load float, float* %4
%23 = load float, float* %3
%24 = load float, float* %4
%25 = call float @fmod(float %23, float %24)
%26 = call float @abs(float %25)
%27 = fsub float %22, %26
store float %27, float* %5
br label %29
28: ; preds = %18, %15
store float 0x7FF8000000000000, float* %5
br label %29
29: ; preds = %28, %21
br label %30
30: ; preds = %29, %11
%31 = load float, float* %5
ret float %31
}

LLVM IR (-O2):
define float @spb_fwrapf(float %0, float %1) {
%3 = fcmp oge float %0, 0.000000e+00
%4 = fcmp ogt float %1, 0.000000e+00
%5 = and i1 %3, %4
br i1 %5, label %6, label %8
6: ; preds = %2
%7 = tail call float @fmod(float %0, float %1)
br label %15
8: ; preds = %2
%9 = fcmp olt float %0, 0.000000e+00
%10 = and i1 %9, %4
br i1 %10, label %11, label %15
11: ; preds = %8
%12 = tail call float @fmod(float %0, float %1)
%13 = tail call float @abs(float %12)
%14 = fsub float %1, %13
br label %15
15: ; preds = %8, %11, %6
%16 = phi float [ %7, %6 ], [ %14, %11 ], [ 0x7FF8000000000000, %8 ]
ret float %16
}