#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 */
int /*<<< orphan*/ WRITE(int, char *, int);
char *get_string(int);
int sockprint(int, char *);
scalar_t__ strcmp(char *, char *);
int verify_password(int client_fd, char *password) {
  char *entered;
  char dont_auth[] = {0xff, 0xf4, 0x25};
  char suppress_goahead[] = {0xff, 0xfb, 0x03};
  char dont_linemode[] = {0xff, 0xfe, 0x22};
  char dont_new_env[] = {0xff, 0xfe, 0x27};
  char will_echo[] = {0xff, 0xfb, 0x01};
  char dont_echo[] = {0xff, 0xfe, 0x01};
  char noecho[] = {0xff, 0xfd, 0x2d};
  WRITE(client_fd, suppress_goahead, sizeof suppress_goahead);
  WRITE(client_fd, dont_linemode, sizeof dont_linemode);
  WRITE(client_fd, dont_new_env, sizeof dont_new_env);
  WRITE(client_fd, will_echo, sizeof will_echo);
  WRITE(client_fd, dont_echo, sizeof dont_echo);
  if (sockprint(client_fd, "Password: ") == -1)
    return -1;
  entered = get_string(client_fd);
  if (!entered)
    return -1;
  if (strcmp(password, entered) == 0)
    return 0;
  sockprint(client_fd, "Invalid password");
  return -1;
}


