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

/* Variables and functions */
scalar_t__ IN_CLASSA(int);
int IN_CLASSA_NET;
scalar_t__ IN_CLASSB(int);
int IN_CLASSB_NET;
scalar_t__ IN_CLASSC(int);
int IN_CLASSC_NET;
scalar_t__ IN_CLASSD(int);
uint32_t classMask(uint32_t prefix) {
  if (IN_CLASSA(prefix))
    return IN_CLASSA_NET;
  if (IN_CLASSB(prefix))
    return IN_CLASSB_NET;
  if (IN_CLASSC(prefix))
    return IN_CLASSC_NET;
  if (IN_CLASSD(prefix))
    return 0xF0000000;
  return 0;
}


x86 assembly (clang, -O0):
<classMask>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    -0x8(%rbp),%edi
call   1050 <IN_CLASSA@plt>
cmp    $0x0,%rax
je     116e <classMask+0x2e>
mov    0x2e84(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11d9 <classMask+0x99>
mov    -0x8(%rbp),%edi
call   1030 <IN_CLASSB@plt>
cmp    $0x0,%rax
je     1191 <classMask+0x51>
mov    0x2e59(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11d9 <classMask+0x99>
mov    -0x8(%rbp),%edi
call   1040 <IN_CLASSC@plt>
cmp    $0x0,%rax
je     11b4 <classMask+0x74>
mov    0x2e26(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11d9 <classMask+0x99>
mov    -0x8(%rbp),%edi
call   1060 <IN_CLASSD@plt>
cmp    $0x0,%rax
je     11d2 <classMask+0x92>
movl   $0xf0000000,-0x4(%rbp)
jmp    11d9 <classMask+0x99>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<classMask>:
push   %rbx
mov    %edi,%ebx
call   1050 <IN_CLASSA@plt>
test   %rax,%rax
je     1156 <classMask+0x16>
mov    0x2e94(%rip),%rax
jmp    117e <classMask+0x3e>
mov    %ebx,%edi
call   1030 <IN_CLASSB@plt>
test   %rax,%rax
je     116b <classMask+0x2b>
mov    0x2e77(%rip),%rax
jmp    117e <classMask+0x3e>
mov    %ebx,%edi
call   1040 <IN_CLASSC@plt>
test   %rax,%rax
je     1182 <classMask+0x42>
mov    0x2e52(%rip),%rax
mov    (%rax),%eax
pop    %rbx
ret
mov    %ebx,%edi
call   1060 <IN_CLASSD@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
sete   %al
shl    $0x1c,%eax
add    $0xf0000000,%eax
pop    %rbx
ret

LLVM IR (-O0):
@IN_CLASSA_NET = global i32 0
@IN_CLASSB_NET = global i32 0
@IN_CLASSC_NET = global i32 0
define i32 @classMask(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
%5 = call i64 @IN_CLASSA(i32 %4)
%6 = icmp ne i64 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %1
%8 = load i32, i32* @IN_CLASSA_NET
store i32 %8, i32* %2
br label %27
9: ; preds = %1
%10 = load i32, i32* %3
%11 = call i64 @IN_CLASSB(i32 %10)
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %9
%14 = load i32, i32* @IN_CLASSB_NET
store i32 %14, i32* %2
br label %27
15: ; preds = %9
%16 = load i32, i32* %3
%17 = call i64 @IN_CLASSC(i32 %16)
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %15
%20 = load i32, i32* @IN_CLASSC_NET
store i32 %20, i32* %2
br label %27
21: ; preds = %15
%22 = load i32, i32* %3
%23 = call i64 @IN_CLASSD(i32 %22)
%24 = icmp ne i64 %23, 0
br i1 %24, label %25, label %26
25: ; preds = %21
store i32 -268435456, i32* %2
br label %27
26: ; preds = %21
store i32 0, i32* %2
br label %27
27: ; preds = %26, %25, %19, %13, %7
%28 = load i32, i32* %2
ret i32 %28
}

LLVM IR (-O2):
@IN_CLASSA_NET = global i32 0
@IN_CLASSB_NET = global i32 0
@IN_CLASSC_NET = global i32 0
define i32 @classMask(i32 %0) {
%2 = tail call i64 @IN_CLASSA(i32 %0)
%3 = icmp eq i64 %2, 0
br i1 %3, label %6, label %4
4: ; preds = %1
%5 = load i32, i32* @IN_CLASSA_NET
br label %20
6: ; preds = %1
%7 = tail call i64 @IN_CLASSB(i32 %0)
%8 = icmp eq i64 %7, 0
br i1 %8, label %11, label %9
9: ; preds = %6
%10 = load i32, i32* @IN_CLASSB_NET
br label %20
11: ; preds = %6
%12 = tail call i64 @IN_CLASSC(i32 %0)
%13 = icmp eq i64 %12, 0
br i1 %13, label %16, label %14
14: ; preds = %11
%15 = load i32, i32* @IN_CLASSC_NET
br label %20
16: ; preds = %11
%17 = tail call i64 @IN_CLASSD(i32 %0)
%18 = icmp eq i64 %17, 0
%19 = select i1 %18, i32 0, i32 -268435456
br label %20
20: ; preds = %16, %14, %9, %4
%21 = phi i32 [ %5, %4 ], [ %10, %9 ], [ %15, %14 ], [ %19, %16 ]
ret i32 %21
}