#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);
char makevaliddns(char c) {
  if (c >= 'A' && c <= 'Z')
    return c - 'A' + 'a';
  if (isalnum(c))
    return c;
  switch (c) {
  case '.':
  case '-':
  case '_':
    return c;
  }
  return -1;
}


x86 assembly (clang, -O0):
<makevaliddns>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x2(%rbp)
movsbl -0x2(%rbp),%eax
cmp    $0x41,%eax
jl     114a <makevaliddns+0x3a>
movsbl -0x2(%rbp),%eax
cmp    $0x5a,%eax
jg     114a <makevaliddns+0x3a>
movsbl -0x2(%rbp),%eax
sub    $0x41,%eax
add    $0x61,%eax
mov    %al,-0x1(%rbp)
jmp    11a0 <makevaliddns+0x90>
movsbl -0x2(%rbp),%edi
call   1030 <isalnum@plt>
cmp    $0x0,%rax
je     1168 <makevaliddns+0x58>
mov    -0x2(%rbp),%al
mov    %al,-0x1(%rbp)
jmp    11a0 <makevaliddns+0x90>
movsbl -0x2(%rbp),%eax
mov    %eax,-0x8(%rbp)
add    $0xffffffd3,%eax
sub    $0x2,%eax
jb     1191 <makevaliddns+0x81>
jmp    1180 <makevaliddns+0x70>
mov    -0x8(%rbp),%eax
sub    $0x5f,%eax
jne    119c <makevaliddns+0x8c>
jmp    1191 <makevaliddns+0x81>
mov    -0x2(%rbp),%al
mov    %al,-0x1(%rbp)
jmp    11a0 <makevaliddns+0x90>
movb   $0xff,-0x1(%rbp)
movsbl -0x1(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<makevaliddns>:
push   %r14
push   %rbx
push   %rax
mov    %edi,%r14d
mov    %r14d,%ebx
lea    -0x41(%rbx),%eax
cmp    $0x19,%al
ja     1126 <makevaliddns+0x16>
add    $0x20,%ebx
jmp    114f <makevaliddns+0x3f>
movsbl %bl,%edi
call   1030 <isalnum@plt>
test   %rax,%rax
jne    114f <makevaliddns+0x3f>
add    $0xffffffd3,%r14d
cmp    $0x32,%r14d
ja     114d <makevaliddns+0x3d>
movabs $0x4000000000003,%rax
bt     %r14,%rax
jb     114f <makevaliddns+0x3f>
mov    $0xff,%bl
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define signext i8 @makevaliddns(i8 signext %0) {
%2 = alloca i8
%3 = alloca i8
store i8 %0, i8* %3
%4 = load i8, i8* %3
%5 = sext i8 %4 to i32
%6 = icmp sge i32 %5, 65
br i1 %6, label %7, label %17
7: ; preds = %1
%8 = load i8, i8* %3
%9 = sext i8 %8 to i32
%10 = icmp sle i32 %9, 90
br i1 %10, label %11, label %17
11: ; preds = %7
%12 = load i8, i8* %3
%13 = sext i8 %12 to i32
%14 = sub nsw i32 %13, 65
%15 = add nsw i32 %14, 97
%16 = trunc i32 %15 to i8
store i8 %16, i8* %2
br label %29
17: ; preds = %7, %1
%18 = load i8, i8* %3
%19 = call i64 @isalnum(i8 signext %18)
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %17
%22 = load i8, i8* %3
store i8 %22, i8* %2
br label %29
23: ; preds = %17
%24 = load i8, i8* %3
%25 = sext i8 %24 to i32
switch i32 %25, label %28 [
i32 46, label %26
i32 45, label %26
i32 95, label %26
]
26: ; preds = %23, %23, %23
%27 = load i8, i8* %3
store i8 %27, i8* %2
br label %29
28: ; preds = %23
store i8 -1, i8* %2
br label %29
29: ; preds = %28, %26, %21, %11
%30 = load i8, i8* %2
ret i8 %30
}

LLVM IR (-O2):
define signext i8 @makevaliddns(i8 signext %0) {
%2 = sext i8 %0 to i32
%3 = add i8 %0, -65
%4 = icmp ult i8 %3, 26
br i1 %4, label %5, label %7
5: ; preds = %1
%6 = add nuw nsw i8 %0, 32
br label %12
7: ; preds = %1
%8 = tail call i64 @isalnum(i8 signext %0)
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %7
switch i32 %2, label %11 [
i32 46, label %12
i32 45, label %12
i32 95, label %12
]
11: ; preds = %10
br label %12
12: ; preds = %10, %10, %10, %7, %11, %5
%13 = phi i8 [ %6, %5 ], [ -1, %11 ], [ %0, %7 ], [ %0, %10 ], [ %0, %10 ], [ %0, %10 ]
ret i8 %13
}