#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 */
scalar_t__ inet_aton(char *, struct in_addr *);
int /*<<< orphan*/ invertl(char *);
int strcasecmp(char *, char *);
int cmpIP(char *left, 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));
    if (inaddra.s_addr > inaddrb.s_addr)
      return 1;
    else if (inaddra.s_addr < inaddrb.s_addr)
      return -1;
    else
      return 0;
  } 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     11c0 <cmpIP+0x90>
mov    -0x18(%rbp),%rdi
lea    -0x28(%rbp),%rsi
call   1040 <inet_aton@plt>
cmp    $0x0,%rax
je     11c0 <cmpIP+0x90>
lea    -0x20(%rbp),%rdi
call   1050 <invertl@plt>
lea    -0x28(%rbp),%rdi
call   1050 <invertl@plt>
mov    -0x20(%rbp),%rax
cmp    -0x28(%rbp),%rax
jle    119a <cmpIP+0x6a>
movl   $0x1,-0x4(%rbp)
jmp    11d0 <cmpIP+0xa0>
mov    -0x20(%rbp),%rax
cmp    -0x28(%rbp),%rax
jge    11b4 <cmpIP+0x84>
movl   $0xffffffff,-0x4(%rbp)
jmp    11d0 <cmpIP+0xa0>
movl   $0x0,-0x4(%rbp)
jmp    11d0 <cmpIP+0xa0>
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     118d <cmpIP+0x5d>
lea    0x8(%rsp),%rsi
mov    %r14,%rdi
call   1040 <inet_aton@plt>
test   %rax,%rax
je     118d <cmpIP+0x5d>
lea    0x10(%rsp),%rdi
call   1050 <invertl@plt>
lea    0x8(%rsp),%rdi
call   1050 <invertl@plt>
mov    0x8(%rsp),%rcx
mov    $0x1,%eax
cmp    %rcx,0x10(%rsp)
jg     1198 <cmpIP+0x68>
setl   %al
movzbl %al,%eax
neg    %eax
jmp    1198 <cmpIP+0x68>
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 { i64 }
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 %36
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 %36
15: ; preds = %11
%16 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %6, i32 0, i32 0
%17 = bitcast i64* %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 i64* %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 i64, i64* %22
%24 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %7, i32 0, i32 0
%25 = load i64, i64* %24
%26 = icmp sgt i64 %23, %25
br i1 %26, label %27, label %28
27: ; preds = %15
store i32 1, i32* %3
br label %40
28: ; preds = %15
%29 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %6, i32 0, i32 0
%30 = load i64, i64* %29
%31 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %7, i32 0, i32 0
%32 = load i64, i64* %31
%33 = icmp slt i64 %30, %32
br i1 %33, label %34, label %35
34: ; preds = %28
store i32 -1, i32* %3
br label %40
35: ; preds = %28
store i32 0, i32* %3
br label %40
36: ; preds = %11, %2
%37 = load i8*, i8** %4
%38 = load i8*, i8** %5
%39 = call i32 @strcasecmp(i8* %37, i8* %38)
store i32 %39, i32* %3
br label %40
40: ; preds = %36, %35, %34, %27
%41 = load i32, i32* %3
ret i32 %41
}

LLVM IR (-O2):
%struct.in_addr = type { i64 }
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 %23, 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 %23, 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 i64, i64* %13
%18 = load i64, i64* %15
%19 = icmp sgt i64 %17, %18
br i1 %19, label %25, label %20
20: ; preds = %12
%21 = icmp slt i64 %17, %18
%22 = sext i1 %21 to i32
br label %25
23: ; preds = %9, %2
%24 = call i32 @strcasecmp(i8* %0, i8* %1)
br label %25
25: ; preds = %20, %12, %23
%26 = phi i32 [ %24, %23 ], [ 1, %12 ], [ %22, %20 ]
ret i32 %26
}