#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 *, char *);
scalar_t__ re_match(char *, char *);
int /*<<< orphan*/ validateType(char *, char *, int);
int check_port(char *port) {
  if (re_match(port, "^[0-9]+-[0-9]+$")) {
    if (!validateType("portrange", port, 1)) {
      printf("Error: [%s] is not a valid port range\n", port);
      return 0;
    }
    return 1;
  } else {
    if (!validateType("port", port, 1)) {
      printf("Error: [%s] is not a valid port\n", port);
      return 0;
    }
    return 1;
  }
}


x86 assembly (clang, -O0):
<check_port>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xeb9(%rip),%rsi
call   1040 <re_match@plt>
cmp    $0x0,%rax
je     119c <check_port+0x6c>
mov    -0x10(%rbp),%rsi
lea    0xeaf(%rip),%rdi
mov    $0x1,%edx
call   1030 <validateType@plt>
cmp    $0x0,%eax
jne    1190 <check_port+0x60>
mov    -0x10(%rbp),%rsi
lea    0xe9b(%rip),%rdi
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    11dd <check_port+0xad>
movl   $0x1,-0x4(%rbp)
jmp    11dd <check_port+0xad>
mov    -0x10(%rbp),%rsi
lea    0xe9a(%rip),%rdi
mov    $0x1,%edx
call   1030 <validateType@plt>
cmp    $0x0,%eax
jne    11d6 <check_port+0xa6>
mov    -0x10(%rbp),%rsi
lea    0xe81(%rip),%rdi
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    11dd <check_port+0xad>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_port>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0xec3(%rip),%rsi
call   1040 <re_match@plt>
test   %rax,%rax
je     116d <check_port+0x3d>
lea    0xec2(%rip),%rdi
mov    $0x1,%ebp
mov    %rbx,%rsi
mov    $0x1,%edx
call   1030 <validateType@plt>
test   %eax,%eax
jne    119b <check_port+0x6b>
lea    0xeaf(%rip),%rdi
jmp    1191 <check_port+0x61>
lea    0xecd(%rip),%rdi
mov    $0x1,%ebp
mov    %rbx,%rsi
mov    $0x1,%edx
call   1030 <validateType@plt>
test   %eax,%eax
jne    119b <check_port+0x6b>
lea    0xeb5(%rip),%rdi
mov    %rbx,%rsi
call   1050 <printf@plt>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [16 x i8] c"^[0-9]+-[0-9]+$\00"
@.str.1 = [10 x i8] c"portrange\00"
@.str.2 = [39 x i8] c"Error: [%s] is not a valid port range\0A\00"
@.str.3 = [5 x i8] c"port\00"
@.str.4 = [33 x i8] c"Error: [%s] is not a valid port\0A\00"
define i32 @check_port(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
store i8* %0, i8** %3
%4 = load i8*, i8** %3
%5 = call i64 @re_match(i8* %4, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%6 = icmp ne i64 %5, 0
br i1 %6, label %7, label %15
7: ; preds = %1
%8 = load i8*, i8** %3
%9 = call i32 @validateType(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %8, i32 1)
%10 = icmp ne i32 %9, 0
br i1 %10, label %14, label %11
11: ; preds = %7
%12 = load i8*, i8** %3
%13 = call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), i8* %12)
store i32 0, i32* %2
br label %23
14: ; preds = %7
store i32 1, i32* %2
br label %23
15: ; preds = %1
%16 = load i8*, i8** %3
%17 = call i32 @validateType(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* %16, i32 1)
%18 = icmp ne i32 %17, 0
br i1 %18, label %22, label %19
19: ; preds = %15
%20 = load i8*, i8** %3
%21 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0), i8* %20)
store i32 0, i32* %2
br label %23
22: ; preds = %15
store i32 1, i32* %2
br label %23
23: ; preds = %22, %19, %14, %11
%24 = load i32, i32* %2
ret i32 %24
}

LLVM IR (-O2):
@.str = [16 x i8] c"^[0-9]+-[0-9]+$\00"
@.str.1 = [10 x i8] c"portrange\00"
@.str.2 = [39 x i8] c"Error: [%s] is not a valid port range\0A\00"
@.str.3 = [5 x i8] c"port\00"
@.str.4 = [33 x i8] c"Error: [%s] is not a valid port\0A\00"
define i32 @check_port(i8* %0) {
%2 = tail call i64 @re_match(i8* %0, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i64 %2, 0
br i1 %3, label %7, label %4
4: ; preds = %1
%5 = tail call i32 @validateType(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %0, i32 1)
%6 = icmp eq i32 %5, 0
br i1 %6, label %10, label %13
7: ; preds = %1
%8 = tail call i32 @validateType(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* %0, i32 1)
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %13
10: ; preds = %7, %4
%11 = phi i8* [ getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), %4 ], [ getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0), %7 ]
%12 = tail call i32 @printf(i8* %11, i8* %0)
br label %13
13: ; preds = %10, %7, %4
%14 = phi i32 [ 1, %4 ], [ 1, %7 ], [ 0, %10 ]
ret i32 %14
}