#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 getchar();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ putchar(char);
char toupper(char);
int main(void) {
  char ch, message[50];
  int i, n;
  printf("Enter message: ");
  for (i = 0; i < 50; i++) {
    if ((ch = getchar()) == '\n') {
      message[i] = ch;
      break;
    }
    (message[i] = toupper(ch));
  }
  printf("In B1FF-speak: ");
  for (i = 0; (ch = message[i]) != '\n'; i++) {
    switch (ch) {
    case 'A':
      ch = '4';
      break;
    case 'B':
      ch = '8';
      break;
    case 'E':
      ch = '3';
      break;
    case 'I':
      ch = '1';
      break;
    case 'O':
      ch = '0';
      break;
    case 'S':
      ch = '5';
      break;
    default:
      break;
    }
    putchar(ch);
  }
  printf("!!!!!!!!\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xef6(%rip),%rdi
call   1050 <printf@plt>
movl   $0x0,-0x44(%rbp)
cmpl   $0x32,-0x44(%rbp)
jge    11b3 <main+0x73>
mov    $0x0,%al
call   1060 <getchar@plt>
mov    %al,-0x5(%rbp)
movsbl %al,%eax
cmp    $0xa,%eax
jne    1192 <main+0x52>
mov    -0x5(%rbp),%cl
movslq -0x44(%rbp),%rax
mov    %cl,-0x40(%rbp,%rax,1)
jmp    11b3 <main+0x73>
movsbl -0x5(%rbp),%edi
call   1040 <toupper@plt>
mov    %al,%cl
movslq -0x44(%rbp),%rax
mov    %cl,-0x40(%rbp,%rax,1)
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    1162 <main+0x22>
lea    0xea2(%rip),%rdi
call   1050 <printf@plt>
movl   $0x0,-0x44(%rbp)
movslq -0x44(%rbp),%rax
mov    -0x40(%rbp,%rax,1),%al
mov    %al,-0x5(%rbp)
movsbl %al,%eax
cmp    $0xa,%eax
je     1259 <main+0x119>
movsbl -0x5(%rbp),%eax
add    $0xffffffbf,%eax
mov    %eax,%ecx
mov    %rcx,-0x50(%rbp)
sub    $0x12,%eax
ja     123d <main+0xfd>
mov    -0x50(%rbp),%rax
lea    0xe02(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movb   $0x34,-0x5(%rbp)
jmp    1242 <main+0x102>
movb   $0x38,-0x5(%rbp)
jmp    1242 <main+0x102>
movb   $0x33,-0x5(%rbp)
jmp    1242 <main+0x102>
movb   $0x31,-0x5(%rbp)
jmp    1242 <main+0x102>
movb   $0x30,-0x5(%rbp)
jmp    1242 <main+0x102>
movb   $0x35,-0x5(%rbp)
jmp    1242 <main+0x102>
jmp    1242 <main+0x102>
movsbl -0x5(%rbp),%edi
call   1030 <putchar@plt>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    11c6 <main+0x86>
lea    0xe0c(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x38,%rsp
lea    0xeee(%rip),%rdi
call   1060 <printf@plt>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
xor    %eax,%eax
call   1070 <getchar@plt>
cmp    $0xa,%al
je     1192 <main+0x42>
movsbl %al,%edi
call   1040 <toupper@plt>
mov    %al,(%rsp,%rbx,1)
add    $0x1,%rbx
cmp    $0x32,%rbx
jne    1170 <main+0x20>
jmp    1196 <main+0x46>
movb   $0xa,(%rsp,%rbx,1)
lea    0xebf(%rip),%rdi
call   1060 <printf@plt>
mov    (%rsp),%al
cmp    $0xa,%al
jne    11bf <main+0x6f>
lea    0xebc(%rip),%rdi
call   1050 <puts@plt>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r14
ret
lea    0x1(%rsp),%rbx
lea    0xe35(%rip),%r14
jmp    11e3 <main+0x93>
mov    $0x35,%al
nop
movsbl %al,%edi
call   1030 <putchar@plt>
movzbl (%rbx),%eax
add    $0x1,%rbx
cmp    $0xa,%al
je     11a9 <main+0x59>
movsbl %al,%ecx
add    $0xffffffbf,%ecx
cmp    $0x12,%ecx
ja     11d0 <main+0x80>
movslq (%r14,%rcx,4),%rcx
add    %r14,%rcx
jmp    *%rcx
mov    $0x34,%al
jmp    11d0 <main+0x80>
mov    $0x38,%al
jmp    11d0 <main+0x80>
mov    $0x33,%al
jmp    11d0 <main+0x80>
mov    $0x31,%al
jmp    11d0 <main+0x80>
mov    $0x30,%al
jmp    11d0 <main+0x80>

LLVM IR (-O0):
@.str = [16 x i8] c"Enter message: \00"
@.str.1 = [16 x i8] c"In B1FF-speak: \00"
@.str.2 = [10 x i8] c"!!!!!!!!\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca [50 x i8]
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %4
br label %7
7: ; preds = %25, %0
%8 = load i32, i32* %4
%9 = icmp slt i32 %8, 50
br i1 %9, label %10, label %28
10: ; preds = %7
%11 = call signext i8 (...) @getchar()
store i8 %11, i8* %2
%12 = sext i8 %11 to i32
%13 = icmp eq i32 %12, 10
br i1 %13, label %14, label %19
14: ; preds = %10
%15 = load i8, i8* %2
%16 = load i32, i32* %4
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 %17
store i8 %15, i8* %18
br label %28
19: ; preds = %10
%20 = load i8, i8* %2
%21 = call signext i8 @toupper(i8 signext %20)
%22 = load i32, i32* %4
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 %23
store i8 %21, i8* %24
br label %25
25: ; preds = %19
%26 = load i32, i32* %4
%27 = add nsw i32 %26, 1
store i32 %27, i32* %4
br label %7
28: ; preds = %14, %7
%29 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %4
br label %30
30: ; preds = %50, %28
%31 = load i32, i32* %4
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 %32
%34 = load i8, i8* %33
store i8 %34, i8* %2
%35 = sext i8 %34 to i32
%36 = icmp ne i32 %35, 10
br i1 %36, label %37, label %53
37: ; preds = %30
%38 = load i8, i8* %2
%39 = sext i8 %38 to i32
switch i32 %39, label %46 [
i32 65, label %40
i32 66, label %41
i32 69, label %42
i32 73, label %43
i32 79, label %44
i32 83, label %45
]
40: ; preds = %37
store i8 52, i8* %2
br label %47
41: ; preds = %37
store i8 56, i8* %2
br label %47
42: ; preds = %37
store i8 51, i8* %2
br label %47
43: ; preds = %37
store i8 49, i8* %2
br label %47
44: ; preds = %37
store i8 48, i8* %2
br label %47
45: ; preds = %37
store i8 53, i8* %2
br label %47
46: ; preds = %37
br label %47
47: ; preds = %46, %45, %44, %43, %42, %41, %40
%48 = load i8, i8* %2
%49 = call i32 @putchar(i8 signext %48)
br label %50
50: ; preds = %47
%51 = load i32, i32* %4
%52 = add nsw i32 %51, 1
store i32 %52, i32* %4
br label %30
53: ; preds = %30
%54 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [16 x i8] c"Enter message: \00"
@.str.1 = [16 x i8] c"In B1FF-speak: \00"
@str = [9 x i8] c"!!!!!!!!\00"
define i32 @main() {
%1 = alloca [50 x i8]
%2 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
br label %4
4: ; preds = %0, %11
%5 = phi i64 [ 0, %0 ], [ %14, %11 ]
%6 = tail call signext i8 (...) @getchar()
%7 = icmp eq i8 %6, 10
br i1 %7, label %8, label %11
8: ; preds = %4
%9 = and i64 %5, 4294967295
%10 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 %9
store i8 10, i8* %10
br label %16
11: ; preds = %4
%12 = tail call signext i8 @toupper(i8 signext %6)
%13 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 %5
store i8 %12, i8* %13
%14 = add nuw nsw i64 %5, 1
%15 = icmp eq i64 %14, 50
br i1 %15, label %16, label %4
16: ; preds = %11, %8
%17 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
%18 = load i8, i8* %2
%19 = icmp eq i8 %18, 10
br i1 %19, label %37, label %20
20: ; preds = %16, %30
%21 = phi i64 [ %33, %30 ], [ 0, %16 ]
%22 = phi i8 [ %35, %30 ], [ %18, %16 ]
%23 = sext i8 %22 to i32
switch i32 %23, label %30 [
i32 65, label %24
i32 66, label %25
i32 69, label %26
i32 73, label %27
i32 79, label %28
i32 83, label %29
]
24: ; preds = %20
br label %30
25: ; preds = %20
br label %30
26: ; preds = %20
br label %30
27: ; preds = %20
br label %30
28: ; preds = %20
br label %30
29: ; preds = %20
br label %30
30: ; preds = %20, %29, %28, %27, %26, %25, %24
%31 = phi i8 [ %22, %20 ], [ 53, %29 ], [ 48, %28 ], [ 49, %27 ], [ 51, %26 ], [ 56, %25 ], [ 52, %24 ]
%32 = tail call i32 @putchar(i8 signext %31)
%33 = add nuw i64 %21, 1
%34 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 %33
%35 = load i8, i8* %34
%36 = icmp eq i8 %35, 10
br i1 %36, label %37, label %20
37: ; preds = %30, %16
%38 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str, i64 0, i64 0))
ret i32 0
}