#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 __irmodl(int /*<<< orphan*/);
long double fabsl(long double);
int /*<<< orphan*/ roundl(long double);
long double truncl(long double);
long double remquol(long double x, long double y, int *quo) {
  long double q = x / y;
  long double n = truncl(q);
  if (fabsl(n - q) >= 0.5L)
    ++n;
  *quo = __irmodl(roundl(q));
  return x - n * y;
}


x86 assembly (clang, -O0):
<remquol>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
fldt   0x20(%rbp)
fldt   0x10(%rbp)
fstpt  -0x10(%rbp)
fstpt  -0x20(%rbp)
mov    %rdi,-0x28(%rbp)
fldt   -0x10(%rbp)
fldt   -0x20(%rbp)
fdivrp %st,%st(1)
fstpt  -0x40(%rbp)
fldt   -0x40(%rbp)
mov    %rsp,%rax
fstpt  (%rax)
call   1050 <truncl@plt>
fstpt  -0x50(%rbp)
fldt   -0x50(%rbp)
fldt   -0x40(%rbp)
fsubrp %st,%st(1)
fabs
flds   0xe8d(%rip)
fxch   %st(1)
fucomip %st(1),%st
fstp   %st(0)
jb     118e <remquol+0x5e>
jmp    1184 <remquol+0x54>
fldt   -0x50(%rbp)
fld1
faddp  %st,%st(1)
fstpt  -0x50(%rbp)
fldt   -0x40(%rbp)
mov    %rsp,%rax
fstpt  (%rax)
call   1040 <roundl@plt>
mov    %eax,%edi
call   1030 <__irmodl@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,(%rax)
fldt   -0x10(%rbp)
fldt   -0x50(%rbp)
fldt   -0x20(%rbp)
fmulp  %st,%st(1)
fsubrp %st,%st(1)
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<remquol>:
push   %rbx
sub    $0x40,%rsp
mov    %rdi,%rbx
fldt   0x60(%rsp)
fld    %st(0)
fstpt  0x28(%rsp)
fldt   0x50(%rsp)
fld    %st(0)
fstpt  0x34(%rsp)
fdivp  %st,%st(1)
fld    %st(0)
fstpt  0x10(%rsp)
fstpt  (%rsp)
call   1050 <truncl@plt>
fldt   0x10(%rsp)
fld    %st(1)
fsub   %st(1),%st
fabs
flds   0xe94(%rip)
fxch   %st(1)
fucomip %st(1),%st
fstp   %st(0)
fld1
fadd   %st(2),%st
fcmovb %st(2),%st
fstp   %st(2)
fxch   %st(1)
fstpt  0x1c(%rsp)
fstpt  (%rsp)
call   1040 <roundl@plt>
mov    %eax,%edi
call   1030 <__irmodl@plt>
mov    %eax,(%rbx)
fldt   0x28(%rsp)
fldt   0x1c(%rsp)
fmulp  %st,%st(1)
fldt   0x34(%rsp)
fsubp  %st,%st(1)
add    $0x40,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define x86_fp80 @remquol(x86_fp80 %0, x86_fp80 %1, i32* %2) {
%4 = alloca x86_fp80
%5 = alloca x86_fp80
%6 = alloca i32*
%7 = alloca x86_fp80
%8 = alloca x86_fp80
store x86_fp80 %0, x86_fp80* %4
store x86_fp80 %1, x86_fp80* %5
store i32* %2, i32** %6
%9 = load x86_fp80, x86_fp80* %4
%10 = load x86_fp80, x86_fp80* %5
%11 = fdiv x86_fp80 %9, %10
store x86_fp80 %11, x86_fp80* %7
%12 = load x86_fp80, x86_fp80* %7
%13 = call x86_fp80 @llvm.trunc.f80(x86_fp80 %12)
store x86_fp80 %13, x86_fp80* %8
%14 = load x86_fp80, x86_fp80* %8
%15 = load x86_fp80, x86_fp80* %7
%16 = fsub x86_fp80 %14, %15
%17 = call x86_fp80 @llvm.fabs.f80(x86_fp80 %16)
%18 = fcmp oge x86_fp80 %17, 0xK3FFE8000000000000000
br i1 %18, label %19, label %22
19: ; preds = %3
%20 = load x86_fp80, x86_fp80* %8
%21 = fadd x86_fp80 %20, 0xK3FFF8000000000000000
store x86_fp80 %21, x86_fp80* %8
br label %22
22: ; preds = %19, %3
%23 = load x86_fp80, x86_fp80* %7
%24 = call i32 @roundl(x86_fp80 %23)
%25 = call i32 @__irmodl(i32 %24)
%26 = load i32*, i32** %6
store i32 %25, i32* %26
%27 = load x86_fp80, x86_fp80* %4
%28 = load x86_fp80, x86_fp80* %8
%29 = load x86_fp80, x86_fp80* %5
%30 = fneg x86_fp80 %28
%31 = call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %30, x86_fp80 %29, x86_fp80 %27)
ret x86_fp80 %31
}

LLVM IR (-O2):
define x86_fp80 @remquol(x86_fp80 %0, x86_fp80 %1, i32* nocapture writeonly %2) {
%4 = fdiv x86_fp80 %0, %1
%5 = tail call x86_fp80 @llvm.trunc.f80(x86_fp80 %4)
%6 = fsub x86_fp80 %5, %4
%7 = tail call x86_fp80 @llvm.fabs.f80(x86_fp80 %6)
%8 = fcmp ult x86_fp80 %7, 0xK3FFE8000000000000000
%9 = fadd x86_fp80 %5, 0xK3FFF8000000000000000
%10 = select i1 %8, x86_fp80 %5, x86_fp80 %9
%11 = tail call i32 @roundl(x86_fp80 %4)
%12 = tail call i32 @__irmodl(i32 %11)
store i32 %12, i32* %2
%13 = fneg x86_fp80 %10
%14 = tail call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %13, x86_fp80 %1, x86_fp80 %0)
ret x86_fp80 %14
}