#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 */
scalar_t__ isalpha(char);
scalar_t__ isupper(char);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, char *);
int toupper(char);
int main() {
  int t, i, k;
  char M[27], str[102];
  printf("Enter the language:");
  scanf("%s", M);
  printf("Enter the string:");
  scanf("%s", str);
  for (i = 0; str[i] != '\0'; i++) {
    if (isalpha(str[i])) {
      if (isupper(str[i])) {
        printf("%c", toupper(M[str[i] - 'A']));
      } else {
        printf("%c", M[str[i] - 'a']);
      }
    } else if (str[i] == '_') {
      printf(" ");
    } else {
      printf("%c", str[i]);
    }
  }
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe97(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x30(%rbp),%rsi
lea    0xe99(%rip),%rdi
call   1070 <scanf@plt>
lea    0xe90(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0xa0(%rbp),%rsi
lea    0xe78(%rip),%rdi
call   1070 <scanf@plt>
movl   $0x0,-0xc(%rbp)
movslq -0xc(%rbp),%rax
movsbl -0xa0(%rbp,%rax,1),%eax
ff
cmp    $0x0,%eax
je     12a6 <main+0x156>
movslq -0xc(%rbp),%rax
movsbl -0xa0(%rbp,%rax,1),%edi
ff
call   1050 <isalpha@plt>
cmp    $0x0,%rax
je     124c <main+0xfc>
movslq -0xc(%rbp),%rax
movsbl -0xa0(%rbp,%rax,1),%edi
ff
call   1060 <isupper@plt>
cmp    $0x0,%rax
je     1223 <main+0xd3>
movslq -0xc(%rbp),%rax
movsbl -0xa0(%rbp,%rax,1),%eax
ff
sub    $0x41,%eax
cltq
movsbl -0x30(%rbp,%rax,1),%edi
call   1030 <toupper@plt>
mov    %eax,%esi
lea    0xe12(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1247 <main+0xf7>
movslq -0xc(%rbp),%rax
movsbl -0xa0(%rbp,%rax,1),%eax
ff
sub    $0x61,%eax
cltq
movsbl -0x30(%rbp,%rax,1),%esi
lea    0xde9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1293 <main+0x143>
movslq -0xc(%rbp),%rax
movsbl -0xa0(%rbp,%rax,1),%eax
ff
cmp    $0x5f,%eax
jne    1274 <main+0x124>
lea    0xdc4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    128e <main+0x13e>
movslq -0xc(%rbp),%rax
movsbl -0xa0(%rbp,%rax,1),%esi
ff
lea    0xda2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1293 <main+0x143>
jmp    1298 <main+0x148>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11a8 <main+0x58>
lea    0xd81(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x88,%rsp
lea    0xe8c(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe92(%rip),%r15
mov    %rsp,%r14
mov    %r15,%rdi
mov    %r14,%rsi
call   1080 <scanf@plt>
lea    0xe80(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x20(%rsp),%rbx
mov    %r15,%rdi
mov    %rbx,%rsi
call   1080 <scanf@plt>
mov    0x20(%rsp),%al
test   %al,%al
je     1218 <main+0xb8>
mov    $0x20,%ebp
jmp    11dd <main+0x7d>
nopl   (%rax)
cmp    $0x5f,%cl
movzbl %cl,%eax
cmove  %ebp,%eax
movsbl %al,%edi
call   1030 <putchar@plt>
movzbl 0x1(%rbx),%eax
add    $0x1,%rbx
test   %al,%al
je     1218 <main+0xb8>
movsbl %al,%edi
call   1060 <isalpha@plt>
movzbl (%rbx),%ecx
test   %rax,%rax
je     11c0 <main+0x60>
movsbl %cl,%edi
call   1070 <isupper@plt>
movsbq (%rbx),%rcx
test   %rax,%rax
je     1210 <main+0xb0>
movsbl -0x41(%rcx,%r14,1),%edi
call   1040 <toupper@plt>
mov    %eax,%edi
jmp    11cc <main+0x6c>
nopl   (%rax)
movsbl -0x61(%rcx,%r14,1),%edi
jmp    11cc <main+0x6c>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x88,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [20 x i8] c"Enter the language:\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [18 x i8] c"Enter the string:\00"
@.str.3 = [3 x i8] c"%c\00"
@.str.4 = [2 x i8] c" \00"
@.str.5 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca [27 x i8]
%6 = alloca [102 x i8]
store i32 0, i32* %1
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%8 = getelementptr inbounds [27 x i8], [27 x i8]* %5, i64 0, i64 0
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %8)
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
%11 = getelementptr inbounds [102 x i8], [102 x i8]* %6, i64 0, i64 0
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %11)
store i32 0, i32* %3
br label %13
13: ; preds = %77, %0
%14 = load i32, i32* %3
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [102 x i8], [102 x i8]* %6, i64 0, i64 %15
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = icmp ne i32 %18, 0
br i1 %19, label %20, label %80
20: ; preds = %13
%21 = load i32, i32* %3
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [102 x i8], [102 x i8]* %6, i64 0, i64 %22
%24 = load i8, i8* %23
%25 = call i64 @isalpha(i8 signext %24)
%26 = icmp ne i64 %25, 0
br i1 %26, label %27, label %59
27: ; preds = %20
%28 = load i32, i32* %3
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [102 x i8], [102 x i8]* %6, i64 0, i64 %29
%31 = load i8, i8* %30
%32 = call i64 @isupper(i8 signext %31)
%33 = icmp ne i64 %32, 0
br i1 %33, label %34, label %46
34: ; preds = %27
%35 = load i32, i32* %3
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [102 x i8], [102 x i8]* %6, i64 0, i64 %36
%38 = load i8, i8* %37
%39 = sext i8 %38 to i32
%40 = sub nsw i32 %39, 65
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds [27 x i8], [27 x i8]* %5, i64 0, i64 %41
%43 = load i8, i8* %42
%44 = call i32 @toupper(i8 signext %43)
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %44)
br label %58
46: ; preds = %27
%47 = load i32, i32* %3
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds [102 x i8], [102 x i8]* %6, i64 0, i64 %48
%50 = load i8, i8* %49
%51 = sext i8 %50 to i32
%52 = sub nsw i32 %51, 97
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds [27 x i8], [27 x i8]* %5, i64 0, i64 %53
%55 = load i8, i8* %54
%56 = sext i8 %55 to i32
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %56)
br label %58
58: ; preds = %46, %34
br label %76
59: ; preds = %20
%60 = load i32, i32* %3
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds [102 x i8], [102 x i8]* %6, i64 0, i64 %61
%63 = load i8, i8* %62
%64 = sext i8 %63 to i32
%65 = icmp eq i32 %64, 95
br i1 %65, label %66, label %68
66: ; preds = %59
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %75
68: ; preds = %59
%69 = load i32, i32* %3
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds [102 x i8], [102 x i8]* %6, i64 0, i64 %70
%72 = load i8, i8* %71
%73 = sext i8 %72 to i32
%74 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %73)
br label %75
75: ; preds = %68, %66
br label %76
76: ; preds = %75, %58
br label %77
77: ; preds = %76
%78 = load i32, i32* %3
%79 = add nsw i32 %78, 1
store i32 %79, i32* %3
br label %13
80: ; preds = %13
%81 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [20 x i8] c"Enter the language:\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [18 x i8] c"Enter the string:\00"
define i32 @main() {
%1 = alloca [27 x i8]
%2 = alloca [102 x i8]
%3 = getelementptr inbounds [27 x i8], [27 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [102 x i8], [102 x i8]* %2, i64 0, i64 0
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %3)
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%9 = load i8, i8* %4
%10 = icmp eq i8 %9, 0
br i1 %10, label %44, label %11
11: ; preds = %0, %37
%12 = phi i64 [ %40, %37 ], [ 0, %0 ]
%13 = phi i8 [ %42, %37 ], [ %9, %0 ]
%14 = phi i8* [ %41, %37 ], [ %4, %0 ]
%15 = call i64 @isalpha(i8 signext %13)
%16 = icmp eq i64 %15, 0
%17 = load i8, i8* %14
br i1 %16, label %33, label %18
18: ; preds = %11
%19 = call i64 @isupper(i8 signext %17)
%20 = icmp eq i64 %19, 0
%21 = load i8, i8* %14
%22 = sext i8 %21 to i64
br i1 %20, label %28, label %23
23: ; preds = %18
%24 = add nsw i64 %22, -65
%25 = getelementptr inbounds [27 x i8], [27 x i8]* %1, i64 0, i64 %24
%26 = load i8, i8* %25
%27 = call i32 @toupper(i8 signext %26)
br label %37
28: ; preds = %18
%29 = add nsw i64 %22, -97
%30 = getelementptr inbounds [27 x i8], [27 x i8]* %1, i64 0, i64 %29
%31 = load i8, i8* %30
%32 = sext i8 %31 to i32
br label %37
33: ; preds = %11
%34 = icmp eq i8 %17, 95
%35 = select i1 %34, i8 32, i8 %17
%36 = sext i8 %35 to i32
br label %37
37: ; preds = %33, %28, %23
%38 = phi i32 [ %32, %28 ], [ %27, %23 ], [ %36, %33 ]
%39 = call i32 @putchar(i32 %38)
%40 = add nuw i64 %12, 1
%41 = getelementptr inbounds [102 x i8], [102 x i8]* %2, i64 0, i64 %40
%42 = load i8, i8* %41
%43 = icmp eq i8 %42, 0
br i1 %43, label %44, label %11
44: ; preds = %37, %0
%45 = call i32 @putchar(i32 10)
ret i32 0
}