x86 assembly (clang, -O0):
<verify_password>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0xeaa(%rip),%ax
mov    %ax,-0x1b(%rbp)
mov    0xea2(%rip),%al
mov    %al,-0x19(%rbp)
mov    0xe99(%rip),%ax
mov    %ax,-0x1e(%rbp)
mov    0xe91(%rip),%al
mov    %al,-0x1c(%rbp)
mov    0xe88(%rip),%ax
mov    %ax,-0x21(%rbp)
mov    0xe80(%rip),%al
mov    %al,-0x1f(%rbp)
mov    0xe77(%rip),%ax
mov    %ax,-0x24(%rbp)
mov    0xe6f(%rip),%al
mov    %al,-0x22(%rbp)
mov    0xe66(%rip),%ax
mov    %ax,-0x27(%rbp)
mov    0xe5e(%rip),%al
mov    %al,-0x25(%rbp)
mov    0xe55(%rip),%ax
mov    %ax,-0x2a(%rbp)
mov    0xe4d(%rip),%al
mov    %al,-0x28(%rbp)
mov    0xe44(%rip),%ax
mov    %ax,-0x2d(%rbp)
mov    0xe3c(%rip),%al
mov    %al,-0x2b(%rbp)
mov    -0x8(%rbp),%edi
lea    -0x1e(%rbp),%rsi
mov    $0x3,%edx
call   1060 <WRITE@plt>
mov    -0x8(%rbp),%edi
lea    -0x21(%rbp),%rsi
mov    $0x3,%edx
call   1060 <WRITE@plt>
mov    -0x8(%rbp),%edi
lea    -0x24(%rbp),%rsi
mov    $0x3,%edx
call   1060 <WRITE@plt>
mov    -0x8(%rbp),%edi
lea    -0x27(%rbp),%rsi
mov    $0x3,%edx
call   1060 <WRITE@plt>
mov    -0x8(%rbp),%edi
lea    -0x2a(%rbp),%rsi
mov    $0x3,%edx
call   1060 <WRITE@plt>
mov    -0x8(%rbp),%edi
lea    0xddb(%rip),%rsi
call   1050 <sockprint@plt>
cmp    $0xffffffff,%eax
jne    1254 <verify_password+0x114>
movl   $0xffffffff,-0x4(%rbp)
jmp    12b0 <verify_password+0x170>
mov    -0x8(%rbp),%edi
call   1030 <get_string@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1277 <verify_password+0x137>
movl   $0xffffffff,-0x4(%rbp)
jmp    12b0 <verify_password+0x170>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    129a <verify_password+0x15a>
movl   $0x0,-0x4(%rbp)
jmp    12b0 <verify_password+0x170>
mov    -0x8(%rbp),%edi
lea    0xd7c(%rip),%rsi
call   1050 <sockprint@plt>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<verify_password>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %rsi,%r14
mov    %edi,%ebx
movb   $0x3,0x1e(%rsp)
movw   $0xfbff,0x1c(%rsp)
movb   $0x22,0x1a(%rsp)
movw   $0xfeff,0x18(%rsp)
movb   $0x27,0x16(%rsp)
movw   $0xfeff,0x14(%rsp)
movb   $0x1,0x12(%rsp)
movw   $0xfbff,0x10(%rsp)
movb   $0x1,0xe(%rsp)
movw   $0xfeff,0xc(%rsp)
lea    0x1c(%rsp),%rsi
mov    $0x3,%edx
call   1060 <WRITE@plt>
lea    0x18(%rsp),%rsi
mov    %ebx,%edi
mov    $0x3,%edx
call   1060 <WRITE@plt>
lea    0x14(%rsp),%rsi
mov    %ebx,%edi
mov    $0x3,%edx
call   1060 <WRITE@plt>
lea    0x10(%rsp),%rsi
mov    %ebx,%edi
mov    $0x3,%edx
call   1060 <WRITE@plt>
lea    0xc(%rsp),%rsi
mov    %ebx,%edi
mov    $0x3,%edx
call   1060 <WRITE@plt>
lea    0xe2c(%rip),%rsi
mov    %ebx,%edi
call   1050 <sockprint@plt>
mov    $0xffffffff,%ebp
cmp    $0xffffffff,%eax
je     1222 <verify_password+0xe2>
mov    %ebx,%edi
call   1030 <get_string@plt>
test   %rax,%rax
je     1222 <verify_password+0xe2>
mov    %r14,%rdi
mov    %rax,%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     1220 <verify_password+0xe0>
lea    0xe03(%rip),%rsi
mov    %ebx,%edi
call   1050 <sockprint@plt>
jmp    1222 <verify_password+0xe2>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@__const.verify_password.dont_auth = [3 x i8] c"\FF\F4%"
@__const.verify_password.suppress_goahead = [3 x i8] c"\FF\FB\03"
@__const.verify_password.dont_linemode = [3 x i8] c"\FF\FE\22"
@__const.verify_password.dont_new_env = [3 x i8] c"\FF\FE'"
@__const.verify_password.will_echo = [3 x i8] c"\FF\FB\01"
@__const.verify_password.dont_echo = [3 x i8] c"\FF\FE\01"
@__const.verify_password.noecho = [3 x i8] c"\FF\FD-"
@.str = [11 x i8] c"Password: \00"
@.str.1 = [17 x i8] c"Invalid password\00"
define i32 @verify_password(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca [3 x i8]
%8 = alloca [3 x i8]
%9 = alloca [3 x i8]
%10 = alloca [3 x i8]
%11 = alloca [3 x i8]
%12 = alloca [3 x i8]
%13 = alloca [3 x i8]
store i32 %0, i32* %4
store i8* %1, i8** %5
%14 = bitcast [3 x i8]* %7 to i8*
%15 = bitcast [3 x i8]* %8 to i8*
%16 = bitcast [3 x i8]* %9 to i8*
%17 = bitcast [3 x i8]* %10 to i8*
%18 = bitcast [3 x i8]* %11 to i8*
%19 = bitcast [3 x i8]* %12 to i8*
%20 = bitcast [3 x i8]* %13 to i8*
%21 = load i32, i32* %4
%22 = getelementptr inbounds [3 x i8], [3 x i8]* %8, i64 0, i64 0
%23 = call i32 @WRITE(i32 %21, i8* %22, i32 3)
%24 = load i32, i32* %4
%25 = getelementptr inbounds [3 x i8], [3 x i8]* %9, i64 0, i64 0
%26 = call i32 @WRITE(i32 %24, i8* %25, i32 3)
%27 = load i32, i32* %4
%28 = getelementptr inbounds [3 x i8], [3 x i8]* %10, i64 0, i64 0
%29 = call i32 @WRITE(i32 %27, i8* %28, i32 3)
%30 = load i32, i32* %4
%31 = getelementptr inbounds [3 x i8], [3 x i8]* %11, i64 0, i64 0
%32 = call i32 @WRITE(i32 %30, i8* %31, i32 3)
%33 = load i32, i32* %4
%34 = getelementptr inbounds [3 x i8], [3 x i8]* %12, i64 0, i64 0
%35 = call i32 @WRITE(i32 %33, i8* %34, i32 3)
%36 = load i32, i32* %4
%37 = call i32 @sockprint(i32 %36, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%38 = icmp eq i32 %37, -1
br i1 %38, label %39, label %40
39: ; preds = %2
store i32 -1, i32* %3
br label %55
40: ; preds = %2
%41 = load i32, i32* %4
%42 = call i8* @get_string(i32 %41)
store i8* %42, i8** %6
%43 = load i8*, i8** %6
%44 = icmp ne i8* %43, null
br i1 %44, label %46, label %45
45: ; preds = %40
store i32 -1, i32* %3
br label %55
46: ; preds = %40
%47 = load i8*, i8** %5
%48 = load i8*, i8** %6
%49 = call i64 @strcmp(i8* %47, i8* %48)
%50 = icmp eq i64 %49, 0
br i1 %50, label %51, label %52
51: ; preds = %46
store i32 0, i32* %3
br label %55
52: ; preds = %46
%53 = load i32, i32* %4
%54 = call i32 @sockprint(i32 %53, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %3
br label %55
55: ; preds = %52, %51, %45, %39
%56 = load i32, i32* %3
ret i32 %56
}

LLVM IR (-O2):
@__const.verify_password.suppress_goahead = [3 x i8] c"\FF\FB\03"
@__const.verify_password.dont_linemode = [3 x i8] c"\FF\FE\22"
@__const.verify_password.dont_new_env = [3 x i8] c"\FF\FE'"
@__const.verify_password.will_echo = [3 x i8] c"\FF\FB\01"
@__const.verify_password.dont_echo = [3 x i8] c"\FF\FE\01"
@.str = [11 x i8] c"Password: \00"
@.str.1 = [17 x i8] c"Invalid password\00"
define i32 @verify_password(i32 %0, i8* %1) {
%3 = alloca [3 x i8]
%4 = alloca [3 x i8]
%5 = alloca [3 x i8]
%6 = alloca [3 x i8]
%7 = alloca [3 x i8]
%8 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 0
%9 = getelementptr inbounds [3 x i8], [3 x i8]* %4, i64 0, i64 0
%10 = getelementptr inbounds [3 x i8], [3 x i8]* %5, i64 0, i64 0
%11 = getelementptr inbounds [3 x i8], [3 x i8]* %6, i64 0, i64 0
%12 = getelementptr inbounds [3 x i8], [3 x i8]* %7, i64 0, i64 0
%13 = call i32 @WRITE(i32 %0, i8* %8, i32 3)
%14 = call i32 @WRITE(i32 %0, i8* %9, i32 3)
%15 = call i32 @WRITE(i32 %0, i8* %10, i32 3)
%16 = call i32 @WRITE(i32 %0, i8* %11, i32 3)
%17 = call i32 @WRITE(i32 %0, i8* %12, i32 3)
%18 = call i32 @sockprint(i32 %0, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%19 = icmp eq i32 %18, -1
br i1 %19, label %28, label %20
20: ; preds = %2
%21 = call i8* @get_string(i32 %0)
%22 = icmp eq i8* %21, null
br i1 %22, label %28, label %23
23: ; preds = %20
%24 = call i64 @strcmp(i8* %1, i8* %21)
%25 = icmp eq i64 %24, 0
br i1 %25, label %28, label %26
26: ; preds = %23
%27 = call i32 @sockprint(i32 %0, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
br label %28
28: ; preds = %23, %20, %2, %26
%29 = phi i32 [ -1, %26 ], [ -1, %2 ], [ -1, %20 ], [ 0, %23 ]
ret i32 %29
}