#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_long;

/* Variables and functions */
int /*<<< orphan*/ htonl(int /*<<< orphan*/);
int /*<<< orphan*/ inet_addr(char *);
scalar_t__ isClassA(int /*<<< orphan*/);
scalar_t__ isClassB(int /*<<< orphan*/);
scalar_t__ isClassC(int /*<<< orphan*/);
u_long getNaturalMask(u_long inaddr) {
  if (isClassA(inaddr)) {
    return inet_addr("255.0.0.0");
  }
  if (isClassB(inaddr)) {
    return inet_addr("255.255.0.0");
  }
  if (isClassC(inaddr)) {
    return inet_addr("255.255.255.0");
  }
  return htonl(0);
}


x86 assembly (clang, -O0):
<getNaturalMask>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    -0x8(%rbp),%edi
call   1040 <isClassA@plt>
cmp    $0x0,%rax
je     1181 <getNaturalMask+0x31>
lea    0xe8c(%rip),%rdi
call   1060 <inet_addr@plt>
mov    %eax,-0x4(%rbp)
jmp    11d7 <getNaturalMask+0x87>
mov    -0x8(%rbp),%edi
call   1070 <isClassB@plt>
cmp    $0x0,%rax
je     11a7 <getNaturalMask+0x57>
lea    0xe70(%rip),%rdi
call   1060 <inet_addr@plt>
mov    %eax,-0x4(%rbp)
jmp    11d7 <getNaturalMask+0x87>
mov    -0x8(%rbp),%edi
call   1030 <isClassC@plt>
cmp    $0x0,%rax
je     11cd <getNaturalMask+0x7d>
lea    0xe56(%rip),%rdi
call   1060 <inet_addr@plt>
mov    %eax,-0x4(%rbp)
jmp    11d7 <getNaturalMask+0x87>
xor    %edi,%edi
call   1050 <htonl@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getNaturalMask>:
push   %rbx
mov    %edi,%ebx
call   1040 <isClassA@plt>
test   %rax,%rax
je     116a <getNaturalMask+0x1a>
lea    0xe9c(%rip),%rdi
pop    %rbx
jmp    1060 <inet_addr@plt>
mov    %ebx,%edi
call   1070 <isClassB@plt>
test   %rax,%rax
je     1183 <getNaturalMask+0x33>
lea    0xe8d(%rip),%rdi
pop    %rbx
jmp    1060 <inet_addr@plt>
mov    %ebx,%edi
call   1030 <isClassC@plt>
test   %rax,%rax
je     119c <getNaturalMask+0x4c>
lea    0xe80(%rip),%rdi
pop    %rbx
jmp    1060 <inet_addr@plt>
xor    %edi,%edi
pop    %rbx
jmp    1050 <htonl@plt>

LLVM IR (-O0):
@.str = [10 x i8] c"255.0.0.0\00"
@.str.1 = [12 x i8] c"255.255.0.0\00"
@.str.2 = [14 x i8] c"255.255.255.0\00"
define i32 @getNaturalMask(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
%5 = call i64 @isClassA(i32 %4)
%6 = icmp ne i64 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %1
%8 = call i32 @inet_addr(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
store i32 %8, i32* %2
br label %23
9: ; preds = %1
%10 = load i32, i32* %3
%11 = call i64 @isClassB(i32 %10)
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %9
%14 = call i32 @inet_addr(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
store i32 %14, i32* %2
br label %23
15: ; preds = %9
%16 = load i32, i32* %3
%17 = call i64 @isClassC(i32 %16)
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %15
%20 = call i32 @inet_addr(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
store i32 %20, i32* %2
br label %23
21: ; preds = %15
%22 = call i32 @htonl(i32 0)
store i32 %22, i32* %2
br label %23
23: ; preds = %21, %19, %13, %7
%24 = load i32, i32* %2
ret i32 %24
}

LLVM IR (-O2):
@.str = [10 x i8] c"255.0.0.0\00"
@.str.1 = [12 x i8] c"255.255.0.0\00"
@.str.2 = [14 x i8] c"255.255.255.0\00"
define i32 @getNaturalMask(i32 %0) {
%2 = tail call i64 @isClassA(i32 %0)
%3 = icmp eq i64 %2, 0
br i1 %3, label %6, label %4
4: ; preds = %1
%5 = tail call i32 @inet_addr(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
br label %18
6: ; preds = %1
%7 = tail call i64 @isClassB(i32 %0)
%8 = icmp eq i64 %7, 0
br i1 %8, label %11, label %9
9: ; preds = %6
%10 = tail call i32 @inet_addr(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
br label %18
11: ; preds = %6
%12 = tail call i64 @isClassC(i32 %0)
%13 = icmp eq i64 %12, 0
br i1 %13, label %16, label %14
14: ; preds = %11
%15 = tail call i32 @inet_addr(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
br label %18
16: ; preds = %11
%17 = tail call i32 @htonl(i32 0)
br label %18
18: ; preds = %16, %14, %9, %4
%19 = phi i32 [ %5, %4 ], [ %10, %9 ], [ %15, %14 ], [ %17, %16 ]
ret i32 %19
}