#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*/ modff(float, float *);
float fmodf(float x, float y) {
  float z;
  float result;
  if (y == 0.0) {
    return 0;
  }
  modff(x / y, &z);
  result = x - z * y;
  if ((x < 0) && (result > 0)) {
    result = -result;
  }
  return (result);
}


x86 assembly (clang, -O0):
<fmodf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movss  %xmm0,-0x8(%rbp)
movss  %xmm1,-0xc(%rbp)
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    114b <fmodf+0x3b>
jp     114b <fmodf+0x3b>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    11c6 <fmodf+0xb6>
movss  -0x8(%rbp),%xmm0
divss  -0xc(%rbp),%xmm0
lea    -0x10(%rbp),%rdi
call   1030 <modff@plt>
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
jbe    11bc <fmodf+0xac>
movss  -0x14(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jbe    11bc <fmodf+0xac>
movss  -0x14(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%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):
<fmodf>:
movaps %xmm0,%xmm2
xorps  %xmm0,%xmm0
ucomiss %xmm0,%xmm1
jne    111e <fmodf+0xe>
jp     111e <fmodf+0xe>
ret
sub    $0x28,%rsp
movaps %xmm2,%xmm0
divss  %xmm1,%xmm0
lea    0xc(%rsp),%rdi
movaps %xmm2,0x10(%rsp)
movss  %xmm1,0x8(%rsp)
call   1030 <modff@plt>
movss  0x8(%rsp),%xmm1
mulss  0xc(%rsp),%xmm1
movaps 0x10(%rsp),%xmm3
movaps %xmm3,%xmm0
subss  %xmm1,%xmm0
movaps 0xea3(%rip),%xmm1
xorps  %xmm0,%xmm1
xorps  %xmm2,%xmm2
cmpltss %xmm2,%xmm3
cmpltss %xmm0,%xmm2
andps  %xmm2,%xmm1
andnps %xmm0,%xmm2
orps   %xmm1,%xmm2
movaps %xmm3,%xmm1
andps  %xmm3,%xmm2
andnps %xmm0,%xmm1
orps   %xmm2,%xmm1
movaps %xmm1,%xmm0
add    $0x28,%rsp
ret

LLVM IR (-O0):
define float @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 = fpext float %8 to double
%10 = fcmp oeq double %9, 0.000000e+00
br i1 %10, label %11, label %12
11: ; preds = %2
store float 0.000000e+00, float* %3
br label %32
12: ; preds = %2
%13 = load float, float* %4
%14 = load float, float* %5
%15 = fdiv float %13, %14
%16 = call i32 @modff(float %15, float* %6)
%17 = load float, float* %4
%18 = load float, float* %6
%19 = load float, float* %5
%20 = fneg float %18
%21 = call float @llvm.fmuladd.f32(float %20, float %19, float %17)
store float %21, float* %7
%22 = load float, float* %4
%23 = fcmp olt float %22, 0.000000e+00
br i1 %23, label %24, label %30
24: ; preds = %12
%25 = load float, float* %7
%26 = fcmp ogt float %25, 0.000000e+00
br i1 %26, label %27, label %30
27: ; preds = %24
%28 = load float, float* %7
%29 = fneg float %28
store float %29, float* %7
br label %30
30: ; preds = %27, %24, %12
%31 = load float, float* %7
store float %31, float* %3
br label %32
32: ; preds = %30, %11
%33 = load float, float* %3
ret float %33
}

LLVM IR (-O2):
define float @fmodf(float %0, float %1) {
%3 = alloca float
%4 = bitcast float* %3 to i8*
%5 = fcmp oeq float %1, 0.000000e+00
br i1 %5, label %17, label %6
6: ; preds = %2
%7 = fdiv float %0, %1
%8 = call i32 @modff(float %7, float* %3)
%9 = load float, float* %3
%10 = fneg float %9
%11 = tail call float @llvm.fmuladd.f32(float %10, float %1, float %0)
%12 = fcmp olt float %0, 0.000000e+00
%13 = fcmp ogt float %11, 0.000000e+00
%14 = select i1 %12, i1 %13, i1 false
%15 = fneg float %11
%16 = select i1 %14, float %15, float %11
br label %17
17: ; preds = %2, %6
%18 = phi float [ %16, %6 ], [ 0.000000e+00, %2 ]
ret float %18
}