#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 __irmodf(int /*<<< orphan*/);
float fabsf(float);
int /*<<< orphan*/ roundf(float);
float truncf(float);
float remquof(float x, float y, int *quo) {
  float q = x / y;
  float n = truncf(q);
  if (fabsf(n - q) >= 0.5F)
    ++n;
  *quo = __irmodf(roundf(q));
  return x - n * y;
}


x86 assembly (clang, -O0):
<remquof>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movss  %xmm0,-0x4(%rbp)
movss  %xmm1,-0x8(%rbp)
mov    %rdi,-0x10(%rbp)
movss  -0x4(%rbp),%xmm0
divss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
call   1040 <truncf@plt>
movss  %xmm0,-0x18(%rbp)
movss  -0x18(%rbp),%xmm0
subss  -0x14(%rbp),%xmm0
movaps 0xe9b(%rip),%xmm1
pand   %xmm1,%xmm0
movss  0xe7f(%rip),%xmm1
ucomiss %xmm1,%xmm0
jb     119c <remquof+0x6c>
movss  0xe72(%rip),%xmm0
addss  -0x18(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x14(%rbp),%xmm0
call   1050 <roundf@plt>
mov    %eax,%edi
call   1030 <__irmodf@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
movss  -0x4(%rbp),%xmm1
movss  -0x18(%rbp),%xmm0
movss  -0x8(%rbp),%xmm2
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<remquof>:
push   %rbx
sub    $0x20,%rsp
mov    %rdi,%rbx
movss  %xmm1,0x8(%rsp)
movss  %xmm0,0xc(%rsp)
divss  %xmm1,%xmm0
movss  %xmm0,0x4(%rsp)
call   1040 <truncf@plt>
movaps %xmm0,%xmm1
movss  0x4(%rsp),%xmm4
subss  %xmm4,%xmm1
andps  0xe99(%rip),%xmm1
movss  0xea1(%rip),%xmm2
addss  %xmm0,%xmm2
movss  0xe99(%rip),%xmm3
cmpnless %xmm1,%xmm3
andps  %xmm3,%xmm0
andnps %xmm2,%xmm3
orps   %xmm0,%xmm3
movaps %xmm3,0x10(%rsp)
movaps %xmm4,%xmm0
call   1050 <roundf@plt>
mov    %eax,%edi
call   1030 <__irmodf@plt>
mov    %eax,(%rbx)
movaps 0x10(%rsp),%xmm1
mulss  0x8(%rsp),%xmm1
movss  0xc(%rsp),%xmm0
subss  %xmm1,%xmm0
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define float @remquof(float %0, float %1, i32* %2) {
%4 = alloca float
%5 = alloca float
%6 = alloca i32*
%7 = alloca float
%8 = alloca float
store float %0, float* %4
store float %1, float* %5
store i32* %2, i32** %6
%9 = load float, float* %4
%10 = load float, float* %5
%11 = fdiv float %9, %10
store float %11, float* %7
%12 = load float, float* %7
%13 = call float @llvm.trunc.f32(float %12)
store float %13, float* %8
%14 = load float, float* %8
%15 = load float, float* %7
%16 = fsub float %14, %15
%17 = call float @llvm.fabs.f32(float %16)
%18 = fcmp oge float %17, 5.000000e-01
br i1 %18, label %19, label %22
19: ; preds = %3
%20 = load float, float* %8
%21 = fadd float %20, 1.000000e+00
store float %21, float* %8
br label %22
22: ; preds = %19, %3
%23 = load float, float* %7
%24 = call i32 @roundf(float %23)
%25 = call i32 @__irmodf(i32 %24)
%26 = load i32*, i32** %6
store i32 %25, i32* %26
%27 = load float, float* %4
%28 = load float, float* %8
%29 = load float, float* %5
%30 = fneg float %28
%31 = call float @llvm.fmuladd.f32(float %30, float %29, float %27)
ret float %31
}

LLVM IR (-O2):
define float @remquof(float %0, float %1, i32* nocapture writeonly %2) {
%4 = fdiv float %0, %1
%5 = tail call float @llvm.trunc.f32(float %4)
%6 = fsub float %5, %4
%7 = tail call float @llvm.fabs.f32(float %6)
%8 = fcmp ult float %7, 5.000000e-01
%9 = fadd float %5, 1.000000e+00
%10 = select i1 %8, float %5, float %9
%11 = tail call i32 @roundf(float %4)
%12 = tail call i32 @__irmodf(i32 %11)
store i32 %12, i32* %2
%13 = fneg float %10
%14 = tail call float @llvm.fmuladd.f32(float %13, float %1, float %0)
ret float %14
}