#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 EOF;
char getchar();
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ *strchr(char *, char);
char tolower(char);
char welcome(void) {
  char choose;
  puts("############################################");
  puts("Welcome to use Public Key Encryption");
  puts("Enter the letter correspnoding to your choice:");
  puts("e)encrype   d)decode ");
  puts("g)get keys  q)quit   ");
  while ((choose = getchar()) != EOF) {
    while (getchar() != '\n') {
      continue;
    }
    choose = tolower(choose);
    if (strchr("edgq", choose) == NULL) {
      puts("Please enter an e,d,g or q:");
    } else {
      break;
    }
  }
  if (choose == EOF) {
    choose = 'q';
  }
  return choose;
}


x86 assembly (clang, -O0):
<welcome>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xeb1(%rip),%rdi
call   1030 <puts@plt>
lea    0xed2(%rip),%rdi
call   1030 <puts@plt>
lea    0xeeb(%rip),%rdi
call   1030 <puts@plt>
lea    0xf0e(%rip),%rdi
call   1030 <puts@plt>
lea    0xf18(%rip),%rdi
call   1030 <puts@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %al,-0x1(%rbp)
movsbl %al,%eax
mov    0x2e50(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     1201 <welcome+0xc1>
jmp    11a8 <welcome+0x68>
mov    $0x0,%al
call   1050 <getchar@plt>
movsbl %al,%eax
cmp    $0xa,%eax
je     11c0 <welcome+0x80>
jmp    11a8 <welcome+0x68>
movsbl -0x1(%rbp),%edi
call   1060 <tolower@plt>
mov    %al,-0x1(%rbp)
lea    0xeda(%rip),%rdi
movsbl -0x1(%rbp),%esi
call   1040 <strchr@plt>
cmp    $0x0,%rax
jne    11f7 <welcome+0xb7>
lea    0xec5(%rip),%rdi
call   1030 <puts@plt>
jmp    11fc <welcome+0xbc>
jmp    1201 <welcome+0xc1>
jmp    1184 <welcome+0x44>
movsbl -0x1(%rbp),%eax
mov    0x2ddc(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
jne    121b <welcome+0xdb>
movb   $0x71,-0x1(%rbp)
movsbl -0x1(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<welcome>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
lea    0xeb1(%rip),%rdi
call   1030 <puts@plt>
lea    0xed2(%rip),%rdi
call   1030 <puts@plt>
lea    0xeeb(%rip),%rdi
call   1030 <puts@plt>
lea    0xf0e(%rip),%rdi
call   1030 <puts@plt>
lea    0xf18(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
mov    %eax,%ebp
mov    0x2e54(%rip),%r12
cmp    (%r12),%al
jne    119e <welcome+0x5e>
mov    %ebp,%ebx
jmp    11f5 <welcome+0xb5>
lea    0xf08(%rip),%r15
lea    0xf06(%rip),%r14
nopl   0x0(%rax)
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    $0xa,%al
jne    11b0 <welcome+0x70>
movsbl %bpl,%edi
call   1060 <tolower@plt>
mov    %eax,%ebx
movsbl %al,%esi
mov    %r15,%rdi
call   1040 <strchr@plt>
test   %rax,%rax
jne    11f1 <welcome+0xb1>
mov    %r14,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
mov    %eax,%ebp
mov    %eax,%ebx
cmp    (%r12),%al
jne    11b0 <welcome+0x70>
jmp    11f5 <welcome+0xb5>
mov    (%r12),%bpl
cmp    %bpl,%bl
movzbl %bl,%ecx
mov    $0x71,%eax
cmovne %ecx,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [45 x i8] c"############################################\00"
@.str.1 = [37 x i8] c"Welcome to use Public Key Encryption\00"
@.str.2 = [47 x i8] c"Enter the letter correspnoding to your choice:\00"
@.str.3 = [22 x i8] c"e)encrype d)decode \00"
@.str.4 = [22 x i8] c"g)get keys q)quit \00"
@EOF = global i8 0
@.str.5 = [5 x i8] c"edgq\00"
@.str.6 = [28 x i8] c"Please enter an e,d,g or q:\00"
define signext i8 @welcome() {
%1 = alloca i8
%2 = call i32 @puts(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0))
%3 = call i32 @puts(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0))
%4 = call i32 @puts(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.2, i64 0, i64 0))
%5 = call i32 @puts(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
%6 = call i32 @puts(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0))
br label %7
7: ; preds = %28, %0
%8 = call signext i8 (...) @getchar()
store i8 %8, i8* %1
%9 = sext i8 %8 to i32
%10 = load i8, i8* @EOF
%11 = sext i8 %10 to i32
%12 = icmp ne i32 %9, %11
br i1 %12, label %13, label %29
13: ; preds = %7
br label %14
14: ; preds = %18, %13
%15 = call signext i8 (...) @getchar()
%16 = sext i8 %15 to i32
%17 = icmp ne i32 %16, 10
br i1 %17, label %18, label %19
18: ; preds = %14
br label %14
19: ; preds = %14
%20 = load i8, i8* %1
%21 = call signext i8 @tolower(i8 signext %20)
store i8 %21, i8* %1
%22 = load i8, i8* %1
%23 = call i32* @strchr(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i8 signext %22)
%24 = icmp eq i32* %23, null
br i1 %24, label %25, label %27
25: ; preds = %19
%26 = call i32 @puts(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0))
br label %28
27: ; preds = %19
br label %29
28: ; preds = %25
br label %7
29: ; preds = %27, %7
%30 = load i8, i8* %1
%31 = sext i8 %30 to i32
%32 = load i8, i8* @EOF
%33 = sext i8 %32 to i32
%34 = icmp eq i32 %31, %33
br i1 %34, label %35, label %36
35: ; preds = %29
store i8 113, i8* %1
br label %36
36: ; preds = %35, %29
%37 = load i8, i8* %1
ret i8 %37
}

