#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 s_addr;
};
typedef int in_addr_t;

/* Variables and functions */
int IN_CLASSA_HOST;
int IN_CLASSA_NSHIFT;
int IN_CLASSB_HOST;
int IN_CLASSB_NSHIFT;
int IN_CLASSC_HOST;
int IN_CLASSC_NSHIFT;
int htonl(int);
struct in_addr inet_makeaddr(in_addr_t net, in_addr_t host) {
  struct in_addr in;
  if (net < 128)
    in.s_addr = (net << IN_CLASSA_NSHIFT) | (host & IN_CLASSA_HOST);
  else if (net < 65536)
    in.s_addr = (net << IN_CLASSB_NSHIFT) | (host & IN_CLASSB_HOST);
  else if (net < 16777216L)
    in.s_addr = (net << IN_CLASSC_NSHIFT) | (host & IN_CLASSC_HOST);
  else
    in.s_addr = net | host;
  in.s_addr = htonl(in.s_addr);
  return in;
}


x86 assembly (clang, -O0):
<inet_makeaddr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0xc(%rbp)
mov    %esi,-0x10(%rbp)
cmpl   $0x80,-0xc(%rbp)
jge    114f <inet_makeaddr+0x3f>
mov    -0xc(%rbp),%eax
mov    0x2eab(%rip),%rcx
mov    (%rcx),%ecx
shl    %cl,%eax
mov    -0x10(%rbp),%ecx
mov    0x2e7d(%rip),%rdx
and    (%rdx),%ecx
or     %ecx,%eax
mov    %eax,-0x8(%rbp)
jmp    11c7 <inet_makeaddr+0xb7>
cmpl   $0x10000,-0xc(%rbp)
jge    1180 <inet_makeaddr+0x70>
mov    -0xc(%rbp),%eax
mov    0x2e52(%rip),%rcx
mov    (%rcx),%ecx
shl    %cl,%eax
mov    -0x10(%rbp),%ecx
mov    0x2e74(%rip),%rdx
and    (%rdx),%ecx
or     %ecx,%eax
mov    %eax,-0x8(%rbp)
jmp    11c2 <inet_makeaddr+0xb2>
movslq -0xc(%rbp),%rax
cmp    $0x1000000,%rax
jge    11b4 <inet_makeaddr+0xa4>
mov    -0xc(%rbp),%eax
mov    0x2e36(%rip),%rcx
mov    (%rcx),%ecx
shl    %cl,%eax
mov    -0x10(%rbp),%ecx
mov    0x2e20(%rip),%rdx
and    (%rdx),%ecx
or     %ecx,%eax
mov    %eax,-0x8(%rbp)
jmp    11bd <inet_makeaddr+0xad>
mov    -0xc(%rbp),%eax
or     -0x10(%rbp),%eax
mov    %eax,-0x8(%rbp)
jmp    11c2 <inet_makeaddr+0xb2>
jmp    11c7 <inet_makeaddr+0xb7>
mov    -0x8(%rbp),%edi
call   1030 <htonl@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<inet_makeaddr>:
cmp    $0x7f,%edi
jg     1129 <inet_makeaddr+0x19>
mov    0x2ec4(%rip),%rax
mov    (%rax),%cl
shl    %cl,%edi
mov    0x2e99(%rip),%rax
jmp    115f <inet_makeaddr+0x4f>
cmp    $0xffff,%edi
ja     1145 <inet_makeaddr+0x35>
mov    0x2e80(%rip),%rax
mov    (%rax),%cl
shl    %cl,%edi
mov    0x2ea5(%rip),%rax
jmp    115f <inet_makeaddr+0x4f>
cmp    $0xffffff,%edi
ja     1161 <inet_makeaddr+0x51>
mov    0x2e7c(%rip),%rax
mov    (%rax),%cl
shl    %cl,%edi
mov    0x2e69(%rip),%rax
and    (%rax),%esi
or     %edi,%esi
mov    %esi,%edi
jmp    1030 <htonl@plt>

