#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 */
typedef struct TYPE_2__ TYPE_1__;

/* Type definitions */
struct TYPE_2__ {
  scalar_t__ s_addr;
};
struct sockaddr_in {
  scalar_t__ sin_port;
  scalar_t__ sin_family;
  TYPE_1__ sin_addr;
};

/* Variables and functions */
int ipaddr_cmp(struct sockaddr_in *addr1, struct sockaddr_in *addr2) {
  if (addr1->sin_addr.s_addr == addr2->sin_addr.s_addr &&
      addr1->sin_port == addr2->sin_port &&
      addr1->sin_family == addr2->sin_family)
    return 0;
  return -1;
}


x86 assembly (clang, -O0):
<ipaddr_cmp>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    -0x18(%rbp),%rcx
cmp    0x10(%rcx),%rax
jne    1158 <ipaddr_cmp+0x58>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    -0x18(%rbp),%rcx
cmp    (%rcx),%rax
jne    1158 <ipaddr_cmp+0x58>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    -0x18(%rbp),%rcx
cmp    0x8(%rcx),%rax
jne    1158 <ipaddr_cmp+0x58>
movl   $0x0,-0x4(%rbp)
jmp    115f <ipaddr_cmp+0x5f>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<ipaddr_cmp>:
mov    0x10(%rdi),%rax
cmp    0x10(%rsi),%rax
jne    111e <ipaddr_cmp+0x1e>
mov    (%rdi),%rax
cmp    (%rsi),%rax
jne    111e <ipaddr_cmp+0x1e>
mov    0x8(%rdi),%rcx
xor    %eax,%eax
cmp    0x8(%rsi),%rcx
je     1123 <ipaddr_cmp+0x23>
mov    $0xffffffff,%eax
ret

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

LLVM IR (-O2):
%struct.sockaddr_in = type { i64, i64, %struct.TYPE_2__ }
%struct.TYPE_2__ = type { i64 }
define i32 @ipaddr_cmp(%struct.sockaddr_in* nocapture %0, %struct.sockaddr_in* nocapture %1) {
%3 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %0, i64 0, i32 2, i32 0
%4 = load i64, i64* %3
%5 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i64 0, i32 2, i32 0
%6 = load i64, i64* %5
%7 = icmp eq i64 %4, %6
br i1 %7, label %8, label %20
8: ; preds = %2
%9 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %0, i64 0, i32 0
%10 = load i64, i64* %9
%11 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i64 0, i32 0
%12 = load i64, i64* %11
%13 = icmp eq i64 %10, %12
br i1 %13, label %14, label %20
14: ; preds = %8
%15 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %0, i64 0, i32 1
%16 = load i64, i64* %15
%17 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i64 0, i32 1
%18 = load i64, i64* %17
%19 = icmp eq i64 %16, %18
br i1 %19, label %21, label %20
20: ; preds = %14, %8, %2
br label %21
21: ; preds = %14, %20
%22 = phi i32 [ -1, %20 ], [ 0, %14 ]
ret i32 %22
}