#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 */
long double floor(long double);
long double fmodl(long double x, long double y) {
  if (y == 0.0)
    return x;
  double m = x - y * floor(x / y);
  if (y > 0.0) {
    if (m >= y)
      return 0.0;
    if (m < 0.0) {
      if ((y + m) == y)
        return 0.0;
      else
        return y + m;
    }
  } else {
    if (m <= y)
      return 0.0;
    if (m > 0.0) {
      if ((y + m) == y)
        return 0.0;
      else
        return y + m;
    }
  }
  return m;
}


x86 assembly (clang, -O0):
<fmodl>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
fldt   0x20(%rbp)
fldt   0x10(%rbp)
fstpt  -0x20(%rbp)
fstpt  -0x30(%rbp)
fldt   -0x30(%rbp)
fldz
fxch   %st(1)
fucomip %st(1),%st
fstp   %st(0)
jne    114b <fmodl+0x3b>
jp     114b <fmodl+0x3b>
jmp    1140 <fmodl+0x30>
fldt   -0x20(%rbp)
fstpt  -0x10(%rbp)
jmp    126a <fmodl+0x15a>
fldt   -0x20(%rbp)
fld    %st(0)
fstpt  -0x44(%rbp)
fldt   -0x30(%rbp)
fld    %st(0)
fstpt  -0x50(%rbp)
fdivrp %st,%st(1)
mov    %rsp,%rax
fstpt  (%rax)
call   1030 <floor@plt>
fldt   -0x50(%rbp)
fldt   -0x44(%rbp)
fxch   %st(1)
fmulp  %st,%st(2)
fsubp  %st,%st(1)
fstpl  -0x38(%rbp)
fldt   -0x30(%rbp)
fldz
fxch   %st(1)
fucomip %st(1),%st
fstp   %st(0)
jbe    11f7 <fmodl+0xe7>
jmp    118c <fmodl+0x7c>
fldl   -0x38(%rbp)
fldt   -0x30(%rbp)
fxch   %st(1)
fucomip %st(1),%st
fstp   %st(0)
jb     11ad <fmodl+0x9d>
jmp    11a3 <fmodl+0x93>
fldz
fstpt  -0x10(%rbp)
jmp    126a <fmodl+0x15a>
xorps  %xmm0,%xmm0
ucomisd -0x38(%rbp),%xmm0
jbe    11f2 <fmodl+0xe2>
fldt   -0x30(%rbp)
fldl   -0x38(%rbp)
fadd   %st(1),%st
fucomip %st(1),%st
fstp   %st(0)
jne    11e2 <fmodl+0xd2>
jp     11e2 <fmodl+0xd2>
jmp    11d8 <fmodl+0xc8>
fldz
fstpt  -0x10(%rbp)
jmp    126a <fmodl+0x15a>
fldt   -0x30(%rbp)
fldl   -0x38(%rbp)
faddp  %st,%st(1)
fstpt  -0x10(%rbp)
jmp    126a <fmodl+0x15a>
jmp    1264 <fmodl+0x154>
fldl   -0x38(%rbp)
fldt   -0x30(%rbp)
fucomip %st(1),%st
fstp   %st(0)
jb     1216 <fmodl+0x106>
jmp    120c <fmodl+0xfc>
fldz
fstpt  -0x10(%rbp)
jmp    126a <fmodl+0x15a>
movsd  -0x38(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    125f <fmodl+0x14f>
fldt   -0x30(%rbp)
fldl   -0x38(%rbp)
fadd   %st(1),%st
fucomip %st(1),%st
fstp   %st(0)
jne    124f <fmodl+0x13f>
jp     124f <fmodl+0x13f>
jmp    1245 <fmodl+0x135>
fldz
fstpt  -0x10(%rbp)
jmp    126a <fmodl+0x15a>
fldt   -0x30(%rbp)
fldl   -0x38(%rbp)
faddp  %st,%st(1)
fstpt  -0x10(%rbp)
jmp    126a <fmodl+0x15a>
jmp    1264 <fmodl+0x154>
fldl   -0x38(%rbp)
fstpt  -0x10(%rbp)
fldt   -0x10(%rbp)
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fmodl>:
sub    $0x48,%rsp
fldt   0x60(%rsp)
fldt   0x50(%rsp)
fldz
fxch   %st(2)
fucomi %st(2),%st
jne    1137 <fmodl+0x27>
jp     1137 <fmodl+0x27>
fstp   %st(2)
fstp   %st(1)
fldz
fldz
fstp   %st(1)
fstp   %st(0)
add    $0x48,%rsp
ret
fld    %st(1)
fstpt  0x24(%rsp)
fdivr  %st,%st(1)
fxch   %st(1)
fstpt  (%rsp)
fxch   %st(1)
fstpt  0x3c(%rsp)
fstpt  0x30(%rsp)
call   1030 <floorl@plt>
fldt   0x30(%rsp)
fldt   0x3c(%rsp)
fxch   %st(2)
fmul   %st(1),%st
fldt   0x24(%rsp)
fsubp  %st,%st(1)
fstpl  0x18(%rsp)
movsd  0x18(%rsp),%xmm0
fucomi %st(1),%st
movsd  %xmm0,0x10(%rsp)
fldl   0x10(%rsp)
jbe    1191 <fmodl+0x81>
fucomi %st(1),%st
fxch   %st(1)
jae    112e <fmodl+0x1e>
fstp   %st(2)
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
jbe    1128 <fmodl+0x18>
jmp    11a3 <fmodl+0x93>
fxch   %st(1)
fucomi %st(1),%st
jae    112e <fmodl+0x1e>
fstp   %st(2)
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    1128 <fmodl+0x18>
fadd   %st(1),%st
fucomi %st(1),%st
fstp   %st(1)
fldz
fcmovne %st(1),%st
fcmovu %st(1),%st
jmp    1128 <fmodl+0x18>

LLVM IR (-O0):
define x86_fp80 @fmodl(x86_fp80 %0, x86_fp80 %1) {
%3 = alloca x86_fp80
%4 = alloca x86_fp80
%5 = alloca x86_fp80
%6 = alloca double
store x86_fp80 %0, x86_fp80* %4
store x86_fp80 %1, x86_fp80* %5
%7 = load x86_fp80, x86_fp80* %5
%8 = fcmp oeq x86_fp80 %7, 0xK00000000000000000000
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = load x86_fp80, x86_fp80* %4
store x86_fp80 %10, x86_fp80* %3
br label %72
11: ; preds = %2
%12 = load x86_fp80, x86_fp80* %4
%13 = load x86_fp80, x86_fp80* %5
%14 = load x86_fp80, x86_fp80* %4
%15 = load x86_fp80, x86_fp80* %5
%16 = fdiv x86_fp80 %14, %15
%17 = call x86_fp80 @floor(x86_fp80 %16)
%18 = fneg x86_fp80 %13
%19 = call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %18, x86_fp80 %17, x86_fp80 %12)
%20 = fptrunc x86_fp80 %19 to double
store double %20, double* %6
%21 = load x86_fp80, x86_fp80* %5
%22 = fcmp ogt x86_fp80 %21, 0xK00000000000000000000
br i1 %22, label %23, label %46
23: ; preds = %11
%24 = load double, double* %6
%25 = fpext double %24 to x86_fp80
%26 = load x86_fp80, x86_fp80* %5
%27 = fcmp oge x86_fp80 %25, %26
br i1 %27, label %28, label %29
28: ; preds = %23
store x86_fp80 0xK00000000000000000000, x86_fp80* %3
br label %72
29: ; preds = %23
%30 = load double, double* %6
%31 = fcmp olt double %30, 0.000000e+00
br i1 %31, label %32, label %45
32: ; preds = %29
%33 = load x86_fp80, x86_fp80* %5
%34 = load double, double* %6
%35 = fpext double %34 to x86_fp80
%36 = fadd x86_fp80 %33, %35
%37 = load x86_fp80, x86_fp80* %5
%38 = fcmp oeq x86_fp80 %36, %37
br i1 %38, label %39, label %40
39: ; preds = %32
store x86_fp80 0xK00000000000000000000, x86_fp80* %3
br label %72
40: ; preds = %32
%41 = load x86_fp80, x86_fp80* %5
%42 = load double, double* %6
%43 = fpext double %42 to x86_fp80
%44 = fadd x86_fp80 %41, %43
store x86_fp80 %44, x86_fp80* %3
br label %72
45: ; preds = %29
br label %69
46: ; preds = %11
%47 = load double, double* %6
%48 = fpext double %47 to x86_fp80
%49 = load x86_fp80, x86_fp80* %5
%50 = fcmp ole x86_fp80 %48, %49
br i1 %50, label %51, label %52
51: ; preds = %46
store x86_fp80 0xK00000000000000000000, x86_fp80* %3
br label %72
52: ; preds = %46
%53 = load double, double* %6
%54 = fcmp ogt double %53, 0.000000e+00
br i1 %54, label %55, label %68
55: ; preds = %52
%56 = load x86_fp80, x86_fp80* %5
%57 = load double, double* %6
%58 = fpext double %57 to x86_fp80
%59 = fadd x86_fp80 %56, %58
%60 = load x86_fp80, x86_fp80* %5
%61 = fcmp oeq x86_fp80 %59, %60
br i1 %61, label %62, label %63
62: ; preds = %55
store x86_fp80 0xK00000000000000000000, x86_fp80* %3
br label %72
63: ; preds = %55
%64 = load x86_fp80, x86_fp80* %5
%65 = load double, double* %6
%66 = fpext double %65 to x86_fp80
%67 = fadd x86_fp80 %64, %66
store x86_fp80 %67, x86_fp80* %3
br label %72
68: ; preds = %52
br label %69
69: ; preds = %68, %45
%70 = load double, double* %6
%71 = fpext double %70 to x86_fp80
store x86_fp80 %71, x86_fp80* %3
br label %72
72: ; preds = %69, %63, %62, %51, %40, %39, %28, %9
%73 = load x86_fp80, x86_fp80* %3
ret x86_fp80 %73
}

