#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 sockaddr_un {
  int /*<<< orphan*/ sun_path;
};
struct sockaddr_storage {
  int ss_family;
};
struct sockaddr_in6 {
  int /*<<< orphan*/ sin6_port;
  int /*<<< orphan*/ sin6_addr;
};
struct TYPE_2__ {
  int /*<<< orphan*/ s_addr;
};
struct sockaddr_in {
  int /*<<< orphan*/ sin_port;
  TYPE_1__ sin_addr;
};

/* Variables and functions */
#define AF_INET 130
#define AF_INET6 129
#define AF_UNIX 128
int /*<<< orphan*/ abort();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ memcmp(int /*<<< orphan*/ *, int /*<<< orphan*/ *, int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcmp(int /*<<< orphan*/, int /*<<< orphan*/);
int addreq(const struct sockaddr_storage *a, const struct sockaddr_storage *b) {
  if (a->ss_family != b->ss_family)
    return 0;
  switch (a->ss_family) {
  case AF_INET: {
    const struct sockaddr_in *aa = (const struct sockaddr_in *)a;
    const struct sockaddr_in *bb = (const struct sockaddr_in *)b;
    return (aa->sin_addr.s_addr == bb->sin_addr.s_addr &&
            aa->sin_port == bb->sin_port);
  }
  case AF_INET6: {
    const struct sockaddr_in6 *aa = (const struct sockaddr_in6 *)a;
    const struct sockaddr_in6 *bb = (const struct sockaddr_in6 *)b;
    return (!memcmp(&aa->sin6_addr, &bb->sin6_addr, sizeof(aa->sin6_addr)) &&
            aa->sin6_port == bb->sin6_port);
  }
  case AF_UNIX: {
    const struct sockaddr_un *aa = (const struct sockaddr_un *)a;
    const struct sockaddr_un *bb = (const struct sockaddr_un *)b;
    return !strcmp(aa->sun_path, bb->sun_path);
  }
  }
  fprintf(stderr, "addrhash: unknown address family %d\n", a->ss_family);
  abort();
}


x86 assembly (clang, -O0):
<addreq>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    -0x18(%rbp),%rcx
cmp    (%rcx),%eax
je     116e <addreq+0x2e>
movl   $0x0,-0x4(%rbp)
jmp    12ac <addreq+0x16c>
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x4c(%rbp)
sub    $0x80,%eax
je     1254 <addreq+0x114>
jmp    1187 <addreq+0x47>
mov    -0x4c(%rbp),%eax
sub    $0x81,%eax
je     11f8 <addreq+0xb8>
jmp    119a <addreq+0x5a>
mov    -0x4c(%rbp),%eax
sub    $0x82,%eax
jne    128a <addreq+0x14a>
jmp    11ad <addreq+0x6d>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rax
mov    0x4(%rax),%ecx
mov    -0x28(%rbp),%rdx
xor    %eax,%eax
cmp    0x4(%rdx),%ecx
mov    %al,-0x4d(%rbp)
jne    11e8 <addreq+0xa8>
mov    -0x20(%rbp),%rax
mov    (%rax),%eax
mov    -0x28(%rbp),%rcx
cmp    (%rcx),%eax
sete   %al
mov    %al,-0x4d(%rbp)
mov    -0x4d(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
jmp    12ac <addreq+0x16c>
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x30(%rbp),%rdi
add    $0x4,%rdi
mov    -0x38(%rbp),%rsi
add    $0x4,%rsi
mov    $0x4,%edx
call   1040 <memcmp@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x4e(%rbp)
jne    1244 <addreq+0x104>
mov    -0x30(%rbp),%rax
mov    (%rax),%eax
mov    -0x38(%rbp),%rcx
cmp    (%rcx),%eax
sete   %al
mov    %al,-0x4e(%rbp)
mov    -0x4e(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
jmp    12ac <addreq+0x16c>
mov    -0x10(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x40(%rbp),%rax
mov    (%rax),%edi
mov    -0x48(%rbp),%rax
mov    (%rax),%esi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
jmp    12ac <addreq+0x16c>
mov    0x2d4f(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%edx
lea    0xd60(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x0,%al
call   1030 <abort@plt>
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<addreq>:
push   %r14
push   %rbx
push   %rax
mov    (%rdi),%edx
cmp    (%rsi),%edx
jne    119a <addreq+0x5a>
cmp    $0x80,%edx
je     1171 <addreq+0x31>
mov    %rsi,%r14
mov    %rdi,%rbx
cmp    $0x81,%edx
je     1184 <addreq+0x44>
cmp    $0x82,%edx
jne    11b1 <addreq+0x71>
mov    0x4(%rbx),%eax
cmp    0x4(%r14),%eax
jmp    11a3 <addreq+0x63>
mov    $0x80,%edi
mov    $0x80,%esi
call   1050 <strcmp@plt>
test   %eax,%eax
jmp    11a3 <addreq+0x63>
lea    0x4(%rbx),%rdi
lea    0x4(%r14),%rsi
mov    $0x4,%edx
call   1040 <memcmp@plt>
test   %eax,%eax
je     119e <addreq+0x5e>
xor    %eax,%eax
jmp    11a6 <addreq+0x66>
mov    (%rbx),%eax
cmp    (%r14),%eax
sete   %al
movzbl %al,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    0x2e28(%rip),%rax
mov    (%rax),%edi
lea    0xe3f(%rip),%rsi
call   1060 <fprintf@plt>
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
%struct.sockaddr_storage = type { i32 }
%struct.sockaddr_in = type { i32, %struct.TYPE_2__ }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr_in6 = type { i32, i32 }
%struct.sockaddr_un = type { i32 }
@stderr = global i32 0
@.str = [37 x i8] c"addrhash: unknown address family %d\0A\00"
define i32 @addreq(%struct.sockaddr_storage* %0, %struct.sockaddr_storage* %1) {
%3 = alloca i32
%4 = alloca %struct.sockaddr_storage*
%5 = alloca %struct.sockaddr_storage*
%6 = alloca %struct.sockaddr_in*
%7 = alloca %struct.sockaddr_in*
%8 = alloca %struct.sockaddr_in6*
%9 = alloca %struct.sockaddr_in6*
%10 = alloca %struct.sockaddr_un*
%11 = alloca %struct.sockaddr_un*
store %struct.sockaddr_storage* %0, %struct.sockaddr_storage** %4
store %struct.sockaddr_storage* %1, %struct.sockaddr_storage** %5
%12 = load %struct.sockaddr_storage*, %struct.sockaddr_storage** %4
%13 = getelementptr inbounds %struct.sockaddr_storage, %struct.sockaddr_storage* %12, i32 0, i32 0
%14 = load i32, i32* %13
%15 = load %struct.sockaddr_storage*, %struct.sockaddr_storage** %5
%16 = getelementptr inbounds %struct.sockaddr_storage, %struct.sockaddr_storage* %15, i32 0, i32 0
%17 = load i32, i32* %16
%18 = icmp ne i32 %14, %17
br i1 %18, label %19, label %20
19: ; preds = %2
store i32 0, i32* %3
br label %93
20: ; preds = %2
%21 = load %struct.sockaddr_storage*, %struct.sockaddr_storage** %4
%22 = getelementptr inbounds %struct.sockaddr_storage, %struct.sockaddr_storage* %21, i32 0, i32 0
%23 = load i32, i32* %22
switch i32 %23, label %86 [
i32 130, label %24
i32 129, label %49
i32 128, label %71
]
24: ; preds = %20
%25 = load %struct.sockaddr_storage*, %struct.sockaddr_storage** %4
%26 = bitcast %struct.sockaddr_storage* %25 to %struct.sockaddr_in*
store %struct.sockaddr_in* %26, %struct.sockaddr_in** %6
%27 = load %struct.sockaddr_storage*, %struct.sockaddr_storage** %5
%28 = bitcast %struct.sockaddr_storage* %27 to %struct.sockaddr_in*
store %struct.sockaddr_in* %28, %struct.sockaddr_in** %7
%29 = load %struct.sockaddr_in*, %struct.sockaddr_in** %6
%30 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %29, i32 0, i32 1
%31 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %30, i32 0, i32 0
%32 = load i32, i32* %31
%33 = load %struct.sockaddr_in*, %struct.sockaddr_in** %7
%34 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %33, i32 0, i32 1
%35 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %34, i32 0, i32 0
%36 = load i32, i32* %35
%37 = icmp eq i32 %32, %36
br i1 %37, label %38, label %46
38: ; preds = %24
%39 = load %struct.sockaddr_in*, %struct.sockaddr_in** %6
%40 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %39, i32 0, i32 0
%41 = load i32, i32* %40
%42 = load %struct.sockaddr_in*, %struct.sockaddr_in** %7
%43 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %42, i32 0, i32 0
%44 = load i32, i32* %43
%45 = icmp eq i32 %41, %44
br label %46
46: ; preds = %38, %24
%47 = phi i1 [ false, %24 ], [ %45, %38 ]
%48 = zext i1 %47 to i32
store i32 %48, i32* %3
br label %93
49: ; preds = %20
%50 = load %struct.sockaddr_storage*, %struct.sockaddr_storage** %4
%51 = bitcast %struct.sockaddr_storage* %50 to %struct.sockaddr_in6*
store %struct.sockaddr_in6* %51, %struct.sockaddr_in6** %8
%52 = load %struct.sockaddr_storage*, %struct.sockaddr_storage** %5
%53 = bitcast %struct.sockaddr_storage* %52 to %struct.sockaddr_in6*
store %struct.sockaddr_in6* %53, %struct.sockaddr_in6** %9
%54 = load %struct.sockaddr_in6*, %struct.sockaddr_in6** %8
%55 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %54, i32 0, i32 1
%56 = load %struct.sockaddr_in6*, %struct.sockaddr_in6** %9
%57 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %56, i32 0, i32 1
%58 = call i32 @memcmp(i32* %55, i32* %57, i32 4)
%59 = icmp ne i32 %58, 0
br i1 %59, label %68, label %60
60: ; preds = %49
%61 = load %struct.sockaddr_in6*, %struct.sockaddr_in6** %8
%62 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %61, i32 0, i32 0
%63 = load i32, i32* %62
%64 = load %struct.sockaddr_in6*, %struct.sockaddr_in6** %9
%65 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %64, i32 0, i32 0
%66 = load i32, i32* %65
%67 = icmp eq i32 %63, %66
br label %68
68: ; preds = %60, %49
%69 = phi i1 [ false, %49 ], [ %67, %60 ]
%70 = zext i1 %69 to i32
store i32 %70, i32* %3
br label %93
71: ; preds = %20
%72 = load %struct.sockaddr_storage*, %struct.sockaddr_storage** %4
%73 = bitcast %struct.sockaddr_storage* %72 to %struct.sockaddr_un*
store %struct.sockaddr_un* %73, %struct.sockaddr_un** %10
%74 = load %struct.sockaddr_storage*, %struct.sockaddr_storage** %5
%75 = bitcast %struct.sockaddr_storage* %74 to %struct.sockaddr_un*
store %struct.sockaddr_un* %75, %struct.sockaddr_un** %11
%76 = load %struct.sockaddr_un*, %struct.sockaddr_un** %10
%77 = getelementptr inbounds %struct.sockaddr_un, %struct.sockaddr_un* %76, i32 0, i32 0
%78 = load i32, i32* %77
%79 = load %struct.sockaddr_un*, %struct.sockaddr_un** %11
%80 = getelementptr inbounds %struct.sockaddr_un, %struct.sockaddr_un* %79, i32 0, i32 0
%81 = load i32, i32* %80
%82 = call i32 @strcmp(i32 %78, i32 %81)
%83 = icmp ne i32 %82, 0
%84 = xor i1 %83, true
%85 = zext i1 %84 to i32
store i32 %85, i32* %3
br label %93
86: ; preds = %20
%87 = load i32, i32* @stderr
%88 = load %struct.sockaddr_storage*, %struct.sockaddr_storage** %4
%89 = getelementptr inbounds %struct.sockaddr_storage, %struct.sockaddr_storage* %88, i32 0, i32 0
%90 = load i32, i32* %89
%91 = call i32 @fprintf(i32 %87, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i32 %90)
%92 = call i32 (...) @abort()
unreachable
93: ; preds = %71, %68, %46, %19
%94 = load i32, i32* %3
ret i32 %94
}

LLVM IR (-O2):
%struct.sockaddr_storage = type { i32 }
@stderr = global i32 0
@.str = [37 x i8] c"addrhash: unknown address family %d\0A\00"
define i32 @addreq(%struct.sockaddr_storage* %0, %struct.sockaddr_storage* %1) {
%3 = getelementptr inbounds %struct.sockaddr_storage, %struct.sockaddr_storage* %0, i64 0, i32 0
%4 = load i32, i32* %3
%5 = getelementptr inbounds %struct.sockaddr_storage, %struct.sockaddr_storage* %1, i64 0, i32 0
%6 = load i32, i32* %5
%7 = icmp eq i32 %4, %6
br i1 %7, label %8, label %31
8: ; preds = %2
switch i32 %4, label %27 [
i32 130, label %9
i32 129, label %15
i32 128, label %24
]
9: ; preds = %8
%10 = getelementptr inbounds %struct.sockaddr_storage, %struct.sockaddr_storage* %0, i64 1, i32 0
%11 = load i32, i32* %10
%12 = getelementptr inbounds %struct.sockaddr_storage, %struct.sockaddr_storage* %1, i64 1, i32 0
%13 = load i32, i32* %12
%14 = icmp eq i32 %11, %13
br label %31
15: ; preds = %8
%16 = getelementptr inbounds %struct.sockaddr_storage, %struct.sockaddr_storage* %0, i64 1, i32 0
%17 = getelementptr inbounds %struct.sockaddr_storage, %struct.sockaddr_storage* %1, i64 1, i32 0
%18 = tail call i32 @memcmp(i32* %16, i32* %17, i32 4)
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %31
20: ; preds = %15
%21 = load i32, i32* %3
%22 = load i32, i32* %5
%23 = icmp eq i32 %21, %22
br label %31
24: ; preds = %8
%25 = tail call i32 @strcmp(i32 128, i32 128)
%26 = icmp eq i32 %25, 0
br label %31
27: ; preds = %8
%28 = load i32, i32* @stderr
%29 = tail call i32 @fprintf(i32 %28, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i32 %4)
%30 = tail call i32 (...) @abort()
unreachable
31: ; preds = %9, %15, %20, %2, %24
%32 = phi i1 [ %26, %24 ], [ false, %2 ], [ false, %15 ], [ %23, %20 ], [ %14, %9 ]
%33 = zext i1 %32 to i32
ret i32 %33
}