#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*/ decode(char *, char *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stdin;
int main(int argc, char *argv[]) {
  if (argc != 2) {
    printf("You should enter a valid string as an argument\n");
    return 1;
  }
  char *key = argv[1];
  int i;
  int n;
  for (i = 0; i < 255; i++) {
    n = key[i];
    if (n == 0) {
      break;
    }
    if (!((n >= 97 && n <= 122) || (n >= 65 && n <= 90))) {
      printf("You should enter a valid string as an argument\n");
      return 1;
    }
  }
  char text[256];
  fgets(text, 256, stdin);
  decode(text, key);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     116b <main+0x3b>
lea    0xea6(%rip),%rdi
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    122d <main+0xfd>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0xff,-0x1c(%rbp)
jge    11fc <main+0xcc>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
jne    11a9 <main+0x79>
jmp    11fc <main+0xcc>
cmpl   $0x61,-0x20(%rbp)
jl     11bd <main+0x8d>
cmpl   $0x7a,-0x20(%rbp)
jle    11e9 <main+0xb9>
cmpl   $0x41,-0x20(%rbp)
jl     11d1 <main+0xa1>
cmpl   $0x5a,-0x20(%rbp)
jle    11e9 <main+0xb9>
lea    0xe28(%rip),%rdi
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    122d <main+0xfd>
jmp    11ee <main+0xbe>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    117e <main+0x4e>
lea    -0x120(%rbp),%rdi
mov    0x2dde(%rip),%rax
mov    (%rax),%edx
mov    $0x100,%esi
call   1040 <fgets@plt>
lea    -0x120(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <decode@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x108,%rsp
cmp    $0x2,%edi
jne    11bf <main+0x8f>
mov    0x8(%rsi),%rbx
mov    $0x2,%eax
nopl   0x0(%rax)
movzbl -0x2(%rbx,%rax,1),%ecx
test   %cl,%cl
je     1197 <main+0x67>
and    $0xdf,%cl
add    $0xbf,%cl
cmp    $0x1a,%cl
jae    11bf <main+0x8f>
movzbl -0x1(%rbx,%rax,1),%ecx
test   %cl,%cl
je     1197 <main+0x67>
and    $0xdf,%cl
add    $0xbf,%cl
cmp    $0x19,%cl
ja     11bf <main+0x8f>
movzbl (%rbx,%rax,1),%ecx
test   %cl,%cl
je     1197 <main+0x67>
and    $0xdf,%cl
add    $0xbf,%cl
cmp    $0x19,%cl
ja     11bf <main+0x8f>
add    $0x3,%rax
cmp    $0x101,%rax
jne    1150 <main+0x20>
mov    0x2e4a(%rip),%rax
mov    (%rax),%edx
mov    %rsp,%r14
mov    %r14,%rdi
mov    $0x100,%esi
call   1040 <fgets@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <decode@plt>
xor    %eax,%eax
jmp    11d0 <main+0xa0>
lea    0xe3a(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%eax
add    $0x108,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [48 x i8] c"You should enter a valid string as an argument\0A\00"
@stdin = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca [256 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* %4
%11 = icmp ne i32 %10, 2
br i1 %11, label %12, label %14
12: ; preds = %2
%13 = call i32 @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %56
14: ; preds = %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
store i8* %17, i8** %6
store i32 0, i32* %7
br label %18
18: ; preds = %46, %14
%19 = load i32, i32* %7
%20 = icmp slt i32 %19, 255
br i1 %20, label %21, label %49
21: ; preds = %18
%22 = load i8*, i8** %6
%23 = load i32, i32* %7
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8, i8* %22, i64 %24
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
store i32 %27, i32* %8
%28 = load i32, i32* %8
%29 = icmp eq i32 %28, 0
br i1 %29, label %30, label %31
30: ; preds = %21
br label %49
31: ; preds = %21
%32 = load i32, i32* %8
%33 = icmp sge i32 %32, 97
br i1 %33, label %34, label %37
34: ; preds = %31
%35 = load i32, i32* %8
%36 = icmp sle i32 %35, 122
br i1 %36, label %45, label %37
37: ; preds = %34, %31
%38 = load i32, i32* %8
%39 = icmp sge i32 %38, 65
br i1 %39, label %40, label %43
40: ; preds = %37
%41 = load i32, i32* %8
%42 = icmp sle i32 %41, 90
br i1 %42, label %45, label %43
43: ; preds = %40, %37
%44 = call i32 @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %56
45: ; preds = %40, %34
br label %46
46: ; preds = %45
%47 = load i32, i32* %7
%48 = add nsw i32 %47, 1
store i32 %48, i32* %7
br label %18
49: ; preds = %30, %18
%50 = getelementptr inbounds [256 x i8], [256 x i8]* %9, i64 0, i64 0
%51 = load i32, i32* @stdin
%52 = call i32 @fgets(i8* %50, i32 256, i32 %51)
%53 = getelementptr inbounds [256 x i8], [256 x i8]* %9, i64 0, i64 0
%54 = load i8*, i8** %6
%55 = call i32 @decode(i8* %53, i8* %54)
store i32 0, i32* %3
br label %56
56: ; preds = %49, %43, %12
%57 = load i32, i32* %3
ret i32 %57
}

LLVM IR (-O2):
@stdin = global i32 0
@str.1 = [47 x i8] c"You should enter a valid string as an argument\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [256 x i8]
%4 = icmp eq i32 %0, 2
br i1 %4, label %7, label %5
5: ; preds = %2
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @str.1, i64 0, i64 0))
br label %47
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
br label %31
10: ; preds = %36
%11 = add nuw nsw i64 %32, 1
%12 = getelementptr inbounds i8, i8* %9, i64 %11
%13 = load i8, i8* %12
%14 = icmp eq i8 %13, 0
br i1 %14, label %42, label %15
15: ; preds = %10
%16 = and i8 %13, -33
%17 = add i8 %16, -65
%18 = icmp ult i8 %17, 26
br i1 %18, label %19, label %40
19: ; preds = %15
%20 = add nuw nsw i64 %32, 2
%21 = getelementptr inbounds i8, i8* %9, i64 %20
%22 = load i8, i8* %21
%23 = icmp eq i8 %22, 0
br i1 %23, label %42, label %24
24: ; preds = %19
%25 = and i8 %22, -33
%26 = add i8 %25, -65
%27 = icmp ult i8 %26, 26
br i1 %27, label %28, label %40
28: ; preds = %24
%29 = add nuw nsw i64 %32, 3
%30 = icmp eq i64 %29, 255
br i1 %30, label %42, label %31
31: ; preds = %28, %7
%32 = phi i64 [ 0, %7 ], [ %29, %28 ]
%33 = getelementptr inbounds i8, i8* %9, i64 %32
%34 = load i8, i8* %33
%35 = icmp eq i8 %34, 0
br i1 %35, label %42, label %36
36: ; preds = %31
%37 = and i8 %34, -33
%38 = add i8 %37, -65
%39 = icmp ult i8 %38, 26
br i1 %39, label %10, label %40
40: ; preds = %24, %15, %36
%41 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @str.1, i64 0, i64 0))
br label %47
42: ; preds = %28, %19, %10, %31
%43 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%44 = load i32, i32* @stdin
%45 = call i32 @fgets(i8* %43, i32 256, i32 %44)
%46 = call i32 @decode(i8* %43, i8* %9)
br label %47
47: ; preds = %40, %42, %5
%48 = phi i32 [ 1, %5 ], [ 0, %42 ], [ 1, %40 ]
ret i32 %48
}