LLVM IR (-O2):
define x86_fp80 @fmodl(x86_fp80 %0, x86_fp80 %1) {
%3 = fcmp oeq x86_fp80 %1, 0xK00000000000000000000
br i1 %3, label %28, label %4
4: ; preds = %2
%5 = fdiv x86_fp80 %0, %1
%6 = tail call x86_fp80 @llvm.floor.f80(x86_fp80 %5)
%7 = fneg x86_fp80 %1
%8 = tail call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %7, x86_fp80 %6, x86_fp80 %0)
%9 = fptrunc x86_fp80 %8 to double
%10 = fcmp ogt x86_fp80 %1, 0xK00000000000000000000
%11 = fpext double %9 to x86_fp80
br i1 %10, label %12, label %20
12: ; preds = %4
%13 = fcmp ult x86_fp80 %11, %1
br i1 %13, label %14, label %28
14: ; preds = %12
%15 = fcmp olt double %9, 0.000000e+00
br i1 %15, label %16, label %28
16: ; preds = %14
%17 = fadd x86_fp80 %11, %1
%18 = fcmp oeq x86_fp80 %17, %1
%19 = select i1 %18, x86_fp80 0xK00000000000000000000, x86_fp80 %17
br label %28
20: ; preds = %4
%21 = fcmp ugt x86_fp80 %11, %1
br i1 %21, label %22, label %28
22: ; preds = %20
%23 = fcmp ogt double %9, 0.000000e+00
br i1 %23, label %24, label %28
24: ; preds = %22
%25 = fadd x86_fp80 %11, %1
%26 = fcmp oeq x86_fp80 %25, %1
%27 = select i1 %26, x86_fp80 0xK00000000000000000000, x86_fp80 %25
br label %28
28: ; preds = %14, %22, %12, %16, %20, %24, %2
%29 = phi x86_fp80 [ %0, %2 ], [ 0xK00000000000000000000, %12 ], [ %19, %16 ], [ 0xK00000000000000000000, %20 ], [ %27, %24 ], [ %11, %22 ], [ %11, %14 ]
ret x86_fp80 %29
}