#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 median(int *, int, int *, int);
double median_opt(int *, int *, int);
int test_negative() {
  int a[] = {-3, -2, -1, 0};
  int b[] = {1, 2, 3, 4};
  return 0.5 == median(a, 4, b, 4) && 0.5 == median(b, 4, a, 4) &&
         0.5 == median_opt(a, b, 4) && 0.5 == median_opt(b, a, 4);
}


x86 assembly (clang, -O0):
<test_negative>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    0xee1(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    0xede(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    0xedb(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xed8(%rip),%rax
mov    %rax,-0x18(%rbp)
lea    -0x10(%rbp),%rdi
lea    -0x20(%rbp),%rdx
mov    $0x4,%ecx
mov    %ecx,%esi
call   1030 <median@plt>
movaps %xmm0,%xmm1
xor    %eax,%eax
movsd  0xe8b(%rip),%xmm0
ucomisd %xmm1,%xmm0
mov    %al,-0x21(%rbp)
jne    121a <test_negative+0xfa>
jp     121a <test_negative+0xfa>
lea    -0x20(%rbp),%rdi
lea    -0x10(%rbp),%rdx
mov    $0x4,%ecx
mov    %ecx,%esi
call   1030 <median@plt>
movaps %xmm0,%xmm1
xor    %eax,%eax
movsd  0xe57(%rip),%xmm0
ucomisd %xmm1,%xmm0
mov    %al,-0x21(%rbp)
jne    121a <test_negative+0xfa>
jp     121a <test_negative+0xfa>
lea    -0x10(%rbp),%rdi
lea    -0x20(%rbp),%rsi
mov    $0x4,%edx
call   1040 <median_opt@plt>
movaps %xmm0,%xmm1
xor    %eax,%eax
movsd  0xe25(%rip),%xmm0
ucomisd %xmm1,%xmm0
mov    %al,-0x21(%rbp)
jne    121a <test_negative+0xfa>
jp     121a <test_negative+0xfa>
lea    -0x20(%rbp),%rdi
lea    -0x10(%rbp),%rsi
mov    $0x4,%edx
call   1040 <median_opt@plt>
movaps %xmm0,%xmm1
movsd  0xdf5(%rip),%xmm0
ucomisd %xmm1,%xmm0
sete   %al
setnp  %cl
and    %cl,%al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_negative>:
push   %rbx
sub    $0x20,%rsp
movaps 0xee4(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movapd 0xee7(%rip),%xmm0
movapd %xmm0,(%rsp)
lea    0x10(%rsp),%rdi
mov    %rsp,%rdx
mov    $0x4,%esi
mov    $0x4,%ecx
call   1030 <median@plt>
xor    %ebx,%ebx
ucomisd 0xea1(%rip),%xmm0
jne    11c7 <test_negative+0xa7>
jp     11c7 <test_negative+0xa7>
mov    %rsp,%rdi
lea    0x10(%rsp),%rdx
mov    $0x4,%esi
mov    $0x4,%ecx
call   1030 <median@plt>
ucomisd 0xe7e(%rip),%xmm0
jne    11c7 <test_negative+0xa7>
jp     11c7 <test_negative+0xa7>
lea    0x10(%rsp),%rdi
mov    %rsp,%rsi
mov    $0x4,%edx
call   1040 <median_opt@plt>
ucomisd 0xe60(%rip),%xmm0
jne    11c7 <test_negative+0xa7>
jp     11c7 <test_negative+0xa7>
mov    %rsp,%rdi
lea    0x10(%rsp),%rsi
mov    $0x4,%edx
call   1040 <median_opt@plt>
cmpeqsd 0xe41(%rip),%xmm0
movq   %xmm0,%rbx
and    $0x1,%ebx
mov    %ebx,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.test_negative.a = [4 x i32] [i32 -3, i32 -2, i32 -1, i32 0]
@__const.test_negative.b = [4 x i32] [i32 1, i32 2, i32 3, i32 4]
define i32 @test_negative() {
%1 = alloca [4 x i32]
%2 = alloca [4 x i32]
%3 = bitcast [4 x i32]* %1 to i8*
%4 = bitcast [4 x i32]* %2 to i8*
%5 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 0
%6 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 0
%7 = call double @median(i32* %5, i32 4, i32* %6, i32 4)
%8 = fcmp oeq double 5.000000e-01, %7
br i1 %8, label %9, label %24
9: ; preds = %0
%10 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 0
%11 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 0
%12 = call double @median(i32* %10, i32 4, i32* %11, i32 4)
%13 = fcmp oeq double 5.000000e-01, %12
br i1 %13, label %14, label %24
14: ; preds = %9
%15 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 0
%16 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 0
%17 = call double @median_opt(i32* %15, i32* %16, i32 4)
%18 = fcmp oeq double 5.000000e-01, %17
br i1 %18, label %19, label %24
19: ; preds = %14
%20 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 0
%21 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 0
%22 = call double @median_opt(i32* %20, i32* %21, i32 4)
%23 = fcmp oeq double 5.000000e-01, %22
br label %24
24: ; preds = %19, %14, %9, %0
%25 = phi i1 [ false, %14 ], [ false, %9 ], [ false, %0 ], [ %23, %19 ]
%26 = zext i1 %25 to i32
ret i32 %26
}

LLVM IR (-O2):
@__const.test_negative.a = [4 x i32] [i32 -3, i32 -2, i32 -1, i32 0]
@__const.test_negative.b = [4 x i32] [i32 1, i32 2, i32 3, i32 4]
define i32 @test_negative() {
%1 = alloca [4 x i32]
%2 = alloca [4 x i32]
%3 = bitcast [4 x i32]* %1 to i8*
%4 = bitcast [4 x i32]* %2 to i8*
%5 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 0
%6 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 0
%7 = call double @median(i32* %5, i32 4, i32* %6, i32 4)
%8 = fcmp oeq double %7, 5.000000e-01
br i1 %8, label %9, label %19
9: ; preds = %0
%10 = call double @median(i32* %6, i32 4, i32* %5, i32 4)
%11 = fcmp oeq double %10, 5.000000e-01
br i1 %11, label %12, label %19
12: ; preds = %9
%13 = call double @median_opt(i32* %5, i32* %6, i32 4)
%14 = fcmp oeq double %13, 5.000000e-01
br i1 %14, label %15, label %19
15: ; preds = %12
%16 = call double @median_opt(i32* %6, i32* %5, i32 4)
%17 = fcmp oeq double %16, 5.000000e-01
%18 = zext i1 %17 to i32
br label %19
19: ; preds = %15, %12, %9, %0
%20 = phi i32 [ 0, %12 ], [ 0, %9 ], [ 0, %0 ], [ %18, %15 ]
ret i32 %20
}