LLVM IR (-O0):
%struct.in_addr = type { i32 }
@IN_CLASSA_NSHIFT = global i32 0
@IN_CLASSA_HOST = global i32 0
@IN_CLASSB_NSHIFT = global i32 0
@IN_CLASSB_HOST = global i32 0
@IN_CLASSC_NSHIFT = global i32 0
@IN_CLASSC_HOST = global i32 0
define i32 @inet_makeaddr(i32 %0, i32 %1) {
%3 = alloca %struct.in_addr
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
%6 = load i32, i32* %4
%7 = icmp slt i32 %6, 128
br i1 %7, label %8, label %17
8: ; preds = %2
%9 = load i32, i32* %4
%10 = load i32, i32* @IN_CLASSA_NSHIFT
%11 = shl i32 %9, %10
%12 = load i32, i32* %5
%13 = load i32, i32* @IN_CLASSA_HOST
%14 = and i32 %12, %13
%15 = or i32 %11, %14
%16 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %3, i32 0, i32 0
store i32 %15, i32* %16
br label %49
17: ; preds = %2
%18 = load i32, i32* %4
%19 = icmp slt i32 %18, 65536
br i1 %19, label %20, label %29
20: ; preds = %17
%21 = load i32, i32* %4
%22 = load i32, i32* @IN_CLASSB_NSHIFT
%23 = shl i32 %21, %22
%24 = load i32, i32* %5
%25 = load i32, i32* @IN_CLASSB_HOST
%26 = and i32 %24, %25
%27 = or i32 %23, %26
%28 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %3, i32 0, i32 0
store i32 %27, i32* %28
br label %48
29: ; preds = %17
%30 = load i32, i32* %4
%31 = sext i32 %30 to i64
%32 = icmp slt i64 %31, 16777216
br i1 %32, label %33, label %42
33: ; preds = %29
%34 = load i32, i32* %4
%35 = load i32, i32* @IN_CLASSC_NSHIFT
%36 = shl i32 %34, %35
%37 = load i32, i32* %5
%38 = load i32, i32* @IN_CLASSC_HOST
%39 = and i32 %37, %38
%40 = or i32 %36, %39
%41 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %3, i32 0, i32 0
store i32 %40, i32* %41
br label %47
42: ; preds = %29
%43 = load i32, i32* %4
%44 = load i32, i32* %5
%45 = or i32 %43, %44
%46 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %3, i32 0, i32 0
store i32 %45, i32* %46
br label %47
47: ; preds = %42, %33
br label %48
48: ; preds = %47, %20
br label %49
49: ; preds = %48, %8
%50 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %3, i32 0, i32 0
%51 = load i32, i32* %50
%52 = call i32 @htonl(i32 %51)
%53 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %3, i32 0, i32 0
store i32 %52, i32* %53
%54 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %3, i32 0, i32 0
%55 = load i32, i32* %54
ret i32 %55
}

LLVM IR (-O2):
@IN_CLASSA_NSHIFT = global i32 0
@IN_CLASSA_HOST = global i32 0
@IN_CLASSB_NSHIFT = global i32 0
@IN_CLASSB_HOST = global i32 0
@IN_CLASSC_NSHIFT = global i32 0
@IN_CLASSC_HOST = global i32 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 = load i32, i32* @IN_CLASSA_NSHIFT
%6 = shl i32 %0, %5
%7 = load i32, i32* @IN_CLASSA_HOST
%8 = and i32 %7, %1
%9 = or i32 %8, %6
br label %28
10: ; preds = %2
%11 = icmp ult i32 %0, 65536
br i1 %11, label %12, label %18
12: ; preds = %10
%13 = load i32, i32* @IN_CLASSB_NSHIFT
%14 = shl i32 %0, %13
%15 = load i32, i32* @IN_CLASSB_HOST
%16 = and i32 %15, %1
%17 = or i32 %16, %14
br label %28
18: ; preds = %10
%19 = icmp ult i32 %0, 16777216
br i1 %19, label %20, label %26
20: ; preds = %18
%21 = load i32, i32* @IN_CLASSC_NSHIFT
%22 = shl i32 %0, %21
%23 = load i32, i32* @IN_CLASSC_HOST
%24 = and i32 %23, %1
%25 = or i32 %24, %22
br label %28
26: ; preds = %18
%27 = or i32 %1, %0
br label %28
28: ; preds = %12, %26, %20, %4
%29 = phi i32 [ %9, %4 ], [ %17, %12 ], [ %25, %20 ], [ %27, %26 ]
%30 = tail call i32 @htonl(i32 %29)
ret i32 %30
}