#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*/ lerror(char *);
int returnchar(unsigned short k) {
  if (k >= 1 && k <= 26)
    return ('a' + k - 1);
  else if (k >= 30 && k <= 39)
    return ('0' + k - 30);
  else
    switch (k) {
    case 0:
      return (' ');
    case 27:
      return ('$');
    case 28:
      return ('.');
    case 29:
      return ('_');
    default:
      lerror("RAD50 non-character");
      return 0;
    }
}


x86 assembly (clang, -O0):
<returnchar>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %di,%ax
mov    %ax,-0x6(%rbp)
movzwl -0x6(%rbp),%eax
cmp    $0x1,%eax
jl     114b <returnchar+0x3b>
movzwl -0x6(%rbp),%eax
cmp    $0x1a,%eax
jg     114b <returnchar+0x3b>
movzwl -0x6(%rbp),%eax
add    $0x61,%eax
sub    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    11e0 <returnchar+0xd0>
movzwl -0x6(%rbp),%eax
cmp    $0x1e,%eax
jl     1177 <returnchar+0x67>
movzwl -0x6(%rbp),%eax
cmp    $0x27,%eax
jg     1177 <returnchar+0x67>
movzwl -0x6(%rbp),%eax
add    $0x30,%eax
sub    $0x1e,%eax
mov    %eax,-0x4(%rbp)
jmp    11e0 <returnchar+0xd0>
movzwl -0x6(%rbp),%eax
mov    %rax,-0x10(%rbp)
sub    $0x1d,%rax
ja     11cd <returnchar+0xbd>
mov    -0x10(%rbp),%rax
lea    0xe6c(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x20,-0x4(%rbp)
jmp    11e0 <returnchar+0xd0>
movl   $0x24,-0x4(%rbp)
jmp    11e0 <returnchar+0xd0>
movl   $0x2e,-0x4(%rbp)
jmp    11e0 <returnchar+0xd0>
movl   $0x5f,-0x4(%rbp)
jmp    11e0 <returnchar+0xd0>
lea    0xea4(%rip),%rdi
call   1030 <lerror@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<returnchar>:
push   %rax
lea    -0x1(%rdi),%eax
cmp    $0x19,%ax
ja     111f <returnchar+0xf>
add    $0x60,%edi
jmp    112b <returnchar+0x1b>
lea    -0x1e(%rdi),%eax
cmp    $0x9,%ax
ja     112f <returnchar+0x1f>
add    $0x12,%edi
mov    %edi,%eax
pop    %rcx
ret
cmp    $0x1d,%di
ja     1162 <returnchar+0x52>
mov    $0x20,%eax
movzwl %di,%ecx
lea    0xebc(%rip),%rdx
movslq (%rdx,%rcx,4),%rcx
add    %rdx,%rcx
jmp    *%rcx
mov    $0x24,%eax
pop    %rcx
ret
mov    $0x2e,%eax
pop    %rcx
ret
mov    $0x5f,%eax
pop    %rcx
ret
lea    0xf0f(%rip),%rdi
call   1030 <lerror@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [20 x i8] c"RAD50 non-character\00"
define i32 @returnchar(i16 zeroext %0) {
%2 = alloca i32
%3 = alloca i16
store i16 %0, i16* %3
%4 = load i16, i16* %3
%5 = zext i16 %4 to i32
%6 = icmp sge i32 %5, 1
br i1 %6, label %7, label %16
7: ; preds = %1
%8 = load i16, i16* %3
%9 = zext i16 %8 to i32
%10 = icmp sle i32 %9, 26
br i1 %10, label %11, label %16
11: ; preds = %7
%12 = load i16, i16* %3
%13 = zext i16 %12 to i32
%14 = add nsw i32 97, %13
%15 = sub nsw i32 %14, 1
store i32 %15, i32* %2
br label %38
16: ; preds = %7, %1
%17 = load i16, i16* %3
%18 = zext i16 %17 to i32
%19 = icmp sge i32 %18, 30
br i1 %19, label %20, label %29
20: ; preds = %16
%21 = load i16, i16* %3
%22 = zext i16 %21 to i32
%23 = icmp sle i32 %22, 39
br i1 %23, label %24, label %29
24: ; preds = %20
%25 = load i16, i16* %3
%26 = zext i16 %25 to i32
%27 = add nsw i32 48, %26
%28 = sub nsw i32 %27, 30
store i32 %28, i32* %2
br label %38
29: ; preds = %20, %16
%30 = load i16, i16* %3
%31 = zext i16 %30 to i32
switch i32 %31, label %36 [
i32 0, label %32
i32 27, label %33
i32 28, label %34
i32 29, label %35
]
32: ; preds = %29
store i32 32, i32* %2
br label %38
33: ; preds = %29
store i32 36, i32* %2
br label %38
34: ; preds = %29
store i32 46, i32* %2
br label %38
35: ; preds = %29
store i32 95, i32* %2
br label %38
36: ; preds = %29
%37 = call i32 @lerror(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %2
br label %38
38: ; preds = %36, %35, %34, %33, %32, %24, %11
%39 = load i32, i32* %2
ret i32 %39
}

LLVM IR (-O2):
@.str = [20 x i8] c"RAD50 non-character\00"
define i32 @returnchar(i16 zeroext %0) {
%2 = zext i16 %0 to i32
%3 = add i16 %0, -1
%4 = icmp ult i16 %3, 26
br i1 %4, label %5, label %7
5: ; preds = %1
%6 = add nuw nsw i32 %2, 96
br label %18
7: ; preds = %1
%8 = add i16 %0, -30
%9 = icmp ult i16 %8, 10
br i1 %9, label %10, label %12
10: ; preds = %7
%11 = add nuw nsw i32 %2, 18
br label %18
12: ; preds = %7
switch i16 %0, label %16 [
i16 0, label %18
i16 27, label %13
i16 28, label %14
i16 29, label %15
]
13: ; preds = %12
br label %18
14: ; preds = %12
br label %18
15: ; preds = %12
br label %18
16: ; preds = %12
%17 = tail call i32 @lerror(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
br label %18
18: ; preds = %12, %16, %15, %14, %13, %10, %5
%19 = phi i32 [ %6, %5 ], [ %11, %10 ], [ 0, %16 ], [ 95, %15 ], [ 46, %14 ], [ 36, %13 ], [ 32, %12 ]
ret i32 %19
}