#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 expression {
  int dummy;
};

/* Variables and functions */
unsigned long bit_offset(struct expression const *);
int compare_expressions(const void *_a, const void *_b) {
  const struct expression *a = _a;
  const struct expression *b = _b;
  unsigned long a_pos = bit_offset(a);
  unsigned long b_pos = bit_offset(b);
  return (a_pos < b_pos) ? -1 : (a_pos == b_pos) ? 0 : 1;
}


x86 assembly (clang, -O0):
<compare_expressions>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <bit_offset@plt>
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <bit_offset@plt>
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x30(%rbp),%rax
jae    1165 <compare_expressions+0x55>
mov    $0xffffffff,%eax
mov    %eax,-0x34(%rbp)
jmp    117d <compare_expressions+0x6d>
mov    -0x28(%rbp),%rdx
mov    -0x30(%rbp),%rsi
mov    $0x1,%eax
xor    %ecx,%ecx
cmp    %rsi,%rdx
cmove  %ecx,%eax
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<compare_expressions>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
call   1030 <bit_offset@plt>
mov    %rax,%rbx
mov    %r14,%rdi
call   1030 <bit_offset@plt>
xor    %ecx,%ecx
cmp    %rax,%rbx
setne  %cl
mov    $0xffffffff,%eax
cmovae %ecx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.expression = type { i32 }
define i32 @compare_expressions(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca %struct.expression*
%6 = alloca %struct.expression*
%7 = alloca i64
%8 = alloca i64
store i8* %0, i8** %3
store i8* %1, i8** %4
%9 = load i8*, i8** %3
%10 = bitcast i8* %9 to %struct.expression*
store %struct.expression* %10, %struct.expression** %5
%11 = load i8*, i8** %4
%12 = bitcast i8* %11 to %struct.expression*
store %struct.expression* %12, %struct.expression** %6
%13 = load %struct.expression*, %struct.expression** %5
%14 = call i64 @bit_offset(%struct.expression* %13)
store i64 %14, i64* %7
%15 = load %struct.expression*, %struct.expression** %6
%16 = call i64 @bit_offset(%struct.expression* %15)
store i64 %16, i64* %8
%17 = load i64, i64* %7
%18 = load i64, i64* %8
%19 = icmp ult i64 %17, %18
br i1 %19, label %20, label %21
20: ; preds = %2
br label %27
21: ; preds = %2
%22 = load i64, i64* %7
%23 = load i64, i64* %8
%24 = icmp eq i64 %22, %23
%25 = zext i1 %24 to i64
%26 = select i1 %24, i32 0, i32 1
br label %27
27: ; preds = %21, %20
%28 = phi i32 [ -1, %20 ], [ %26, %21 ]
ret i32 %28
}

LLVM IR (-O2):
%struct.expression = type { i32 }
define i32 @compare_expressions(i8* %0, i8* %1) {
%3 = bitcast i8* %0 to %struct.expression*
%4 = bitcast i8* %1 to %struct.expression*
%5 = tail call i64 @bit_offset(%struct.expression* %3)
%6 = tail call i64 @bit_offset(%struct.expression* %4)
%7 = icmp ult i64 %5, %6
%8 = icmp ne i64 %5, %6
%9 = zext i1 %8 to i32
%10 = select i1 %7, i32 -1, i32 %9
ret i32 %10
}