#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 gb_copy_sign(float, float);
float gb_remainder(float, float);
float gb_mod(float x, float y) {
  float result;
  y = ((y) > 0 ? (y) : -(y));
  result = gb_remainder(((x) > 0 ? (x) : -(x)), y);
  if (((result) >= 0 ? 1 : -1))
    result += y;
  return gb_copy_sign(result, x);
}


x86 assembly (clang, -O0):
<gb_mod>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movss  %xmm0,-0x4(%rbp)
movss  %xmm1,-0x8(%rbp)
movss  -0x8(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jbe    1152 <gb_mod+0x32>
movss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
jmp    1169 <gb_mod+0x49>
movss  -0x8(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x8(%rbp)
movss  -0x4(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jbe    1193 <gb_mod+0x73>
movss  -0x4(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
jmp    11aa <gb_mod+0x8a>
movss  -0x4(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
movss  -0x8(%rbp),%xmm1
call   1030 <gb_remainder@plt>
movss  %xmm0,-0xc(%rbp)
movss  -0xc(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jb     11de <gb_mod+0xbe>
mov    $0x1,%al
test   $0x1,%al
jne    11ed <gb_mod+0xcd>
jmp    11fc <gb_mod+0xdc>
mov    $0x1,%al
test   $0x1,%al
jne    11ed <gb_mod+0xcd>
jmp    11fc <gb_mod+0xdc>
movss  -0x8(%rbp),%xmm0
addss  -0xc(%rbp),%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0xc(%rbp),%xmm0
movss  -0x4(%rbp),%xmm1
call   1040 <gb_copy_sign@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gb_mod>:
sub    $0x28,%rsp
movaps %xmm0,%xmm4
movaps 0xed2(%rip),%xmm2
xorps  %xmm5,%xmm5
cmpltss %xmm1,%xmm5
movaps %xmm5,%xmm3
andps  %xmm1,%xmm5
xorps  %xmm2,%xmm1
xorps  %xmm0,%xmm0
andnps %xmm1,%xmm3
orps   %xmm3,%xmm5
movaps %xmm5,(%rsp)
movaps %xmm4,0x10(%rsp)
xorps  %xmm4,%xmm2
cmpltss %xmm4,%xmm0
movaps %xmm0,%xmm1
andnps %xmm2,%xmm1
andps  %xmm4,%xmm0
orps   %xmm1,%xmm0
movaps %xmm5,%xmm1
call   1030 <gb_remainder@plt>
addss  (%rsp),%xmm0
movaps 0x10(%rsp),%xmm1
add    $0x28,%rsp
jmp    1040 <gb_copy_sign@plt>

LLVM IR (-O0):
define float @gb_mod(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* %4
%7 = fcmp ogt float %6, 0.000000e+00
br i1 %7, label %8, label %10
8: ; preds = %2
%9 = load float, float* %4
br label %13
10: ; preds = %2
%11 = load float, float* %4
%12 = fneg float %11
br label %13
13: ; preds = %10, %8
%14 = phi float [ %9, %8 ], [ %12, %10 ]
store float %14, float* %4
%15 = load float, float* %3
%16 = fcmp ogt float %15, 0.000000e+00
br i1 %16, label %17, label %19
17: ; preds = %13
%18 = load float, float* %3
br label %22
19: ; preds = %13
%20 = load float, float* %3
%21 = fneg float %20
br label %22
22: ; preds = %19, %17
%23 = phi float [ %18, %17 ], [ %21, %19 ]
%24 = load float, float* %4
%25 = call float @gb_remainder(float %23, float %24)
store float %25, float* %5
%26 = load float, float* %5
%27 = fcmp oge float %26, 0.000000e+00
br i1 %27, label %28, label %29
28: ; preds = %22
br i1 true, label %30, label %34
29: ; preds = %22
br i1 true, label %30, label %34
30: ; preds = %29, %28
%31 = load float, float* %4
%32 = load float, float* %5
%33 = fadd float %32, %31
store float %33, float* %5
br label %34
34: ; preds = %30, %29, %28
%35 = load float, float* %5
%36 = load float, float* %3
%37 = call float @gb_copy_sign(float %35, float %36)
ret float %37
}

LLVM IR (-O2):
define float @gb_mod(float %0, float %1) {
%3 = fcmp ogt float %1, 0.000000e+00
%4 = fneg float %1
%5 = select i1 %3, float %1, float %4
%6 = fcmp ogt float %0, 0.000000e+00
%7 = fneg float %0
%8 = select i1 %6, float %0, float %7
%9 = tail call float @gb_remainder(float %8, float %5)
%10 = fadd float %5, %9
%11 = tail call float @gb_copy_sign(float %10, float %0)
ret float %11
}