#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 in6_addr {
  int *s6_addr32;
};

/* Variables and functions */
int htonl(int);
bool ipv6_addr_loopback(const struct in6_addr *a) {
  return (a->s6_addr32[0] | a->s6_addr32[1] | a->s6_addr32[2] |
          (a->s6_addr32[3] ^ htonl(1))) == 0;
}


x86 assembly (clang, -O0):
<ipv6_addr_loopback>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    (%rax),%eax
mov    -0x8(%rbp),%rcx
mov    (%rcx),%rcx
or     0x4(%rcx),%eax
mov    -0x8(%rbp),%rcx
mov    (%rcx),%rcx
or     0x8(%rcx),%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    0xc(%rax),%eax
mov    %eax,-0x10(%rbp)
mov    $0x1,%edi
call   1030 <htonl@plt>
mov    -0x10(%rbp),%ecx
mov    %eax,%edx
mov    -0xc(%rbp),%eax
xor    %edx,%ecx
or     %ecx,%eax
cmp    $0x0,%eax
sete   %al
and    $0x1,%al
movzbl %al,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ipv6_addr_loopback>:
push   %rbp
push   %rbx
push   %rax
mov    (%rdi),%rax
mov    0x4(%rax),%ebx
mov    0xc(%rax),%ebp
or     (%rax),%ebx
or     0x8(%rax),%ebx
mov    $0x1,%edi
call   1030 <htonl@plt>
xor    %ebp,%eax
xor    %ecx,%ecx
or     %ebx,%eax
sete   %cl
mov    %ecx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.in6_addr = type { i32* }
define i32 @ipv6_addr_loopback(%struct.in6_addr* %0) {
%2 = alloca %struct.in6_addr*
store %struct.in6_addr* %0, %struct.in6_addr** %2
%3 = load %struct.in6_addr*, %struct.in6_addr** %2
%4 = getelementptr inbounds %struct.in6_addr, %struct.in6_addr* %3, i32 0, i32 0
%5 = load i32*, i32** %4
%6 = getelementptr inbounds i32, i32* %5, i64 0
%7 = load i32, i32* %6
%8 = load %struct.in6_addr*, %struct.in6_addr** %2
%9 = getelementptr inbounds %struct.in6_addr, %struct.in6_addr* %8, i32 0, i32 0
%10 = load i32*, i32** %9
%11 = getelementptr inbounds i32, i32* %10, i64 1
%12 = load i32, i32* %11
%13 = or i32 %7, %12
%14 = load %struct.in6_addr*, %struct.in6_addr** %2
%15 = getelementptr inbounds %struct.in6_addr, %struct.in6_addr* %14, i32 0, i32 0
%16 = load i32*, i32** %15
%17 = getelementptr inbounds i32, i32* %16, i64 2
%18 = load i32, i32* %17
%19 = or i32 %13, %18
%20 = load %struct.in6_addr*, %struct.in6_addr** %2
%21 = getelementptr inbounds %struct.in6_addr, %struct.in6_addr* %20, i32 0, i32 0
%22 = load i32*, i32** %21
%23 = getelementptr inbounds i32, i32* %22, i64 3
%24 = load i32, i32* %23
%25 = call i32 @htonl(i32 1)
%26 = xor i32 %24, %25
%27 = or i32 %19, %26
%28 = icmp eq i32 %27, 0
%29 = zext i1 %28 to i32
ret i32 %29
}

LLVM IR (-O2):
%struct.in6_addr = type { i32* }
define i32 @ipv6_addr_loopback(%struct.in6_addr* nocapture %0) {
%2 = getelementptr inbounds %struct.in6_addr, %struct.in6_addr* %0, i64 0, i32 0
%3 = load i32*, i32** %2
%4 = load i32, i32* %3
%5 = getelementptr inbounds i32, i32* %3, i64 1
%6 = load i32, i32* %5
%7 = or i32 %6, %4
%8 = getelementptr inbounds i32, i32* %3, i64 2
%9 = load i32, i32* %8
%10 = or i32 %7, %9
%11 = getelementptr inbounds i32, i32* %3, i64 3
%12 = load i32, i32* %11
%13 = tail call i32 @htonl(i32 1)
%14 = xor i32 %13, %12
%15 = or i32 %10, %14
%16 = icmp eq i32 %15, 0
%17 = zext i1 %16 to i32
ret i32 %17
}