#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 */
struct fastx_read_s {
  int dummy;
};

/* Variables and functions */
int fastx_read_compare(struct fastx_read_s *const, struct fastx_read_s *const);
int pair_comparator_qsort(struct fastx_read_s *const pair1[2],
                          struct fastx_read_s *const pair2[2]) {
  int result;
  if (!(result = fastx_read_compare(pair1[0], pair2[0]))) {
    return fastx_read_compare(pair1[1], pair2[1]);
  }
  return result;
}


x86 assembly (clang, -O0):
<pair_comparator_qsort>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    -0x18(%rbp),%rax
mov    (%rax),%rsi
call   1030 <fastx_read_compare@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0x0,%eax
jne    115c <pair_comparator_qsort+0x4c>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rsi
call   1030 <fastx_read_compare@plt>
mov    %eax,-0x4(%rbp)
jmp    1162 <pair_comparator_qsort+0x52>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pair_comparator_qsort>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
mov    (%rdi),%rdi
mov    (%rsi),%rsi
call   1030 <fastx_read_compare@plt>
test   %eax,%eax
je     1131 <pair_comparator_qsort+0x21>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    0x8(%rbx),%rdi
mov    0x8(%r14),%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <fastx_read_compare@plt>

LLVM IR (-O0):
%struct.fastx_read_s = type { i32 }
define i32 @pair_comparator_qsort(%struct.fastx_read_s** %0, %struct.fastx_read_s** %1) {
%3 = alloca i32
%4 = alloca %struct.fastx_read_s**
%5 = alloca %struct.fastx_read_s**
%6 = alloca i32
store %struct.fastx_read_s** %0, %struct.fastx_read_s*** %4
store %struct.fastx_read_s** %1, %struct.fastx_read_s*** %5
%7 = load %struct.fastx_read_s**, %struct.fastx_read_s*** %4
%8 = getelementptr inbounds %struct.fastx_read_s*, %struct.fastx_read_s** %7, i64 0
%9 = load %struct.fastx_read_s*, %struct.fastx_read_s** %8
%10 = load %struct.fastx_read_s**, %struct.fastx_read_s*** %5
%11 = getelementptr inbounds %struct.fastx_read_s*, %struct.fastx_read_s** %10, i64 0
%12 = load %struct.fastx_read_s*, %struct.fastx_read_s** %11
%13 = call i32 @fastx_read_compare(%struct.fastx_read_s* %9, %struct.fastx_read_s* %12)
store i32 %13, i32* %6
%14 = icmp ne i32 %13, 0
br i1 %14, label %23, label %15
15: ; preds = %2
%16 = load %struct.fastx_read_s**, %struct.fastx_read_s*** %4
%17 = getelementptr inbounds %struct.fastx_read_s*, %struct.fastx_read_s** %16, i64 1
%18 = load %struct.fastx_read_s*, %struct.fastx_read_s** %17
%19 = load %struct.fastx_read_s**, %struct.fastx_read_s*** %5
%20 = getelementptr inbounds %struct.fastx_read_s*, %struct.fastx_read_s** %19, i64 1
%21 = load %struct.fastx_read_s*, %struct.fastx_read_s** %20
%22 = call i32 @fastx_read_compare(%struct.fastx_read_s* %18, %struct.fastx_read_s* %21)
store i32 %22, i32* %3
br label %25
23: ; preds = %2
%24 = load i32, i32* %6
store i32 %24, i32* %3
br label %25
25: ; preds = %23, %15
%26 = load i32, i32* %3
ret i32 %26
}

LLVM IR (-O2):
%struct.fastx_read_s = type { i32 }
define i32 @pair_comparator_qsort(%struct.fastx_read_s** nocapture %0, %struct.fastx_read_s** nocapture %1) {
%3 = load %struct.fastx_read_s*, %struct.fastx_read_s** %0
%4 = load %struct.fastx_read_s*, %struct.fastx_read_s** %1
%5 = tail call i32 @fastx_read_compare(%struct.fastx_read_s* %3, %struct.fastx_read_s* %4)
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %13
7: ; preds = %2
%8 = getelementptr inbounds %struct.fastx_read_s*, %struct.fastx_read_s** %0, i64 1
%9 = load %struct.fastx_read_s*, %struct.fastx_read_s** %8
%10 = getelementptr inbounds %struct.fastx_read_s*, %struct.fastx_read_s** %1, i64 1
%11 = load %struct.fastx_read_s*, %struct.fastx_read_s** %10
%12 = tail call i32 @fastx_read_compare(%struct.fastx_read_s* %9, %struct.fastx_read_s* %11)
br label %13
13: ; preds = %2, %7
%14 = phi i32 [ %12, %7 ], [ %5, %2 ]
ret i32 %14
}