#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*/ EXIT_FAILURE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
scalar_t__ isalnum(char);
int /*<<< orphan*/ printf(char *, char *, char);
int validate_pkg(char *pkg) {
  int i = 0;
  char in;
  while ((in = pkg[i]) != '\0') {
    if (!(isalnum(in) || in == '.' || in == '-')) {
      printf("Package name (%s) contains invalid character %c\n", pkg, in);
      exit(EXIT_FAILURE);
    }
    i++;
  }
  return 1;
}


x86 assembly (clang, -O0):
<validate_pkg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0xd(%rbp)
movsbl %al,%eax
cmp    $0x0,%eax
je     11ba <validate_pkg+0x8a>
movsbl -0xd(%rbp),%edi
call   1040 <isalnum@plt>
cmp    $0x0,%rax
jne    11ac <validate_pkg+0x7c>
movsbl -0xd(%rbp),%eax
cmp    $0x2e,%eax
je     11ac <validate_pkg+0x7c>
movsbl -0xd(%rbp),%eax
cmp    $0x2d,%eax
je     11ac <validate_pkg+0x7c>
mov    -0x8(%rbp),%rsi
lea    0xe6b(%rip),%rdi
movsbl -0xd(%rbp),%edx
call   1030 <printf@plt>
mov    0x2e3b(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1143 <validate_pkg+0x13>
mov    $0x1,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<validate_pkg>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    (%rdi),%bl
test   %bl,%bl
je     1195 <validate_pkg+0x65>
mov    %rdi,%r14
lea    0x1(%rdi),%rbp
jmp    115c <validate_pkg+0x2c>
cs nopw 0x0(%rax,%rax,1)
movzbl 0x0(%rbp),%ebx
add    $0x1,%rbp
test   %bl,%bl
je     1195 <validate_pkg+0x65>
movsbl %bl,%r15d
mov    %r15d,%edi
call   1040 <isalnum@plt>
test   %rax,%rax
jne    1150 <validate_pkg+0x20>
add    $0xd3,%bl
cmp    $0x2,%bl
jb     1150 <validate_pkg+0x20>
lea    0xe84(%rip),%rdi
mov    %r14,%rsi
mov    %r15d,%edx
call   1030 <printf@plt>
mov    0x2e52(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [49 x i8] c"Package name (%s) contains invalid character %c\0A\00"
@EXIT_FAILURE = global i32 0
define i32 @validate_pkg(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i8
store i8* %0, i8** %2
store i32 0, i32* %3
br label %5
5: ; preds = %31, %1
%6 = load i8*, i8** %2
%7 = load i32, i32* %3
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds i8, i8* %6, i64 %8
%10 = load i8, i8* %9
store i8 %10, i8* %4
%11 = sext i8 %10 to i32
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %34
13: ; preds = %5
%14 = load i8, i8* %4
%15 = call i64 @isalnum(i8 signext %14)
%16 = icmp ne i64 %15, 0
br i1 %16, label %31, label %17
17: ; preds = %13
%18 = load i8, i8* %4
%19 = sext i8 %18 to i32
%20 = icmp eq i32 %19, 46
br i1 %20, label %31, label %21
21: ; preds = %17
%22 = load i8, i8* %4
%23 = sext i8 %22 to i32
%24 = icmp eq i32 %23, 45
br i1 %24, label %31, label %25
25: ; preds = %21
%26 = load i8*, i8** %2
%27 = load i8, i8* %4
%28 = call i32 @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0), i8* %26, i8 signext %27)
%29 = load i32, i32* @EXIT_FAILURE
%30 = call i32 @exit(i32 %29)
unreachable
31: ; preds = %21, %17, %13
%32 = load i32, i32* %3
%33 = add nsw i32 %32, 1
store i32 %33, i32* %3
br label %5
34: ; preds = %5
ret i32 1
}

LLVM IR (-O2):
@.str = [49 x i8] c"Package name (%s) contains invalid character %c\0A\00"
@EXIT_FAILURE = global i32 0
define i32 @validate_pkg(i8* %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 0
br i1 %3, label %22, label %8
4: ; preds = %8
%5 = getelementptr inbounds i8, i8* %0, i64 %17
%6 = load i8, i8* %5
%7 = icmp eq i8 %6, 0
br i1 %7, label %22, label %8
8: ; preds = %1, %4
%9 = phi i64 [ %17, %4 ], [ 0, %1 ]
%10 = phi i8 [ %6, %4 ], [ %2, %1 ]
%11 = tail call i64 @isalnum(i8 signext %10)
%12 = freeze i64 %11
%13 = icmp ne i64 %12, 0
%14 = add i8 %10, -45
%15 = icmp ult i8 %14, 2
%16 = or i1 %13, %15
%17 = add nuw i64 %9, 1
br i1 %16, label %4, label %18
18: ; preds = %8
%19 = tail call i32 @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0), i8* %0, i8 signext %10)
%20 = load i32, i32* @EXIT_FAILURE
%21 = tail call i32 @exit(i32 %20)
unreachable
22: ; preds = %4, %1
ret i32 1
}