#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 /*<<< orphan*/ EDOM;
int FP_INFINITE;
int FP_NAN;
int FP_ZERO;
double NAN;
int /*<<< orphan*/ errno;
int fpclassify(double);
int /*<<< orphan*/ fpu_remainder(double *, double);
double remainder(double x, double y) {
  int xclass, yclass;
  xclass = fpclassify(x);
  yclass = fpclassify(y);
  if (xclass == FP_NAN || yclass == FP_NAN)
    return NAN;
  if (xclass == FP_INFINITE || yclass == FP_ZERO) {
    errno = EDOM;
    return NAN;
  }
  fpu_remainder(&x, y);
  return x;
}


x86 assembly (clang, -O0):
<remainder>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1030 <fpclassify@plt>
mov    %eax,-0x1c(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1030 <fpclassify@plt>
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%eax
mov    0x2e8a(%rip),%rcx
cmp    (%rcx),%eax
je     1170 <remainder+0x50>
mov    -0x20(%rbp),%eax
mov    0x2e78(%rip),%rcx
cmp    (%rcx),%eax
jne    1185 <remainder+0x65>
mov    0x2e81(%rip),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11e8 <remainder+0xc8>
mov    -0x1c(%rbp),%eax
mov    0x2e49(%rip),%rcx
cmp    (%rcx),%eax
je     11a9 <remainder+0x89>
mov    -0x20(%rbp),%eax
mov    0x2e27(%rip),%rcx
cmp    (%rcx),%eax
jne    11d0 <remainder+0xb0>
mov    0x2e20(%rip),%rax
mov    (%rax),%ecx
mov    0x2dff(%rip),%rax
mov    %ecx,(%rax)
mov    0x2e36(%rip),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11e8 <remainder+0xc8>
movsd  -0x18(%rbp),%xmm0
lea    -0x10(%rbp),%rdi
call   1040 <fpu_remainder@plt>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<remainder>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
movsd  %xmm1,0x8(%rsp)
movsd  %xmm0,0x10(%rsp)
call   1030 <fpclassify@plt>
mov    %eax,%ebp
movsd  0x8(%rsp),%xmm0
call   1030 <fpclassify@plt>
mov    0x2e95(%rip),%rcx
mov    (%rcx),%ecx
mov    0x2ea4(%rip),%rbx
cmp    %ecx,%ebp
je     1199 <remainder+0x79>
cmp    %ecx,%eax
je     1199 <remainder+0x79>
mov    0x2e75(%rip),%rcx
cmp    (%rcx),%ebp
je     1187 <remainder+0x67>
mov    0x2e5a(%rip),%rcx
cmp    (%rcx),%eax
je     1187 <remainder+0x67>
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
movsd  0x8(%rsp),%xmm0
call   1040 <fpu_remainder@plt>
jmp    1199 <remainder+0x79>
mov    0x2e42(%rip),%rax
mov    (%rax),%eax
mov    0x2e21(%rip),%rcx
mov    %eax,(%rcx)
movsd  (%rbx),%xmm0
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@FP_NAN = global i32 0
@NAN = global double 0.000000e+00
@FP_INFINITE = global i32 0
@FP_ZERO = global i32 0
@EDOM = global i32 0
@errno = global i32 0
define double @remainder(double %0, double %1) {
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca i32
%7 = alloca i32
store double %0, double* %4
store double %1, double* %5
%8 = load double, double* %4
%9 = call i32 @fpclassify(double %8)
store i32 %9, i32* %6
%10 = load double, double* %5
%11 = call i32 @fpclassify(double %10)
store i32 %11, i32* %7
%12 = load i32, i32* %6
%13 = load i32, i32* @FP_NAN
%14 = icmp eq i32 %12, %13
br i1 %14, label %19, label %15
15: ; preds = %2
%16 = load i32, i32* %7
%17 = load i32, i32* @FP_NAN
%18 = icmp eq i32 %16, %17
br i1 %18, label %19, label %21
19: ; preds = %15, %2
%20 = load double, double* @NAN
store double %20, double* %3
br label %36
21: ; preds = %15
%22 = load i32, i32* %6
%23 = load i32, i32* @FP_INFINITE
%24 = icmp eq i32 %22, %23
br i1 %24, label %29, label %25
25: ; preds = %21
%26 = load i32, i32* %7
%27 = load i32, i32* @FP_ZERO
%28 = icmp eq i32 %26, %27
br i1 %28, label %29, label %32
29: ; preds = %25, %21
%30 = load i32, i32* @EDOM
store i32 %30, i32* @errno
%31 = load double, double* @NAN
store double %31, double* %3
br label %36
32: ; preds = %25
%33 = load double, double* %5
%34 = call i32 @fpu_remainder(double* %4, double %33)
%35 = load double, double* %4
store double %35, double* %3
br label %36
36: ; preds = %32, %29, %19
%37 = load double, double* %3
ret double %37
}

LLVM IR (-O2):
@FP_NAN = global i32 0
@NAN = global double 0.000000e+00
@FP_INFINITE = global i32 0
@FP_ZERO = global i32 0
@EDOM = global i32 0
@errno = global i32 0
define double @remainder(double %0, double %1) {
%3 = alloca double
store double %0, double* %3
%4 = tail call i32 @fpclassify(double %0)
%5 = tail call i32 @fpclassify(double %1)
%6 = load i32, i32* @FP_NAN
%7 = icmp eq i32 %4, %6
%8 = icmp eq i32 %5, %6
%9 = select i1 %7, i1 true, i1 %8
br i1 %9, label %20, label %10
10: ; preds = %2
%11 = load i32, i32* @FP_INFINITE
%12 = icmp eq i32 %4, %11
%13 = load i32, i32* @FP_ZERO
%14 = icmp eq i32 %5, %13
%15 = select i1 %12, i1 true, i1 %14
br i1 %15, label %16, label %18
16: ; preds = %10
%17 = load i32, i32* @EDOM
store i32 %17, i32* @errno
br label %20
18: ; preds = %10
%19 = call i32 @fpu_remainder(double* %3, double %1)
br label %20
20: ; preds = %2, %18, %16
%21 = phi double* [ @NAN, %16 ], [ %3, %18 ], [ @NAN, %2 ]
%22 = load double, double* %21
ret double %22
}