#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 *, ...);
scalar_t__ strcmp(char *, char *);
int password(char *pass) {
  int i = 0;
  char ent_password[50];
  char c;
  while (1) {
    c = getch();
    if (c == '\n') {
      break;
    }
    ent_password[i++] = c;
    c = '*';
    printf("%c", c);
  }
  ent_password[i] = '\0';
  if (strcmp(ent_password, pass) == 0) {
    return 1;
  } else {
    printf("\nWrong Password\n");
    getch();
    return 0;
  }
}


x86 assembly (clang, -O0):
<password>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    $0x0,%al
call   1050 <getch@plt>
mov    %al,-0x51(%rbp)
movsbl -0x51(%rbp),%eax
cmp    $0xa,%eax
jne    115f <password+0x2f>
jmp    118e <password+0x5e>
mov    -0x51(%rbp),%cl
mov    -0x14(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x14(%rbp)
cltq
mov    %cl,-0x50(%rbp,%rax,1)
movb   $0x2a,-0x51(%rbp)
movsbl -0x51(%rbp),%esi
lea    0xe7e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1143 <password+0x13>
movslq -0x14(%rbp),%rax
movb   $0x0,-0x50(%rbp,%rax,1)
lea    -0x50(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11ba <password+0x8a>
movl   $0x1,-0x4(%rbp)
jmp    11d6 <password+0xa6>
lea    0xe42(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1050 <getch@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<password>:
push   %r14
push   %rbx
sub    $0x38,%rsp
mov    %rdi,%r14
xor    %ebx,%ebx
xor    %eax,%eax
call   1060 <getch@plt>
cmp    $0xa,%al
je     117e <password+0x3e>
xor    %ebx,%ebx
nopl   0x0(%rax)
mov    %al,(%rsp,%rbx,1)
add    $0x1,%rbx
mov    $0x2a,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
call   1060 <getch@plt>
cmp    $0xa,%al
jne    1160 <password+0x20>
mov    %ebx,%ebx
movb   $0x0,(%rsp,%rbx,1)
mov    %rsp,%rdi
mov    %r14,%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     11a9 <password+0x69>
lea    0xe67(%rip),%rdi
call   1040 <puts@plt>
xor    %ebx,%ebx
xor    %eax,%eax
call   1060 <getch@plt>
jmp    11ae <password+0x6e>
mov    $0x1,%ebx
mov    %ebx,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%c\00"
@.str.1 = [17 x i8] c"\0AWrong Password\0A\00"
define i32 @password(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca [50 x i8]
%6 = alloca i8
store i8* %0, i8** %3
store i32 0, i32* %4
br label %7
7: ; preds = %1, %13
%8 = call signext i8 (...) @getch()
store i8 %8, i8* %6
%9 = load i8, i8* %6
%10 = sext i8 %9 to i32
%11 = icmp eq i32 %10, 10
br i1 %11, label %12, label %13
12: ; preds = %7
br label %22
13: ; preds = %7
%14 = load i8, i8* %6
%15 = load i32, i32* %4
%16 = add nsw i32 %15, 1
store i32 %16, i32* %4
%17 = sext i32 %15 to i64
%18 = getelementptr inbounds [50 x i8], [50 x i8]* %5, i64 0, i64 %17
store i8 %14, i8* %18
store i8 42, i8* %6
%19 = load i8, i8* %6
%20 = sext i8 %19 to i32
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %20)
br label %7
22: ; preds = %12
%23 = load i32, i32* %4
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [50 x i8], [50 x i8]* %5, i64 0, i64 %24
store i8 0, i8* %25
%26 = getelementptr inbounds [50 x i8], [50 x i8]* %5, i64 0, i64 0
%27 = load i8*, i8** %3
%28 = call i64 @strcmp(i8* %26, i8* %27)
%29 = icmp eq i64 %28, 0
br i1 %29, label %30, label %31
30: ; preds = %22
store i32 1, i32* %2
br label %34
31: ; preds = %22
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%33 = call signext i8 (...) @getch()
store i32 0, i32* %2
br label %34
34: ; preds = %31, %30
%35 = load i32, i32* %2
ret i32 %35
}

LLVM IR (-O2):
@str = [16 x i8] c"\0AWrong Password\00"
define i32 @password(i8* %0) {
%2 = alloca [50 x i8]
%3 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%4 = tail call signext i8 (...) @getch()
%5 = icmp eq i8 %4, 10
br i1 %5, label %16, label %6
6: ; preds = %1, %6
%7 = phi i64 [ %9, %6 ], [ 0, %1 ]
%8 = phi i8 [ %12, %6 ], [ %4, %1 ]
%9 = add nuw i64 %7, 1
%10 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 %7
store i8 %8, i8* %10
%11 = tail call i32 @putchar(i32 42)
%12 = tail call signext i8 (...) @getch()
%13 = icmp eq i8 %12, 10
br i1 %13, label %14, label %6
14: ; preds = %6
%15 = and i64 %9, 4294967295
br label %16
16: ; preds = %14, %1
%17 = phi i64 [ 0, %1 ], [ %15, %14 ]
%18 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 %17
store i8 0, i8* %18
%19 = call i64 @strcmp(i8* %3, i8* %0)
%20 = icmp eq i64 %19, 0
br i1 %20, label %24, label %21
21: ; preds = %16
%22 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str, i64 0, i64 0))
%23 = call signext i8 (...) @getch()
br label %24
24: ; preds = %16, %21
%25 = phi i32 [ 0, %21 ], [ 1, %16 ]
ret i32 %25
}