#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 tolower(char);
int dirichlet_code(char aa) {
  char x;
  x = tolower(aa);
  if ((x < 'a') || (x > 'z'))
    printf("CODE UNDEFINED\n");
  else if (x <= 'a')
    return x - 'a';
  else if (x <= 'i')
    return x - ('a' + 1);
  else if (x <= 'n')
    return x - ('a' + 2);
  else if (x <= 't')
    return x - ('a' + 3);
  else if (x <= 'w')
    return x - ('a' + 4);
  else if (x == 'y')
    return x - ('a' + 5);
  else {
    printf("ERROR in dirichlet_code\n");
    return 0;
  }
  return 0;
}


x86 assembly (clang, -O0):
<dirichlet_code>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x5(%rbp)
movsbl -0x5(%rbp),%edi
call   1040 <tolower@plt>
mov    %al,-0x6(%rbp)
movsbl -0x6(%rbp),%eax
cmp    $0x61,%eax
jl     1154 <dirichlet_code+0x34>
movsbl -0x6(%rbp),%eax
cmp    $0x7a,%eax
jle    1165 <dirichlet_code+0x45>
lea    0xea5(%rip),%rdi
call   1030 <printf@plt>
jmp    1225 <dirichlet_code+0x105>
movsbl -0x6(%rbp),%eax
cmp    $0x61,%eax
jg     1181 <dirichlet_code+0x61>
movsbl -0x6(%rbp),%eax
sub    $0x61,%eax
mov    %eax,-0x4(%rbp)
jmp    122c <dirichlet_code+0x10c>
movsbl -0x6(%rbp),%eax
cmp    $0x69,%eax
jg     119d <dirichlet_code+0x7d>
movsbl -0x6(%rbp),%eax
sub    $0x62,%eax
mov    %eax,-0x4(%rbp)
jmp    122c <dirichlet_code+0x10c>
movsbl -0x6(%rbp),%eax
cmp    $0x6e,%eax
jg     11b9 <dirichlet_code+0x99>
movsbl -0x6(%rbp),%eax
sub    $0x63,%eax
mov    %eax,-0x4(%rbp)
jmp    122c <dirichlet_code+0x10c>
movsbl -0x6(%rbp),%eax
cmp    $0x74,%eax
jg     11d5 <dirichlet_code+0xb5>
movsbl -0x6(%rbp),%eax
sub    $0x64,%eax
mov    %eax,-0x4(%rbp)
jmp    122c <dirichlet_code+0x10c>
movsbl -0x6(%rbp),%eax
cmp    $0x77,%eax
jg     11f1 <dirichlet_code+0xd1>
movsbl -0x6(%rbp),%eax
sub    $0x65,%eax
mov    %eax,-0x4(%rbp)
jmp    122c <dirichlet_code+0x10c>
movsbl -0x6(%rbp),%eax
cmp    $0x79,%eax
jne    120d <dirichlet_code+0xed>
movsbl -0x6(%rbp),%eax
sub    $0x66,%eax
mov    %eax,-0x4(%rbp)
jmp    122c <dirichlet_code+0x10c>
lea    0xdfc(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    122c <dirichlet_code+0x10c>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dirichlet_code>:
push   %rax
call   1040 <tolower@plt>
mov    %eax,%ecx
lea    -0x7b(%rcx),%eax
cmp    $0xe5,%al
ja     113f <dirichlet_code+0x1f>
lea    0xee2(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
jmp    1146 <dirichlet_code+0x26>
xor    %eax,%eax
cmp    $0x62,%cl
jae    1148 <dirichlet_code+0x28>
pop    %rcx
ret
movsbl %cl,%eax
cmp    $0x69,%cl
ja     1155 <dirichlet_code+0x35>
add    $0xffffff9e,%eax
pop    %rcx
ret
cmp    $0x6e,%cl
ja     115f <dirichlet_code+0x3f>
add    $0xffffff9d,%eax
pop    %rcx
ret
cmp    $0x74,%cl
ja     1169 <dirichlet_code+0x49>
add    $0xffffff9c,%eax
pop    %rcx
ret
cmp    $0x77,%cl
ja     1173 <dirichlet_code+0x53>
add    $0xffffff9b,%eax
pop    %rcx
ret
mov    $0x13,%eax
cmp    $0x79,%cl
je     1146 <dirichlet_code+0x26>
lea    0xe7c(%rip),%rdi
jmp    1136 <dirichlet_code+0x16>

LLVM IR (-O0):
@.str = [16 x i8] c"CODE UNDEFINED\0A\00"
@.str.1 = [25 x i8] c"ERROR in dirichlet_code\0A\00"
define i32 @dirichlet_code(i8 signext %0) {
%2 = alloca i32
%3 = alloca i8
%4 = alloca i8
store i8 %0, i8* %3
%5 = load i8, i8* %3
%6 = call signext i8 @tolower(i8 signext %5)
store i8 %6, i8* %4
%7 = load i8, i8* %4
%8 = sext i8 %7 to i32
%9 = icmp slt i32 %8, 97
br i1 %9, label %14, label %10
10: ; preds = %1
%11 = load i8, i8* %4
%12 = sext i8 %11 to i32
%13 = icmp sgt i32 %12, 122
br i1 %13, label %14, label %16
14: ; preds = %10, %1
%15 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
br label %66
16: ; preds = %10
%17 = load i8, i8* %4
%18 = sext i8 %17 to i32
%19 = icmp sle i32 %18, 97
br i1 %19, label %20, label %24
20: ; preds = %16
%21 = load i8, i8* %4
%22 = sext i8 %21 to i32
%23 = sub nsw i32 %22, 97
store i32 %23, i32* %2
br label %67
24: ; preds = %16
%25 = load i8, i8* %4
%26 = sext i8 %25 to i32
%27 = icmp sle i32 %26, 105
br i1 %27, label %28, label %32
28: ; preds = %24
%29 = load i8, i8* %4
%30 = sext i8 %29 to i32
%31 = sub nsw i32 %30, 98
store i32 %31, i32* %2
br label %67
32: ; preds = %24
%33 = load i8, i8* %4
%34 = sext i8 %33 to i32
%35 = icmp sle i32 %34, 110
br i1 %35, label %36, label %40
36: ; preds = %32
%37 = load i8, i8* %4
%38 = sext i8 %37 to i32
%39 = sub nsw i32 %38, 99
store i32 %39, i32* %2
br label %67
40: ; preds = %32
%41 = load i8, i8* %4
%42 = sext i8 %41 to i32
%43 = icmp sle i32 %42, 116
br i1 %43, label %44, label %48
44: ; preds = %40
%45 = load i8, i8* %4
%46 = sext i8 %45 to i32
%47 = sub nsw i32 %46, 100
store i32 %47, i32* %2
br label %67
48: ; preds = %40
%49 = load i8, i8* %4
%50 = sext i8 %49 to i32
%51 = icmp sle i32 %50, 119
br i1 %51, label %52, label %56
52: ; preds = %48
%53 = load i8, i8* %4
%54 = sext i8 %53 to i32
%55 = sub nsw i32 %54, 101
store i32 %55, i32* %2
br label %67
56: ; preds = %48
%57 = load i8, i8* %4
%58 = sext i8 %57 to i32
%59 = icmp eq i32 %58, 121
br i1 %59, label %60, label %64
60: ; preds = %56
%61 = load i8, i8* %4
%62 = sext i8 %61 to i32
%63 = sub nsw i32 %62, 102
store i32 %63, i32* %2
br label %67
64: ; preds = %56
%65 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %2
br label %67
66: ; preds = %14
store i32 0, i32* %2
br label %67
67: ; preds = %66, %64, %60, %52, %44, %36, %28, %20
%68 = load i32, i32* %2
ret i32 %68
}

LLVM IR (-O2):
@str = [24 x i8] c"ERROR in dirichlet_code\00"
@str.2 = [15 x i8] c"CODE UNDEFINED\00"
define i32 @dirichlet_code(i8 signext %0) {
%2 = tail call signext i8 @tolower(i8 signext %0)
%3 = sext i8 %2 to i32
%4 = add i8 %2, -123
%5 = icmp ult i8 %4, -26
br i1 %5, label %6, label %8
6: ; preds = %1
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.2, i64 0, i64 0))
br label %30
8: ; preds = %1
%9 = icmp ult i8 %2, 98
br i1 %9, label %30, label %10
10: ; preds = %8
%11 = icmp ult i8 %2, 106
br i1 %11, label %12, label %14
12: ; preds = %10
%13 = add nsw i32 %3, -98
br label %30
14: ; preds = %10
%15 = icmp ult i8 %2, 111
br i1 %15, label %16, label %18
16: ; preds = %14
%17 = add nsw i32 %3, -99
br label %30
18: ; preds = %14
%19 = icmp ult i8 %2, 117
br i1 %19, label %20, label %22
20: ; preds = %18
%21 = add nsw i32 %3, -100
br label %30
22: ; preds = %18
%23 = icmp ult i8 %2, 120
br i1 %23, label %24, label %26
24: ; preds = %22
%25 = add nsw i32 %3, -101
br label %30
26: ; preds = %22
%27 = icmp eq i8 %2, 121
br i1 %27, label %30, label %28
28: ; preds = %26
%29 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str, i64 0, i64 0))
br label %30
30: ; preds = %26, %8, %6, %28, %24, %20, %16, %12
%31 = phi i32 [ 0, %6 ], [ %13, %12 ], [ %17, %16 ], [ %21, %20 ], [ %25, %24 ], [ 0, %28 ], [ 0, %8 ], [ 19, %26 ]
ret i32 %31
}