#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 */
struct termios {
  int /*<<< orphan*/ c_lflag;
};
typedef int /*<<< orphan*/ buff;

/* Variables and functions */
int /*<<< orphan*/ ECHO;
int /*<<< orphan*/ STDIN_FILENO;
int /*<<< orphan*/ TCSAFLUSH;
int /*<<< orphan*/ crypt(char *, char *);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ sscanf(char *, char *, char *);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
scalar_t__ strcmp(char *, int /*<<< orphan*/);
int /*<<< orphan*/ tcgetattr(int /*<<< orphan*/, struct termios *);
int /*<<< orphan*/ tcsetattr(int /*<<< orphan*/, int /*<<< orphan*/,
                             struct termios *);
short int pass() {
  char buff[20];
  char password[20];
  struct termios attr;
  fflush(stdout);
  tcgetattr(STDIN_FILENO, &attr);
  attr.c_lflag &= ~ECHO;
  tcsetattr(STDIN_FILENO, TCSAFLUSH, &attr);
  fgets(buff, sizeof(buff), stdin);
  sscanf(buff, "%s", password);
  attr.c_lflag |= ECHO;
  tcsetattr(STDIN_FILENO, TCSAFLUSH, &attr);
  printf("\n");
  return (short int)strcmp("pdlELWSmvhs8s", crypt(password, "pdlELWSmvhs8s"));
}


