#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*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stderr;
void string_to_enigma_input(char *str, unsigned char *text) {
  int i;
  for (i = 0; str[i] != '\0'; i++) {
    if (str[i] < 'A' || str[i] > 'Z') {
      fprintf(stderr, "Warn: string_to_enigma_input: Input string contains "
                      "invalid characters - replaced with 'X'.");
      text[i] = 'A' - 'X';
    } else {
      text[i] = str[i] - 'A';
    }
  }
  if (i != 13)
    fprintf(stderr,
            "Warn: string_to_enigma_input: Input string was not of length 13.");
  return;
}


x86 assembly (clang, -O0):
<string_to_enigma_input>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     11bb <string_to_enigma_input+0xab>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x41,%eax
jl     1166 <string_to_enigma_input+0x56>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x5a,%eax
jle    118c <string_to_enigma_input+0x7c>
mov    0x2e73(%rip),%rax
mov    (%rax),%edi
lea    0xe8a(%rip),%rsi
call   1030 <fprintf@plt>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movb   $0xe9,(%rax,%rcx,1)
jmp    11a8 <string_to_enigma_input+0x98>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
sub    $0x41,%eax
mov    %al,%dl
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
jmp    11ad <string_to_enigma_input+0x9d>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1127 <string_to_enigma_input+0x17>
cmpl   $0xd,-0x14(%rbp)
je     11da <string_to_enigma_input+0xca>
mov    0x2e14(%rip),%rax
mov    (%rax),%edi
lea    0xe87(%rip),%rsi
call   1030 <fprintf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<string_to_enigma_input>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    (%rdi),%al
test   %al,%al
je     117b <string_to_enigma_input+0x6b>
mov    %rsi,%r14
mov    %rdi,%r12
xor    %ebx,%ebx
mov    0x2eb2(%rip),%r13
lea    0xecb(%rip),%r15
jmp    1154 <string_to_enigma_input+0x44>
nopw   0x0(%rax,%rax,1)
add    $0xbf,%al
mov    %al,(%r14,%rbx,1)
movzbl 0x1(%r12,%rbx,1),%eax
add    $0x1,%rbx
test   %al,%al
je     116c <string_to_enigma_input+0x5c>
lea    -0x5b(%rax),%ecx
cmp    $0xe5,%cl
ja     1140 <string_to_enigma_input+0x30>
mov    0x0(%r13),%edi
mov    %r15,%rsi
call   1030 <fprintf@plt>
mov    $0xe9,%al
jmp    1142 <string_to_enigma_input+0x32>
cmp    $0xd,%ebx
jne    117b <string_to_enigma_input+0x6b>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
mov    0x2e5e(%rip),%rax
mov    (%rax),%edi
lea    0xed1(%rip),%rsi
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    1030 <fprintf@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [92 x i8] c"Warn: string_to_enigma_input: Input string contains invalid characters - replaced with 'X'.\00"
@.str.1 = [65 x i8] c"Warn: string_to_enigma_input: Input string was not of length 13.\00"
define void @string_to_enigma_input(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
store i32 0, i32* %5
br label %6
6: ; preds = %51, %2
%7 = load i8*, i8** %3
%8 = load i32, i32* %5
%9 = sext i32 %8 to i64
%10 = getelementptr inbounds i8, i8* %7, i64 %9
%11 = load i8, i8* %10
%12 = sext i8 %11 to i32
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %54
14: ; preds = %6
%15 = load i8*, i8** %3
%16 = load i32, i32* %5
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8, i8* %15, i64 %17
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp slt i32 %20, 65
br i1 %21, label %30, label %22
22: ; preds = %14
%23 = load i8*, i8** %3
%24 = load i32, i32* %5
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %23, i64 %25
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = icmp sgt i32 %28, 90
br i1 %29, label %30, label %37
30: ; preds = %22, %14
%31 = load i32, i32* @stderr
%32 = call i32 @fprintf(i32 %31, i8* getelementptr inbounds ([92 x i8], [92 x i8]* @.str, i64 0, i64 0))
%33 = load i8*, i8** %4
%34 = load i32, i32* %5
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i8, i8* %33, i64 %35
store i8 -23, i8* %36
br label %50
37: ; preds = %22
%38 = load i8*, i8** %3
%39 = load i32, i32* %5
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i8, i8* %38, i64 %40
%42 = load i8, i8* %41
%43 = sext i8 %42 to i32
%44 = sub nsw i32 %43, 65
%45 = trunc i32 %44 to i8
%46 = load i8*, i8** %4
%47 = load i32, i32* %5
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds i8, i8* %46, i64 %48
store i8 %45, i8* %49
br label %50
50: ; preds = %37, %30
br label %51
51: ; preds = %50
%52 = load i32, i32* %5
%53 = add nsw i32 %52, 1
store i32 %53, i32* %5
br label %6
54: ; preds = %6
%55 = load i32, i32* %5
%56 = icmp ne i32 %55, 13
br i1 %56, label %57, label %60
57: ; preds = %54
%58 = load i32, i32* @stderr
%59 = call i32 @fprintf(i32 %58, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.1, i64 0, i64 0))
br label %60
60: ; preds = %57, %54
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [92 x i8] c"Warn: string_to_enigma_input: Input string contains invalid characters - replaced with 'X'.\00"
@.str.1 = [65 x i8] c"Warn: string_to_enigma_input: Input string was not of length 13.\00"
define void @string_to_enigma_input(i8* nocapture %0, i8* nocapture writeonly %1) {
%3 = load i8, i8* %0
%4 = icmp eq i8 %3, 0
br i1 %4, label %25, label %5
5: ; preds = %2, %15
%6 = phi i64 [ %18, %15 ], [ 0, %2 ]
%7 = phi i8 [ %20, %15 ], [ %3, %2 ]
%8 = add i8 %7, -91
%9 = icmp ult i8 %8, -26
br i1 %9, label %10, label %13
10: ; preds = %5
%11 = load i32, i32* @stderr
%12 = tail call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([92 x i8], [92 x i8]* @.str, i64 0, i64 0))
br label %15
13: ; preds = %5
%14 = add nsw i8 %7, -65
br label %15
15: ; preds = %10, %13
%16 = phi i8 [ -23, %10 ], [ %14, %13 ]
%17 = getelementptr inbounds i8, i8* %1, i64 %6
store i8 %16, i8* %17
%18 = add nuw i64 %6, 1
%19 = getelementptr inbounds i8, i8* %0, i64 %18
%20 = load i8, i8* %19
%21 = icmp eq i8 %20, 0
br i1 %21, label %22, label %5
22: ; preds = %15
%23 = trunc i64 %18 to i32
%24 = icmp eq i32 %23, 13
br i1 %24, label %28, label %25
25: ; preds = %2, %22
%26 = load i32, i32* @stderr
%27 = tail call i32 @fprintf(i32 %26, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.1, i64 0, i64 0))
br label %28
28: ; preds = %25, %22
ret void
}