#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 */
scalar_t__ copysignl(double, long double volatile);
int /*<<< orphan*/ printf(char *, char const *);
long double remainderl(long double, long double);
int test_func(const char *s, long double x, long double y,
              long double expected) {
  volatile long double r;
  r = remainderl(x, y);
  if (r != expected || copysignl(1.0, r) != copysignl(1.0, expected)) {
    printf("FAIL: "
           "remainderl"
           " (%s)\n",
           s);
    return 1;
  } else {
    printf("PASS: "
           "remainderl"
           " (%s)\n",
           s);
    return 0;
  }
}


x86 assembly (clang, -O0):
<test_func>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
fldt   0x30(%rbp)
fldt   0x20(%rbp)
fldt   0x10(%rbp)
mov    %rdi,-0x10(%rbp)
fstpt  -0x20(%rbp)
fstpt  -0x30(%rbp)
fstpt  -0x40(%rbp)
fldt   -0x20(%rbp)
fldt   -0x30(%rbp)
mov    %rsp,%rax
fstpt  0x10(%rax)
fstpt  (%rax)
call   1050 <remainderl@plt>
fstpt  -0x50(%rbp)
fldt   -0x50(%rbp)
fldt   -0x40(%rbp)
fxch   %st(1)
fucomip %st(1),%st
fstp   %st(0)
jne    11c2 <test_func+0x92>
jp     11c2 <test_func+0x92>
jmp    1184 <test_func+0x54>
fldt   -0x50(%rbp)
mov    %rsp,%rax
fstpt  (%rax)
movsd  0xe6c(%rip),%xmm0
call   1040 <copysignl@plt>
mov    %rax,-0x58(%rbp)
fldt   -0x40(%rbp)
mov    %rsp,%rax
fstpt  (%rax)
movsd  0xe53(%rip),%xmm0
call   1040 <copysignl@plt>
mov    %rax,%rcx
mov    -0x58(%rbp),%rax
cmp    %rcx,%rax
je     11de <test_func+0xae>
mov    -0x10(%rbp),%rsi
lea    0xe3b(%rip),%rdi
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11f5 <test_func+0xc5>
mov    -0x10(%rbp),%rsi
lea    0xe36(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_func>:
push   %rbp
push   %r14
push   %rbx
sub    $0x40,%rsp
mov    %rdi,%rbx
fldt   0x80(%rsp)
fstpt  0x24(%rsp)
fldt   0x60(%rsp)
fldt   0x70(%rsp)
fstpt  0x10(%rsp)
fstpt  (%rsp)
call   1050 <remainderl@plt>
fstpt  0x30(%rsp)
fldt   0x30(%rsp)
fldt   0x24(%rsp)
fxch   %st(1)
fucomip %st(1),%st
fstp   %st(0)
jne    1170 <test_func+0x40>
jnp    117e <test_func+0x4e>
mov    $0x1,%ebp
lea    0xe8c(%rip),%rdi
jmp    11c4 <test_func+0x94>
fldt   0x30(%rsp)
fstpt  (%rsp)
movsd  0xe73(%rip),%xmm0
call   1040 <copysignl@plt>
mov    %rax,%r14
fldt   0x24(%rsp)
fstpt  (%rsp)
movsd  0xe5c(%rip),%xmm0
call   1040 <copysignl@plt>
xor    %ebp,%ebp
cmp    %rax,%r14
setne  %bpl
lea    0xe66(%rip),%rax
lea    0xe48(%rip),%rdi
cmove  %rax,%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
mov    %ebp,%eax
add    $0x40,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [23 x i8] c"FAIL: remainderl (%s)\0A\00"
@.str.1 = [23 x i8] c"PASS: remainderl (%s)\0A\00"
define i32 @test_func(i8* %0, x86_fp80 %1, x86_fp80 %2, x86_fp80 %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca x86_fp80
%8 = alloca x86_fp80
%9 = alloca x86_fp80
%10 = alloca x86_fp80
store i8* %0, i8** %6
store x86_fp80 %1, x86_fp80* %7
store x86_fp80 %2, x86_fp80* %8
store x86_fp80 %3, x86_fp80* %9
%11 = load x86_fp80, x86_fp80* %7
%12 = load x86_fp80, x86_fp80* %8
%13 = call x86_fp80 @remainderl(x86_fp80 %11, x86_fp80 %12)
store volatile x86_fp80 %13, x86_fp80* %10
%14 = load volatile x86_fp80, x86_fp80* %10
%15 = load x86_fp80, x86_fp80* %9
%16 = fcmp une x86_fp80 %14, %15
br i1 %16, label %23, label %17
17: ; preds = %4
%18 = load volatile x86_fp80, x86_fp80* %10
%19 = call i64 @copysignl(double 1.000000e+00, x86_fp80 %18)
%20 = load x86_fp80, x86_fp80* %9
%21 = call i64 @copysignl(double 1.000000e+00, x86_fp80 %20)
%22 = icmp ne i64 %19, %21
br i1 %22, label %23, label %26
23: ; preds = %17, %4
%24 = load i8*, i8** %6
%25 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %24)
store i32 1, i32* %5
br label %29
26: ; preds = %17
%27 = load i8*, i8** %6
%28 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* %27)
store i32 0, i32* %5
br label %29
29: ; preds = %26, %23
%30 = load i32, i32* %5
ret i32 %30
}

LLVM IR (-O2):
@.str = [23 x i8] c"FAIL: remainderl (%s)\0A\00"
@.str.1 = [23 x i8] c"PASS: remainderl (%s)\0A\00"
define i32 @test_func(i8* %0, x86_fp80 %1, x86_fp80 %2, x86_fp80 %3) {
%5 = alloca x86_fp80
%6 = bitcast x86_fp80* %5 to i8*
%7 = tail call x86_fp80 @remainderl(x86_fp80 %1, x86_fp80 %2)
store volatile x86_fp80 %7, x86_fp80* %5
%8 = load volatile x86_fp80, x86_fp80* %5
%9 = fcmp une x86_fp80 %8, %3
br i1 %9, label %18, label %10
10: ; preds = %4
%11 = load volatile x86_fp80, x86_fp80* %5
%12 = tail call i64 @copysignl(double 1.000000e+00, x86_fp80 %11)
%13 = tail call i64 @copysignl(double 1.000000e+00, x86_fp80 %3)
%14 = icmp eq i64 %12, %13
%15 = select i1 %14, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0)
%16 = xor i1 %14, true
%17 = zext i1 %16 to i32
br label %18
18: ; preds = %10, %4
%19 = phi i8* [ getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), %4 ], [ %15, %10 ]
%20 = phi i32 [ 1, %4 ], [ %17, %10 ]
%21 = tail call i32 @printf(i8* %19, i8* %0)
ret i32 %20
}