#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(int);
int domain_valid(const char *cp) {
  for (; '\0' != *cp; cp++)
    if (!('.' == *cp || '-' == *cp || '_' == *cp || isalnum((int)*cp)))
      return (0);
  return (1);
}


x86 assembly (clang, -O0):
<domain_valid>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    %ecx,%eax
je     11a1 <domain_valid+0x91>
mov    -0x10(%rbp),%rax
movsbl (%rax),%ecx
mov    $0x2e,%eax
cmp    %ecx,%eax
je     118b <domain_valid+0x7b>
mov    -0x10(%rbp),%rax
movsbl (%rax),%ecx
mov    $0x2d,%eax
cmp    %ecx,%eax
je     118b <domain_valid+0x7b>
mov    -0x10(%rbp),%rax
movsbl (%rax),%ecx
mov    $0x5f,%eax
cmp    %ecx,%eax
je     118b <domain_valid+0x7b>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isalnum@plt>
cmp    $0x0,%rax
jne    118b <domain_valid+0x7b>
movl   $0x0,-0x4(%rbp)
jmp    11a8 <domain_valid+0x98>
jmp    1190 <domain_valid+0x80>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    111c <domain_valid+0xc>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<domain_valid>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
movabs $0x4000000000003,%r14
jmp    1134 <domain_valid+0x24>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%rbx
movzbl (%rbx),%eax
lea    -0x2d(%rax),%ecx
cmp    $0x32,%cl
ja     1148 <domain_valid+0x38>
movzbl %cl,%ecx
bt     %rcx,%r14
jb     1130 <domain_valid+0x20>
test   %al,%al
je     115d <domain_valid+0x4d>
movsbl %al,%edi
call   1030 <isalnum@plt>
test   %rax,%rax
jne    1130 <domain_valid+0x20>
xor    %eax,%eax
jmp    1162 <domain_valid+0x52>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @domain_valid(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
store i8* %0, i8** %3
br label %4
4: ; preds = %32, %1
%5 = load i8*, i8** %3
%6 = load i8, i8* %5
%7 = sext i8 %6 to i32
%8 = icmp ne i32 0, %7
br i1 %8, label %9, label %35
9: ; preds = %4
%10 = load i8*, i8** %3
%11 = load i8, i8* %10
%12 = sext i8 %11 to i32
%13 = icmp eq i32 46, %12
br i1 %13, label %31, label %14
14: ; preds = %9
%15 = load i8*, i8** %3
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp eq i32 45, %17
br i1 %18, label %31, label %19
19: ; preds = %14
%20 = load i8*, i8** %3
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = icmp eq i32 95, %22
br i1 %23, label %31, label %24
24: ; preds = %19
%25 = load i8*, i8** %3
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = call i64 @isalnum(i32 %27)
%29 = icmp ne i64 %28, 0
br i1 %29, label %31, label %30
30: ; preds = %24
store i32 0, i32* %2
br label %36
31: ; preds = %24, %19, %14, %9
br label %32
32: ; preds = %31
%33 = load i8*, i8** %3
%34 = getelementptr inbounds i8, i8* %33, i32 1
store i8* %34, i8** %3
br label %4
35: ; preds = %4
store i32 1, i32* %2
br label %36
36: ; preds = %35, %30
%37 = load i32, i32* %2
ret i32 %37
}

LLVM IR (-O2):
define i32 @domain_valid(i8* nocapture %0) {
br label %2
2: ; preds = %9, %1
%3 = phi i8* [ %0, %1 ], [ %10, %9 ]
%4 = load i8, i8* %3
switch i8 %4, label %5 [
i8 0, label %11
i8 46, label %9
i8 45, label %9
i8 95, label %9
]
5: ; preds = %2
%6 = sext i8 %4 to i32
%7 = tail call i64 @isalnum(i32 %6)
%8 = icmp eq i64 %7, 0
br i1 %8, label %11, label %9
9: ; preds = %2, %2, %2, %5
%10 = getelementptr inbounds i8, i8* %3, i64 1
br label %2
11: ; preds = %2, %5
%12 = phi i32 [ 0, %5 ], [ 1, %2 ]
ret i32 %12
}