#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 *);
void bruteForceAttack(const char *ciphertext) {
  for (int i = 1; i < 26; i++) {
    printf("Key: %d Plaintext: ", i);
    shiftAndPrint(i - 2 * i, ciphertext);
    printf("\n");
  }
}


x86 assembly (clang, -O0):
<bruteForceAttack>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x1,-0xc(%rbp)
cmpl   $0x1a,-0xc(%rbp)
jge    117e <bruteForceAttack+0x5e>
mov    -0xc(%rbp),%esi
lea    0xeb9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%edi
mov    -0xc(%rbp),%eax
shl    $0x1,%eax
sub    %eax,%edi
mov    -0x8(%rbp),%rsi
call   1040 <shiftAndPrint@plt>
lea    0xeab(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1133 <bruteForceAttack+0x13>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bruteForceAttack>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
mov    $0x1,%ebp
mov    $0xffffffff,%ebx
lea    0xeb5(%rip),%r15
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebx,%edi
mov    %r14,%rsi
call   1050 <shiftAndPrint@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%ebp
add    $0xffffffff,%ebx
cmp    $0xffffffe6,%ebx
jne    1150 <bruteForceAttack+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [20 x i8] c"Key: %d Plaintext: \00"
@.str.1 = [2 x i8] c"\0A\00"
define void @bruteForceAttack(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
store i32 1, i32* %3
br label %4
4: ; preds = %17, %1
%5 = load i32, i32* %3
%6 = icmp slt i32 %5, 26
br i1 %6, label %7, label %20
7: ; preds = %4
%8 = load i32, i32* %3
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %8)
%10 = load i32, i32* %3
%11 = load i32, i32* %3
%12 = mul nsw i32 2, %11
%13 = sub nsw i32 %10, %12
%14 = load i8*, i8** %2
%15 = call i32 @shiftAndPrint(i32 %13, i8* %14)
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %17
17: ; preds = %7
%18 = load i32, i32* %3
%19 = add nsw i32 %18, 1
store i32 %19, i32* %3
br label %4
20: ; preds = %4
ret void
}

LLVM IR (-O2):
@.str = [20 x i8] c"Key: %d Plaintext: \00"
define void @bruteForceAttack(i8* %0) {
br label %3
2: ; preds = %3
ret void
3: ; preds = %1, %3
%4 = phi i32 [ 1, %1 ], [ %9, %3 ]
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %4)
%6 = sub nsw i32 0, %4
%7 = tail call i32 @shiftAndPrint(i32 %6, i8* %0)
%8 = tail call i32 @putchar(i32 10)
%9 = add nuw nsw i32 %4, 1
%10 = icmp eq i32 %9, 26
br i1 %10, label %2, label %3
}