#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 */
struct position {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ exit(int /*<<< orphan*/);
void *malloc(int);
int /*<<< orphan*/ printf(char *, ...);
char *reverseSearchOnTable(char **, char *, struct position *, int, int);
int /*<<< orphan*/ scanf(char *, ...);
struct position *searchOnTable(char **, char *, int);
int /*<<< orphan*/ system(char *);
int main(void) {
  char **table;
  char sentence[255];
  char answ;
  struct position *posXY;
  char *de_crypt_sen;
  int i, table_len, method = 0;
  printf("------------- Bifid Cipher/Decipher v1.0 -------------\n\n");
  printf("Do you want to use default table? (y/n): ");
  scanf(" %c", &answ);
  printf("\n");
  if (answ == 'n') {
    printf("Size of table (ex: 5 for 5x5): ");
    scanf("%i", &table_len);
    printf("\n");
    table = malloc(table_len * sizeof(char *));
    for (i = 0; i < table_len; i++)
      table[i] = malloc((table_len + 1) * sizeof(char));
    printf("Write your table:\n\n");
    for (i = 0; i < table_len; i++)
      scanf("%s", table[i]);
    printf("\n");
  } else if (answ == 'y') {
    table_len = 5;
    table = malloc(table_len * sizeof(char *));
    for (i = 0; i < table_len; i++)
      table[i] = malloc((table_len + 1) * sizeof(char));
    table[0] = "abcde";
    table[1] = "fghik";
    table[2] = "lmnop";
    table[3] = "qrstu";
    table[4] = "vwxyz";
  } else {
    printf("Invalid operation\n");
    exit(0);
  }
  printf("Do you want to cipher (0) or decipher (1)? : ");
  scanf("%i", &method);
  printf("\n");
  if (method == 0) {
    printf("Write the sentence: ");
    scanf(" %[^\n]s", sentence);
    printf("\n");
    posXY = searchOnTable(table, sentence, table_len);
    printf("\n");
    de_crypt_sen =
        reverseSearchOnTable(table, sentence, posXY, table_len, method);
    printf("\n\nCiphered sentence: %s\n", de_crypt_sen);
    if (answ == 'n')
      printf("\nREMEMBER: Copy your table, otherwise you can't decipher the "
             "sentence.\n");
    printf("\n");
    system("PAUSE");
  } else if (method == 1) {
    printf("Write the sentence: ");
    scanf(" %[^\n]s", sentence);
    printf("\n");
    posXY = searchOnTable(table, sentence, table_len);
    printf("\n");
    de_crypt_sen =
        reverseSearchOnTable(table, sentence, posXY, table_len, method);
    printf("\n\nDeciphered sentence: %s\n", de_crypt_sen);
    printf("\n");
    system("PAUSE");
  } else {
    printf("Invalid operation\n");
    exit(0);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x140,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x134(%rbp)
lea    0xe6d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe98(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xeb4(%rip),%rdi
lea    -0x111(%rbp),%rsi
mov    $0x0,%al
call   1080 <scanf@plt>
lea    0xe73(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movsbl -0x111(%rbp),%eax
cmp    $0x6e,%eax
jne    12e8 <main+0x178>
lea    0xe85(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe97(%rip),%rdi
lea    -0x130(%rbp),%rsi
mov    $0x0,%al
call   1080 <scanf@plt>
lea    0xe32(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movslq -0x130(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x12c(%rbp)
mov    -0x12c(%rbp),%eax
cmp    -0x130(%rbp),%eax
jge    127a <main+0x10a>
mov    -0x130(%rbp),%eax
add    $0x1,%eax
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,%rdx
mov    -0x10(%rbp),%rax
movslq -0x12c(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x12c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x12c(%rbp)
jmp    122c <main+0xbc>
lea    0xe09(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x12c(%rbp)
mov    -0x12c(%rbp),%eax
cmp    -0x130(%rbp),%eax
jge    12d5 <main+0x165>
mov    -0x10(%rbp),%rax
movslq -0x12c(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xde4(%rip),%rdi
mov    $0x0,%al
call   1080 <scanf@plt>
mov    -0x12c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x12c(%rbp)
jmp    1292 <main+0x122>
lea    0xd5b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    13d9 <main+0x269>
movsbl -0x111(%rbp),%eax
cmp    $0x79,%eax
jne    13bf <main+0x24f>
movl   $0x5,-0x130(%rbp)
movslq -0x130(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x12c(%rbp)
mov    -0x12c(%rbp),%eax
cmp    -0x130(%rbp),%eax
jge    1370 <main+0x200>
mov    -0x130(%rbp),%eax
add    $0x1,%eax
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,%rdx
mov    -0x10(%rbp),%rax
movslq -0x12c(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x12c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x12c(%rbp)
jmp    1322 <main+0x1b2>
mov    -0x10(%rbp),%rax
lea    0xd26(%rip),%rcx
mov    %rcx,(%rax)
mov    -0x10(%rbp),%rax
lea    0xd1e(%rip),%rcx
mov    %rcx,0x8(%rax)
mov    -0x10(%rbp),%rax
lea    0xd15(%rip),%rcx
mov    %rcx,0x10(%rax)
mov    -0x10(%rbp),%rax
lea    0xd0c(%rip),%rcx
mov    %rcx,0x18(%rax)
mov    -0x10(%rbp),%rax
lea    0xd03(%rip),%rcx
mov    %rcx,0x20(%rax)
jmp    13d4 <main+0x264>
lea    0xcf9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %edi,%edi
call   1090 <exit@plt>
jmp    13d9 <main+0x269>
lea    0xcf2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xc99(%rip),%rdi
lea    -0x134(%rbp),%rsi
mov    $0x0,%al
call   1080 <scanf@plt>
lea    0xc34(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x0,-0x134(%rbp)
jne    14f0 <main+0x380>
lea    0xce2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x110(%rbp),%rsi
lea    0xce2(%rip),%rdi
mov    $0x0,%al
call   1080 <scanf@plt>
lea    0xbf6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
lea    -0x110(%rbp),%rsi
mov    -0x130(%rbp),%edx
call   1060 <searchOnTable@plt>
mov    %rax,-0x120(%rbp)
lea    0xbcb(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
lea    -0x110(%rbp),%rsi
mov    -0x120(%rbp),%rdx
mov    -0x130(%rbp),%ecx
mov    -0x134(%rbp),%r8d
call   1050 <reverseSearchOnTable@plt>
mov    %rax,-0x128(%rbp)
mov    -0x128(%rbp),%rsi
lea    0xc71(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movsbl -0x111(%rbp),%eax
cmp    $0x6e,%eax
jne    14d1 <main+0x361>
lea    0xc6c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xb5f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xc98(%rip),%rdi
call   1030 <system@plt>
jmp    15d2 <main+0x462>
cmpl   $0x1,-0x134(%rbp)
jne    15b8 <main+0x448>
lea    0xbfc(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x110(%rbp),%rsi
lea    0xbfc(%rip),%rdi
mov    $0x0,%al
call   1080 <scanf@plt>
lea    0xb10(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
lea    -0x110(%rbp),%rsi
mov    -0x130(%rbp),%edx
call   1060 <searchOnTable@plt>
mov    %rax,-0x120(%rbp)
lea    0xae5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
lea    -0x110(%rbp),%rsi
mov    -0x120(%rbp),%rdx
mov    -0x130(%rbp),%ecx
mov    -0x134(%rbp),%r8d
call   1050 <reverseSearchOnTable@plt>
mov    %rax,-0x128(%rbp)
mov    -0x128(%rbp),%rsi
lea    0xbf2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xa97(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xbd0(%rip),%rdi
call   1030 <system@plt>
jmp    15cd <main+0x45d>
lea    0xb00(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %edi,%edi
call   1090 <exit@plt>
jmp    15d2 <main+0x462>
xor    %eax,%eax
add    $0x140,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x118,%rsp
movl   $0x0,0xc(%rsp)
lea    0xf4b(%rip),%rdi
call   1040 <puts@plt>
lea    0xe48(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe64(%rip),%rdi
lea    0x7(%rsp),%rsi
xor    %eax,%eax
call   10a0 <scanf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0x7(%rsp),%al
cmp    $0x79,%al
je     1298 <main+0x108>
cmp    $0x6e,%al
jne    1446 <main+0x2b6>
lea    0xe37(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe49(%rip),%rdi
lea    0x8(%rsp),%rsi
xor    %eax,%eax
call   10a0 <scanf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0x8(%rsp),%r14d
lea    0x0(,%r14,8),%edi
call   1090 <malloc@plt>
mov    %rax,%r15
test   %r14d,%r14d
jle    1254 <main+0xc4>
lea    0x1(%r14),%ebp
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
mov    %ebp,%edi
call   1090 <malloc@plt>
mov    %rax,(%r15,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%r14
jne    1240 <main+0xb0>
lea    0xf2d(%rip),%rdi
call   1040 <puts@plt>
cmpl   $0x0,0x8(%rsp)
jle    128c <main+0xfc>
lea    0xde3(%rip),%r14
xor    %ebx,%ebx
mov    (%r15,%rbx,8),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   10a0 <scanf@plt>
add    $0x1,%rbx
movslq 0x8(%rsp),%rax
cmp    %rax,%rbx
jl     1270 <main+0xe0>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    12e3 <main+0x153>
movl   $0x5,0x8(%rsp)
mov    $0x28,%edi
call   1090 <malloc@plt>
mov    %rax,%r15
lea    0xda0(%rip),%rax
mov    %rax,(%r15)
lea    0xd9c(%rip),%rax
mov    %rax,0x8(%r15)
lea    0xd97(%rip),%rax
mov    %rax,0x10(%r15)
lea    0xd92(%rip),%rax
mov    %rax,0x18(%r15)
lea    0xd8d(%rip),%rax
mov    %rax,0x20(%r15)
lea    0xd88(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xd56(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   10a0 <scanf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0xc(%rsp),%eax
cmp    $0x1,%eax
je     13ae <main+0x21e>
test   %eax,%eax
jne    1446 <main+0x2b6>
lea    0xd76(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xd7d(%rip),%rdi
lea    0x10(%rsp),%r14
mov    %r14,%rsi
xor    %eax,%eax
call   10a0 <scanf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0x8(%rsp),%edx
mov    %r15,%rdi
mov    %r14,%rsi
call   1080 <searchOnTable@plt>
mov    %rax,%rbp
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0x8(%rsp),%ecx
mov    0xc(%rsp),%r8d
mov    %r15,%rdi
mov    %r14,%rsi
mov    %rbp,%rdx
call   1070 <reverseSearchOnTable@plt>
lea    0xd32(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
cmpb   $0x6e,0x7(%rsp)
jne    1420 <main+0x290>
lea    0xd9a(%rip),%rdi
call   1040 <puts@plt>
jmp    1420 <main+0x290>
lea    0xceb(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xcf2(%rip),%rdi
lea    0x10(%rsp),%r14
mov    %r14,%rsi
xor    %eax,%eax
call   10a0 <scanf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0x8(%rsp),%edx
mov    %r15,%rdi
mov    %r14,%rsi
call   1080 <searchOnTable@plt>
mov    %rax,%rbp
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0x8(%rsp),%ecx
mov    0xc(%rsp),%r8d
mov    %r15,%rdi
mov    %r14,%rsi
mov    %rbp,%rdx
call   1070 <reverseSearchOnTable@plt>
lea    0xcc6(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xca5(%rip),%rdi
call   1050 <system@plt>
xor    %eax,%eax
add    $0x118,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xce2(%rip),%rdi
call   1040 <puts@plt>
xor    %edi,%edi
call   10b0 <exit@plt>

LLVM IR (-O0):
%struct.position = type { i32 }
@.str = [57 x i8] c"------------- Bifid Cipher/Decipher v1.0 -------------\0A\0A\00"
@.str.1 = [42 x i8] c"Do you want to use default table? (y/n): \00"
@.str.2 = [4 x i8] c" %c\00"
@.str.3 = [2 x i8] c"\0A\00"
@.str.4 = [32 x i8] c"Size of table (ex: 5 for 5x5): \00"
@.str.5 = [3 x i8] c"%i\00"
@.str.6 = [20 x i8] c"Write your table:\0A\0A\00"
@.str.7 = [3 x i8] c"%s\00"
@.str.8 = [6 x i8] c"abcde\00"
@.str.9 = [6 x i8] c"fghik\00"
@.str.10 = [6 x i8] c"lmnop\00"
@.str.11 = [6 x i8] c"qrstu\00"
@.str.12 = [6 x i8] c"vwxyz\00"
@.str.13 = [19 x i8] c"Invalid operation\0A\00"
@.str.14 = [46 x i8] c"Do you want to cipher (0) or decipher (1)? : \00"
@.str.15 = [21 x i8] c"Write the sentence: \00"
@.str.16 = [8 x i8] c" %[^\0A]s\00"
@.str.17 = [25 x i8] c"\0A\0ACiphered sentence: %s\0A\00"
@.str.18 = [72 x i8] c"\0AREMEMBER: Copy your table, otherwise you can't decipher the sentence.\0A\00"
@.str.19 = [6 x i8] c"PAUSE\00"
@.str.20 = [27 x i8] c"\0A\0ADeciphered sentence: %s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8**
%3 = alloca [255 x i8]
%4 = alloca i8
%5 = alloca %struct.position*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %9
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str, i64 0, i64 0))
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0))
%12 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %4)
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%14 = load i8, i8* %4
%15 = sext i8 %14 to i32
%16 = icmp eq i32 %15, 110
br i1 %16, label %17, label %63
17: ; preds = %0
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.4, i64 0, i64 0))
%19 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %8)
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%21 = load i32, i32* %8
%22 = sext i32 %21 to i64
%23 = mul i64 %22, 8
%24 = trunc i64 %23 to i32
%25 = call i8* @malloc(i32 %24)
%26 = bitcast i8* %25 to i8**
store i8** %26, i8*** %2
store i32 0, i32* %7
br label %27
27: ; preds = %42, %17
%28 = load i32, i32* %7
%29 = load i32, i32* %8
%30 = icmp slt i32 %28, %29
br i1 %30, label %31, label %45
31: ; preds = %27
%32 = load i32, i32* %8
%33 = add nsw i32 %32, 1
%34 = sext i32 %33 to i64
%35 = mul i64 %34, 1
%36 = trunc i64 %35 to i32
%37 = call i8* @malloc(i32 %36)
%38 = load i8**, i8*** %2
%39 = load i32, i32* %7
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i8*, i8** %38, i64 %40
store i8* %37, i8** %41
br label %42
42: ; preds = %31
%43 = load i32, i32* %7
%44 = add nsw i32 %43, 1
store i32 %44, i32* %7
br label %27
45: ; preds = %27
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0))
store i32 0, i32* %7
br label %47
47: ; preds = %58, %45
%48 = load i32, i32* %7
%49 = load i32, i32* %8
%50 = icmp slt i32 %48, %49
br i1 %50, label %51, label %61
51: ; preds = %47
%52 = load i8**, i8*** %2
%53 = load i32, i32* %7
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds i8*, i8** %52, i64 %54
%56 = load i8*, i8** %55
%57 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i8* %56)
br label %58
58: ; preds = %51
%59 = load i32, i32* %7
%60 = add nsw i32 %59, 1
store i32 %60, i32* %7
br label %47
61: ; preds = %47
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %107
63: ; preds = %0
%64 = load i8, i8* %4
%65 = sext i8 %64 to i32
%66 = icmp eq i32 %65, 121
br i1 %66, label %67, label %103
67: ; preds = %63
store i32 5, i32* %8
%68 = load i32, i32* %8
%69 = sext i32 %68 to i64
%70 = mul i64 %69, 8
%71 = trunc i64 %70 to i32
%72 = call i8* @malloc(i32 %71)
%73 = bitcast i8* %72 to i8**
store i8** %73, i8*** %2
store i32 0, i32* %7
br label %74
74: ; preds = %89, %67
%75 = load i32, i32* %7
%76 = load i32, i32* %8
%77 = icmp slt i32 %75, %76
br i1 %77, label %78, label %92
78: ; preds = %74
%79 = load i32, i32* %8
%80 = add nsw i32 %79, 1
%81 = sext i32 %80 to i64
%82 = mul i64 %81, 1
%83 = trunc i64 %82 to i32
%84 = call i8* @malloc(i32 %83)
%85 = load i8**, i8*** %2
%86 = load i32, i32* %7
%87 = sext i32 %86 to i64
%88 = getelementptr inbounds i8*, i8** %85, i64 %87
store i8* %84, i8** %88
br label %89
89: ; preds = %78
%90 = load i32, i32* %7
%91 = add nsw i32 %90, 1
store i32 %91, i32* %7
br label %74
92: ; preds = %74
%93 = load i8**, i8*** %2
%94 = getelementptr inbounds i8*, i8** %93, i64 0
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0), i8** %94
%95 = load i8**, i8*** %2
%96 = getelementptr inbounds i8*, i8** %95, i64 1
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0), i8** %96
%97 = load i8**, i8*** %2
%98 = getelementptr inbounds i8*, i8** %97, i64 2
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.10, i64 0, i64 0), i8** %98
%99 = load i8**, i8*** %2
%100 = getelementptr inbounds i8*, i8** %99, i64 3
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i64 0, i64 0), i8** %100
%101 = load i8**, i8*** %2
%102 = getelementptr inbounds i8*, i8** %101, i64 4
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.12, i64 0, i64 0), i8** %102
br label %106
103: ; preds = %63
%104 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.13, i64 0, i64 0))
%105 = call i32 @exit(i32 0)
unreachable
106: ; preds = %92
br label %107
107: ; preds = %106, %61
%108 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.14, i64 0, i64 0))
%109 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %9)
%110 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%111 = load i32, i32* %9
%112 = icmp eq i32 %111, 0
br i1 %112, label %113, label %139
113: ; preds = %107
%114 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.15, i64 0, i64 0))
%115 = getelementptr inbounds [255 x i8], [255 x i8]* %3, i64 0, i64 0
%116 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.16, i64 0, i64 0), i8* %115)
%117 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%118 = load i8**, i8*** %2
%119 = getelementptr inbounds [255 x i8], [255 x i8]* %3, i64 0, i64 0
%120 = load i32, i32* %8
%121 = call %struct.position* @searchOnTable(i8** %118, i8* %119, i32 %120)
store %struct.position* %121, %struct.position** %5
%122 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%123 = load i8**, i8*** %2
%124 = getelementptr inbounds [255 x i8], [255 x i8]* %3, i64 0, i64 0
%125 = load %struct.position*, %struct.position** %5
%126 = load i32, i32* %8
%127 = load i32, i32* %9
%128 = call i8* @reverseSearchOnTable(i8** %123, i8* %124, %struct.position* %125, i32 %126, i32 %127)
store i8* %128, i8** %6
%129 = load i8*, i8** %6
%130 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.17, i64 0, i64 0), i8* %129)
%131 = load i8, i8* %4
%132 = sext i8 %131 to i32
%133 = icmp eq i32 %132, 110
br i1 %133, label %134, label %136
134: ; preds = %113
%135 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([72 x i8], [72 x i8]* @.str.18, i64 0, i64 0))
br label %136
136: ; preds = %134, %113
%137 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%138 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.19, i64 0, i64 0))
br label %166
139: ; preds = %107
%140 = load i32, i32* %9
%141 = icmp eq i32 %140, 1
br i1 %141, label %142, label %162
142: ; preds = %139
%143 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.15, i64 0, i64 0))
%144 = getelementptr inbounds [255 x i8], [255 x i8]* %3, i64 0, i64 0
%145 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.16, i64 0, i64 0), i8* %144)
%146 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%147 = load i8**, i8*** %2
%148 = getelementptr inbounds [255 x i8], [255 x i8]* %3, i64 0, i64 0
%149 = load i32, i32* %8
%150 = call %struct.position* @searchOnTable(i8** %147, i8* %148, i32 %149)
store %struct.position* %150, %struct.position** %5
%151 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%152 = load i8**, i8*** %2
%153 = getelementptr inbounds [255 x i8], [255 x i8]* %3, i64 0, i64 0
%154 = load %struct.position*, %struct.position** %5
%155 = load i32, i32* %8
%156 = load i32, i32* %9
%157 = call i8* @reverseSearchOnTable(i8** %152, i8* %153, %struct.position* %154, i32 %155, i32 %156)
store i8* %157, i8** %6
%158 = load i8*, i8** %6
%159 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.20, i64 0, i64 0), i8* %158)
%160 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%161 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.19, i64 0, i64 0))
br label %165
162: ; preds = %139
%163 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.13, i64 0, i64 0))
%164 = call i32 @exit(i32 0)
unreachable
165: ; preds = %142
br label %166
166: ; preds = %165, %136
ret i32 0
}

