#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 floorf(float);
float ps2_fmodf(float x, float y) {
  float i, f;
  if (y == 0.0f) {
    return 0.0f;
  }
  i = floorf(x / y);
  f = x - i * y;
  if ((x < 0.0f) != (y < 0.0f)) {
    f = f - y;
  }
  return f;
}


x86 assembly (clang, -O0):
<ps2_fmodf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movss  %xmm0,-0x8(%rbp)
movss  %xmm1,-0xc(%rbp)
movss  -0xc(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    1146 <ps2_fmodf+0x36>
jp     1146 <ps2_fmodf+0x36>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    11c3 <ps2_fmodf+0xb3>
movss  -0x8(%rbp),%xmm0
divss  -0xc(%rbp),%xmm0
call   1030 <floorf@plt>
movss  %xmm0,-0x10(%rbp)
movss  -0x8(%rbp),%xmm1
movss  -0x10(%rbp),%xmm0
movss  -0xc(%rbp),%xmm2
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x14(%rbp)
xorps  %xmm0,%xmm0
ucomiss -0x8(%rbp),%xmm0
seta   %al
and    $0x1,%al
movzbl %al,%eax
xorps  %xmm0,%xmm0
ucomiss -0xc(%rbp),%xmm0
seta   %cl
and    $0x1,%cl
movzbl %cl,%ecx
cmp    %ecx,%eax
je     11b9 <ps2_fmodf+0xa9>
movss  -0x14(%rbp),%xmm0
subss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ps2_fmodf>:
movaps %xmm0,%xmm2
xorps  %xmm0,%xmm0
ucomiss %xmm0,%xmm1
jne    111e <ps2_fmodf+0xe>
jp     111e <ps2_fmodf+0xe>
ret
push   %rax
movaps %xmm2,%xmm0
divss  %xmm1,%xmm0
movss  %xmm2,0x4(%rsp)
movss  %xmm1,(%rsp)
call   1030 <floorf@plt>
movss  (%rsp),%xmm3
movss  0x4(%rsp),%xmm2
mulss  %xmm3,%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm2,%xmm1
setbe  %al
ucomiss %xmm3,%xmm1
subss  %xmm0,%xmm2
seta   %cl
xor    %al,%cl
lea    0x8(%rsp),%rsp
jne    1164 <ps2_fmodf+0x54>
movaps %xmm3,%xmm1
subss  %xmm1,%xmm2
movaps %xmm2,%xmm0
ret

LLVM IR (-O0):
define float @ps2_fmodf(float %0, float %1) {
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = alloca float
%7 = alloca float
store float %0, float* %4
store float %1, float* %5
%8 = load float, float* %5
%9 = fcmp oeq float %8, 0.000000e+00
br i1 %9, label %10, label %11
10: ; preds = %2
store float 0.000000e+00, float* %3
br label %34
11: ; preds = %2
%12 = load float, float* %4
%13 = load float, float* %5
%14 = fdiv float %12, %13
%15 = call float @llvm.floor.f32(float %14)
store float %15, float* %6
%16 = load float, float* %4
%17 = load float, float* %6
%18 = load float, float* %5
%19 = fneg float %17
%20 = call float @llvm.fmuladd.f32(float %19, float %18, float %16)
store float %20, float* %7
%21 = load float, float* %4
%22 = fcmp olt float %21, 0.000000e+00
%23 = zext i1 %22 to i32
%24 = load float, float* %5
%25 = fcmp olt float %24, 0.000000e+00
%26 = zext i1 %25 to i32
%27 = icmp ne i32 %23, %26
br i1 %27, label %28, label %32
28: ; preds = %11
%29 = load float, float* %7
%30 = load float, float* %5
%31 = fsub float %29, %30
store float %31, float* %7
br label %32
32: ; preds = %28, %11
%33 = load float, float* %7
store float %33, float* %3
br label %34
34: ; preds = %32, %10
%35 = load float, float* %3
ret float %35
}

LLVM IR (-O2):
define float @ps2_fmodf(float %0, float %1) {
%3 = fcmp oeq float %1, 0.000000e+00
br i1 %3, label %14, label %4
4: ; preds = %2
%5 = fdiv float %0, %1
%6 = tail call float @llvm.floor.f32(float %5)
%7 = fneg float %6
%8 = tail call float @llvm.fmuladd.f32(float %7, float %1, float %0)
%9 = fcmp uge float %0, 0.000000e+00
%10 = fcmp olt float %1, 0.000000e+00
%11 = xor i1 %9, %10
%12 = select i1 %11, float 0.000000e+00, float %1
%13 = fsub float %8, %12
br label %14
14: ; preds = %2, %4
%15 = phi float [ %13, %4 ], [ 0.000000e+00, %2 ]
ret float %15
}