#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 getch();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ putch(char);
int /*<<< orphan*/ puts(char *);
int main() {
  char password[25], ch;
  int i;
  printf("\033[H\033[J");
  puts("Enter password : ");
  while (1) {
    if (i < 0) {
      i = 0;
    }
    ch = getch();
    if (ch == 13)
      break;
    if (ch == 8) {
      printf("b");
      printf(NULL);
      printf("b");
      i--;
      continue;
    }
    password[i++] = ch;
    ch = '*';
    putch(ch);
  }
  password[i] = '\0';
  printf("\nPassword Entered : %s", password);
  getch();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xea3(%rip),%rdi
call   1030 <puts@plt>
cmpl   $0x0,-0x28(%rbp)
jge    117a <main+0x3a>
movl   $0x0,-0x28(%rbp)
mov    $0x0,%al
call   1050 <getch@plt>
mov    %al,-0x21(%rbp)
movsbl -0x21(%rbp),%eax
cmp    $0xd,%eax
jne    1196 <main+0x56>
jmp    11fe <main+0xbe>
movsbl -0x21(%rbp),%eax
cmp    $0x8,%eax
jne    11d8 <main+0x98>
lea    0xe6f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe56(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x28(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x28(%rbp)
jmp    1169 <main+0x29>
mov    -0x21(%rbp),%cl
mov    -0x28(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x28(%rbp)
cltq
mov    %cl,-0x20(%rbp,%rax,1)
movb   $0x2a,-0x21(%rbp)
movsbl -0x21(%rbp),%edi
call   1060 <putch@plt>
jmp    1169 <main+0x29>
movslq -0x28(%rbp),%rax
movb   $0x0,-0x20(%rbp,%rax,1)
lea    -0x20(%rbp),%rsi
lea    0xe09(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1050 <getch@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x28,%rsp
lea    0xea3(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe9a(%rip),%rdi
call   1040 <puts@plt>
jmp    11a0 <main+0x50>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    $0x62,%edi
call   1030 <putchar@plt>
xor    %edi,%edi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x62,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebp
test   %ebp,%ebp
cmovs  %ebx,%ebp
xor    %eax,%eax
call   1060 <getch@plt>
cmp    $0x8,%al
je     1180 <main+0x30>
mov    %ebp,%ecx
cmp    $0xd,%al
je     11c8 <main+0x78>
add    $0x1,%ebp
mov    %al,(%rsp,%rcx,1)
mov    $0x2a,%edi
call   1070 <putch@plt>
jmp    11a0 <main+0x50>
movb   $0x0,(%rsp,%rcx,1)
lea    0xe46(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1060 <getch@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"\1B[H\1B[J\00"
@.str.1 = [18 x i8] c"Enter password : \00"
@.str.2 = [2 x i8] c"b\00"
@.str.3 = [23 x i8] c"\0APassword Entered : %s\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [25 x i8]
%3 = alloca i8
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @puts(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
br label %7
7: ; preds = %0, %21, %27
%8 = load i32, i32* %4
%9 = icmp slt i32 %8, 0
br i1 %9, label %10, label %11
10: ; preds = %7
store i32 0, i32* %4
br label %11
11: ; preds = %10, %7
%12 = call signext i8 (...) @getch()
store i8 %12, i8* %3
%13 = load i8, i8* %3
%14 = sext i8 %13 to i32
%15 = icmp eq i32 %14, 13
br i1 %15, label %16, label %17
16: ; preds = %11
br label %35
17: ; preds = %11
%18 = load i8, i8* %3
%19 = sext i8 %18 to i32
%20 = icmp eq i32 %19, 8
br i1 %20, label %21, label %27
21: ; preds = %17
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%23 = call i32 (i8*, ...) @printf(i8* null)
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%25 = load i32, i32* %4
%26 = add nsw i32 %25, -1
store i32 %26, i32* %4
br label %7
27: ; preds = %17
%28 = load i8, i8* %3
%29 = load i32, i32* %4
%30 = add nsw i32 %29, 1
store i32 %30, i32* %4
%31 = sext i32 %29 to i64
%32 = getelementptr inbounds [25 x i8], [25 x i8]* %2, i64 0, i64 %31
store i8 %28, i8* %32
store i8 42, i8* %3
%33 = load i8, i8* %3
%34 = call i32 @putch(i8 signext %33)
br label %7
35: ; preds = %16
%36 = load i32, i32* %4
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [25 x i8], [25 x i8]* %2, i64 0, i64 %37
store i8 0, i8* %38
%39 = getelementptr inbounds [25 x i8], [25 x i8]* %2, i64 0, i64 0
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i8* %39)
%41 = call signext i8 (...) @getch()
ret i32 0
}

LLVM IR (-O2):
@.str = [7 x i8] c"\1B[H\1B[J\00"
@.str.1 = [18 x i8] c"Enter password : \00"
@.str.3 = [23 x i8] c"\0APassword Entered : %s\00"
define i32 @main() {
%1 = alloca [25 x i8]
%2 = getelementptr inbounds [25 x i8], [25 x i8]* %1, i64 0, i64 0
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
br label %5
5: ; preds = %15, %0
%6 = phi i32 [ undef, %0 ], [ %16, %15 ]
%7 = icmp sgt i32 %6, 0
%8 = select i1 %7, i32 %6, i32 0
%9 = tail call signext i8 (...) @getch()
switch i8 %9, label %17 [
i8 13, label %22
i8 8, label %10
]
10: ; preds = %5
%11 = tail call i32 @putchar(i32 98)
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) null)
%13 = tail call i32 @putchar(i32 98)
%14 = add nsw i32 %8, -1
br label %15
15: ; preds = %10, %17
%16 = phi i32 [ %14, %10 ], [ %18, %17 ]
br label %5
17: ; preds = %5
%18 = add nuw nsw i32 %8, 1
%19 = zext i32 %8 to i64
%20 = getelementptr inbounds [25 x i8], [25 x i8]* %1, i64 0, i64 %19
store i8 %9, i8* %20
%21 = tail call i32 @putch(i8 signext 42)
br label %15
22: ; preds = %5
%23 = zext i32 %8 to i64
%24 = getelementptr inbounds [25 x i8], [25 x i8]* %1, i64 0, i64 %23
store i8 0, i8* %24
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i8* %2)
%26 = call signext i8 (...) @getch()
ret i32 0
}