#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 */

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ re_match(char *, char *);
int /*<<< orphan*/ validateType(char *, char *, int);
int check_network(char *network) {
  if (!validateType("ipv4net", network, 1)) {
    printf("Error: [%s] isn't a valid IPv4 network\n", network);
    return 0;
  }
  if (re_match(network, "^0.0.0.0/0$")) {
    printf("Error: 0.0.0.0/0 invalid in network-group\n");
    return 0;
  }
  if (re_match(network, "/0$")) {
    printf("Error: zero subnet invalid in network-group\n");
    return 0;
  }
  return 1;
}


x86 assembly (clang, -O0):
<check_network>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xeb9(%rip),%rdi
mov    $0x1,%edx
call   1030 <validateType@plt>
cmp    $0x0,%eax
jne    1178 <check_network+0x48>
mov    -0x10(%rbp),%rsi
lea    0xea3(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    11e7 <check_network+0xb7>
mov    -0x10(%rbp),%rdi
lea    0xead(%rip),%rsi
call   1040 <re_match@plt>
cmp    $0x0,%rax
je     11ac <check_network+0x7c>
lea    0xea3(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    11e7 <check_network+0xb7>
mov    -0x10(%rbp),%rdi
lea    0xe81(%rip),%rsi
call   1040 <re_match@plt>
cmp    $0x0,%rax
je     11e0 <check_network+0xb0>
lea    0xe9a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    11e7 <check_network+0xb7>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_network>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0xeb3(%rip),%rdi
mov    %rbx,%rsi
mov    $0x1,%edx
call   1030 <validateType@plt>
test   %eax,%eax
je     117b <check_network+0x3b>
lea    0xecb(%rip),%rsi
mov    %rbx,%rdi
call   1040 <re_match@plt>
test   %rax,%rax
je     1190 <check_network+0x50>
lea    0xeef(%rip),%rdi
jmp    11ab <check_network+0x6b>
lea    0xe86(%rip),%rdi
xor    %ebp,%ebp
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    11b2 <check_network+0x72>
lea    0xea1(%rip),%rsi
mov    %rbx,%rdi
call   1040 <re_match@plt>
test   %rax,%rax
je     11bb <check_network+0x7b>
lea    0xe91(%rip),%rdi
call   1050 <puts@plt>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
mov    $0x1,%ebp
jmp    11b2 <check_network+0x72>

LLVM IR (-O0):
@.str = [8 x i8] c"ipv4net\00"
@.str.1 = [40 x i8] c"Error: [%s] isn't a valid IPv4 network\0A\00"
@.str.2 = [12 x i8] c"^0.0.0.0/0$\00"
@.str.3 = [43 x i8] c"Error: 0.0.0.0/0 invalid in network-group\0A\00"
@.str.4 = [4 x i8] c"/0$\00"
@.str.5 = [45 x i8] c"Error: zero subnet invalid in network-group\0A\00"
define i32 @check_network(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
store i8* %0, i8** %3
%4 = load i8*, i8** %3
%5 = call i32 @validateType(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* %4, i32 1)
%6 = icmp ne i32 %5, 0
br i1 %6, label %10, label %7
7: ; preds = %1
%8 = load i8*, i8** %3
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0), i8* %8)
store i32 0, i32* %2
br label %23
10: ; preds = %1
%11 = load i8*, i8** %3
%12 = call i64 @re_match(i8* %11, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %10
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %2
br label %23
16: ; preds = %10
%17 = load i8*, i8** %3
%18 = call i64 @re_match(i8* %17, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %16
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.5, i64 0, i64 0))
store i32 0, i32* %2
br label %23
22: ; preds = %16
store i32 1, i32* %2
br label %23
23: ; preds = %22, %20, %14, %7
%24 = load i32, i32* %2
ret i32 %24
}

LLVM IR (-O2):
@.str = [8 x i8] c"ipv4net\00"
@.str.1 = [40 x i8] c"Error: [%s] isn't a valid IPv4 network\0A\00"
@.str.2 = [12 x i8] c"^0.0.0.0/0$\00"
@.str.4 = [4 x i8] c"/0$\00"
@str = [44 x i8] c"Error: zero subnet invalid in network-group\00"
@str.6 = [42 x i8] c"Error: 0.0.0.0/0 invalid in network-group\00"
define i32 @check_network(i8* %0) {
%2 = tail call i32 @validateType(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* %0, i32 1)
%3 = icmp eq i32 %2, 0
br i1 %3, label %4, label %6
4: ; preds = %1
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0), i8* %0)
br label %16
6: ; preds = %1
%7 = tail call i64 @re_match(i8* %0, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%8 = icmp eq i64 %7, 0
br i1 %8, label %11, label %9
9: ; preds = %6
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @str.6, i64 0, i64 0))
br label %16
11: ; preds = %6
%12 = tail call i64 @re_match(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
br i1 %13, label %16, label %14
14: ; preds = %11
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @str, i64 0, i64 0))
br label %16
16: ; preds = %11, %14, %9, %4
%17 = phi i32 [ 0, %9 ], [ 0, %14 ], [ 0, %4 ], [ 1, %11 ]
ret i32 %17
}