#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 *, ...);
int /*<<< orphan*/ shiftAndPrint(int, char const *);
int /*<<< orphan*/ shiftCharsOnce(char *);
scalar_t__ strstr(char const *, char *);
void dictionaryAttack(char *word, const char *ciphertext) {
  bool successFlag = false;
  for (int i = 1; i < 26; i++) {
    shiftCharsOnce(word);
    if (strstr(ciphertext, word)) {
      successFlag = true;
      printf("Success! Key: %d Plaintext: ", i);
      shiftAndPrint(i - 2 * i, ciphertext);
      printf("\n");
    }
  }
  if (!successFlag) {
    shiftCharsOnce(word);
    printf("The string %s was not a substring of any plaintext for all "
           "possible shift values\n",
           word);
  }
}


x86 assembly (clang, -O0):
<dictionaryAttack>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x1,-0x18(%rbp)
cmpl   $0x1a,-0x18(%rbp)
jge    11d5 <dictionaryAttack+0x95>
mov    -0x8(%rbp),%rdi
call   1060 <shiftCharsOnce@plt>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1050 <strstr@plt>
cmp    $0x0,%rax
je     11c2 <dictionaryAttack+0x82>
movl   $0x1,-0x14(%rbp)
mov    -0x18(%rbp),%esi
lea    0xe67(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%edi
mov    -0x18(%rbp),%eax
shl    $0x1,%eax
sub    %eax,%edi
mov    -0x10(%rbp),%rsi
call   1040 <shiftAndPrint@plt>
lea    0xeb2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11c7 <dictionaryAttack+0x87>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    115e <dictionaryAttack+0x1e>
cmpl   $0x0,-0x14(%rbp)
jne    11fa <dictionaryAttack+0xba>
mov    -0x8(%rbp),%rdi
call   1060 <shiftCharsOnce@plt>
mov    -0x8(%rbp),%rsi
lea    0xe2a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dictionaryAttack>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r12
mov    $0x1,%bpl
mov    $0x1,%ebx
lea    0xe93(%rip),%r15
nopl   (%rax)
mov    %r12,%rdi
call   1070 <shiftCharsOnce@plt>
mov    %r14,%rdi
mov    %r12,%rsi
call   1060 <strstr@plt>
test   %rax,%rax
jne    1192 <dictionaryAttack+0x42>
add    $0x1,%ebx
cmp    $0x1a,%ebx
jne    1170 <dictionaryAttack+0x20>
jmp    11c2 <dictionaryAttack+0x72>
xor    %ebp,%ebp
mov    %r15,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebx,%edi
neg    %edi
mov    %r14,%rsi
call   1050 <shiftAndPrint@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0x1(%rbx),%eax
cmp    $0x19,%ebx
mov    %eax,%ebx
jne    1170 <dictionaryAttack+0x20>
jmp    11e9 <dictionaryAttack+0x99>
test   $0x1,%bpl
je     11e9 <dictionaryAttack+0x99>
mov    %r12,%rdi
call   1070 <shiftCharsOnce@plt>
lea    0xe46(%rip),%rdi
mov    %r12,%rsi
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <printf@plt>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [29 x i8] c"Success! Key: %d Plaintext: \00"
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [82 x i8] c"The string %s was not a substring of any plaintext for all possible shift values\0A\00"
define void @dictionaryAttack(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
store i32 0, i32* %5
store i32 1, i32* %6
br label %7
7: ; preds = %28, %2
%8 = load i32, i32* %6
%9 = icmp slt i32 %8, 26
br i1 %9, label %10, label %31
10: ; preds = %7
%11 = load i8*, i8** %3
%12 = call i32 @shiftCharsOnce(i8* %11)
%13 = load i8*, i8** %4
%14 = load i8*, i8** %3
%15 = call i64 @strstr(i8* %13, i8* %14)
%16 = icmp ne i64 %15, 0
br i1 %16, label %17, label %27
17: ; preds = %10
store i32 1, i32* %5
%18 = load i32, i32* %6
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i32 %18)
%20 = load i32, i32* %6
%21 = load i32, i32* %6
%22 = mul nsw i32 2, %21
%23 = sub nsw i32 %20, %22
%24 = load i8*, i8** %4
%25 = call i32 @shiftAndPrint(i32 %23, i8* %24)
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %27
27: ; preds = %17, %10
br label %28
28: ; preds = %27
%29 = load i32, i32* %6
%30 = add nsw i32 %29, 1
store i32 %30, i32* %6
br label %7
31: ; preds = %7
%32 = load i32, i32* %5
%33 = icmp ne i32 %32, 0
br i1 %33, label %39, label %34
34: ; preds = %31
%35 = load i8*, i8** %3
%36 = call i32 @shiftCharsOnce(i8* %35)
%37 = load i8*, i8** %3
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([82 x i8], [82 x i8]* @.str.2, i64 0, i64 0), i8* %37)
br label %39
39: ; preds = %34, %31
ret void
}

LLVM IR (-O2):
@.str = [29 x i8] c"Success! Key: %d Plaintext: \00"
@.str.2 = [82 x i8] c"The string %s was not a substring of any plaintext for all possible shift values\0A\00"
define void @dictionaryAttack(i8* %0, i8* %1) {
br label %3
3: ; preds = %15, %2
%4 = phi i32 [ %20, %15 ], [ 1, %2 ]
%5 = phi i1 [ false, %15 ], [ true, %2 ]
br label %7
6: ; preds = %12
br i1 %5, label %22, label %25
7: ; preds = %3, %12
%8 = phi i32 [ %13, %12 ], [ %4, %3 ]
%9 = tail call i32 @shiftCharsOnce(i8* %0)
%10 = tail call i64 @strstr(i8* %1, i8* %0)
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %7
%13 = add nuw nsw i32 %8, 1
%14 = icmp eq i32 %13, 26
br i1 %14, label %6, label %7
15: ; preds = %7
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i32 %8)
%17 = sub nsw i32 0, %8
%18 = tail call i32 @shiftAndPrint(i32 %17, i8* %1)
%19 = tail call i32 @putchar(i32 10)
%20 = add nuw nsw i32 %8, 1
%21 = icmp eq i32 %20, 26
br i1 %21, label %25, label %3
22: ; preds = %6
%23 = tail call i32 @shiftCharsOnce(i8* %0)
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([82 x i8], [82 x i8]* @.str.2, i64 0, i64 0), i8* %0)
br label %25
25: ; preds = %15, %22, %6
ret void
}