#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_4__ TYPE_2__;
typedef struct TYPE_3__ TYPE_1__;

/* Type definitions */
struct TYPE_3__ {
  int /*<<< orphan*/ *s6_addr;
};
struct sockaddr_in6 {
  TYPE_1__ sin6_addr;
};
struct TYPE_4__ {
  int /*<<< orphan*/ s_addr;
};
struct sockaddr_in {
  TYPE_2__ sin_addr;
};
struct sockaddr {
  int sa_family;
};
struct in6_addr {
  int dummy;
};

/* Variables and functions */
#define AF_INET 129
#define AF_INET6 128
int /*<<< orphan*/ abort();
int /*<<< orphan*/ memcmp(int /*<<< orphan*/ *, int /*<<< orphan*/ *, int);
int ishostseq(struct sockaddr *ia1, struct sockaddr *ia2) {
  if (ia1->sa_family != ia2->sa_family)
    return 0;
  switch (ia1->sa_family) {
  case AF_INET:
    return (((struct sockaddr_in *)(ia1))->sin_addr.s_addr ==
            ((struct sockaddr_in *)(ia2))->sin_addr.s_addr);
  case AF_INET6:
    return (memcmp(&((struct sockaddr_in6 *)(ia1))->sin6_addr.s6_addr[0],
                   &((struct sockaddr_in6 *)(ia2))->sin6_addr.s6_addr[0],
                   sizeof(struct in6_addr)) == 0);
  default:
    break;
  }
  abort();
}


x86 assembly (clang, -O0):
<ishostseq>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    -0x18(%rbp),%rcx
cmp    (%rcx),%eax
je     114e <ishostseq+0x2e>
movl   $0x0,-0x4(%rbp)
jmp    11cd <ishostseq+0xad>
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
sub    $0x80,%eax
je     1196 <ishostseq+0x76>
jmp    1167 <ishostseq+0x47>
mov    -0x1c(%rbp),%eax
sub    $0x81,%eax
jne    11c1 <ishostseq+0xa1>
jmp    117a <ishostseq+0x5a>
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    -0x18(%rbp),%rcx
cmp    (%rcx),%eax
sete   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
jmp    11cd <ishostseq+0xad>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    -0x18(%rbp),%rax
mov    (%rax),%rsi
mov    $0x4,%edx
call   1040 <memcmp@plt>
cmp    $0x0,%eax
sete   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
jmp    11cd <ishostseq+0xad>
jmp    11c6 <ishostseq+0xa6>
mov    $0x0,%al
call   1030 <abort@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ishostseq>:
push   %rax
mov    (%rdi),%ecx
xor    %eax,%eax
cmp    (%rsi),%ecx
jne    1157 <ishostseq+0x37>
mov    $0x1,%eax
cmp    $0x81,%ecx
je     1157 <ishostseq+0x37>
cmp    $0x80,%ecx
jne    1159 <ishostseq+0x39>
mov    (%rdi),%rdi
mov    (%rsi),%rsi
mov    $0x4,%edx
call   1040 <memcmp@plt>
mov    %eax,%ecx
xor    %eax,%eax
test   %ecx,%ecx
sete   %al
pop    %rcx
ret
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
%struct.sockaddr = type { i32 }
%struct.sockaddr_in = type { %struct.TYPE_4__ }
%struct.TYPE_4__ = type { i32 }
%struct.sockaddr_in6 = type { %struct.TYPE_3__ }
%struct.TYPE_3__ = type { i32* }
define i32 @ishostseq(%struct.sockaddr* %0, %struct.sockaddr* %1) {
%3 = alloca i32
%4 = alloca %struct.sockaddr*
%5 = alloca %struct.sockaddr*
store %struct.sockaddr* %0, %struct.sockaddr** %4
store %struct.sockaddr* %1, %struct.sockaddr** %5
%6 = load %struct.sockaddr*, %struct.sockaddr** %4
%7 = getelementptr inbounds %struct.sockaddr, %struct.sockaddr* %6, i32 0, i32 0
%8 = load i32, i32* %7
%9 = load %struct.sockaddr*, %struct.sockaddr** %5
%10 = getelementptr inbounds %struct.sockaddr, %struct.sockaddr* %9, i32 0, i32 0
%11 = load i32, i32* %10
%12 = icmp ne i32 %8, %11
br i1 %12, label %13, label %14
13: ; preds = %2
store i32 0, i32* %3
br label %50
14: ; preds = %2
%15 = load %struct.sockaddr*, %struct.sockaddr** %4
%16 = getelementptr inbounds %struct.sockaddr, %struct.sockaddr* %15, i32 0, i32 0
%17 = load i32, i32* %16
switch i32 %17, label %47 [
i32 129, label %18
i32 128, label %31
]
18: ; preds = %14
%19 = load %struct.sockaddr*, %struct.sockaddr** %4
%20 = bitcast %struct.sockaddr* %19 to %struct.sockaddr_in*
%21 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %20, i32 0, i32 0
%22 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %21, i32 0, i32 0
%23 = load i32, i32* %22
%24 = load %struct.sockaddr*, %struct.sockaddr** %5
%25 = bitcast %struct.sockaddr* %24 to %struct.sockaddr_in*
%26 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %25, i32 0, i32 0
%27 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %26, i32 0, i32 0
%28 = load i32, i32* %27
%29 = icmp eq i32 %23, %28
%30 = zext i1 %29 to i32
store i32 %30, i32* %3
br label %50
31: ; preds = %14
%32 = load %struct.sockaddr*, %struct.sockaddr** %4
%33 = bitcast %struct.sockaddr* %32 to %struct.sockaddr_in6*
%34 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %33, i32 0, i32 0
%35 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %34, i32 0, i32 0
%36 = load i32*, i32** %35
%37 = getelementptr inbounds i32, i32* %36, i64 0
%38 = load %struct.sockaddr*, %struct.sockaddr** %5
%39 = bitcast %struct.sockaddr* %38 to %struct.sockaddr_in6*
%40 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %39, i32 0, i32 0
%41 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %40, i32 0, i32 0
%42 = load i32*, i32** %41
%43 = getelementptr inbounds i32, i32* %42, i64 0
%44 = call i32 @memcmp(i32* %37, i32* %43, i32 4)
%45 = icmp eq i32 %44, 0
%46 = zext i1 %45 to i32
store i32 %46, i32* %3
br label %50
47: ; preds = %14
br label %48
48: ; preds = %47
%49 = call i32 (...) @abort()
unreachable
50: ; preds = %31, %18, %13
%51 = load i32, i32* %3
ret i32 %51
}

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