#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 colemak(char **, int);
int dvorak(char **, int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ getchar();
int /*<<< orphan*/ printf(char *, ...);
int qwerty(char **, int);
int /*<<< orphan*/ stdin;
int workman(char **, int);
void conversion(int layoutOrder[]) {
  char layout[2][96];
  char userInput[64] = {0};
  char translatedOutput[64];
  int offset[2] = {25};
  int i, j;
  printf("Place your text here:\n$ ");
  getchar();
  fgets(userInput, 64, stdin);
  for (i = 0; i < 2; i++) {
    switch (layoutOrder[i]) {
    case 0:
      offset[1] = dvorak(layout, i);
      break;
    case 1:
      offset[1] = qwerty(layout, i);
      break;
    case 2:
      offset[1] = colemak(layout, i);
      break;
    case 3:
      offset[1] = workman(layout, i);
      break;
    default:
      printf("Something went wrong! Please restart the program and try again.");
      exit(-1);
    }
  }
  printf("Translated Text:\n");
  for (i = 0; i < 64; i++) {
    for (j = 0; j < 96; j++) {
      if (userInput[i] == layout[0][j]) {
        if (j == offset[0] || j == offset[1]) {
          j++;
        }
        printf("%c", layout[1][j]);
        break;
      }
    }
  }
}


x86 assembly (clang, -O0):
<conversion>:
push   %rbp
mov    %rsp,%rbp
sub    $0x170,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x110(%rbp),%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1050 <memset@plt>
mov    0xe57(%rip),%rax
mov    %rax,-0x158(%rbp)
lea    0xe51(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1090 <getchar@plt>
lea    -0x110(%rbp),%rdi
mov    0x2e05(%rip),%rax
mov    (%rax),%edx
mov    $0x40,%esi
call   1070 <fgets@plt>
movl   $0x0,-0x15c(%rbp)
cmpl   $0x2,-0x15c(%rbp)
jge    12e1 <conversion+0x151>
mov    -0x8(%rbp),%rax
movslq -0x15c(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %rax,-0x168(%rbp)
sub    $0x3,%rax
ja     12b0 <conversion+0x120>
mov    -0x168(%rbp),%rax
lea    0xdcd(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    -0xd0(%rbp),%rdi
mov    -0x15c(%rbp),%esi
call   1030 <dvorak@plt>
mov    %eax,-0x154(%rbp)
jmp    12c8 <conversion+0x138>
lea    -0xd0(%rbp),%rdi
mov    -0x15c(%rbp),%esi
call   1060 <qwerty@plt>
mov    %eax,-0x154(%rbp)
jmp    12c8 <conversion+0x138>
lea    -0xd0(%rbp),%rdi
mov    -0x15c(%rbp),%esi
call   1080 <colemak@plt>
mov    %eax,-0x154(%rbp)
jmp    12c8 <conversion+0x138>
lea    -0xd0(%rbp),%rdi
mov    -0x15c(%rbp),%esi
call   10a0 <workman@plt>
mov    %eax,-0x154(%rbp)
jmp    12c8 <conversion+0x138>
lea    0xd7a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0xffffffff,%edi
call   10b0 <exit@plt>
jmp    12cd <conversion+0x13d>
mov    -0x15c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x15c(%rbp)
jmp    11f9 <conversion+0x69>
lea    0xd89(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x15c(%rbp)
cmpl   $0x40,-0x15c(%rbp)
jge    13c7 <conversion+0x237>
movl   $0x0,-0x160(%rbp)
cmpl   $0x60,-0x160(%rbp)
jge    13ae <conversion+0x21e>
movslq -0x15c(%rbp),%rax
movsbl -0x110(%rbp,%rax,1),%eax
ff
movslq -0x160(%rbp),%rcx
movsbl -0xd0(%rbp,%rcx,1),%ecx
ff
cmp    %ecx,%eax
jne    1395 <conversion+0x205>
mov    -0x160(%rbp),%eax
cmp    -0x158(%rbp),%eax
je     1367 <conversion+0x1d7>
mov    -0x160(%rbp),%eax
cmp    -0x154(%rbp),%eax
jne    1376 <conversion+0x1e6>
mov    -0x160(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x160(%rbp)
movslq -0x160(%rbp),%rax
movsbl -0x70(%rbp,%rax,1),%esi
lea    0xcfa(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    13ae <conversion+0x21e>
jmp    139a <conversion+0x20a>
mov    -0x160(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x160(%rbp)
jmp    1310 <conversion+0x180>
jmp    13b3 <conversion+0x223>
mov    -0x15c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x15c(%rbp)
jmp    12f9 <conversion+0x169>
add    $0x170,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<conversion>:
push   %rbp
push   %rbx
sub    $0x108,%rsp
mov    %rdi,%rbx
xorps  %xmm0,%xmm0
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
lea    0xe57(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
call   10a0 <getchar@plt>
mov    0x2e0a(%rip),%rax
mov    (%rax),%edx
mov    %rsp,%rdi
mov    $0x40,%esi
call   1080 <fgets@plt>
mov    (%rbx),%eax
cmp    $0x3,%rax
ja     1358 <conversion+0x1b8>
lea    0xe00(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0x40(%rsp),%rdi
xor    %esi,%esi
call   1050 <dvorak@plt>
jmp    123f <conversion+0x9f>
lea    0x40(%rsp),%rdi
xor    %esi,%esi
call   1070 <qwerty@plt>
jmp    123f <conversion+0x9f>
lea    0x40(%rsp),%rdi
xor    %esi,%esi
call   1090 <colemak@plt>
jmp    123f <conversion+0x9f>
lea    0x40(%rsp),%rdi
xor    %esi,%esi
call   10b0 <workman@plt>
mov    0x4(%rbx),%eax
cmp    $0x3,%rax
ja     1358 <conversion+0x1b8>
lea    0xdbd(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0x40(%rsp),%rdi
mov    $0x1,%esi
call   1050 <dvorak@plt>
jmp    129e <conversion+0xfe>
lea    0x40(%rsp),%rdi
mov    $0x1,%esi
call   1070 <qwerty@plt>
jmp    129e <conversion+0xfe>
lea    0x40(%rsp),%rdi
mov    $0x1,%esi
call   1090 <colemak@plt>
jmp    129e <conversion+0xfe>
lea    0x40(%rsp),%rdi
mov    $0x1,%esi
call   10b0 <workman@plt>
mov    %eax,%ebp
lea    0xdd2(%rip),%rdi
call   1040 <puts@plt>
xor    %ebx,%ebx
jmp    12e9 <conversion+0x149>
add    $0xfffffffffffffffb,%rax
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
cmp    $0x19,%eax
sete   %cl
cmp    %eax,%ebp
sete   %dl
or     %cl,%dl
movzbl %dl,%ecx
add    %eax,%ecx
movsbl 0xa0(%rsp,%rcx,1),%edi
call   1030 <putchar@plt>
add    $0x1,%rbx
cmp    $0x40,%rbx
je     134e <conversion+0x1ae>
mov    (%rsp,%rbx,1),%cl
mov    $0x5,%eax
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
cmp    0x3b(%rsp,%rax,1),%cl
je     12b0 <conversion+0x110>
cmp    0x3c(%rsp,%rax,1),%cl
je     1330 <conversion+0x190>
cmp    0x3d(%rsp,%rax,1),%cl
je     1336 <conversion+0x196>
cmp    0x3e(%rsp,%rax,1),%cl
je     133c <conversion+0x19c>
cmp    0x3f(%rsp,%rax,1),%cl
je     1345 <conversion+0x1a5>
cmp    0x40(%rsp,%rax,1),%cl
je     12c0 <conversion+0x120>
add    $0x6,%rax
cmp    $0x65,%rax
jne    1300 <conversion+0x160>
jmp    12df <conversion+0x13f>
add    $0xfffffffffffffffc,%rax
jmp    12c0 <conversion+0x120>
add    $0xfffffffffffffffd,%rax
jmp    12c0 <conversion+0x120>
add    $0xfffffffffffffffe,%rax
jmp    12c0 <conversion+0x120>
add    $0xffffffffffffffff,%rax
jmp    12c0 <conversion+0x120>
add    $0x108,%rsp
pop    %rbx
pop    %rbp
ret
lea    0xcda(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0xffffffff,%edi
call   10c0 <exit@plt>

LLVM IR (-O0):
@__const.conversion.offset = [2 x i32] [i32 25, i32 0]
@.str = [25 x i8] c"Place your text here:\0A$ \00"
@stdin = global i32 0
@.str.1 = [64 x i8] c"Something went wrong! Please restart the program and try again.\00"
@.str.2 = [18 x i8] c"Translated Text:\0A\00"
@.str.3 = [3 x i8] c"%c\00"
define void @conversion(i32* %0) {
%2 = alloca i32*
%3 = alloca [2 x [96 x i8]]
%4 = alloca [64 x i8]
%5 = alloca [64 x i8]
%6 = alloca [2 x i32]
%7 = alloca i32
%8 = alloca i32
store i32* %0, i32** %2
%9 = bitcast [64 x i8]* %4 to i8*
%10 = bitcast [2 x i32]* %6 to i8*
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%12 = call i32 (...) @getchar()
%13 = getelementptr inbounds [64 x i8], [64 x i8]* %4, i64 0, i64 0
%14 = load i32, i32* @stdin
%15 = call i32 @fgets(i8* %13, i32 64, i32 %14)
store i32 0, i32* %7
br label %16
16: ; preds = %53, %1
%17 = load i32, i32* %7
%18 = icmp slt i32 %17, 2
br i1 %18, label %19, label %56
19: ; preds = %16
%20 = load i32*, i32** %2
%21 = load i32, i32* %7
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i32, i32* %20, i64 %22
%24 = load i32, i32* %23
switch i32 %24, label %49 [
i32 0, label %25
i32 1, label %31
i32 2, label %37
i32 3, label %43
]
25: ; preds = %19
%26 = getelementptr inbounds [2 x [96 x i8]], [2 x [96 x i8]]* %3, i64 0, i64 0
%27 = bitcast [96 x i8]* %26 to i8**
%28 = load i32, i32* %7
%29 = call i32 @dvorak(i8** %27, i32 %28)
%30 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 1
store i32 %29, i32* %30
br label %52
31: ; preds = %19
%32 = getelementptr inbounds [2 x [96 x i8]], [2 x [96 x i8]]* %3, i64 0, i64 0
%33 = bitcast [96 x i8]* %32 to i8**
%34 = load i32, i32* %7
%35 = call i32 @qwerty(i8** %33, i32 %34)
%36 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 1
store i32 %35, i32* %36
br label %52
37: ; preds = %19
%38 = getelementptr inbounds [2 x [96 x i8]], [2 x [96 x i8]]* %3, i64 0, i64 0
%39 = bitcast [96 x i8]* %38 to i8**
%40 = load i32, i32* %7
%41 = call i32 @colemak(i8** %39, i32 %40)
%42 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 1
store i32 %41, i32* %42
br label %52
43: ; preds = %19
%44 = getelementptr inbounds [2 x [96 x i8]], [2 x [96 x i8]]* %3, i64 0, i64 0
%45 = bitcast [96 x i8]* %44 to i8**
%46 = load i32, i32* %7
%47 = call i32 @workman(i8** %45, i32 %46)
%48 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 1
store i32 %47, i32* %48
br label %52
49: ; preds = %19
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str.1, i64 0, i64 0))
%51 = call i32 @exit(i32 -1)
unreachable
52: ; preds = %43, %37, %31, %25
br label %53
53: ; preds = %52
%54 = load i32, i32* %7
%55 = add nsw i32 %54, 1
store i32 %55, i32* %7
br label %16
56: ; preds = %16
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %7
br label %58
58: ; preds = %104, %56
%59 = load i32, i32* %7
%60 = icmp slt i32 %59, 64
br i1 %60, label %61, label %107
61: ; preds = %58
store i32 0, i32* %8
br label %62
62: ; preds = %100, %61
%63 = load i32, i32* %8
%64 = icmp slt i32 %63, 96
br i1 %64, label %65, label %103
65: ; preds = %62
%66 = load i32, i32* %7
%67 = sext i32 %66 to i64
%68 = getelementptr inbounds [64 x i8], [64 x i8]* %4, i64 0, i64 %67
%69 = load i8, i8* %68
%70 = sext i8 %69 to i32
%71 = getelementptr inbounds [2 x [96 x i8]], [2 x [96 x i8]]* %3, i64 0, i64 0
%72 = load i32, i32* %8
%73 = sext i32 %72 to i64
%74 = getelementptr inbounds [96 x i8], [96 x i8]* %71, i64 0, i64 %73
%75 = load i8, i8* %74
%76 = sext i8 %75 to i32
%77 = icmp eq i32 %70, %76
br i1 %77, label %78, label %99
78: ; preds = %65
%79 = load i32, i32* %8
%80 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 0
%81 = load i32, i32* %80
%82 = icmp eq i32 %79, %81
br i1 %82, label %88, label %83
83: ; preds = %78
%84 = load i32, i32* %8
%85 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 1
%86 = load i32, i32* %85
%87 = icmp eq i32 %84, %86
br i1 %87, label %88, label %91
88: ; preds = %83, %78
%89 = load i32, i32* %8
%90 = add nsw i32 %89, 1
store i32 %90, i32* %8
br label %91
91: ; preds = %88, %83
%92 = getelementptr inbounds [2 x [96 x i8]], [2 x [96 x i8]]* %3, i64 0, i64 1
%93 = load i32, i32* %8
%94 = sext i32 %93 to i64
%95 = getelementptr inbounds [96 x i8], [96 x i8]* %92, i64 0, i64 %94
%96 = load i8, i8* %95
%97 = sext i8 %96 to i32
%98 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %97)
br label %103
99: ; preds = %65
br label %100
100: ; preds = %99
%101 = load i32, i32* %8
%102 = add nsw i32 %101, 1
store i32 %102, i32* %8
br label %62
103: ; preds = %91, %62
br label %104
104: ; preds = %103
%105 = load i32, i32* %7
%106 = add nsw i32 %105, 1
store i32 %106, i32* %7
br label %58
107: ; preds = %58
ret void
}

LLVM IR (-O2):
@.str = [25 x i8] c"Place your text here:\0A$ \00"
@stdin = global i32 0
@.str.1 = [64 x i8] c"Something went wrong! Please restart the program and try again.\00"
@str = [17 x i8] c"Translated Text:\00"
define void @conversion(i32* nocapture %0) {
%2 = alloca [2 x [96 x i8]]
%3 = alloca [64 x i8]
%4 = getelementptr inbounds [2 x [96 x i8]], [2 x [96 x i8]]* %2, i64 0, i64 0, i64 0
%5 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%7 = tail call i32 (...) @getchar()
%8 = load i32, i32* @stdin
%9 = call i32 @fgets(i8* %5, i32 64, i32 %8)
%10 = bitcast [2 x [96 x i8]]* %2 to i8**
%11 = load i32, i32* %0
switch i32 %11, label %20 [
i32 0, label %12
i32 1, label %14
i32 2, label %16
i32 3, label %18
]
12: ; preds = %1
%13 = call i32 @dvorak(i8** %10, i32 0)
br label %23
14: ; preds = %1
%15 = call i32 @qwerty(i8** %10, i32 0)
br label %23
16: ; preds = %1
%17 = call i32 @colemak(i8** %10, i32 0)
br label %23
18: ; preds = %1
%19 = call i32 @workman(i8** %10, i32 0)
br label %23
20: ; preds = %23, %1
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([64 x i8], [64 x i8]* @.str.1, i64 0, i64 0))
%22 = call i32 @exit(i32 -1)
unreachable
23: ; preds = %12, %14, %16, %18
%24 = getelementptr inbounds i32, i32* %0, i64 1
%25 = load i32, i32* %24
switch i32 %25, label %20 [
i32 0, label %32
i32 1, label %30
i32 2, label %28
i32 3, label %26
]
26: ; preds = %23
%27 = call i32 @workman(i8** %10, i32 1)
br label %34
28: ; preds = %23
%29 = call i32 @colemak(i8** %10, i32 1)
br label %34
30: ; preds = %23
%31 = call i32 @qwerty(i8** %10, i32 1)
br label %34
32: ; preds = %23
%33 = call i32 @dvorak(i8** %10, i32 1)
br label %34
34: ; preds = %32, %30, %28, %26
%35 = phi i32 [ %27, %26 ], [ %29, %28 ], [ %31, %30 ], [ %33, %32 ]
%36 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str, i64 0, i64 0))
br label %37
37: ; preds = %34, %87
%38 = phi i64 [ 0, %34 ], [ %88, %87 ]
%39 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 %38
%40 = load i8, i8* %39
br label %41
41: ; preds = %84, %37
%42 = phi i64 [ 0, %37 ], [ %85, %84 ]
%43 = getelementptr inbounds [2 x [96 x i8]], [2 x [96 x i8]]* %2, i64 0, i64 0, i64 %42
%44 = load i8, i8* %43
%45 = icmp eq i8 %40, %44
br i1 %45, label %46, label %59
46: ; preds = %79, %74, %69, %64, %59, %41
%47 = phi i64 [ %42, %41 ], [ %60, %59 ], [ %65, %64 ], [ %70, %69 ], [ %75, %74 ], [ %80, %79 ]
%48 = trunc i64 %47 to i32
%49 = icmp eq i32 %48, 25
%50 = icmp eq i32 %35, %48
%51 = select i1 %49, i1 true, i1 %50
%52 = zext i1 %51 to i64
%53 = add nuw i64 %47, %52
%54 = and i64 %53, 4294967295
%55 = getelementptr inbounds [2 x [96 x i8]], [2 x [96 x i8]]* %2, i64 0, i64 1, i64 %54
%56 = load i8, i8* %55
%57 = sext i8 %56 to i32
%58 = call i32 @putchar(i32 %57)
br label %87
59: ; preds = %41
%60 = or i64 %42, 1
%61 = getelementptr inbounds [2 x [96 x i8]], [2 x [96 x i8]]* %2, i64 0, i64 0, i64 %60
%62 = load i8, i8* %61
%63 = icmp eq i8 %40, %62
br i1 %63, label %46, label %64
64: ; preds = %59
%65 = add nuw nsw i64 %42, 2
%66 = getelementptr inbounds [2 x [96 x i8]], [2 x [96 x i8]]* %2, i64 0, i64 0, i64 %65
%67 = load i8, i8* %66
%68 = icmp eq i8 %40, %67
br i1 %68, label %46, label %69
69: ; preds = %64
%70 = add nuw nsw i64 %42, 3
%71 = getelementptr inbounds [2 x [96 x i8]], [2 x [96 x i8]]* %2, i64 0, i64 0, i64 %70
%72 = load i8, i8* %71
%73 = icmp eq i8 %40, %72
br i1 %73, label %46, label %74
74: ; preds = %69
%75 = add nuw nsw i64 %42, 4
%76 = getelementptr inbounds [2 x [96 x i8]], [2 x [96 x i8]]* %2, i64 0, i64 0, i64 %75
%77 = load i8, i8* %76
%78 = icmp eq i8 %40, %77
br i1 %78, label %46, label %79
79: ; preds = %74
%80 = add nuw nsw i64 %42, 5
%81 = getelementptr inbounds [2 x [96 x i8]], [2 x [96 x i8]]* %2, i64 0, i64 0, i64 %80
%82 = load i8, i8* %81
%83 = icmp eq i8 %40, %82
br i1 %83, label %46, label %84
84: ; preds = %79
%85 = add nuw nsw i64 %42, 6
%86 = icmp eq i64 %85, 96
br i1 %86, label %87, label %41
87: ; preds = %84, %46
%88 = add nuw nsw i64 %38, 1
%89 = icmp eq i64 %88, 64
br i1 %89, label %90, label %37
90: ; preds = %87
ret void
}