#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 */
scalar_t__ isalnum(char);
int strlen(char *);
scalar_t__ strstr(char *, char *);
int is_valid_machine_name(char *name) {
  int i, len;
  len = strlen(name);
  for (i = 0; i < len; i++) {
    if (isalnum(name[i]))
      continue;
    if (name[i] == '-' || name[i] == '_' || name[i] == '.')
      continue;
    return 0;
  }
  if (strstr(name, ".."))
    return 0;
  return 1;
}


x86 assembly (clang, -O0):
<is_valid_machine_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x18(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    11d9 <is_valid_machine_name+0xa9>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1040 <isalnum@plt>
cmp    $0x0,%rax
je     117b <is_valid_machine_name+0x4b>
jmp    11cb <is_valid_machine_name+0x9b>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2d,%eax
je     11ba <is_valid_machine_name+0x8a>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x5f,%eax
je     11ba <is_valid_machine_name+0x8a>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2e,%eax
jne    11bf <is_valid_machine_name+0x8f>
jmp    11cb <is_valid_machine_name+0x9b>
movl   $0x0,-0x4(%rbp)
jmp    1206 <is_valid_machine_name+0xd6>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    114f <is_valid_machine_name+0x1f>
mov    -0x10(%rbp),%rdi
lea    0xe1c(%rip),%rsi
call   1050 <strstr@plt>
cmp    $0x0,%rax
je     11ff <is_valid_machine_name+0xcf>
movl   $0x0,-0x4(%rbp)
jmp    1206 <is_valid_machine_name+0xd6>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<is_valid_machine_name>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r15
call   1030 <strlen@plt>
test   %eax,%eax
jle    1190 <is_valid_machine_name+0x60>
mov    %eax,%r14d
xor    %ebx,%ebx
movabs $0x4000000000003,%r12
jmp    1169 <is_valid_machine_name+0x39>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x1,%rbx
cmp    %rbx,%r14
je     1190 <is_valid_machine_name+0x60>
movsbl (%r15,%rbx,1),%edi
call   1040 <isalnum@plt>
test   %rax,%rax
jne    1160 <is_valid_machine_name+0x30>
movzbl (%r15,%rbx,1),%eax
add    $0xd3,%al
cmp    $0x32,%al
ja     118c <is_valid_machine_name+0x5c>
movzbl %al,%eax
bt     %rax,%r12
jb     1160 <is_valid_machine_name+0x30>
xor    %eax,%eax
jmp    11aa <is_valid_machine_name+0x7a>
lea    0xe69(%rip),%rsi
mov    %r15,%rdi
call   1050 <strstr@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
sete   %al
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"..\00"
define i32 @is_valid_machine_name(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %3
%6 = load i8*, i8** %3
%7 = call i32 @strlen(i8* %6)
store i32 %7, i32* %5
store i32 0, i32* %4
br label %8
8: ; preds = %47, %1
%9 = load i32, i32* %4
%10 = load i32, i32* %5
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %50
12: ; preds = %8
%13 = load i8*, i8** %3
%14 = load i32, i32* %4
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i8, i8* %13, i64 %15
%17 = load i8, i8* %16
%18 = call i64 @isalnum(i8 signext %17)
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %21
20: ; preds = %12
br label %47
21: ; preds = %12
%22 = load i8*, i8** %3
%23 = load i32, i32* %4
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8, i8* %22, i64 %24
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = icmp eq i32 %27, 45
br i1 %28, label %45, label %29
29: ; preds = %21
%30 = load i8*, i8** %3
%31 = load i32, i32* %4
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i8, i8* %30, i64 %32
%34 = load i8, i8* %33
%35 = sext i8 %34 to i32
%36 = icmp eq i32 %35, 95
br i1 %36, label %45, label %37
37: ; preds = %29
%38 = load i8*, i8** %3
%39 = load i32, i32* %4
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i8, i8* %38, i64 %40
%42 = load i8, i8* %41
%43 = sext i8 %42 to i32
%44 = icmp eq i32 %43, 46
br i1 %44, label %45, label %46
45: ; preds = %37, %29, %21
br label %47
46: ; preds = %37
store i32 0, i32* %2
br label %56
47: ; preds = %45, %20
%48 = load i32, i32* %4
%49 = add nsw i32 %48, 1
store i32 %49, i32* %4
br label %8
50: ; preds = %8
%51 = load i8*, i8** %3
%52 = call i64 @strstr(i8* %51, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%53 = icmp ne i64 %52, 0
br i1 %53, label %54, label %55
54: ; preds = %50
store i32 0, i32* %2
br label %56
55: ; preds = %50
store i32 1, i32* %2
br label %56
56: ; preds = %55, %54, %46
%57 = load i32, i32* %2
ret i32 %57
}

LLVM IR (-O2):
@.str = [3 x i8] c"..\00"
define i32 @is_valid_machine_name(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = icmp sgt i32 %2, 0
br i1 %3, label %4, label %17
4: ; preds = %1
%5 = zext i32 %2 to i64
br label %6
6: ; preds = %4, %14
%7 = phi i64 [ 0, %4 ], [ %15, %14 ]
%8 = getelementptr inbounds i8, i8* %0, i64 %7
%9 = load i8, i8* %8
%10 = tail call i64 @isalnum(i8 signext %9)
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %6
%13 = load i8, i8* %8
switch i8 %13, label %21 [
i8 45, label %14
i8 95, label %14
i8 46, label %14
]
14: ; preds = %12, %12, %12, %6
%15 = add nuw nsw i64 %7, 1
%16 = icmp eq i64 %15, %5
br i1 %16, label %17, label %6
17: ; preds = %14, %1
%18 = tail call i64 @strstr(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
%20 = zext i1 %19 to i32
br label %21
21: ; preds = %12, %17
%22 = phi i32 [ %20, %17 ], [ 0, %12 ]
ret i32 %22
}