#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 */
typedef int /*<<< orphan*/ DES_cblock;

/* Variables and functions */
int BUFSIZ;
int /*<<< orphan*/ DES_string_to_key(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ OPENSSL_cleanse(char *, int);
int UI_UTIL_read_pw(char *, char *, int, char const *, int);
int DES_read_password(DES_cblock *key, const char *prompt, int verify) {
  int ok;
  char buf[BUFSIZ], buff[BUFSIZ];
  if ((ok = UI_UTIL_read_pw(buf, buff, BUFSIZ, prompt, verify)) == 0)
    DES_string_to_key(buf, key);
  OPENSSL_cleanse(buf, BUFSIZ);
  OPENSSL_cleanse(buff, BUFSIZ);
  return (ok);
}


x86 assembly (clang, -O0):
<DES_read_password>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    0x2e96(%rip),%rax
mov    (%rax),%ecx
mov    %rsp,%rdx
mov    %rdx,-0x20(%rbp)
mov    %rcx,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rdi
sub    %rdx,%rdi
mov    %rdi,-0x40(%rbp)
mov    %rdi,%rsp
mov    %rcx,-0x28(%rbp)
mov    (%rax),%eax
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rsi
sub    %rcx,%rsi
mov    %rsi,-0x38(%rbp)
mov    %rsi,%rsp
mov    %rax,-0x30(%rbp)
mov    0x2e4c(%rip),%rax
mov    (%rax),%edx
mov    -0x10(%rbp),%rcx
mov    -0x14(%rbp),%r8d
call   1040 <UI_UTIL_read_pw@plt>
mov    %eax,-0x18(%rbp)
cmp    $0x0,%eax
jne    11bc <DES_read_password+0x8c>
mov    -0x40(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1050 <DES_string_to_key@plt>
mov    -0x40(%rbp),%rdi
mov    0x2e19(%rip),%rax
mov    (%rax),%esi
call   1030 <OPENSSL_cleanse@plt>
mov    -0x38(%rbp),%rdi
mov    0x2e07(%rip),%rax
mov    (%rax),%esi
call   1030 <OPENSSL_cleanse@plt>
mov    -0x18(%rbp),%eax
mov    -0x20(%rbp),%rcx
mov    %rcx,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<DES_read_password>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%r8d
mov    %rsi,%rcx
mov    %rdi,%r14
mov    0x2e92(%rip),%r13
mov    0x0(%r13),%edx
mov    %rsp,%rbx
mov    %rdx,%rax
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
mov    %rsp,%r15
sub    %rax,%r15
mov    %r15,%rsp
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <UI_UTIL_read_pw@plt>
mov    %eax,%r12d
test   %eax,%eax
jne    118c <DES_read_password+0x5c>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <DES_string_to_key@plt>
mov    0x0(%r13),%esi
mov    %rbx,%rdi
call   1030 <OPENSSL_cleanse@plt>
mov    0x0(%r13),%esi
mov    %r15,%rdi
call   1030 <OPENSSL_cleanse@plt>
mov    %r12d,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@BUFSIZ = global i32 0
define i32 @DES_read_password(i32* %0, i8* %1, i32 %2) {
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i64
%10 = alloca i64
store i32* %0, i32** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%11 = load i32, i32* @BUFSIZ
%12 = zext i32 %11 to i64
%13 = call i8* @llvm.stacksave()
store i8* %13, i8** %8
%14 = alloca i8, i64 %12
store i64 %12, i64* %9
%15 = load i32, i32* @BUFSIZ
%16 = zext i32 %15 to i64
%17 = alloca i8, i64 %16
store i64 %16, i64* %10
%18 = load i32, i32* @BUFSIZ
%19 = load i8*, i8** %5
%20 = load i32, i32* %6
%21 = call i32 @UI_UTIL_read_pw(i8* %14, i8* %17, i32 %18, i8* %19, i32 %20)
store i32 %21, i32* %7
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %26
23: ; preds = %3
%24 = load i32*, i32** %4
%25 = call i32 @DES_string_to_key(i8* %14, i32* %24)
br label %26
26: ; preds = %23, %3
%27 = load i32, i32* @BUFSIZ
%28 = call i32 @OPENSSL_cleanse(i8* %14, i32 %27)
%29 = load i32, i32* @BUFSIZ
%30 = call i32 @OPENSSL_cleanse(i8* %17, i32 %29)
%31 = load i32, i32* %7
%32 = load i8*, i8** %8
ret i32 %31
}

LLVM IR (-O2):
@BUFSIZ = global i32 0
define i32 @DES_read_password(i32* %0, i8* %1, i32 %2) {
%4 = load i32, i32* @BUFSIZ
%5 = zext i32 %4 to i64
%6 = alloca i8, i64 %5
%7 = alloca i8, i64 %5
%8 = call i32 @UI_UTIL_read_pw(i8* %6, i8* %7, i32 %4, i8* %1, i32 %2)
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %3
%11 = call i32 @DES_string_to_key(i8* %6, i32* %0)
br label %12
12: ; preds = %10, %3
%13 = load i32, i32* @BUFSIZ
%14 = call i32 @OPENSSL_cleanse(i8* %6, i32 %13)
%15 = load i32, i32* @BUFSIZ
%16 = call i32 @OPENSSL_cleanse(i8* %7, i32 %15)
ret i32 %8
}