x86 assembly (clang, -O0):
<pass>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    0x2e39(%rip),%rax
mov    (%rax),%edi
call   1070 <fflush@plt>
mov    0x2e23(%rip),%rax
mov    (%rax),%edi
lea    -0x48(%rbp),%rsi
call   1090 <tcgetattr@plt>
mov    0x2e29(%rip),%rax
mov    (%rax),%eax
xor    $0xffffffff,%eax
and    -0x48(%rbp),%eax
mov    %eax,-0x48(%rbp)
mov    0x2dff(%rip),%rax
mov    (%rax),%edi
mov    0x2e1e(%rip),%rax
mov    (%rax),%esi
lea    -0x48(%rbp),%rdx
call   10a0 <tcsetattr@plt>
lea    -0x20(%rbp),%rdi
mov    0x2e00(%rip),%rax
mov    (%rax),%edx
mov    $0x14,%esi
call   1050 <fgets@plt>
lea    -0x20(%rbp),%rdi
lea    -0x40(%rbp),%rdx
lea    0xe05(%rip),%rsi
call   1080 <sscanf@plt>
mov    0x2dd1(%rip),%rax
mov    (%rax),%eax
or     -0x48(%rbp),%eax
mov    %eax,-0x48(%rbp)
mov    0x2daa(%rip),%rax
mov    (%rax),%edi
mov    0x2dc9(%rip),%rax
mov    (%rax),%esi
lea    -0x48(%rbp),%rdx
call   10a0 <tcsetattr@plt>
lea    0xdd2(%rip),%rdi
call   1040 <printf@plt>
lea    -0x40(%rbp),%rdi
lea    0xdc4(%rip),%rsi
call   1030 <crypt@plt>
mov    %eax,%esi
lea    0xdb6(%rip),%rdi
call   1060 <strcmp@plt>
cwtl
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pass>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    0x2e33(%rip),%rax
mov    (%rax),%edi
call   1070 <fflush@plt>
mov    0x2e1d(%rip),%r12
mov    (%r12),%edi
lea    0x8(%rsp),%r14
mov    %r14,%rsi
call   1090 <tcgetattr@plt>
mov    0x2e1d(%rip),%r13
mov    0x0(%r13),%eax
not    %eax
and    %eax,0x8(%rsp)
mov    (%r12),%edi
mov    0x2e18(%rip),%rbp
mov    0x0(%rbp),%esi
mov    %r14,%rdx
call   10a0 <tcsetattr@plt>
mov    0x2dfe(%rip),%rax
mov    (%rax),%edx
lea    0x30(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x14,%esi
call   1050 <fgets@plt>
lea    0xe03(%rip),%rsi
lea    0x10(%rsp),%r15
mov    %rbx,%rdi
mov    %r15,%rdx
call   1080 <sscanf@plt>
mov    0x0(%r13),%eax
or     %eax,0x8(%rsp)
mov    (%r12),%edi
mov    0x0(%rbp),%esi
mov    %r14,%rdx
call   10a0 <tcsetattr@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xdce(%rip),%rbx
mov    %r15,%rdi
mov    %rbx,%rsi
call   1040 <crypt@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1060 <strcmp@plt>
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.termios = type { i32 }
@stdout = global i32 0
@STDIN_FILENO = global i32 0
@ECHO = global i32 0
@TCSAFLUSH = global i32 0
@stdin = global i32 0
@.str = [3 x i8] c"%s\00"
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [14 x i8] c"pdlELWSmvhs8s\00"
define signext i16 @pass() {
%1 = alloca [20 x i8]
%2 = alloca [20 x i8]
%3 = alloca %struct.termios
%4 = load i32, i32* @stdout
%5 = call i32 @fflush(i32 %4)
%6 = load i32, i32* @STDIN_FILENO
%7 = call i32 @tcgetattr(i32 %6, %struct.termios* %3)
%8 = load i32, i32* @ECHO
%9 = xor i32 %8, -1
%10 = getelementptr inbounds %struct.termios, %struct.termios* %3, i32 0, i32 0
%11 = load i32, i32* %10
%12 = and i32 %11, %9
store i32 %12, i32* %10
%13 = load i32, i32* @STDIN_FILENO
%14 = load i32, i32* @TCSAFLUSH
%15 = call i32 @tcsetattr(i32 %13, i32 %14, %struct.termios* %3)
%16 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%17 = load i32, i32* @stdin
%18 = call i32 @fgets(i8* %16, i32 20, i32 %17)
%19 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%20 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%21 = call i32 @sscanf(i8* %19, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %20)
%22 = load i32, i32* @ECHO
%23 = getelementptr inbounds %struct.termios, %struct.termios* %3, i32 0, i32 0
%24 = load i32, i32* %23
%25 = or i32 %24, %22
store i32 %25, i32* %23
%26 = load i32, i32* @STDIN_FILENO
%27 = load i32, i32* @TCSAFLUSH
%28 = call i32 @tcsetattr(i32 %26, i32 %27, %struct.termios* %3)
%29 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%30 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%31 = call i32 @crypt(i8* %30, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
%32 = call i64 @strcmp(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 %31)
%33 = trunc i64 %32 to i16
ret i16 %33
}

LLVM IR (-O2):
%struct.termios = type { i32 }
@stdout = global i32 0
@STDIN_FILENO = global i32 0
@ECHO = global i32 0
@TCSAFLUSH = global i32 0
@stdin = global i32 0
@.str = [3 x i8] c"%s\00"
@.str.2 = [14 x i8] c"pdlELWSmvhs8s\00"
define signext i16 @pass() {
%1 = alloca [20 x i8]
%2 = alloca [20 x i8]
%3 = alloca %struct.termios
%4 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%5 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%6 = bitcast %struct.termios* %3 to i8*
%7 = load i32, i32* @stdout
%8 = tail call i32 @fflush(i32 %7)
%9 = load i32, i32* @STDIN_FILENO
%10 = call i32 @tcgetattr(i32 %9, %struct.termios* %3)
%11 = load i32, i32* @ECHO
%12 = xor i32 %11, -1
%13 = getelementptr inbounds %struct.termios, %struct.termios* %3, i64 0, i32 0
%14 = load i32, i32* %13
%15 = and i32 %14, %12
store i32 %15, i32* %13
%16 = load i32, i32* @STDIN_FILENO
%17 = load i32, i32* @TCSAFLUSH
%18 = call i32 @tcsetattr(i32 %16, i32 %17, %struct.termios* %3)
%19 = load i32, i32* @stdin
%20 = call i32 @fgets(i8* %4, i32 20, i32 %19)
%21 = call i32 @sscanf(i8* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %5)
%22 = load i32, i32* @ECHO
%23 = load i32, i32* %13
%24 = or i32 %23, %22
store i32 %24, i32* %13
%25 = load i32, i32* @STDIN_FILENO
%26 = load i32, i32* @TCSAFLUSH
%27 = call i32 @tcsetattr(i32 %25, i32 %26, %struct.termios* %3)
%28 = call i32 @putchar(i32 10)
%29 = call i32 @crypt(i8* %5, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
%30 = call i64 @strcmp(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 %29)
%31 = trunc i64 %30 to i16
ret i16 %31
}