#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 sockaddr_in6 {
  scalar_t__ sin6_port;
  int /*<<< orphan*/ sin6_addr;
};

/* Variables and functions */
scalar_t__ memcmp(int /*<<< orphan*/ *, int /*<<< orphan*/ *, int);
int sockaddr_cmp(const struct sockaddr_in6 *a, const struct sockaddr_in6 *b) {
  return memcmp(&a->sin6_addr, &b->sin6_addr, sizeof(a->sin6_addr)) ||
         a->sin6_port != b->sin6_port;
}


x86 assembly (clang, -O0):
<sockaddr_cmp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
add    $0x8,%rdi
mov    -0x10(%rbp),%rsi
add    $0x8,%rsi
mov    $0x4,%edx
call   1030 <memcmp@plt>
mov    %rax,%rcx
mov    $0x1,%al
cmp    $0x0,%rcx
mov    %al,-0x11(%rbp)
jne    1160 <sockaddr_cmp+0x50>
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    -0x10(%rbp),%rcx
cmp    (%rcx),%rax
setne  %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sockaddr_cmp>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
add    $0x8,%rdi
add    $0x8,%rsi
mov    $0x4,%edx
call   1030 <memcmp@plt>
mov    %rax,%rcx
mov    $0x1,%eax
test   %rcx,%rcx
jne    1144 <sockaddr_cmp+0x34>
mov    (%rbx),%rcx
xor    %eax,%eax
cmp    (%r14),%rcx
setne  %al
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.sockaddr_in6 = type { i64, i32 }
define i32 @sockaddr_cmp(%struct.sockaddr_in6* %0, %struct.sockaddr_in6* %1) {
%3 = alloca %struct.sockaddr_in6*
%4 = alloca %struct.sockaddr_in6*
store %struct.sockaddr_in6* %0, %struct.sockaddr_in6** %3
store %struct.sockaddr_in6* %1, %struct.sockaddr_in6** %4
%5 = load %struct.sockaddr_in6*, %struct.sockaddr_in6** %3
%6 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %5, i32 0, i32 1
%7 = load %struct.sockaddr_in6*, %struct.sockaddr_in6** %4
%8 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %7, i32 0, i32 1
%9 = call i64 @memcmp(i32* %6, i32* %8, i32 4)
%10 = icmp ne i64 %9, 0
br i1 %10, label %19, label %11
11: ; preds = %2
%12 = load %struct.sockaddr_in6*, %struct.sockaddr_in6** %3
%13 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %12, i32 0, i32 0
%14 = load i64, i64* %13
%15 = load %struct.sockaddr_in6*, %struct.sockaddr_in6** %4
%16 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %15, i32 0, i32 0
%17 = load i64, i64* %16
%18 = icmp ne i64 %14, %17
br label %19
19: ; preds = %11, %2
%20 = phi i1 [ true, %2 ], [ %18, %11 ]
%21 = zext i1 %20 to i32
ret i32 %21
}

LLVM IR (-O2):
%struct.sockaddr_in6 = type { i64, i32 }
define i32 @sockaddr_cmp(%struct.sockaddr_in6* %0, %struct.sockaddr_in6* %1) {
%3 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %0, i64 0, i32 1
%4 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %1, i64 0, i32 1
%5 = tail call i64 @memcmp(i32* %3, i32* %4, i32 4)
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %14
7: ; preds = %2
%8 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %0, i64 0, i32 0
%9 = load i64, i64* %8
%10 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %1, i64 0, i32 0
%11 = load i64, i64* %10
%12 = icmp ne i64 %9, %11
%13 = zext i1 %12 to i32
br label %14
14: ; preds = %7, %2
%15 = phi i32 [ 1, %2 ], [ %13, %7 ]
ret i32 %15
}