LLVM IR (-O2):
@.str = [45 x i8] c"############################################\00"
@.str.1 = [37 x i8] c"Welcome to use Public Key Encryption\00"
@.str.2 = [47 x i8] c"Enter the letter correspnoding to your choice:\00"
@.str.3 = [22 x i8] c"e)encrype d)decode \00"
@.str.4 = [22 x i8] c"g)get keys q)quit \00"
@EOF = global i8 0
@.str.5 = [5 x i8] c"edgq\00"
@.str.6 = [28 x i8] c"Please enter an e,d,g or q:\00"
define signext i8 @welcome() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0))
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0))
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @.str.2, i64 0, i64 0))
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0))
%6 = tail call signext i8 (...) @getchar()
%7 = load i8, i8* @EOF
%8 = icmp eq i8 %6, %7
br i1 %8, label %25, label %9
9: ; preds = %0, %20
%10 = phi i8 [ %22, %20 ], [ %6, %0 ]
br label %11
11: ; preds = %9, %11
%12 = tail call signext i8 (...) @getchar()
%13 = icmp eq i8 %12, 10
br i1 %13, label %14, label %11
14: ; preds = %11
%15 = tail call signext i8 @tolower(i8 signext %10)
%16 = tail call i32* @strchr(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i8 signext %15)
%17 = icmp eq i32* %16, null
br i1 %17, label %20, label %18
18: ; preds = %14
%19 = load i8, i8* @EOF
br label %25
20: ; preds = %14
%21 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0))
%22 = tail call signext i8 (...) @getchar()
%23 = load i8, i8* @EOF
%24 = icmp eq i8 %22, %23
br i1 %24, label %25, label %9
25: ; preds = %20, %18, %0
%26 = phi i8 [ %6, %0 ], [ %19, %18 ], [ %22, %20 ]
%27 = phi i8 [ %6, %0 ], [ %15, %18 ], [ %22, %20 ]
%28 = icmp eq i8 %27, %26
%29 = select i1 %28, i8 113, i8 %27
ret i8 %29
}