#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 */
typedef int /*<<< orphan*/ u_int32_t;
struct in_addr {
  int /*<<< orphan*/ s_addr;
};
typedef int /*<<< orphan*/ in_addr_t;
typedef int /*<<< orphan*/ i;

/* Variables and functions */
scalar_t__ IN_CLASSA(int /*<<< orphan*/);
int /*<<< orphan*/ IN_CLASSA_HOST;
scalar_t__ IN_CLASSB(int /*<<< orphan*/);
int /*<<< orphan*/ IN_CLASSB_HOST;
int /*<<< orphan*/ IN_CLASSC_HOST;
int /*<<< orphan*/ ntohl(int /*<<< orphan*/);
in_addr_t inet_lnaof(struct in_addr in) {
  u_int32_t i = ntohl(in.s_addr);
  if (IN_CLASSA(i))
    return ((i)&IN_CLASSA_HOST);
  else if (IN_CLASSB(i))
    return ((i)&IN_CLASSB_HOST);
  else
    return ((i)&IN_CLASSC_HOST);
}


x86 assembly (clang, -O0):
<inet_lnaof>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    -0x8(%rbp),%edi
call   1040 <ntohl@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%edi
call   1050 <IN_CLASSA@plt>
cmp    $0x0,%rax
je     116c <inet_lnaof+0x3c>
mov    -0xc(%rbp),%eax
mov    0x2e6e(%rip),%rcx
and    (%rcx),%eax
mov    %eax,-0x4(%rbp)
jmp    11a1 <inet_lnaof+0x71>
mov    -0xc(%rbp),%edi
call   1030 <IN_CLASSB@plt>
cmp    $0x0,%rax
je     1192 <inet_lnaof+0x62>
mov    -0xc(%rbp),%eax
mov    0x2e60(%rip),%rcx
and    (%rcx),%eax
mov    %eax,-0x4(%rbp)
jmp    11a1 <inet_lnaof+0x71>
mov    -0xc(%rbp),%eax
mov    0x2e3c(%rip),%rcx
and    (%rcx),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<inet_lnaof>:
push   %rbx
call   1040 <ntohl@plt>
mov    %eax,%ebx
mov    %eax,%edi
call   1050 <IN_CLASSA@plt>
test   %rax,%rax
je     114d <inet_lnaof+0x1d>
mov    0x2e85(%rip),%rax
jmp    1169 <inet_lnaof+0x39>
mov    %ebx,%edi
call   1030 <IN_CLASSB@plt>
test   %rax,%rax
jne    1162 <inet_lnaof+0x32>
mov    0x2e78(%rip),%rax
jmp    1169 <inet_lnaof+0x39>
mov    0x2e7f(%rip),%rax
mov    (%rax),%eax
and    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
%struct.in_addr = type { i32 }
@IN_CLASSA_HOST = global i32 0
@IN_CLASSB_HOST = global i32 0
@IN_CLASSC_HOST = global i32 0
define i32 @inet_lnaof(i32 %0) {
%2 = alloca i32
%3 = alloca %struct.in_addr
%4 = alloca i32
%5 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %3, i32 0, i32 0
store i32 %0, i32* %5
%6 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %3, i32 0, i32 0
%7 = load i32, i32* %6
%8 = call i32 @ntohl(i32 %7)
store i32 %8, i32* %4
%9 = load i32, i32* %4
%10 = call i64 @IN_CLASSA(i32 %9)
%11 = icmp ne i64 %10, 0
br i1 %11, label %12, label %16
12: ; preds = %1
%13 = load i32, i32* %4
%14 = load i32, i32* @IN_CLASSA_HOST
%15 = and i32 %13, %14
store i32 %15, i32* %2
br label %28
16: ; preds = %1
%17 = load i32, i32* %4
%18 = call i64 @IN_CLASSB(i32 %17)
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %24
20: ; preds = %16
%21 = load i32, i32* %4
%22 = load i32, i32* @IN_CLASSB_HOST
%23 = and i32 %21, %22
store i32 %23, i32* %2
br label %28
24: ; preds = %16
%25 = load i32, i32* %4
%26 = load i32, i32* @IN_CLASSC_HOST
%27 = and i32 %25, %26
store i32 %27, i32* %2
br label %28
28: ; preds = %24, %20, %12
%29 = load i32, i32* %2
ret i32 %29
}

LLVM IR (-O2):
@IN_CLASSA_HOST = global i32 0
@IN_CLASSB_HOST = global i32 0
@IN_CLASSC_HOST = global i32 0
define i32 @inet_lnaof(i32 %0) {
%2 = tail call i32 @ntohl(i32 %0)
%3 = tail call i64 @IN_CLASSA(i32 %2)
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %9
5: ; preds = %1
%6 = tail call i64 @IN_CLASSB(i32 %2)
%7 = icmp eq i64 %6, 0
%8 = select i1 %7, i32* @IN_CLASSC_HOST, i32* @IN_CLASSB_HOST
br label %9
9: ; preds = %5, %1
%10 = phi i32* [ @IN_CLASSA_HOST, %1 ], [ %8, %5 ]
%11 = load i32, i32* %10
%12 = and i32 %11, %2
ret i32 %12
}