#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_one_empty() {
  int a[] = {1, 2, 3};
  return 2.0 == median(a, 3, NULL, 0) && 2.0 == median(NULL, 0, a, 3) &&
         2.0 == median_opt(a, NULL, 3) && 2.0 == median_opt(NULL, a, 3);
}


x86 assembly (clang, -O0):
<test_one_empty>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    0xed9(%rip),%rax
mov    %rax,-0xc(%rbp)
mov    0xed7(%rip),%eax
mov    %eax,-0x4(%rbp)
lea    -0xc(%rbp),%rdi
mov    $0x3,%esi
xor    %eax,%eax
mov    %eax,%edx
xor    %ecx,%ecx
call   1030 <median@plt>
movaps %xmm0,%xmm1
xor    %eax,%eax
movsd  0xea3(%rip),%xmm0
ucomisd %xmm1,%xmm0
mov    %al,-0xd(%rbp)
jne    1202 <test_one_empty+0xe2>
jp     1202 <test_one_empty+0xe2>
lea    -0xc(%rbp),%rdx
xor    %eax,%eax
mov    %eax,%edi
xor    %esi,%esi
mov    $0x3,%ecx
call   1030 <median@plt>
movaps %xmm0,%xmm1
xor    %eax,%eax
movsd  0xe6f(%rip),%xmm0
ucomisd %xmm1,%xmm0
mov    %al,-0xd(%rbp)
jne    1202 <test_one_empty+0xe2>
jp     1202 <test_one_empty+0xe2>
lea    -0xc(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0x3,%edx
call   1040 <median_opt@plt>
movaps %xmm0,%xmm1
xor    %eax,%eax
movsd  0xe3d(%rip),%xmm0
ucomisd %xmm1,%xmm0
mov    %al,-0xd(%rbp)
jne    1202 <test_one_empty+0xe2>
jp     1202 <test_one_empty+0xe2>
lea    -0xc(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edi
mov    $0x3,%edx
call   1040 <median_opt@plt>
movaps %xmm0,%xmm1
movsd  0xe0d(%rip),%xmm0
ucomisd %xmm1,%xmm0
sete   %al
setnp  %cl
and    %cl,%al
mov    %al,-0xd(%rbp)
mov    -0xd(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_one_empty>:
push   %rbx
sub    $0x10,%rsp
mov    0xee5(%rip),%eax
mov    %eax,0x8(%rsp)
mov    0xed2(%rip),%rax
mov    %rax,(%rsp)
xor    %ebx,%ebx
mov    %rsp,%rdi
mov    $0x3,%esi
xor    %edx,%edx
xor    %ecx,%ecx
call   1030 <median@plt>
ucomisd 0xeab(%rip),%xmm0
jne    11b5 <test_one_empty+0x95>
jp     11b5 <test_one_empty+0x95>
xor    %ebx,%ebx
mov    %rsp,%rdx
xor    %edi,%edi
xor    %esi,%esi
mov    $0x3,%ecx
call   1030 <median@plt>
ucomisd 0xe8c(%rip),%xmm0
jne    11b5 <test_one_empty+0x95>
jp     11b5 <test_one_empty+0x95>
xor    %ebx,%ebx
mov    %rsp,%rdi
xor    %esi,%esi
mov    $0x3,%edx
call   1040 <median_opt@plt>
ucomisd 0xe6f(%rip),%xmm0
jne    11b5 <test_one_empty+0x95>
jp     11b5 <test_one_empty+0x95>
mov    %rsp,%rsi
xor    %edi,%edi
mov    $0x3,%edx
call   1040 <median_opt@plt>
cmpeqsd 0xe53(%rip),%xmm0
movq   %xmm0,%rbx
and    $0x1,%ebx
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
ret

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

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