#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 in_addr {
  int /*<<< orphan*/ s_addr;
};

/* Variables and functions */
long IN_CLASSA_NSHIFT;
long IN_CLASSB_NSHIFT;
long IN_CLASSC_NSHIFT;
int /*<<< orphan*/ htonl(long);
extern struct in_addr inet_makeaddr(int net, int lna) {
  long a;
  struct in_addr in;
  if (net <= 0x7f)
    a = ((long)net << IN_CLASSA_NSHIFT) | lna;
  else if (net <= 0x3fff)
    a = 0x80000000 | ((long)net << IN_CLASSB_NSHIFT) | lna;
  else
    a = 0xc0000000 | ((long)net << IN_CLASSC_NSHIFT) | lna;
  in.s_addr = htonl(a);
  return in;
}


x86 assembly (clang, -O0):
<inet_makeaddr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0xc(%rbp)
mov    %esi,-0x10(%rbp)
cmpl   $0x7f,-0xc(%rbp)
jg     1149 <inet_makeaddr+0x39>
movslq -0xc(%rbp),%rax
mov    0x2eb5(%rip),%rcx
mov    (%rcx),%rcx
shl    %cl,%rax
movslq -0x10(%rbp),%rcx
or     %rcx,%rax
mov    %rax,-0x18(%rbp)
jmp    11b2 <inet_makeaddr+0xa2>
cmpl   $0x3fff,-0xc(%rbp)
jg     1184 <inet_makeaddr+0x74>
movslq -0xc(%rbp),%rax
mov    0x2e6f(%rip),%rcx
mov    (%rcx),%rcx
shl    %cl,%rax
movabs $0x80000000,%rcx
or     %rcx,%rax
movslq -0x10(%rbp),%rcx
or     %rcx,%rax
mov    %rax,-0x18(%rbp)
jmp    11ad <inet_makeaddr+0x9d>
movslq -0xc(%rbp),%rax
mov    0x2e49(%rip),%rcx
mov    (%rcx),%rcx
shl    %cl,%rax
movabs $0xc0000000,%rcx
or     %rcx,%rax
movslq -0x10(%rbp),%rcx
or     %rcx,%rax
mov    %rax,-0x18(%rbp)
jmp    11b2 <inet_makeaddr+0xa2>
mov    -0x18(%rbp),%rdi
call   1030 <htonl@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<inet_makeaddr>:
cmp    $0x7f,%edi
jg     112f <inet_makeaddr+0x1f>
movslq %edi,%rax
mov    0x2ec9(%rip),%rcx
mov    (%rcx),%cl
shl    %cl,%rax
movslq %esi,%rdi
or     %rax,%rdi
jmp    1030 <htonl@plt>
mov    $0x80000000,%eax
mov    %edi,%edx
cmp    $0x3fff,%edi
ja     1158 <inet_makeaddr+0x48>
mov    0x2e8b(%rip),%rcx
mov    (%rcx),%cl
shl    %cl,%rdx
movslq %esi,%rdi
or     %rdx,%rdi
or     %rax,%rdi
jmp    1030 <htonl@plt>
mov    0x2e79(%rip),%rcx
mov    (%rcx),%cl
shl    %cl,%rdx
movslq %esi,%rcx
add    $0x40000000,%rax
or     %rcx,%rax
or     %rdx,%rax
mov    %rax,%rdi
jmp    1030 <htonl@plt>

LLVM IR (-O0):
%struct.in_addr = type { i32 }
@IN_CLASSA_NSHIFT = global i64 0
@IN_CLASSB_NSHIFT = global i64 0
@IN_CLASSC_NSHIFT = global i64 0
define i32 @inet_makeaddr(i32 %0, i32 %1) {
%3 = alloca %struct.in_addr
%4 = alloca i32
%5 = alloca i32
%6 = alloca i64
store i32 %0, i32* %4
store i32 %1, i32* %5
%7 = load i32, i32* %4
%8 = icmp sle i32 %7, 127
br i1 %8, label %9, label %17
9: ; preds = %2
%10 = load i32, i32* %4
%11 = sext i32 %10 to i64
%12 = load i64, i64* @IN_CLASSA_NSHIFT
%13 = shl i64 %11, %12
%14 = load i32, i32* %5
%15 = sext i32 %14 to i64
%16 = or i64 %13, %15
store i64 %16, i64* %6
br label %39
17: ; preds = %2
%18 = load i32, i32* %4
%19 = icmp sle i32 %18, 16383
br i1 %19, label %20, label %29
20: ; preds = %17
%21 = load i32, i32* %4
%22 = sext i32 %21 to i64
%23 = load i64, i64* @IN_CLASSB_NSHIFT
%24 = shl i64 %22, %23
%25 = or i64 2147483648, %24
%26 = load i32, i32* %5
%27 = sext i32 %26 to i64
%28 = or i64 %25, %27
store i64 %28, i64* %6
br label %38
29: ; preds = %17
%30 = load i32, i32* %4
%31 = sext i32 %30 to i64
%32 = load i64, i64* @IN_CLASSC_NSHIFT
%33 = shl i64 %31, %32
%34 = or i64 3221225472, %33
%35 = load i32, i32* %5
%36 = sext i32 %35 to i64
%37 = or i64 %34, %36
store i64 %37, i64* %6
br label %38
38: ; preds = %29, %20
br label %39
39: ; preds = %38, %9
%40 = load i64, i64* %6
%41 = call i32 @htonl(i64 %40)
%42 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %3, i32 0, i32 0
store i32 %41, i32* %42
%43 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %3, i32 0, i32 0
%44 = load i32, i32* %43
ret i32 %44
}

LLVM IR (-O2):
@IN_CLASSA_NSHIFT = global i64 0
@IN_CLASSB_NSHIFT = global i64 0
@IN_CLASSC_NSHIFT = global i64 0
define i32 @inet_makeaddr(i32 %0, i32 %1) {
%3 = icmp slt i32 %0, 128
br i1 %3, label %4, label %10
4: ; preds = %2
%5 = sext i32 %0 to i64
%6 = load i64, i64* @IN_CLASSA_NSHIFT
%7 = shl i64 %5, %6
%8 = sext i32 %1 to i64
%9 = or i64 %7, %8
br label %25
10: ; preds = %2
%11 = icmp ult i32 %0, 16384
%12 = zext i32 %0 to i64
br i1 %11, label %13, label %19
13: ; preds = %10
%14 = load i64, i64* @IN_CLASSB_NSHIFT
%15 = shl i64 %12, %14
%16 = sext i32 %1 to i64
%17 = or i64 %15, %16
%18 = or i64 %17, 2147483648
br label %25
19: ; preds = %10
%20 = load i64, i64* @IN_CLASSC_NSHIFT
%21 = shl i64 %12, %20
%22 = sext i32 %1 to i64
%23 = or i64 %21, %22
%24 = or i64 %23, 3221225472
br label %25
25: ; preds = %13, %19, %4
%26 = phi i64 [ %9, %4 ], [ %18, %13 ], [ %24, %19 ]
%27 = tail call i32 @htonl(i64 %26)
ret i32 %27
}