#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__ ELFHash(char *);
int /*<<< orphan*/ clear_type();
char getch();
int /*<<< orphan*/ printf(char *);
scalar_t__ rw_option(char, int /*<<< orphan*/, int /*<<< orphan*/);
void check_load() {
  int i = 0;
  char a[200] = {0};
  char b;
  printf("please input the password : ");
  while ((b = getch()) == '\r')
    ;
  while (b != '\r') {
    if (b != 127) {
      printf("*");
      a[i] = b;
      i++;
    } else if (i >= 0) {
      a[i] = 0;
      if (i > 0) {
        i--;
        printf("\b \b");
      }
    }
    b = getch();
    a[i] = 0;
  }
  while (ELFHash(a) != rw_option('r', 0, 0)) {
    clear_type();
    printf("error : please input the password : ");
    i = 0;
    while ((b = getch()) == '\r')
      ;
    while (b != '\r') {
      if (b != 127) {
        printf("*");
        a[i] = b;
        i++;
      } else if (i >= 0) {
        a[i] = 0;
        if (i > 0) {
          i--;
          printf("\b \b");
        }
      }
      b = getch();
    }
    a[i] = 0;
  }
  clear_type();
}


x86 assembly (clang, -O0):
<check_load>:
push   %rbp
mov    %rsp,%rbp
sub    $0xe0,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0xd0(%rbp),%rdi
xor    %esi,%esi
mov    $0xc8,%edx
call   1050 <memset@plt>
lea    0xe82(%rip),%rdi
call   1030 <printf@plt>
mov    $0x0,%al
call   1070 <getch@plt>
mov    %al,-0xd1(%rbp)
movsbl %al,%eax
cmp    $0xd,%eax
jne    11af <check_load+0x4f>
jmp    1191 <check_load+0x31>
jmp    11b4 <check_load+0x54>
movsbl -0xd1(%rbp),%eax
cmp    $0xd,%eax
je     125c <check_load+0xfc>
movsbl -0xd1(%rbp),%eax
cmp    $0x7f,%eax
je     11ff <check_load+0x9f>
lea    0xe25(%rip),%rdi
call   1030 <printf@plt>
mov    -0xd1(%rbp),%cl
movslq -0x4(%rbp),%rax
mov    %cl,-0xd0(%rbp,%rax,1)
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    123e <check_load+0xde>
cmpl   $0x0,-0x4(%rbp)
jl     1239 <check_load+0xd9>
movslq -0x4(%rbp),%rax
movb   $0x0,-0xd0(%rbp,%rax,1)
cmpl   $0x0,-0x4(%rbp)
jle    1234 <check_load+0xd4>
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x4(%rbp)
lea    0xdd3(%rip),%rdi
call   1030 <printf@plt>
jmp    1239 <check_load+0xd9>
jmp    123e <check_load+0xde>
mov    $0x0,%al
call   1070 <getch@plt>
mov    %al,-0xd1(%rbp)
movslq -0x4(%rbp),%rax
movb   $0x0,-0xd0(%rbp,%rax,1)
jmp    11b4 <check_load+0x54>
jmp    1261 <check_load+0x101>
lea    -0xd0(%rbp),%rdi
call   1060 <ELFHash@plt>
mov    %rax,-0xe0(%rbp)
mov    $0x72,%edi
xor    %edx,%edx
mov    %edx,%esi
call   1080 <rw_option@plt>
mov    %rax,%rcx
mov    -0xe0(%rbp),%rax
cmp    %rcx,%rax
je     137f <check_load+0x21f>
mov    $0x0,%al
call   1040 <clear_type@plt>
lea    0xd63(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1070 <getch@plt>
mov    %al,-0xd1(%rbp)
movsbl %al,%eax
cmp    $0xd,%eax
jne    12cd <check_load+0x16d>
jmp    12af <check_load+0x14f>
jmp    12d2 <check_load+0x172>
movsbl -0xd1(%rbp),%eax
cmp    $0xd,%eax
je     136e <check_load+0x20e>
movsbl -0xd1(%rbp),%eax
cmp    $0x7f,%eax
je     131d <check_load+0x1bd>
lea    0xd07(%rip),%rdi
call   1030 <printf@plt>
mov    -0xd1(%rbp),%cl
movslq -0x4(%rbp),%rax
mov    %cl,-0xd0(%rbp,%rax,1)
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    135c <check_load+0x1fc>
cmpl   $0x0,-0x4(%rbp)
jl     1357 <check_load+0x1f7>
movslq -0x4(%rbp),%rax
movb   $0x0,-0xd0(%rbp,%rax,1)
cmpl   $0x0,-0x4(%rbp)
jle    1352 <check_load+0x1f2>
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x4(%rbp)
lea    0xcb5(%rip),%rdi
call   1030 <printf@plt>
jmp    1357 <check_load+0x1f7>
jmp    135c <check_load+0x1fc>
mov    $0x0,%al
call   1070 <getch@plt>
mov    %al,-0xd1(%rbp)
jmp    12d2 <check_load+0x172>
movslq -0x4(%rbp),%rax
movb   $0x0,-0xd0(%rbp,%rax,1)
jmp    1261 <check_load+0x101>
mov    $0x0,%al
call   1040 <clear_type@plt>
add    $0xe0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_load>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0xd0,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0xb0(%rsp)
movaps %xmm0,0xa0(%rsp)
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
movq   $0x0,0xc0(%rsp)
lea    0xe40(%rip),%rdi
call   1040 <printf@plt>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1070 <getch@plt>
cmp    $0xd,%al
je     11e0 <check_load+0x80>
mov    %eax,%ebx
lea    0xe0c(%rip),%r14
xor    %ebp,%ebp
jmp    1220 <check_load+0xc0>
add    $0xffffffff,%ebp
mov    %r14,%rdi
call   1040 <printf@plt>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %eax,%eax
call   1070 <getch@plt>
mov    %eax,%ebx
movslq %ebp,%rax
movb   $0x0,(%rsp,%rax,1)
cmp    $0x7f,%bl
je     1240 <check_load+0xe0>
cmp    $0xd,%bl
je     1250 <check_load+0xf0>
mov    $0x2a,%edi
call   1030 <putchar@plt>
movslq %ebp,%rax
mov    %bl,(%rsp,%rax,1)
add    $0x1,%ebp
jmp    1210 <check_load+0xb0>
nop
test   %ebp,%ebp
js     1210 <check_load+0xb0>
mov    %ebp,%eax
movb   $0x0,(%rsp,%rax,1)
jne    11f8 <check_load+0x98>
xor    %ebp,%ebp
jmp    1210 <check_load+0xb0>
mov    %rsp,%rdi
call   1060 <ELFHash@plt>
mov    %rax,%rbx
mov    $0x72,%edi
xor    %esi,%esi
xor    %edx,%edx
call   1080 <rw_option@plt>
cmp    %rax,%rbx
jne    1285 <check_load+0x125>
xor    %eax,%eax
call   1050 <clear_type@plt>
add    $0xd0,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xd78(%rip),%r14
lea    0xd6d(%rip),%r12
mov    %rsp,%r15
jmp    12c5 <check_load+0x165>
nopl   0x0(%rax,%rax,1)
movslq %ebp,%rax
movb   $0x0,(%rsp,%rax,1)
mov    %r15,%rdi
call   1060 <ELFHash@plt>
mov    %rax,%rbx
mov    $0x72,%edi
xor    %esi,%esi
xor    %edx,%edx
call   1080 <rw_option@plt>
cmp    %rax,%rbx
je     126e <check_load+0x10e>
xor    %eax,%eax
call   1050 <clear_type@plt>
mov    %r14,%rdi
call   1040 <printf@plt>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
xor    %eax,%eax
call   1070 <getch@plt>
cmp    $0xd,%al
je     12e0 <check_load+0x180>
mov    %eax,%ebx
xor    %ebp,%ebp
jmp    1309 <check_load+0x1a9>
add    $0xffffffff,%ebp
mov    %r12,%rdi
call   1040 <printf@plt>
nopl   0x0(%rax)
xor    %eax,%eax
call   1070 <getch@plt>
mov    %eax,%ebx
cmp    $0x7f,%bl
je     1330 <check_load+0x1d0>
cmp    $0xd,%bl
je     12a0 <check_load+0x140>
mov    $0x2a,%edi
call   1030 <putchar@plt>
movslq %ebp,%rax
mov    %bl,(%rsp,%rax,1)
add    $0x1,%ebp
jmp    1300 <check_load+0x1a0>
nopl   0x0(%rax,%rax,1)
test   %ebp,%ebp
js     1300 <check_load+0x1a0>
mov    %ebp,%eax
movb   $0x0,(%rsp,%rax,1)
jne    12f1 <check_load+0x191>
xor    %ebp,%ebp
jmp    1300 <check_load+0x1a0>

LLVM IR (-O0):
@.str = [29 x i8] c"please input the password : \00"
@.str.1 = [2 x i8] c"*\00"
@.str.2 = [4 x i8] c"\08 \08\00"
@.str.3 = [37 x i8] c"error : please input the password : \00"
define void @check_load() {
%1 = alloca i32
%2 = alloca [200 x i8]
%3 = alloca i8
store i32 0, i32* %1
%4 = bitcast [200 x i8]* %2 to i8*
%5 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
br label %6
6: ; preds = %10, %0
%7 = call signext i8 (...) @getch()
store i8 %7, i8* %3
%8 = sext i8 %7 to i32
%9 = icmp eq i32 %8, 13
br i1 %9, label %10, label %11
10: ; preds = %6
br label %6
11: ; preds = %6
br label %12
12: ; preds = %43, %11
%13 = load i8, i8* %3
%14 = sext i8 %13 to i32
%15 = icmp ne i32 %14, 13
br i1 %15, label %16, label %48
16: ; preds = %12
%17 = load i8, i8* %3
%18 = sext i8 %17 to i32
%19 = icmp ne i32 %18, 127
br i1 %19, label %20, label %28
20: ; preds = %16
%21 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%22 = load i8, i8* %3
%23 = load i32, i32* %1
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [200 x i8], [200 x i8]* %2, i64 0, i64 %24
store i8 %22, i8* %25
%26 = load i32, i32* %1
%27 = add nsw i32 %26, 1
store i32 %27, i32* %1
br label %43
28: ; preds = %16
%29 = load i32, i32* %1
%30 = icmp sge i32 %29, 0
br i1 %30, label %31, label %42
31: ; preds = %28
%32 = load i32, i32* %1
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [200 x i8], [200 x i8]* %2, i64 0, i64 %33
store i8 0, i8* %34
%35 = load i32, i32* %1
%36 = icmp sgt i32 %35, 0
br i1 %36, label %37, label %41
37: ; preds = %31
%38 = load i32, i32* %1
%39 = add nsw i32 %38, -1
store i32 %39, i32* %1
%40 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
br label %41
41: ; preds = %37, %31
br label %42
42: ; preds = %41, %28
br label %43
43: ; preds = %42, %20
%44 = call signext i8 (...) @getch()
store i8 %44, i8* %3
%45 = load i32, i32* %1
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds [200 x i8], [200 x i8]* %2, i64 0, i64 %46
store i8 0, i8* %47
br label %12
48: ; preds = %12
br label %49
49: ; preds = %96, %48
%50 = getelementptr inbounds [200 x i8], [200 x i8]* %2, i64 0, i64 0
%51 = call i64 @ELFHash(i8* %50)
%52 = call i64 @rw_option(i8 signext 114, i32 0, i32 0)
%53 = icmp ne i64 %51, %52
br i1 %53, label %54, label %100
54: ; preds = %49
%55 = call i32 (...) @clear_type()
%56 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %1
br label %57
57: ; preds = %61, %54
%58 = call signext i8 (...) @getch()
store i8 %58, i8* %3
%59 = sext i8 %58 to i32
%60 = icmp eq i32 %59, 13
br i1 %60, label %61, label %62
61: ; preds = %57
br label %57
62: ; preds = %57
br label %63
63: ; preds = %94, %62
%64 = load i8, i8* %3
%65 = sext i8 %64 to i32
%66 = icmp ne i32 %65, 13
br i1 %66, label %67, label %96
67: ; preds = %63
%68 = load i8, i8* %3
%69 = sext i8 %68 to i32
%70 = icmp ne i32 %69, 127
br i1 %70, label %71, label %79
71: ; preds = %67
%72 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%73 = load i8, i8* %3
%74 = load i32, i32* %1
%75 = sext i32 %74 to i64
%76 = getelementptr inbounds [200 x i8], [200 x i8]* %2, i64 0, i64 %75
store i8 %73, i8* %76
%77 = load i32, i32* %1
%78 = add nsw i32 %77, 1
store i32 %78, i32* %1
br label %94
79: ; preds = %67
%80 = load i32, i32* %1
%81 = icmp sge i32 %80, 0
br i1 %81, label %82, label %93
82: ; preds = %79
%83 = load i32, i32* %1
%84 = sext i32 %83 to i64
%85 = getelementptr inbounds [200 x i8], [200 x i8]* %2, i64 0, i64 %84
store i8 0, i8* %85
%86 = load i32, i32* %1
%87 = icmp sgt i32 %86, 0
br i1 %87, label %88, label %92
88: ; preds = %82
%89 = load i32, i32* %1
%90 = add nsw i32 %89, -1
store i32 %90, i32* %1
%91 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
br label %92
92: ; preds = %88, %82
br label %93
93: ; preds = %92, %79
br label %94
94: ; preds = %93, %71
%95 = call signext i8 (...) @getch()
store i8 %95, i8* %3
br label %63
96: ; preds = %63
%97 = load i32, i32* %1
%98 = sext i32 %97 to i64
%99 = getelementptr inbounds [200 x i8], [200 x i8]* %2, i64 0, i64 %98
store i8 0, i8* %99
br label %49
100: ; preds = %49
%101 = call i32 (...) @clear_type()
ret void
}

LLVM IR (-O2):
@.str = [29 x i8] c"please input the password : \00"
@.str.2 = [4 x i8] c"\08 \08\00"
@.str.3 = [37 x i8] c"error : please input the password : \00"
define void @check_load() {
%1 = alloca [200 x i8]
%2 = getelementptr inbounds [200 x i8], [200 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
br label %4
4: ; preds = %4, %0
%5 = tail call signext i8 (...) @getch()
%6 = icmp eq i8 %5, 13
br i1 %6, label %4, label %7
7: ; preds = %4, %28
%8 = phi i32 [ %29, %28 ], [ 0, %4 ]
%9 = phi i8 [ %30, %28 ], [ %5, %4 ]
switch i8 %9, label %14 [
i8 13, label %10
i8 127, label %19
]
10: ; preds = %7
%11 = call i64 @ELFHash(i8* %2)
%12 = call i64 @rw_option(i8 signext 114, i32 0, i32 0)
%13 = icmp eq i64 %11, %12
br i1 %13, label %65, label %33
14: ; preds = %7
%15 = tail call i32 @putchar(i32 42)
%16 = sext i32 %8 to i64
%17 = getelementptr inbounds [200 x i8], [200 x i8]* %1, i64 0, i64 %16
store i8 %9, i8* %17
%18 = add nsw i32 %8, 1
br label %28
19: ; preds = %7
%20 = icmp sgt i32 %8, -1
br i1 %20, label %21, label %28
21: ; preds = %19
%22 = zext i32 %8 to i64
%23 = getelementptr inbounds [200 x i8], [200 x i8]* %1, i64 0, i64 %22
store i8 0, i8* %23
%24 = icmp eq i32 %8, 0
br i1 %24, label %28, label %25
25: ; preds = %21
%26 = add nsw i32 %8, -1
%27 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
br label %28
28: ; preds = %19, %25, %21, %14
%29 = phi i32 [ %18, %14 ], [ %26, %25 ], [ 0, %21 ], [ %8, %19 ]
%30 = tail call signext i8 (...) @getch()
%31 = sext i32 %29 to i64
%32 = getelementptr inbounds [200 x i8], [200 x i8]* %1, i64 0, i64 %31
store i8 0, i8* %32
br label %7
33: ; preds = %10, %59
%34 = call i32 (...) @clear_type()
%35 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0))
br label %36
36: ; preds = %36, %33
%37 = call signext i8 (...) @getch()
%38 = icmp eq i8 %37, 13
br i1 %38, label %36, label %39
39: ; preds = %36, %56
%40 = phi i32 [ %57, %56 ], [ 0, %36 ]
%41 = phi i8 [ %58, %56 ], [ %37, %36 ]
switch i8 %41, label %42 [
i8 13, label %59
i8 127, label %47
]
42: ; preds = %39
%43 = call i32 @putchar(i32 42)
%44 = sext i32 %40 to i64
%45 = getelementptr inbounds [200 x i8], [200 x i8]* %1, i64 0, i64 %44
store i8 %41, i8* %45
%46 = add nsw i32 %40, 1
br label %56
47: ; preds = %39
%48 = icmp sgt i32 %40, -1
br i1 %48, label %49, label %56
49: ; preds = %47
%50 = zext i32 %40 to i64
%51 = getelementptr inbounds [200 x i8], [200 x i8]* %1, i64 0, i64 %50
store i8 0, i8* %51
%52 = icmp eq i32 %40, 0
br i1 %52, label %56, label %53
53: ; preds = %49
%54 = add nsw i32 %40, -1
%55 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
br label %56
56: ; preds = %47, %53, %49, %42
%57 = phi i32 [ %46, %42 ], [ %54, %53 ], [ 0, %49 ], [ %40, %47 ]
%58 = call signext i8 (...) @getch()
br label %39
59: ; preds = %39
%60 = sext i32 %40 to i64
%61 = getelementptr inbounds [200 x i8], [200 x i8]* %1, i64 0, i64 %60
store i8 0, i8* %61
%62 = call i64 @ELFHash(i8* %2)
%63 = call i64 @rw_option(i8 signext 114, i32 0, i32 0)
%64 = icmp eq i64 %62, %63
br i1 %64, label %65, label %33
65: ; preds = %59, %10
%66 = call i32 (...) @clear_type()
ret void
}