#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 toupper(char);
signed char owen_charconvert(char sign, char next) {
  char res;
  char ch;
  if (sign == '.') {
    printf("DOT\n");
    return -1;
  }
  ch = toupper(sign);
  if ((ch >= '0') && (ch <= '9'))
    res = ch - '0';
  else if ((ch >= 'A') && (ch <= 'Z'))
    res = ch - 'A' + 10;
  else
    switch (sign) {
    case '-':
      res = 10 + 26 + 0;
      break;
    case '_':
      res = 10 + 26 + 1;
      break;
    case '/':
      res = 10 + 26 + 2;
      break;
    case ' ':
      res = 10 + 26 + 3;
      break;
    default:
      printf("NOF\n");
      return -1;
    }
  res *= 2;
  if (next == '.')
    res++;
  return res;
}


x86 assembly (clang, -O0):
<owen_charconvert>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %sil,%al
mov    %dil,%cl
mov    %cl,-0x2(%rbp)
mov    %al,-0x3(%rbp)
movsbl -0x2(%rbp),%eax
cmp    $0x2e,%eax
jne    1156 <owen_charconvert+0x36>
lea    0xeb8(%rip),%rdi
call   1040 <printf@plt>
movb   $0xff,-0x1(%rbp)
jmp    1267 <owen_charconvert+0x147>
movsbl -0x2(%rbp),%edi
call   1030 <toupper@plt>
mov    %al,-0x5(%rbp)
movsbl -0x5(%rbp),%eax
cmp    $0x30,%eax
jl     118b <owen_charconvert+0x6b>
movsbl -0x5(%rbp),%eax
cmp    $0x39,%eax
jg     118b <owen_charconvert+0x6b>
movsbl -0x5(%rbp),%eax
sub    $0x30,%eax
mov    %al,-0x4(%rbp)
jmp    1242 <owen_charconvert+0x122>
movsbl -0x5(%rbp),%eax
cmp    $0x41,%eax
jl     11b7 <owen_charconvert+0x97>
movsbl -0x5(%rbp),%eax
cmp    $0x5a,%eax
jg     11b7 <owen_charconvert+0x97>
movsbl -0x5(%rbp),%eax
sub    $0x41,%eax
add    $0xa,%eax
mov    %al,-0x4(%rbp)
jmp    123d <owen_charconvert+0x11d>
movsbl -0x2(%rbp),%eax
mov    %eax,-0xc(%rbp)
sub    $0x20,%eax
je     121a <owen_charconvert+0xfa>
jmp    11cc <owen_charconvert+0xac>
mov    -0xc(%rbp),%eax
sub    $0x2d,%eax
je     11ff <owen_charconvert+0xdf>
jmp    11dd <owen_charconvert+0xbd>
mov    -0xc(%rbp),%eax
sub    $0x2f,%eax
je     1211 <owen_charconvert+0xf1>
jmp    11ee <owen_charconvert+0xce>
mov    -0xc(%rbp),%eax
sub    $0x5f,%eax
je     1208 <owen_charconvert+0xe8>
jmp    1223 <owen_charconvert+0x103>
movb   $0x24,-0x4(%rbp)
jmp    1238 <owen_charconvert+0x118>
movb   $0x25,-0x4(%rbp)
jmp    1238 <owen_charconvert+0x118>
movb   $0x26,-0x4(%rbp)
jmp    1238 <owen_charconvert+0x118>
movb   $0x27,-0x4(%rbp)
jmp    1238 <owen_charconvert+0x118>
lea    0xddb(%rip),%rdi
call   1040 <printf@plt>
movb   $0xff,-0x1(%rbp)
jmp    1267 <owen_charconvert+0x147>
jmp    123d <owen_charconvert+0x11d>
jmp    1242 <owen_charconvert+0x122>
movsbl -0x4(%rbp),%eax
shl    $0x1,%eax
mov    %al,-0x4(%rbp)
movsbl -0x3(%rbp),%eax
cmp    $0x2e,%eax
jne    1261 <owen_charconvert+0x141>
mov    -0x4(%rbp),%al
add    $0x1,%al
mov    %al,-0x4(%rbp)
mov    -0x4(%rbp),%al
mov    %al,-0x1(%rbp)
movsbl -0x1(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<owen_charconvert>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebp
cmp    $0x2e,%bpl
jne    113b <owen_charconvert+0x1b>
lea    0xed2(%rip),%rdi
call   1040 <puts@plt>
mov    $0xff,%al
jmp    1164 <owen_charconvert+0x44>
mov    %esi,%ebx
movsbl %bpl,%edi
call   1030 <toupper@plt>
lea    -0x30(%rax),%ecx
cmp    $0xa,%cl
jb     115a <owen_charconvert+0x3a>
lea    -0x41(%rax),%ecx
cmp    $0x19,%cl
ja     116b <owen_charconvert+0x4b>
add    $0xc9,%al
mov    %eax,%ecx
add    %cl,%cl
cmp    $0x2e,%bl
sete   %al
or     %cl,%al
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
cmp    $0x2e,%ebp
jg     117e <owen_charconvert+0x5e>
cmp    $0x20,%ebp
je     118c <owen_charconvert+0x6c>
mov    $0x24,%cl
cmp    $0x2d,%ebp
je     115a <owen_charconvert+0x3a>
jmp    1194 <owen_charconvert+0x74>
cmp    $0x2f,%ebp
je     1190 <owen_charconvert+0x70>
cmp    $0x5f,%ebp
jne    1194 <owen_charconvert+0x74>
mov    $0x25,%cl
jmp    115a <owen_charconvert+0x3a>
mov    $0x27,%cl
jmp    115a <owen_charconvert+0x3a>
mov    $0x26,%cl
jmp    115a <owen_charconvert+0x3a>
lea    0xe65(%rip),%rdi
jmp    1132 <owen_charconvert+0x12>

LLVM IR (-O0):
@.str = [5 x i8] c"DOT\0A\00"
@.str.1 = [5 x i8] c"NOF\0A\00"
define signext i8 @owen_charconvert(i8 signext %0, i8 signext %1) {
%3 = alloca i8
%4 = alloca i8
%5 = alloca i8
%6 = alloca i8
%7 = alloca i8
store i8 %0, i8* %4
store i8 %1, i8* %5
%8 = load i8, i8* %4
%9 = sext i8 %8 to i32
%10 = icmp eq i32 %9, 46
br i1 %10, label %11, label %13
11: ; preds = %2
%12 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i8 -1, i8* %3
br label %66
13: ; preds = %2
%14 = load i8, i8* %4
%15 = call signext i8 @toupper(i8 signext %14)
store i8 %15, i8* %7
%16 = load i8, i8* %7
%17 = sext i8 %16 to i32
%18 = icmp sge i32 %17, 48
br i1 %18, label %19, label %28
19: ; preds = %13
%20 = load i8, i8* %7
%21 = sext i8 %20 to i32
%22 = icmp sle i32 %21, 57
br i1 %22, label %23, label %28
23: ; preds = %19
%24 = load i8, i8* %7
%25 = sext i8 %24 to i32
%26 = sub nsw i32 %25, 48
%27 = trunc i32 %26 to i8
store i8 %27, i8* %6
br label %53
28: ; preds = %19, %13
%29 = load i8, i8* %7
%30 = sext i8 %29 to i32
%31 = icmp sge i32 %30, 65
br i1 %31, label %32, label %42
32: ; preds = %28
%33 = load i8, i8* %7
%34 = sext i8 %33 to i32
%35 = icmp sle i32 %34, 90
br i1 %35, label %36, label %42
36: ; preds = %32
%37 = load i8, i8* %7
%38 = sext i8 %37 to i32
%39 = sub nsw i32 %38, 65
%40 = add nsw i32 %39, 10
%41 = trunc i32 %40 to i8
store i8 %41, i8* %6
br label %52
42: ; preds = %32, %28
%43 = load i8, i8* %4
%44 = sext i8 %43 to i32
switch i32 %44, label %49 [
i32 45, label %45
i32 95, label %46
i32 47, label %47
i32 32, label %48
]
45: ; preds = %42
store i8 36, i8* %6
br label %51
46: ; preds = %42
store i8 37, i8* %6
br label %51
47: ; preds = %42
store i8 38, i8* %6
br label %51
48: ; preds = %42
store i8 39, i8* %6
br label %51
49: ; preds = %42
%50 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
store i8 -1, i8* %3
br label %66
51: ; preds = %48, %47, %46, %45
br label %52
52: ; preds = %51, %36
br label %53
53: ; preds = %52, %23
%54 = load i8, i8* %6
%55 = sext i8 %54 to i32
%56 = mul nsw i32 %55, 2
%57 = trunc i32 %56 to i8
store i8 %57, i8* %6
%58 = load i8, i8* %5
%59 = sext i8 %58 to i32
%60 = icmp eq i32 %59, 46
br i1 %60, label %61, label %64
61: ; preds = %53
%62 = load i8, i8* %6
%63 = add i8 %62, 1
store i8 %63, i8* %6
br label %64
64: ; preds = %61, %53
%65 = load i8, i8* %6
store i8 %65, i8* %3
br label %66
66: ; preds = %64, %49, %11
%67 = load i8, i8* %3
ret i8 %67
}

LLVM IR (-O2):
@str = [4 x i8] c"NOF\00"
@str.2 = [4 x i8] c"DOT\00"
define signext i8 @owen_charconvert(i8 signext %0, i8 signext %1) {
%3 = sext i8 %0 to i32
%4 = icmp eq i8 %0, 46
br i1 %4, label %5, label %7
5: ; preds = %2
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @str.2, i64 0, i64 0))
br label %28
7: ; preds = %2
%8 = tail call signext i8 @toupper(i8 signext %0)
%9 = add i8 %8, -48
%10 = icmp ult i8 %9, 10
br i1 %10, label %22, label %11
11: ; preds = %7
%12 = add i8 %8, -65
%13 = icmp ult i8 %12, 26
br i1 %13, label %14, label %16
14: ; preds = %11
%15 = add nsw i8 %8, -55
br label %22
16: ; preds = %11
switch i32 %3, label %20 [
i32 45, label %22
i32 95, label %17
i32 47, label %18
i32 32, label %19
]
17: ; preds = %16
br label %22
18: ; preds = %16
br label %22
19: ; preds = %16
br label %22
20: ; preds = %16
%21 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @str, i64 0, i64 0))
br label %28
22: ; preds = %7, %16, %14, %19, %18, %17
%23 = phi i8 [ %15, %14 ], [ 39, %19 ], [ 38, %18 ], [ 37, %17 ], [ 36, %16 ], [ %9, %7 ]
%24 = shl nuw nsw i8 %23, 1
%25 = icmp eq i8 %1, 46
%26 = zext i1 %25 to i8
%27 = or i8 %24, %26
br label %28
28: ; preds = %22, %20, %5
%29 = phi i8 [ -1, %5 ], [ %27, %22 ], [ -1, %20 ]
ret i8 %29
}