#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 in_addr {
  scalar_t__ s_addr;
};

/* Variables and functions */
int cmp_in_addr(const void *a, const void *b) {
  struct in_addr *ina = (struct in_addr *)a;
  struct in_addr *inb = (struct in_addr *)b;
  if (ina->s_addr == inb->s_addr)
    return 0;
  if (ina->s_addr > inb->s_addr)
    return 1;
  return -1;
}


x86 assembly (clang, -O0):
<cmp_in_addr>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
mov    -0x28(%rbp),%rcx
cmp    (%rcx),%rax
jne    113c <cmp_in_addr+0x3c>
movl   $0x0,-0x4(%rbp)
jmp    1163 <cmp_in_addr+0x63>
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
mov    -0x28(%rbp),%rcx
cmp    (%rcx),%rax
jle    115c <cmp_in_addr+0x5c>
movl   $0x1,-0x4(%rbp)
jmp    1163 <cmp_in_addr+0x63>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<cmp_in_addr>:
mov    (%rdi),%rax
xor    %ecx,%ecx
xor    %edx,%edx
cmp    (%rsi),%rax
setg   %dl
lea    -0x1(%rdx,%rdx,1),%eax
cmove  %ecx,%eax
ret

LLVM IR (-O0):
%struct.in_addr = type { i64 }
define i32 @cmp_in_addr(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca %struct.in_addr*
%7 = alloca %struct.in_addr*
store i8* %0, i8** %4
store i8* %1, i8** %5
%8 = load i8*, i8** %4
%9 = bitcast i8* %8 to %struct.in_addr*
store %struct.in_addr* %9, %struct.in_addr** %6
%10 = load i8*, i8** %5
%11 = bitcast i8* %10 to %struct.in_addr*
store %struct.in_addr* %11, %struct.in_addr** %7
%12 = load %struct.in_addr*, %struct.in_addr** %6
%13 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %12, i32 0, i32 0
%14 = load i64, i64* %13
%15 = load %struct.in_addr*, %struct.in_addr** %7
%16 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %15, i32 0, i32 0
%17 = load i64, i64* %16
%18 = icmp eq i64 %14, %17
br i1 %18, label %19, label %20
19: ; preds = %2
store i32 0, i32* %3
br label %30
20: ; preds = %2
%21 = load %struct.in_addr*, %struct.in_addr** %6
%22 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %21, i32 0, i32 0
%23 = load i64, i64* %22
%24 = load %struct.in_addr*, %struct.in_addr** %7
%25 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %24, i32 0, i32 0
%26 = load i64, i64* %25
%27 = icmp sgt i64 %23, %26
br i1 %27, label %28, label %29
28: ; preds = %20
store i32 1, i32* %3
br label %30
29: ; preds = %20
store i32 -1, i32* %3
br label %30
30: ; preds = %29, %28, %19
%31 = load i32, i32* %3
ret i32 %31
}

LLVM IR (-O2):
define i32 @cmp_in_addr(i8* nocapture %0, i8* nocapture %1) {
%3 = bitcast i8* %0 to i64*
%4 = load i64, i64* %3
%5 = bitcast i8* %1 to i64*
%6 = load i64, i64* %5
%7 = icmp eq i64 %4, %6
%8 = icmp sgt i64 %4, %6
%9 = select i1 %8, i32 1, i32 -1
%10 = select i1 %7, i32 0, i32 %9
ret i32 %10
}