#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;
  scalar_t__ sin6_flowinfo;
  scalar_t__ sin6_scope_id;
  int /*<<< orphan*/ sin6_addr;
};
struct in6_addr {
  int dummy;
};

/* Variables and functions */
scalar_t__ memcmp(int /*<<< orphan*/ *, int /*<<< orphan*/ *, int);
int sockutil_a6_eq(struct sockaddr_in6 *a, struct sockaddr_in6 *b,
                   unsigned ignore) {
  if (!(ignore & 0x2) && (a->sin6_port != b->sin6_port)) {
    return 0;
  }
  if (!(ignore & 0x4) &&
      memcmp(&a->sin6_addr, &b->sin6_addr, sizeof(struct in6_addr))) {
    return 0;
  }
  if (!(ignore & 0x8) && (a->sin6_flowinfo != b->sin6_flowinfo)) {
    return 0;
  }
  if (!(ignore & 0x10) && (a->sin6_scope_id != b->sin6_scope_id)) {
    return 0;
  }
  return 1;
}


x86 assembly (clang, -O0):
<sockutil_a6_eq>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
and    $0x2,%eax
cmp    $0x0,%eax
jne    1152 <sockutil_a6_eq+0x42>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    -0x18(%rbp),%rcx
cmp    (%rcx),%rax
je     1152 <sockutil_a6_eq+0x42>
movl   $0x0,-0x4(%rbp)
jmp    11fa <sockutil_a6_eq+0xea>
mov    -0x1c(%rbp),%eax
and    $0x4,%eax
cmp    $0x0,%eax
jne    1191 <sockutil_a6_eq+0x81>
mov    -0x10(%rbp),%rdi
add    $0x18,%rdi
mov    -0x18(%rbp),%rsi
add    $0x18,%rsi
mov    $0x4,%edx
call   1030 <memcmp@plt>
cmp    $0x0,%rax
je     1191 <sockutil_a6_eq+0x81>
movl   $0x0,-0x4(%rbp)
jmp    11fa <sockutil_a6_eq+0xea>
mov    -0x1c(%rbp),%eax
and    $0x8,%eax
cmp    $0x0,%eax
jne    11c2 <sockutil_a6_eq+0xb2>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    -0x18(%rbp),%rcx
cmp    0x8(%rcx),%rax
je     11c2 <sockutil_a6_eq+0xb2>
movl   $0x0,-0x4(%rbp)
jmp    11fa <sockutil_a6_eq+0xea>
mov    -0x1c(%rbp),%eax
and    $0x10,%eax
cmp    $0x0,%eax
jne    11f3 <sockutil_a6_eq+0xe3>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    -0x18(%rbp),%rcx
cmp    0x10(%rcx),%rax
je     11f3 <sockutil_a6_eq+0xe3>
movl   $0x0,-0x4(%rbp)
jmp    11fa <sockutil_a6_eq+0xea>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sockutil_a6_eq>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%ebp
mov    %rsi,%r14
mov    %rdi,%rbx
test   $0x2,%bpl
jne    112c <sockutil_a6_eq+0x1c>
mov    (%rbx),%rcx
xor    %eax,%eax
cmp    (%r14),%rcx
jne    1177 <sockutil_a6_eq+0x67>
test   $0x4,%bpl
jne    114e <sockutil_a6_eq+0x3e>
lea    0x18(%rbx),%rdi
lea    0x18(%r14),%rsi
mov    $0x4,%edx
call   1030 <memcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
jne    1177 <sockutil_a6_eq+0x67>
test   $0x8,%bpl
jne    1160 <sockutil_a6_eq+0x50>
mov    0x8(%rbx),%rcx
xor    %eax,%eax
cmp    0x8(%r14),%rcx
jne    1177 <sockutil_a6_eq+0x67>
test   $0x10,%bpl
jne    1172 <sockutil_a6_eq+0x62>
mov    0x10(%rbx),%rcx
xor    %eax,%eax
cmp    0x10(%r14),%rcx
jne    1177 <sockutil_a6_eq+0x67>
mov    $0x1,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.sockaddr_in6 = type { i64, i64, i64, i32 }
define i32 @sockutil_a6_eq(%struct.sockaddr_in6* %0, %struct.sockaddr_in6* %1, i32 %2) {
%4 = alloca i32
%5 = alloca %struct.sockaddr_in6*
%6 = alloca %struct.sockaddr_in6*
%7 = alloca i32
store %struct.sockaddr_in6* %0, %struct.sockaddr_in6** %5
store %struct.sockaddr_in6* %1, %struct.sockaddr_in6** %6
store i32 %2, i32* %7
%8 = load i32, i32* %7
%9 = and i32 %8, 2
%10 = icmp ne i32 %9, 0
br i1 %10, label %20, label %11
11: ; preds = %3
%12 = load %struct.sockaddr_in6*, %struct.sockaddr_in6** %5
%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** %6
%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 i1 %18, label %19, label %20
19: ; preds = %11
store i32 0, i32* %4
br label %59
20: ; preds = %11, %3
%21 = load i32, i32* %7
%22 = and i32 %21, 4
%23 = icmp ne i32 %22, 0
br i1 %23, label %32, label %24
24: ; preds = %20
%25 = load %struct.sockaddr_in6*, %struct.sockaddr_in6** %5
%26 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %25, i32 0, i32 3
%27 = load %struct.sockaddr_in6*, %struct.sockaddr_in6** %6
%28 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %27, i32 0, i32 3
%29 = call i64 @memcmp(i32* %26, i32* %28, i32 4)
%30 = icmp ne i64 %29, 0
br i1 %30, label %31, label %32
31: ; preds = %24
store i32 0, i32* %4
br label %59
32: ; preds = %24, %20
%33 = load i32, i32* %7
%34 = and i32 %33, 8
%35 = icmp ne i32 %34, 0
br i1 %35, label %45, label %36
36: ; preds = %32
%37 = load %struct.sockaddr_in6*, %struct.sockaddr_in6** %5
%38 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %37, i32 0, i32 1
%39 = load i64, i64* %38
%40 = load %struct.sockaddr_in6*, %struct.sockaddr_in6** %6
%41 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %40, i32 0, i32 1
%42 = load i64, i64* %41
%43 = icmp ne i64 %39, %42
br i1 %43, label %44, label %45
44: ; preds = %36
store i32 0, i32* %4
br label %59
45: ; preds = %36, %32
%46 = load i32, i32* %7
%47 = and i32 %46, 16
%48 = icmp ne i32 %47, 0
br i1 %48, label %58, label %49
49: ; preds = %45
%50 = load %struct.sockaddr_in6*, %struct.sockaddr_in6** %5
%51 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %50, i32 0, i32 2
%52 = load i64, i64* %51
%53 = load %struct.sockaddr_in6*, %struct.sockaddr_in6** %6
%54 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %53, i32 0, i32 2
%55 = load i64, i64* %54
%56 = icmp ne i64 %52, %55
br i1 %56, label %57, label %58
57: ; preds = %49
store i32 0, i32* %4
br label %59
58: ; preds = %49, %45
store i32 1, i32* %4
br label %59
59: ; preds = %58, %57, %44, %31, %19
%60 = load i32, i32* %4
ret i32 %60
}

