#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 dummy;
};
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) {
  in_addr_t addr;
  if (net < 128)
    addr = (net << IN_CLASSA_NSHIFT) | (host & IN_CLASSA_HOST);
  else if (net < 65536)
    addr = (net << IN_CLASSB_NSHIFT) | (host & IN_CLASSB_HOST);
  else if (net < 16777216L)
    addr = (net << IN_CLASSC_NSHIFT) | (host & IN_CLASSC_HOST);
  else
    addr = net | host;
  addr = htonl(addr);
  return (*(struct in_addr *)&addr);
}


x86 assembly (clang, -O0):
<inet_makeaddr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%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,-0x14(%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,-0x14(%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,-0x14(%rbp)
jmp    11bd <inet_makeaddr+0xad>
mov    -0xc(%rbp),%eax
or     -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    11c2 <inet_makeaddr+0xb2>
jmp    11c7 <inet_makeaddr+0xb7>
mov    -0x14(%rbp),%edi
call   1030 <htonl@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
add    $0x20,%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
%6 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
%7 = load i32, i32* %4
%8 = icmp slt i32 %7, 128
br i1 %8, label %9, label %17
9: ; preds = %2
%10 = load i32, i32* %4
%11 = load i32, i32* @IN_CLASSA_NSHIFT
%12 = shl i32 %10, %11
%13 = load i32, i32* %5
%14 = load i32, i32* @IN_CLASSA_HOST
%15 = and i32 %13, %14
%16 = or i32 %12, %15
store i32 %16, i32* %6
br label %46
17: ; preds = %2
%18 = load i32, i32* %4
%19 = icmp slt i32 %18, 65536
br i1 %19, label %20, label %28
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
store i32 %27, i32* %6
br label %45
28: ; preds = %17
%29 = load i32, i32* %4
%30 = sext i32 %29 to i64
%31 = icmp slt i64 %30, 16777216
br i1 %31, label %32, label %40
32: ; preds = %28
%33 = load i32, i32* %4
%34 = load i32, i32* @IN_CLASSC_NSHIFT
%35 = shl i32 %33, %34
%36 = load i32, i32* %5
%37 = load i32, i32* @IN_CLASSC_HOST
%38 = and i32 %36, %37
%39 = or i32 %35, %38
store i32 %39, i32* %6
br label %44
40: ; preds = %28
%41 = load i32, i32* %4
%42 = load i32, i32* %5
%43 = or i32 %41, %42
store i32 %43, i32* %6
br label %44
44: ; preds = %40, %32
br label %45
45: ; preds = %44, %20
br label %46
46: ; preds = %45, %9
%47 = load i32, i32* %6
%48 = call i32 @htonl(i32 %47)
store i32 %48, i32* %6
%49 = bitcast i32* %6 to %struct.in_addr*
%50 = bitcast %struct.in_addr* %3 to i8*
%51 = bitcast %struct.in_addr* %49 to i8*
%52 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %3, i32 0, i32 0
%53 = load i32, i32* %52
ret i32 %53
}

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
}