#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 */
char *decrypt(char *, char *, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, ...);
int main(int argc, char *argv[]) {
  char str[100], str2[100], end;
  int choose;
  do {
    printf("1: Verschlüsseln\n2: Entschlüsseln\n");
    scanf("%d", &choose);
    switch (choose) {
    case 1:
      printf("Bitte geben Sie das zu verschlüsselnde Wort ein:\n");
      scanf("%s", str);
      printf("Bitte geben Sie das zugehörige Schlüsselwort ein:\n");
      scanf("%s", str2);
      printf("Das verschlüsselte Wort ist %s\n", decrypt(str, str2, 0));
      break;
    case 2:
      printf("Bitte geben Sie das zu entschlüsselnde Wort ein:\n");
      scanf("%s", str);
      printf("Bitte geben Sie das zugehörige Schlüsselwort ein:\n");
      scanf("%s", str2);
      printf("Das gesuchte Wort war %s\n", decrypt(str, str2, 1));
      break;
    }
    printf("Programm beenden? (y/n)\n");
    scanf("%s", &end);
  } while (end != 'y');
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x100,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xeb0(%rip),%rdi
xor    %eax,%eax
mov    %al,-0xfd(%rbp)
call   1040 <printf@plt>
mov    -0xfd(%rbp),%al
lea    0xebb(%rip),%rdi
lea    -0xf8(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0xf8(%rbp),%eax
mov    %eax,-0xfc(%rbp)
sub    $0x1,%eax
je     11a4 <main+0x74>
jmp    1190 <main+0x60>
mov    -0xfc(%rbp),%eax
sub    $0x2,%eax
je     120f <main+0xdf>
jmp    1278 <main+0x148>
lea    0xe7d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x80(%rbp),%rsi
lea    0xe9e(%rip),%rdi
mov    $0x0,%al
call   1050 <scanf@plt>
lea    0xe93(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0xf0(%rbp),%rsi
lea    0xe7b(%rip),%rdi
mov    $0x0,%al
call   1050 <scanf@plt>
lea    -0x80(%rbp),%rdi
lea    -0xf0(%rbp),%rsi
xor    %edx,%edx
call   1030 <decrypt@plt>
mov    %rax,%rsi
lea    0xe90(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1278 <main+0x148>
lea    0xe9e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x80(%rbp),%rsi
lea    0xe33(%rip),%rdi
mov    $0x0,%al
call   1050 <scanf@plt>
lea    0xe28(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0xf0(%rbp),%rsi
lea    0xe10(%rip),%rdi
mov    $0x0,%al
call   1050 <scanf@plt>
lea    -0x80(%rbp),%rdi
lea    -0xf0(%rbp),%rsi
mov    $0x1,%edx
call   1030 <decrypt@plt>
mov    %rax,%rsi
lea    0xe76(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe82(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xdce(%rip),%rdi
lea    -0xf1(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
movsbl -0xf1(%rbp),%eax
cmp    $0x79,%eax
jne    1149 <main+0x19>
xor    %eax,%eax
add    $0x100,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xe8,%rsp
lea    0xeab(%rip),%rbx
lea    0x80(%rsp),%r13
lea    0x10(%rsp),%rbp
lea    0xb(%rsp),%r15
jmp    11d6 <main+0x96>
nopl   0x0(%rax)
call   1040 <puts@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
lea    0xf58(%rip),%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
mov    %r13,%rdi
mov    %rbp,%rsi
mov    %r14d,%edx
call   1030 <decrypt@plt>
mov    %r12,%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xeda(%rip),%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
cmpb   $0x79,0xb(%rsp)
je     1234 <main+0xf4>
lea    0xe64(%rip),%rdi
call   1040 <puts@plt>
lea    0xe17(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
mov    0xc(%rsp),%eax
lea    0xeaf(%rip),%rdi
mov    $0x0,%r14d
lea    0xdf9(%rip),%r12
cmp    $0x1,%eax
je     1170 <main+0x30>
cmp    $0x2,%eax
jne    11b6 <main+0x76>
mov    $0x1,%r14d
lea    0xe3d(%rip),%rdi
lea    0xdf8(%rip),%r12
jmp    1170 <main+0x30>
xor    %eax,%eax
add    $0xe8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [37 x i8] c"1: Verschl\C3\BCsseln\0A2: Entschl\C3\BCsseln\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [51 x i8] c"Bitte geben Sie das zu verschl\C3\BCsselnde Wort ein:\0A\00"
@.str.3 = [3 x i8] c"%s\00"
@.str.4 = [53 x i8] c"Bitte geben Sie das zugeh\C3\B6rige Schl\C3\BCsselwort ein:\0A\00"
@.str.5 = [33 x i8] c"Das verschl\C3\BCsselte Wort ist %s\0A\00"
@.str.6 = [51 x i8] c"Bitte geben Sie das zu entschl\C3\BCsselnde Wort ein:\0A\00"
@.str.7 = [26 x i8] c"Das gesuchte Wort war %s\0A\00"
@.str.8 = [25 x i8] c"Programm beenden? (y/n)\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [100 x i8]
%7 = alloca [100 x i8]
%8 = alloca i8
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
br label %10
10: ; preds = %39, %2
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
%12 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %9)
%13 = load i32, i32* %9
switch i32 %13, label %36 [
i32 1, label %14
i32 2, label %25
]
14: ; preds = %10
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.2, i64 0, i64 0))
%16 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%17 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %16)
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.4, i64 0, i64 0))
%19 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%20 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %19)
%21 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%22 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%23 = call i8* @decrypt(i8* %21, i8* %22, i32 0)
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.5, i64 0, i64 0), i8* %23)
br label %36
25: ; preds = %10
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.6, i64 0, i64 0))
%27 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%28 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %27)
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.4, i64 0, i64 0))
%30 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%31 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %30)
%32 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%33 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%34 = call i8* @decrypt(i8* %32, i8* %33, i32 1)
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.7, i64 0, i64 0), i8* %34)
br label %36
36: ; preds = %10, %25, %14
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.8, i64 0, i64 0))
%38 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %8)
br label %39
39: ; preds = %36
%40 = load i8, i8* %8
%41 = sext i8 %40 to i32
%42 = icmp ne i32 %41, 121
br i1 %42, label %10, label %43
43: ; preds = %39
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@.str.3 = [3 x i8] c"%s\00"
@.str.5 = [33 x i8] c"Das verschl\C3\BCsselte Wort ist %s\0A\00"
@.str.7 = [26 x i8] c"Das gesuchte Wort war %s\0A\00"
@str = [36 x i8] c"1: Verschl\C3\BCsseln\0A2: Entschl\C3\BCsseln\00"
@str.9 = [50 x i8] c"Bitte geben Sie das zu entschl\C3\BCsselnde Wort ein:\00"
@str.11 = [24 x i8] c"Programm beenden? (y/n)\00"
@str.12 = [50 x i8] c"Bitte geben Sie das zu verschl\C3\BCsselnde Wort ein:\00"
@str.13 = [52 x i8] c"Bitte geben Sie das zugeh\C3\B6rige Schl\C3\BCsselwort ein:\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [100 x i8]
%4 = alloca [100 x i8]
%5 = alloca i8
%6 = alloca i32
%7 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%8 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%9 = bitcast i32* %6 to i8*
br label %10
10: ; preds = %26, %2
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str, i64 0, i64 0))
%12 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %6)
%13 = load i32, i32* %6
switch i32 %13, label %26 [
i32 1, label %15
i32 2, label %14
]
14: ; preds = %10
br label %15
15: ; preds = %10, %14
%16 = phi i8* [ getelementptr inbounds ([50 x i8], [50 x i8]* @str.9, i64 0, i64 0), %14 ], [ getelementptr inbounds ([50 x i8], [50 x i8]* @str.12, i64 0, i64 0), %10 ]
%17 = phi i8* [ getelementptr inbounds ([52 x i8], [52 x i8]* @str.13, i64 0, i64 0), %14 ], [ getelementptr inbounds ([52 x i8], [52 x i8]* @str.13, i64 0, i64 0), %10 ]
%18 = phi i32 [ 1, %14 ], [ 0, %10 ]
%19 = phi i8* [ getelementptr inbounds ([26 x i8], [26 x i8]* @.str.7, i64 0, i64 0), %14 ], [ getelementptr inbounds ([33 x i8], [33 x i8]* @.str.5, i64 0, i64 0), %10 ]
%20 = call i32 @puts(i8* dereferenceable(1) %16)
%21 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %7)
%22 = call i32 @puts(i8* dereferenceable(1) %17)
%23 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %8)
%24 = call i8* @decrypt(i8* %7, i8* %8, i32 %18)
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %19, i8* %24)
br label %26
26: ; preds = %15, %10
%27 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.11, i64 0, i64 0))
%28 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %5)
%29 = load i8, i8* %5
%30 = icmp eq i8 %29, 121
br i1 %30, label %31, label %10
31: ; preds = %26
ret i32 0
}