LLVM IR (-O2):
%struct.sockaddr_in6 = type { i64, i64, i64, i32 }
define i32 @sockutil_a6_eq(%struct.sockaddr_in6* %0, %struct.sockaddr_in6* %1, i32 %2) {
%4 = and i32 %2, 2
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %12
6: ; preds = %3
%7 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %0, i64 0, i32 0
%8 = load i64, i64* %7
%9 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %1, i64 0, i32 0
%10 = load i64, i64* %9
%11 = icmp eq i64 %8, %10
br i1 %11, label %12, label %39
12: ; preds = %6, %3
%13 = and i32 %2, 4
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %20
15: ; preds = %12
%16 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %0, i64 0, i32 3
%17 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %1, i64 0, i32 3
%18 = tail call i64 @memcmp(i32* %16, i32* %17, i32 4)
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %39
20: ; preds = %15, %12
%21 = and i32 %2, 8
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %29
23: ; preds = %20
%24 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %0, i64 0, i32 1
%25 = load i64, i64* %24
%26 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %1, i64 0, i32 1
%27 = load i64, i64* %26
%28 = icmp eq i64 %25, %27
br i1 %28, label %29, label %39
29: ; preds = %23, %20
%30 = and i32 %2, 16
%31 = icmp eq i32 %30, 0
br i1 %31, label %32, label %38
32: ; preds = %29
%33 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %0, i64 0, i32 2
%34 = load i64, i64* %33
%35 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %1, i64 0, i32 2
%36 = load i64, i64* %35
%37 = icmp eq i64 %34, %36
br i1 %37, label %38, label %39
38: ; preds = %32, %29
br label %39
39: ; preds = %32, %23, %15, %6, %38
%40 = phi i32 [ 1, %38 ], [ 0, %6 ], [ 0, %15 ], [ 0, %23 ], [ 0, %32 ]
ret i32 %40
}