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

/* Variables and functions */
int /*<<< orphan*/ memcmp(int /*<<< orphan*/, int /*<<< orphan*/, int);
int sin6_equals(const struct sockaddr_in6 *a, const struct sockaddr_in6 *b) {
  return !memcmp(a->sin6_addr.s6_addr, b->sin6_addr.s6_addr, 16) &&
         a->sin6_port == b->sin6_port;
}


x86 assembly (clang, -O0):
<sin6_equals>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%esi
mov    $0x10,%edx
call   1030 <memcmp@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x11(%rbp)
jne    115c <sin6_equals+0x4c>
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    -0x10(%rbp),%rcx
cmp    (%rcx),%rax
sete   %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):
<sin6_equals>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
mov    0x8(%rdi),%edi
mov    0x8(%rsi),%esi
mov    $0x10,%edx
call   1030 <memcmp@plt>
mov    %eax,%ecx
xor    %eax,%eax
test   %ecx,%ecx
jne    113d <sin6_equals+0x2d>
mov    (%rbx),%rcx
xor    %eax,%eax
cmp    (%r14),%rcx
sete   %al
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.sockaddr_in6 = type { i64, %struct.TYPE_2__ }
%struct.TYPE_2__ = type { i32 }
define i32 @sin6_equals(%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 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %6, i32 0, i32 0
%8 = load i32, i32* %7
%9 = load %struct.sockaddr_in6*, %struct.sockaddr_in6** %4
%10 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %9, i32 0, i32 1
%11 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %10, i32 0, i32 0
%12 = load i32, i32* %11
%13 = call i32 @memcmp(i32 %8, i32 %12, i32 16)
%14 = icmp ne i32 %13, 0
br i1 %14, label %23, label %15
15: ; preds = %2
%16 = load %struct.sockaddr_in6*, %struct.sockaddr_in6** %3
%17 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %16, i32 0, i32 0
%18 = load i64, i64* %17
%19 = load %struct.sockaddr_in6*, %struct.sockaddr_in6** %4
%20 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %19, i32 0, i32 0
%21 = load i64, i64* %20
%22 = icmp eq i64 %18, %21
br label %23
23: ; preds = %15, %2
%24 = phi i1 [ false, %2 ], [ %22, %15 ]
%25 = zext i1 %24 to i32
ret i32 %25
}

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