#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__ fpequal(double, double);
int /*<<< orphan*/ test1(char *, int, int /*<<< orphan*/);
void run_zero_opt_test(double d1, double d2) {
  test1(("optimizations don't break the sign of 0"),
        (fpequal(d1 - d2, 0.0) && fpequal(-d1 + 0.0, 0.0) &&
         fpequal(-d1 - d2, -0.0) && fpequal(-(d1 - d2), -0.0) &&
         fpequal(-d1 - (-d2), 0.0)),
        0);
}


x86 assembly (clang, -O0):
<run_zero_opt_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  -0x8(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
call   1030 <fpequal@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x11(%rbp)
je     1261 <run_zero_opt_test+0x141>
movsd  -0x8(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
xorps  %xmm1,%xmm1
addsd  %xmm1,%xmm0
xorps  %xmm1,%xmm1
call   1030 <fpequal@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x11(%rbp)
je     1261 <run_zero_opt_test+0x141>
movsd  -0x8(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
subsd  -0x10(%rbp),%xmm0
movsd  0xe44(%rip),%xmm1
call   1030 <fpequal@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x11(%rbp)
je     1261 <run_zero_opt_test+0x141>
movsd  -0x8(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  0xe04(%rip),%xmm1
call   1030 <fpequal@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x11(%rbp)
je     1261 <run_zero_opt_test+0x141>
movsd  -0x8(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  -0x10(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
subsd  %xmm1,%xmm0
xorps  %xmm1,%xmm1
call   1030 <fpequal@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
and    $0x1,%al
movzbl %al,%esi
lea    0xd98(%rip),%rdi
xor    %edx,%edx
call   1040 <test1@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<run_zero_opt_test>:
push   %rbx
sub    $0x30,%rsp
movapd %xmm0,0x10(%rsp)
movsd  %xmm1,0x8(%rsp)
subsd  %xmm1,%xmm0
xorpd  %xmm1,%xmm1
movapd %xmm0,0x20(%rsp)
call   1030 <fpequal@plt>
xor    %ebx,%ebx
test   %rax,%rax
je     11c6 <run_zero_opt_test+0xa6>
xorpd  %xmm0,%xmm0
subsd  0x10(%rsp),%xmm0
xorpd  %xmm1,%xmm1
call   1030 <fpequal@plt>
test   %rax,%rax
je     11c6 <run_zero_opt_test+0xa6>
movapd 0xe95(%rip),%xmm0
xorpd  0x10(%rsp),%xmm0
subsd  0x8(%rsp),%xmm0
movsd  0xe91(%rip),%xmm1
call   1030 <fpequal@plt>
test   %rax,%rax
je     11c6 <run_zero_opt_test+0xa6>
movapd 0x20(%rsp),%xmm0
xorpd  0xe69(%rip),%xmm0
movsd  0xe71(%rip),%xmm1
call   1030 <fpequal@plt>
test   %rax,%rax
je     11c6 <run_zero_opt_test+0xa6>
movsd  0x8(%rsp),%xmm0
subsd  0x10(%rsp),%xmm0
xorpd  %xmm1,%xmm1
call   1030 <fpequal@plt>
xor    %ebx,%ebx
test   %rax,%rax
setne  %bl
lea    0xe4b(%rip),%rdi
mov    %ebx,%esi
xor    %edx,%edx
add    $0x30,%rsp
pop    %rbx
jmp    1040 <test1@plt>

LLVM IR (-O0):
@.str = [40 x i8] c"optimizations don't break the sign of 0\00"
define void @run_zero_opt_test(double %0, double %1) {
%3 = alloca double
%4 = alloca double
store double %0, double* %3
store double %1, double* %4
%5 = load double, double* %3
%6 = load double, double* %4
%7 = fsub double %5, %6
%8 = call i64 @fpequal(double %7, double 0.000000e+00)
%9 = icmp ne i64 %8, 0
br i1 %9, label %10, label %38
10: ; preds = %2
%11 = load double, double* %3
%12 = fneg double %11
%13 = fadd double %12, 0.000000e+00
%14 = call i64 @fpequal(double %13, double 0.000000e+00)
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %38
16: ; preds = %10
%17 = load double, double* %3
%18 = fneg double %17
%19 = load double, double* %4
%20 = fsub double %18, %19
%21 = call i64 @fpequal(double %20, double -0.000000e+00)
%22 = icmp ne i64 %21, 0
br i1 %22, label %23, label %38
23: ; preds = %16
%24 = load double, double* %3
%25 = load double, double* %4
%26 = fsub double %24, %25
%27 = fneg double %26
%28 = call i64 @fpequal(double %27, double -0.000000e+00)
%29 = icmp ne i64 %28, 0
br i1 %29, label %30, label %38
30: ; preds = %23
%31 = load double, double* %3
%32 = fneg double %31
%33 = load double, double* %4
%34 = fneg double %33
%35 = fsub double %32, %34
%36 = call i64 @fpequal(double %35, double 0.000000e+00)
%37 = icmp ne i64 %36, 0
br label %38
38: ; preds = %30, %23, %16, %10, %2
%39 = phi i1 [ false, %23 ], [ false, %16 ], [ false, %10 ], [ false, %2 ], [ %37, %30 ]
%40 = zext i1 %39 to i32
%41 = call i32 @test1(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), i32 %40, i32 0)
ret void
}

LLVM IR (-O2):
@.str = [40 x i8] c"optimizations don't break the sign of 0\00"
define void @run_zero_opt_test(double %0, double %1) {
%3 = fsub double %0, %1
%4 = tail call i64 @fpequal(double %3, double 0.000000e+00)
%5 = icmp eq i64 %4, 0
br i1 %5, label %24, label %6
6: ; preds = %2
%7 = fsub double 0.000000e+00, %0
%8 = tail call i64 @fpequal(double %7, double 0.000000e+00)
%9 = icmp eq i64 %8, 0
br i1 %9, label %24, label %10
10: ; preds = %6
%11 = fneg double %0
%12 = fsub double %11, %1
%13 = tail call i64 @fpequal(double %12, double -0.000000e+00)
%14 = icmp eq i64 %13, 0
br i1 %14, label %24, label %15
15: ; preds = %10
%16 = fneg double %3
%17 = tail call i64 @fpequal(double %16, double -0.000000e+00)
%18 = icmp eq i64 %17, 0
br i1 %18, label %24, label %19
19: ; preds = %15
%20 = fsub double %1, %0
%21 = tail call i64 @fpequal(double %20, double 0.000000e+00)
%22 = icmp ne i64 %21, 0
%23 = zext i1 %22 to i32
br label %24
24: ; preds = %19, %15, %10, %6, %2
%25 = phi i32 [ 0, %15 ], [ 0, %10 ], [ 0, %6 ], [ 0, %2 ], [ %23, %19 ]
%26 = tail call i32 @test1(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), i32 %25, i32 0)
ret void
}