LLVM IR (-O2):
%struct.position = type { i32 }
@.str.1 = [42 x i8] c"Do you want to use default table? (y/n): \00"
@.str.2 = [4 x i8] c" %c\00"
@.str.4 = [32 x i8] c"Size of table (ex: 5 for 5x5): \00"
@.str.5 = [3 x i8] c"%i\00"
@.str.7 = [3 x i8] c"%s\00"
@.str.8 = [6 x i8] c"abcde\00"
@.str.9 = [6 x i8] c"fghik\00"
@.str.10 = [6 x i8] c"lmnop\00"
@.str.11 = [6 x i8] c"qrstu\00"
@.str.12 = [6 x i8] c"vwxyz\00"
@.str.14 = [46 x i8] c"Do you want to cipher (0) or decipher (1)? : \00"
@.str.15 = [21 x i8] c"Write the sentence: \00"
@.str.16 = [8 x i8] c" %[^\0A]s\00"
@.str.17 = [25 x i8] c"\0A\0ACiphered sentence: %s\0A\00"
@.str.19 = [6 x i8] c"PAUSE\00"
@.str.20 = [27 x i8] c"\0A\0ADeciphered sentence: %s\0A\00"
@str = [56 x i8] c"------------- Bifid Cipher/Decipher v1.0 -------------\0A\00"
@str.22 = [18 x i8] c"Invalid operation\00"
@str.23 = [71 x i8] c"\0AREMEMBER: Copy your table, otherwise you can't decipher the sentence.\00"
@str.24 = [19 x i8] c"Write your table:\0A\00"
define i32 @main() {
%1 = alloca [255 x i8]
%2 = alloca i8
%3 = alloca i32
%4 = alloca i32
%5 = getelementptr inbounds [255 x i8], [255 x i8]* %1, i64 0, i64 0
%6 = bitcast i32* %3 to i8*
%7 = bitcast i32* %4 to i8*
store i32 0, i32* %4
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([56 x i8], [56 x i8]* @str, i64 0, i64 0))
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %2)
%11 = call i32 @putchar(i32 10)
%12 = load i8, i8* %2
switch i8 %12, label %53 [
i8 110, label %13
i8 121, label %46
]
13: ; preds = %0
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.4, i64 0, i64 0))
%15 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %3)
%16 = call i32 @putchar(i32 10)
%17 = load i32, i32* %3
%18 = shl i32 %17, 3
%19 = call i8* @malloc(i32 %18)
%20 = bitcast i8* %19 to i8**
%21 = icmp sgt i32 %17, 0
br i1 %21, label %22, label %31
22: ; preds = %13
%23 = add nuw nsw i32 %17, 1
%24 = zext i32 %17 to i64
br label %25
25: ; preds = %22, %25
%26 = phi i64 [ 0, %22 ], [ %29, %25 ]
%27 = call i8* @malloc(i32 %23)
%28 = getelementptr inbounds i8*, i8** %20, i64 %26
store i8* %27, i8** %28
%29 = add nuw nsw i64 %26, 1
%30 = icmp eq i64 %29, %24
br i1 %30, label %31, label %25
31: ; preds = %25, %13
%32 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.24, i64 0, i64 0))
%33 = load i32, i32* %3
%34 = icmp sgt i32 %33, 0
br i1 %34, label %35, label %44
35: ; preds = %31, %35
%36 = phi i64 [ %40, %35 ], [ 0, %31 ]
%37 = getelementptr inbounds i8*, i8** %20, i64 %36
%38 = load i8*, i8** %37
%39 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i8* %38)
%40 = add nuw nsw i64 %36, 1
%41 = load i32, i32* %3
%42 = sext i32 %41 to i64
%43 = icmp slt i64 %40, %42
br i1 %43, label %35, label %44
44: ; preds = %35, %31
%45 = call i32 @putchar(i32 10)
br label %56
46: ; preds = %0
store i32 5, i32* %3
%47 = call dereferenceable_or_null(40) i8* @malloc(i32 40)
%48 = bitcast i8* %47 to i8**
%49 = getelementptr inbounds i8*, i8** %48, i64 1
%50 = getelementptr inbounds i8*, i8** %48, i64 2
%51 = getelementptr inbounds i8*, i8** %48, i64 3
%52 = getelementptr inbounds i8*, i8** %48, i64 4
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0), i8** %48
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0), i8** %49
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.10, i64 0, i64 0), i8** %50
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i64 0, i64 0), i8** %51
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.12, i64 0, i64 0), i8** %52
br label %56
53: ; preds = %0
%54 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.22, i64 0, i64 0))
%55 = call i32 @exit(i32 0)
unreachable
56: ; preds = %46, %44
%57 = phi i8** [ %20, %44 ], [ %48, %46 ]
%58 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str.14, i64 0, i64 0))
%59 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %4)
%60 = call i32 @putchar(i32 10)
%61 = load i32, i32* %4
switch i32 %61, label %88 [
i32 0, label %62
i32 1, label %77
]
62: ; preds = %56
%63 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.15, i64 0, i64 0))
%64 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.16, i64 0, i64 0), i8* %5)
%65 = call i32 @putchar(i32 10)
%66 = load i32, i32* %3
%67 = call %struct.position* @searchOnTable(i8** %57, i8* %5, i32 %66)
%68 = call i32 @putchar(i32 10)
%69 = load i32, i32* %3
%70 = load i32, i32* %4
%71 = call i8* @reverseSearchOnTable(i8** %57, i8* %5, %struct.position* %67, i32 %69, i32 %70)
%72 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.17, i64 0, i64 0), i8* %71)
%73 = load i8, i8* %2
%74 = icmp eq i8 %73, 110
br i1 %74, label %75, label %91
75: ; preds = %62
%76 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([71 x i8], [71 x i8]* @str.23, i64 0, i64 0))
br label %91
77: ; preds = %56
%78 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.15, i64 0, i64 0))
%79 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.16, i64 0, i64 0), i8* %5)
%80 = call i32 @putchar(i32 10)
%81 = load i32, i32* %3
%82 = call %struct.position* @searchOnTable(i8** %57, i8* %5, i32 %81)
%83 = call i32 @putchar(i32 10)
%84 = load i32, i32* %3
%85 = load i32, i32* %4
%86 = call i8* @reverseSearchOnTable(i8** %57, i8* %5, %struct.position* %82, i32 %84, i32 %85)
%87 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.20, i64 0, i64 0), i8* %86)
br label %91
88: ; preds = %56
%89 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.22, i64 0, i64 0))
%90 = call i32 @exit(i32 0)
unreachable
91: ; preds = %62, %75, %77
%92 = call i32 @putchar(i32 10)
%93 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.19, i64 0, i64 0))
ret i32 0
}