#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_4__ {
  scalar_t__ s_addr;
};
struct sockaddr_in {
  TYPE_2__ sin_addr;
};
struct sockaddr {
  scalar_t__ sa_family;
};
struct ifaddrs {
  struct ifaddrs *ifa_next;
  TYPE_1__ *ifa_addr;
};
struct TYPE_3__ {
  scalar_t__ sa_family;
};

/* Variables and functions */
scalar_t__ AF_INET;
int addrinifaddrs(struct sockaddr *sa, struct ifaddrs *ifaddr) {
  while (ifaddr) {
    if (ifaddr->ifa_addr->sa_family == sa->sa_family) {
      if (sa->sa_family == AF_INET) {
        struct sockaddr_in *sin, *ifsin;
        sin = (struct sockaddr_in *)sa;
        ifsin = (struct sockaddr_in *)ifaddr->ifa_addr;
        if (ifsin->sin_addr.s_addr == sin->sin_addr.s_addr) {
          return 1;
        }
      } else {
        return 0;
      }
    }
    ifaddr = ifaddr->ifa_next;
  }
  return 0;
}


x86 assembly (clang, -O0):
<addrinifaddrs>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11a0 <addrinifaddrs+0xa0>
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rax
mov    (%rax),%rax
mov    -0x10(%rbp),%rcx
cmp    (%rcx),%rax
jne    1190 <addrinifaddrs+0x90>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    0x2eab(%rip),%rcx
cmp    (%rcx),%rax
jne    117f <addrinifaddrs+0x7f>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    (%rax),%rax
mov    -0x20(%rbp),%rcx
cmp    (%rcx),%rax
jne    117a <addrinifaddrs+0x7a>
movl   $0x1,-0x4(%rbp)
jmp    11a7 <addrinifaddrs+0xa7>
jmp    118b <addrinifaddrs+0x8b>
movl   $0x0,-0x4(%rbp)
jmp    11a7 <addrinifaddrs+0xa7>
jmp    1190 <addrinifaddrs+0x90>
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
jmp    110c <addrinifaddrs+0xc>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<addrinifaddrs>:
xor    %eax,%eax
test   %rsi,%rsi
je     1121 <addrinifaddrs+0x21>
mov    (%rdi),%rcx
nopw   0x0(%rax,%rax,1)
mov    0x8(%rsi),%rdx
cmp    %rcx,(%rdx)
je     1122 <addrinifaddrs+0x22>
mov    (%rsi),%rsi
test   %rsi,%rsi
jne    1110 <addrinifaddrs+0x10>
ret
mov    0x2ebf(%rip),%rdx
xor    %eax,%eax
cmp    (%rdx),%rcx
sete   %al
ret

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

LLVM IR (-O2):
%struct.sockaddr = type { i64 }
%struct.ifaddrs = type { %struct.ifaddrs*, %struct.TYPE_3__* }
%struct.TYPE_3__ = type { i64 }
@AF_INET = global i64 0
define i32 @addrinifaddrs(%struct.sockaddr* nocapture %0, %struct.ifaddrs* %1) {
%3 = icmp eq %struct.ifaddrs* %1, null
br i1 %3, label %22, label %4
4: ; preds = %2
%5 = getelementptr inbounds %struct.sockaddr, %struct.sockaddr* %0, i64 0, i32 0
%6 = load i64, i64* %5
br label %7
7: ; preds = %4, %18
%8 = phi %struct.ifaddrs* [ %1, %4 ], [ %20, %18 ]
%9 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %8, i64 0, i32 1
%10 = load %struct.TYPE_3__*, %struct.TYPE_3__** %9
%11 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %10, i64 0, i32 0
%12 = load i64, i64* %11
%13 = icmp eq i64 %12, %6
br i1 %13, label %14, label %18
14: ; preds = %7
%15 = load i64, i64* @AF_INET
%16 = icmp eq i64 %6, %15
%17 = zext i1 %16 to i32
br label %22
18: ; preds = %7
%19 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %8, i64 0, i32 0
%20 = load %struct.ifaddrs*, %struct.ifaddrs** %19
%21 = icmp eq %struct.ifaddrs* %20, null
br i1 %21, label %22, label %7
22: ; preds = %18, %2, %14
%23 = phi i32 [ %17, %14 ], [ 0, %2 ], [ 0, %18 ]
ret i32 %23
}