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

/* Variables and functions */
scalar_t__ inet_aton(char const *, struct in_addr *);
int /*<<< orphan*/ invertl(char *);
int strcasecmp(char const *, char const *);
int cmpIP(const char *left, const char *right) {
  struct in_addr inaddra, inaddrb;
  if (inet_aton(left, &inaddra) != 0 && inet_aton(right, &inaddrb) != 0) {
    invertl((char *)(&inaddra.s_addr));
    invertl((char *)(&inaddrb.s_addr));
    return inaddra.s_addr - inaddrb.s_addr;
  } else
    return strcasecmp(left, right);
}


x86 assembly (clang, -O0):
<cmpIP>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1040 <inet_aton@plt>
cmp    $0x0,%rax
je     118e <cmpIP+0x5e>
mov    -0x18(%rbp),%rdi
lea    -0x28(%rbp),%rsi
call   1040 <inet_aton@plt>
cmp    $0x0,%rax
je     118e <cmpIP+0x5e>
lea    -0x20(%rbp),%rdi
call   1050 <invertl@plt>
lea    -0x28(%rbp),%rdi
call   1050 <invertl@plt>
mov    -0x20(%rbp),%eax
sub    -0x28(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    119e <cmpIP+0x6e>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <strcasecmp@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cmpIP>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0x10(%rsp),%rsi
call   1040 <inet_aton@plt>
test   %rax,%rax
je     117c <cmpIP+0x4c>
lea    0x8(%rsp),%rsi
mov    %r14,%rdi
call   1040 <inet_aton@plt>
test   %rax,%rax
je     117c <cmpIP+0x4c>
lea    0x10(%rsp),%rdi
call   1050 <invertl@plt>
lea    0x8(%rsp),%rdi
call   1050 <invertl@plt>
mov    0x10(%rsp),%eax
sub    0x8(%rsp),%eax
jmp    1187 <cmpIP+0x57>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <strcasecmp@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.in_addr = type { i32 }
define i32 @cmpIP(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 = call i64 @inet_aton(i8* %8, %struct.in_addr* %6)
%10 = icmp ne i64 %9, 0
br i1 %10, label %11, label %27
11: ; preds = %2
%12 = load i8*, i8** %5
%13 = call i64 @inet_aton(i8* %12, %struct.in_addr* %7)
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %27
15: ; preds = %11
%16 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %6, i32 0, i32 0
%17 = bitcast i32* %16 to i8*
%18 = call i32 @invertl(i8* %17)
%19 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %7, i32 0, i32 0
%20 = bitcast i32* %19 to i8*
%21 = call i32 @invertl(i8* %20)
%22 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %6, i32 0, i32 0
%23 = load i32, i32* %22
%24 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %7, i32 0, i32 0
%25 = load i32, i32* %24
%26 = sub nsw i32 %23, %25
store i32 %26, i32* %3
br label %31
27: ; preds = %11, %2
%28 = load i8*, i8** %4
%29 = load i8*, i8** %5
%30 = call i32 @strcasecmp(i8* %28, i8* %29)
store i32 %30, i32* %3
br label %31
31: ; preds = %27, %15
%32 = load i32, i32* %3
ret i32 %32
}

LLVM IR (-O2):
%struct.in_addr = type { i32 }
define i32 @cmpIP(i8* %0, i8* %1) {
%3 = alloca %struct.in_addr
%4 = alloca %struct.in_addr
%5 = bitcast %struct.in_addr* %3 to i8*
%6 = bitcast %struct.in_addr* %4 to i8*
%7 = call i64 @inet_aton(i8* %0, %struct.in_addr* %3)
%8 = icmp eq i64 %7, 0
br i1 %8, label %20, label %9
9: ; preds = %2
%10 = call i64 @inet_aton(i8* %1, %struct.in_addr* %4)
%11 = icmp eq i64 %10, 0
br i1 %11, label %20, label %12
12: ; preds = %9
%13 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %3, i64 0, i32 0
%14 = call i32 @invertl(i8* %5)
%15 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %4, i64 0, i32 0
%16 = call i32 @invertl(i8* %6)
%17 = load i32, i32* %13
%18 = load i32, i32* %15
%19 = sub nsw i32 %17, %18
br label %22
20: ; preds = %9, %2
%21 = call i32 @strcasecmp(i8* %0, i8* %1)
br label %22
22: ; preds = %20, %12
%23 = phi i32 [ %19, %12 ], [ %21, %20 ]
ret i32 %23
}