#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 TYPE_2__ {
  int s_addr;
};
struct sockaddr_in {
  TYPE_1__ sin_addr;
};
struct in_addr {
  int s_addr;
};
struct ifaddrs {
  scalar_t__ ifa_netmask;
  scalar_t__ ifa_addr;
};

/* Variables and functions */
int in_subnet(struct in_addr ip, struct ifaddrs *ifs) {
  if ((ip.s_addr &
       ((struct sockaddr_in *)(ifs->ifa_netmask))->sin_addr.s_addr) ==
      (((struct sockaddr_in *)(ifs->ifa_addr))->sin_addr.s_addr &
       ((struct sockaddr_in *)(ifs->ifa_netmask))->sin_addr.s_addr))
    return 1;
  return 0;
}


x86 assembly (clang, -O0):
<in_subnet>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%eax
mov    -0x10(%rbp),%rcx
mov    (%rcx),%rcx
and    (%rcx),%eax
mov    -0x10(%rbp),%rcx
mov    0x8(%rcx),%rcx
mov    (%rcx),%ecx
mov    -0x10(%rbp),%rdx
mov    (%rdx),%rdx
and    (%rdx),%ecx
cmp    %ecx,%eax
jne    113e <in_subnet+0x3e>
movl   $0x1,-0x4(%rbp)
jmp    1145 <in_subnet+0x45>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<in_subnet>:
mov    (%rsi),%rcx
mov    0x8(%rsi),%rax
xor    (%rax),%edi
xor    %eax,%eax
test   %edi,(%rcx)
sete   %al
ret

LLVM IR (-O0):
%struct.ifaddrs = type { i64, i64 }
%struct.in_addr = type { i32 }
%struct.sockaddr_in = type { %struct.TYPE_2__ }
%struct.TYPE_2__ = type { i32 }
define i32 @in_subnet(i32 %0, %struct.ifaddrs* %1) {
%3 = alloca i32
%4 = alloca %struct.in_addr
%5 = alloca %struct.ifaddrs*
%6 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %4, i32 0, i32 0
store i32 %0, i32* %6
store %struct.ifaddrs* %1, %struct.ifaddrs** %5
%7 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %4, i32 0, i32 0
%8 = load i32, i32* %7
%9 = load %struct.ifaddrs*, %struct.ifaddrs** %5
%10 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %9, i32 0, i32 0
%11 = load i64, i64* %10
%12 = inttoptr i64 %11 to %struct.sockaddr_in*
%13 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %12, i32 0, i32 0
%14 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %13, i32 0, i32 0
%15 = load i32, i32* %14
%16 = and i32 %8, %15
%17 = load %struct.ifaddrs*, %struct.ifaddrs** %5
%18 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %17, i32 0, i32 1
%19 = load i64, i64* %18
%20 = inttoptr i64 %19 to %struct.sockaddr_in*
%21 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %20, i32 0, i32 0
%22 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %21, i32 0, i32 0
%23 = load i32, i32* %22
%24 = load %struct.ifaddrs*, %struct.ifaddrs** %5
%25 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %24, i32 0, i32 0
%26 = load i64, i64* %25
%27 = inttoptr i64 %26 to %struct.sockaddr_in*
%28 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %27, i32 0, i32 0
%29 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %28, i32 0, i32 0
%30 = load i32, i32* %29
%31 = and i32 %23, %30
%32 = icmp eq i32 %16, %31
br i1 %32, label %33, label %34
33: ; preds = %2
store i32 1, i32* %3
br label %35
34: ; preds = %2
store i32 0, i32* %3
br label %35
35: ; preds = %34, %33
%36 = load i32, i32* %3
ret i32 %36
}

LLVM IR (-O2):
%struct.ifaddrs = type { i64, i64 }
%struct.sockaddr_in = type { %struct.TYPE_2__ }
%struct.TYPE_2__ = type { i32 }
define i32 @in_subnet(i32 %0, %struct.ifaddrs* nocapture %1) {
%3 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %1, i64 0, i32 0
%4 = load i64, i64* %3
%5 = inttoptr i64 %4 to %struct.sockaddr_in*
%6 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %5, i64 0, i32 0, i32 0
%7 = load i32, i32* %6
%8 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %1, i64 0, i32 1
%9 = load i64, i64* %8
%10 = inttoptr i64 %9 to %struct.sockaddr_in*
%11 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %10, i64 0, i32 0, i32 0
%12 = load i32, i32* %11
%13 = xor i32 %12, %0
%14 = and i32 %13, %7
%15 = icmp eq i32 %14, 0
%16 = zext i1 %15 to i32
ret i32 %16
}