#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 getcha();
char getchar();
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char **argv) {
  int i = 0;
  char d, c = 'h', s[6];
  printf("Enter five secret letters\n");
  s[5] = '\0';
  do {
    d = getcha();
    printf("*");
    s[i++] = d;
  } while (i < 5);
  printf("\nThank you!!\n Now enter one more letter.\n");
  c = getchar();
  printf(
      "You just typed %c,\nbut the last letter of your secret string was %c\n",
      c, d);
  printf("Your secret string was: %s\n", s);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movb   $0x68,-0x16(%rbp)
lea    0xea8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movb   $0x0,-0x17(%rbp)
mov    $0x0,%al
call   1050 <getcha@plt>
mov    %al,-0x15(%rbp)
lea    0xea7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x15(%rbp),%cl
mov    -0x14(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x14(%rbp)
cltq
mov    %cl,-0x1c(%rbp,%rax,1)
cmpl   $0x5,-0x14(%rbp)
jl     1163 <main+0x33>
lea    0xe7d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %al,-0x16(%rbp)
movsbl -0x16(%rbp),%esi
movsbl -0x15(%rbp),%edx
lea    0xe87(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x1c(%rbp),%rsi
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xf05(%rip),%rdi
call   1040 <puts@plt>
movb   $0x0,0xf(%rsp)
xor    %eax,%eax
call   1070 <getcha@plt>
mov    %eax,%ebx
mov    $0x2a,%edi
call   1030 <putchar@plt>
mov    %bl,0xa(%rsp)
xor    %eax,%eax
call   1070 <getcha@plt>
mov    %eax,%ebx
mov    $0x2a,%edi
call   1030 <putchar@plt>
mov    %bl,0xb(%rsp)
xor    %eax,%eax
call   1070 <getcha@plt>
mov    %eax,%ebx
mov    $0x2a,%edi
call   1030 <putchar@plt>
mov    %bl,0xc(%rsp)
xor    %eax,%eax
call   1070 <getcha@plt>
mov    %eax,%ebx
mov    $0x2a,%edi
call   1030 <putchar@plt>
mov    %bl,0xd(%rsp)
xor    %eax,%eax
call   1070 <getcha@plt>
mov    %eax,%ebx
mov    $0x2a,%edi
call   1030 <putchar@plt>
mov    %bl,0xe(%rsp)
lea    0xe9b(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   1060 <getchar@plt>
movsbl %al,%esi
movsbl %bl,%edx
lea    0xe07(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe3e(%rip),%rdi
lea    0xa(%rsp),%rsi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [27 x i8] c"Enter five secret letters\0A\00"
@.str.1 = [2 x i8] c"*\00"
@.str.2 = [42 x i8] c"\0AThank you!!\0A Now enter one more letter.\0A\00"
@.str.3 = [69 x i8] c"You just typed %c,\0Abut the last letter of your secret string was %c\0A\00"
@.str.4 = [28 x i8] c"Your secret string was: %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8
%8 = alloca i8
%9 = alloca [6 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
store i8 104, i8* %8
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%11 = getelementptr inbounds [6 x i8], [6 x i8]* %9, i64 0, i64 5
store i8 0, i8* %11
br label %12
12: ; preds = %20, %2
%13 = call signext i8 (...) @getcha()
store i8 %13, i8* %7
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%15 = load i8, i8* %7
%16 = load i32, i32* %6
%17 = add nsw i32 %16, 1
store i32 %17, i32* %6
%18 = sext i32 %16 to i64
%19 = getelementptr inbounds [6 x i8], [6 x i8]* %9, i64 0, i64 %18
store i8 %15, i8* %19
br label %20
20: ; preds = %12
%21 = load i32, i32* %6
%22 = icmp slt i32 %21, 5
br i1 %22, label %12, label %23
23: ; preds = %20
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0))
%25 = call signext i8 (...) @getchar()
store i8 %25, i8* %8
%26 = load i8, i8* %8
%27 = sext i8 %26 to i32
%28 = load i8, i8* %7
%29 = sext i8 %28 to i32
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str.3, i64 0, i64 0), i32 %27, i32 %29)
%31 = getelementptr inbounds [6 x i8], [6 x i8]* %9, i64 0, i64 0
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0), i8* %31)
ret i32 0
}

LLVM IR (-O2):
@.str.3 = [69 x i8] c"You just typed %c,\0Abut the last letter of your secret string was %c\0A\00"
@.str.4 = [28 x i8] c"Your secret string was: %s\0A\00"
@str = [26 x i8] c"Enter five secret letters\00"
@str.5 = [41 x i8] c"\0AThank you!!\0A Now enter one more letter.\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [6 x i8]
%4 = getelementptr inbounds [6 x i8], [6 x i8]* %3, i64 0, i64 0
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str, i64 0, i64 0))
%6 = getelementptr inbounds [6 x i8], [6 x i8]* %3, i64 0, i64 5
store i8 0, i8* %6
%7 = tail call signext i8 (...) @getcha()
%8 = tail call i32 @putchar(i32 42)
store i8 %7, i8* %4
%9 = tail call signext i8 (...) @getcha()
%10 = tail call i32 @putchar(i32 42)
%11 = getelementptr inbounds [6 x i8], [6 x i8]* %3, i64 0, i64 1
store i8 %9, i8* %11
%12 = tail call signext i8 (...) @getcha()
%13 = tail call i32 @putchar(i32 42)
%14 = getelementptr inbounds [6 x i8], [6 x i8]* %3, i64 0, i64 2
store i8 %12, i8* %14
%15 = tail call signext i8 (...) @getcha()
%16 = tail call i32 @putchar(i32 42)
%17 = getelementptr inbounds [6 x i8], [6 x i8]* %3, i64 0, i64 3
store i8 %15, i8* %17
%18 = tail call signext i8 (...) @getcha()
%19 = tail call i32 @putchar(i32 42)
%20 = getelementptr inbounds [6 x i8], [6 x i8]* %3, i64 0, i64 4
store i8 %18, i8* %20
%21 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str.5, i64 0, i64 0))
%22 = tail call signext i8 (...) @getchar()
%23 = sext i8 %22 to i32
%24 = sext i8 %18 to i32
%25 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([69 x i8], [69 x i8]* @.str.3, i64 0, i64 0), i32 %23, i32 %24)
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0), i8* %4)
ret i32 0
}