#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 */
double NAN;
scalar_t__ isinf(double);
scalar_t__ isnan(double);
double round_toward_zero(double);
double our_fmod(double x, double y) {
  double n, r;
  if (isnan(x)) {
    return x;
  }
  if (isnan(y)) {
    return y;
  }
  if (isinf(x) || y == 0.0) {
    return NAN;
  }
  if (x == 0.0 && y != 0.0) {
    return x;
  }
  n = round_toward_zero(x / y);
  r = x - (n * y);
  return r;
}


x86 assembly (clang, -O0):
<our_fmod>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1040 <isnan@plt>
cmp    $0x0,%rax
je     1165 <our_fmod+0x35>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    125e <our_fmod+0x12e>
movsd  -0x18(%rbp),%xmm0
call   1040 <isnan@plt>
cmp    $0x0,%rax
je     1188 <our_fmod+0x58>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    125e <our_fmod+0x12e>
movsd  -0x10(%rbp),%xmm0
call   1050 <isinf@plt>
cmp    $0x0,%rax
jne    11b4 <our_fmod+0x84>
movsd  -0x18(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    11c9 <our_fmod+0x99>
jp     11c9 <our_fmod+0x99>
mov    0x2e3d(%rip),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    125e <our_fmod+0x12e>
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    120d <our_fmod+0xdd>
jp     120d <our_fmod+0xdd>
movsd  -0x18(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    11fe <our_fmod+0xce>
jp     11fe <our_fmod+0xce>
jmp    120d <our_fmod+0xdd>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    125e <our_fmod+0x12e>
movsd  -0x10(%rbp),%xmm0
divsd  -0x18(%rbp),%xmm0
call   1030 <round_toward_zero@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<our_fmod>:
sub    $0x18,%rsp
movsd  %xmm1,0x8(%rsp)
movsd  %xmm0,0x10(%rsp)
call   1040 <isnan@plt>
test   %rax,%rax
je     1155 <our_fmod+0x25>
movsd  0x10(%rsp),%xmm0
add    $0x18,%rsp
ret
movsd  0x8(%rsp),%xmm0
call   1040 <isnan@plt>
test   %rax,%rax
je     1170 <our_fmod+0x40>
movsd  0x8(%rsp),%xmm0
add    $0x18,%rsp
ret
movsd  0x10(%rsp),%xmm0
call   1050 <isinf@plt>
xorpd  %xmm0,%xmm0
movsd  0x8(%rsp),%xmm2
ucomisd %xmm0,%xmm2
jne    118d <our_fmod+0x5d>
jnp    11ca <our_fmod+0x9a>
test   %rax,%rax
jne    11ca <our_fmod+0x9a>
xorpd  %xmm0,%xmm0
movsd  0x10(%rsp),%xmm1
ucomisd %xmm0,%xmm1
movapd %xmm1,%xmm0
jne    11a8 <our_fmod+0x78>
jnp    11c5 <our_fmod+0x95>
divsd  %xmm2,%xmm0
call   1030 <round_toward_zero@plt>
mulsd  0x8(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
subsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
add    $0x18,%rsp
ret
mov    0x2e27(%rip),%rax
movsd  (%rax),%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
@NAN = global double 0.000000e+00
define double @our_fmod(double %0, double %1) {
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
store double %0, double* %4
store double %1, double* %5
%8 = load double, double* %4
%9 = call i64 @isnan(double %8)
%10 = icmp ne i64 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %2
%12 = load double, double* %4
store double %12, double* %3
br label %47
13: ; preds = %2
%14 = load double, double* %5
%15 = call i64 @isnan(double %14)
%16 = icmp ne i64 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %13
%18 = load double, double* %5
store double %18, double* %3
br label %47
19: ; preds = %13
%20 = load double, double* %4
%21 = call i64 @isinf(double %20)
%22 = icmp ne i64 %21, 0
br i1 %22, label %26, label %23
23: ; preds = %19
%24 = load double, double* %5
%25 = fcmp oeq double %24, 0.000000e+00
br i1 %25, label %26, label %28
26: ; preds = %23, %19
%27 = load double, double* @NAN
store double %27, double* %3
br label %47
28: ; preds = %23
%29 = load double, double* %4
%30 = fcmp oeq double %29, 0.000000e+00
br i1 %30, label %31, label %36
31: ; preds = %28
%32 = load double, double* %5
%33 = fcmp une double %32, 0.000000e+00
br i1 %33, label %34, label %36
34: ; preds = %31
%35 = load double, double* %4
store double %35, double* %3
br label %47
36: ; preds = %31, %28
%37 = load double, double* %4
%38 = load double, double* %5
%39 = fdiv double %37, %38
%40 = call double @round_toward_zero(double %39)
store double %40, double* %6
%41 = load double, double* %4
%42 = load double, double* %6
%43 = load double, double* %5
%44 = fneg double %42
%45 = call double @llvm.fmuladd.f64(double %44, double %43, double %41)
store double %45, double* %7
%46 = load double, double* %7
store double %46, double* %3
br label %47
47: ; preds = %36, %34, %26, %17, %11
%48 = load double, double* %3
ret double %48
}

LLVM IR (-O2):
@NAN = global double 0.000000e+00
define double @our_fmod(double %0, double %1) {
%3 = tail call i64 @isnan(double %0)
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %22
5: ; preds = %2
%6 = tail call i64 @isnan(double %1)
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %22
8: ; preds = %5
%9 = tail call i64 @isinf(double %0)
%10 = icmp ne i64 %9, 0
%11 = fcmp oeq double %1, 0.000000e+00
%12 = or i1 %11, %10
br i1 %12, label %13, label %15
13: ; preds = %8
%14 = load double, double* @NAN
br label %22
15: ; preds = %8
%16 = fcmp oeq double %0, 0.000000e+00
br i1 %16, label %22, label %17
17: ; preds = %15
%18 = fdiv double %0, %1
%19 = tail call double @round_toward_zero(double %18)
%20 = fneg double %19
%21 = tail call double @llvm.fmuladd.f64(double %20, double %1, double %0)
br label %22
22: ; preds = %15, %5, %2, %17, %13
%23 = phi double [ %14, %13 ], [ %21, %17 ], [ %0, %2 ], [ %1, %5 ], [ %0, %15 ]
ret double %23
}