#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 fmodf(float, float);
float gmodf(float a, float b) {
  float r;
  if (a >= 0)
    return fmodf(a, b);
  r = fmodf(-a, b);
  return (r == 0) ? r : b - r;
}


x86 assembly (clang, -O0):
<gmodf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movss  %xmm0,-0x8(%rbp)
movss  %xmm1,-0xc(%rbp)
movss  -0x8(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jb     114c <gmodf+0x3c>
movss  -0x8(%rbp),%xmm0
movss  -0xc(%rbp),%xmm1
call   1030 <fmodf@plt>
movss  %xmm0,-0x4(%rbp)
jmp    11ac <gmodf+0x9c>
movss  -0x8(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  -0xc(%rbp),%xmm1
call   1030 <fmodf@plt>
movss  %xmm0,-0x10(%rbp)
movss  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    1193 <gmodf+0x83>
jp     1193 <gmodf+0x83>
movss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
jmp    11a2 <gmodf+0x92>
movss  -0xc(%rbp),%xmm0
subss  -0x10(%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):
<gmodf>:
xorps  %xmm2,%xmm2
ucomiss %xmm2,%xmm0
jae    114a <gmodf+0x3a>
sub    $0x18,%rsp
xorps  0xedd(%rip),%xmm0
movaps %xmm1,(%rsp)
call   1030 <fmodf@plt>
movaps (%rsp),%xmm2
subss  %xmm0,%xmm2
xorps  %xmm1,%xmm1
cmpeqss %xmm0,%xmm1
andps  %xmm1,%xmm0
andnps %xmm2,%xmm1
orps   %xmm1,%xmm0
add    $0x18,%rsp
ret
jmp    1030 <fmodf@plt>

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

LLVM IR (-O2):
define float @gmodf(float %0, float %1) {
%3 = fcmp ult float %0, 0.000000e+00
br i1 %3, label %6, label %4
4: ; preds = %2
%5 = tail call float @fmodf(float %0, float %1)
br label %12
6: ; preds = %2
%7 = fneg float %0
%8 = tail call float @fmodf(float %7, float %1)
%9 = fcmp oeq float %8, 0.000000e+00
%10 = fsub float %1, %8
%11 = select i1 %9, float %8, float %10
br label %12
12: ; preds = %6, %4
%13 = phi float [ %5, %4 ], [ %11, %6 ]
ret float %13
}