#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*/ prompt;

/* Variables and functions */
char *getpass(char *);
int /*<<< orphan*/ memcpy(char *, char *, size_t);
int /*<<< orphan*/ snprintf(char *, int, char *, char *);
scalar_t__ strlen(char *);
int pass_cb(char *buf, int size, int rwflag, void *u) {
  char *passphrase;
  char prompt[128];
  (void)&(rwflag);
  snprintf(prompt, sizeof(prompt), "\"%s\" passphrase: ", (char *)u);
  if ((passphrase = getpass(prompt)) == NULL) {
    return -1;
  }
  (void)memcpy(buf, passphrase, (size_t)size);
  return (int)strlen(passphrase);
}


x86 assembly (clang, -O0):
<pass_cb>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
lea    -0xb0(%rbp),%rdi
mov    -0x20(%rbp),%rcx
mov    $0x80,%esi
lea    0xe90(%rip),%rdx
call   1040 <snprintf@plt>
lea    -0xb0(%rbp),%rdi
call   1060 <getpass@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    119b <pass_cb+0x5b>
movl   $0xffffffff,-0x4(%rbp)
jmp    11b8 <pass_cb+0x78>
mov    -0x10(%rbp),%rdi
mov    -0x28(%rbp),%rsi
movslq -0x14(%rbp),%rdx
call   1050 <memcpy@plt>
mov    -0x28(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pass_cb>:
push   %rbp
push   %r14
push   %rbx
sub    $0x80,%rsp
mov    %esi,%ebp
mov    %rdi,%r14
lea    0xea9(%rip),%rdx
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x80,%esi
call   1040 <snprintf@plt>
mov    %rbx,%rdi
call   1060 <getpass@plt>
test   %rax,%rax
je     118f <pass_cb+0x4f>
mov    %rax,%rbx
movslq %ebp,%rdx
mov    %r14,%rdi
mov    %rax,%rsi
call   1050 <memcpy@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
jmp    1194 <pass_cb+0x54>
mov    $0xffffffff,%eax
add    $0x80,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [18 x i8] c"\22%s\22 passphrase: \00"
define i32 @pass_cb(i8* %0, i32 %1, i32 %2, i8* %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca [128 x i8]
store i8* %0, i8** %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i8* %3, i8** %9
%12 = getelementptr inbounds [128 x i8], [128 x i8]* %11, i64 0, i64 0
%13 = load i8*, i8** %9
%14 = call i32 @snprintf(i8* %12, i32 128, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %13)
%15 = getelementptr inbounds [128 x i8], [128 x i8]* %11, i64 0, i64 0
%16 = call i8* @getpass(i8* %15)
store i8* %16, i8** %10
%17 = icmp eq i8* %16, null
br i1 %17, label %18, label %19
18: ; preds = %4
store i32 -1, i32* %5
br label %28
19: ; preds = %4
%20 = load i8*, i8** %6
%21 = load i8*, i8** %10
%22 = load i32, i32* %7
%23 = sext i32 %22 to i64
%24 = call i32 @memcpy(i8* %20, i8* %21, i64 %23)
%25 = load i8*, i8** %10
%26 = call i64 @strlen(i8* %25)
%27 = trunc i64 %26 to i32
store i32 %27, i32* %5
br label %28
28: ; preds = %19, %18
%29 = load i32, i32* %5
ret i32 %29
}

LLVM IR (-O2):
@.str = [18 x i8] c"\22%s\22 passphrase: \00"
define i32 @pass_cb(i8* %0, i32 %1, i32 %2, i8* %3) {
%5 = alloca [128 x i8]
%6 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 0
%7 = call i32 @snprintf(i8* %6, i32 128, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %3)
%8 = call i8* @getpass(i8* %6)
%9 = icmp eq i8* %8, null
br i1 %9, label %15, label %10
10: ; preds = %4
%11 = sext i32 %1 to i64
%12 = call i32 @memcpy(i8* %0, i8* %8, i64 %11)
%13 = call i64 @strlen(i8* %8)
%14 = trunc i64 %13 to i32
br label %15
15: ; preds = %4, %10
%16 = phi i32 [ %14, %10 ], [ -1, %4 ]
ret i32 %16
}