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

/* Variables and functions */
int UI_add_input_string(int /*<<< orphan*/ *, char const *, int /*<<< orphan*/,
                        char *, int /*<<< orphan*/, int);
int UI_add_verify_string(int /*<<< orphan*/ *, char const *, int /*<<< orphan*/,
                         char *, int /*<<< orphan*/, int, char *);
int /*<<< orphan*/ UI_free(int /*<<< orphan*/ *);
int /*<<< orphan*/ *UI_new();
int UI_process(int /*<<< orphan*/ *);
int UI_UTIL_read_pw(char *buf, char *buff, int size, const char *prompt,
                    int verify) {
  int ok = 0;
  UI *ui;
  if (size < 1)
    return -1;
  ui = UI_new();
  if (ui) {
    ok = UI_add_input_string(ui, prompt, 0, buf, 0, size - 1);
    if (ok >= 0 && verify)
      ok = UI_add_verify_string(ui, prompt, 0, buff, 0, size - 1, buf);
    if (ok >= 0)
      ok = UI_process(ui);
    UI_free(ui);
  }
  if (ok > 0)
    ok = 0;
  return (ok);
}


x86 assembly (clang, -O0):
<UI_UTIL_read_pw>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8d,-0x2c(%rbp)
movl   $0x0,-0x30(%rbp)
cmpl   $0x1,-0x1c(%rbp)
jge    1188 <UI_UTIL_read_pw+0x38>
movl   $0xffffffff,-0x4(%rbp)
jmp    1234 <UI_UTIL_read_pw+0xe4>
mov    $0x0,%al
call   1070 <UI_new@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
je     121d <UI_UTIL_read_pw+0xcd>
mov    -0x38(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x10(%rbp),%rcx
mov    -0x1c(%rbp),%r9d
sub    $0x1,%r9d
xor    %r8d,%r8d
mov    %r8d,%edx
call   1060 <UI_add_input_string@plt>
mov    %eax,-0x30(%rbp)
cmpl   $0x0,-0x30(%rbp)
jl     11fe <UI_UTIL_read_pw+0xae>
cmpl   $0x0,-0x2c(%rbp)
je     11fe <UI_UTIL_read_pw+0xae>
mov    -0x38(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x18(%rbp),%rcx
mov    -0x1c(%rbp),%r9d
sub    $0x1,%r9d
mov    -0x10(%rbp),%rax
xor    %r8d,%r8d
mov    %r8d,%edx
mov    %rax,(%rsp)
call   1040 <UI_add_verify_string@plt>
mov    %eax,-0x30(%rbp)
cmpl   $0x0,-0x30(%rbp)
jl     1214 <UI_UTIL_read_pw+0xc4>
mov    -0x38(%rbp),%rdi
call   1030 <UI_process@plt>
mov    %eax,-0x30(%rbp)
mov    -0x38(%rbp),%rdi
call   1050 <UI_free@plt>
cmpl   $0x0,-0x30(%rbp)
jle    122e <UI_UTIL_read_pw+0xde>
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<UI_UTIL_read_pw>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
test   %edx,%edx
jle    11e9 <UI_UTIL_read_pw+0x99>
mov    %r8d,%r15d
mov    %rcx,%r12
mov    %edx,%ebp
mov    %rdi,%r13
mov    %rsi,0x10(%rsp)
xor    %ebx,%ebx
xor    %eax,%eax
call   1070 <UI_new@plt>
test   %rax,%rax
je     11f8 <UI_UTIL_read_pw+0xa8>
mov    %rax,%r14
add    $0xffffffff,%ebp
mov    %rax,%rdi
mov    %r12,%rsi
xor    %edx,%edx
mov    %r13,%rcx
xor    %r8d,%r8d
mov    %ebp,%r9d
call   1060 <UI_add_input_string@plt>
mov    %eax,%ebx
test   %r15d,%r15d
je     11c9 <UI_UTIL_read_pw+0x79>
test   %ebx,%ebx
js     11c9 <UI_UTIL_read_pw+0x79>
mov    %r13,(%rsp)
mov    %r14,%rdi
mov    %r12,%rsi
xor    %edx,%edx
mov    0x10(%rsp),%rcx
xor    %r8d,%r8d
mov    %ebp,%r9d
call   1040 <UI_add_verify_string@plt>
mov    %eax,%ebx
test   %ebx,%ebx
js     11f0 <UI_UTIL_read_pw+0xa0>
mov    %r14,%rdi
call   1030 <UI_process@plt>
mov    %eax,%ebp
mov    %r14,%rdi
call   1050 <UI_free@plt>
xor    %ebx,%ebx
test   %ebp,%ebp
jns    11f8 <UI_UTIL_read_pw+0xa8>
mov    %ebp,%ebx
jmp    11f8 <UI_UTIL_read_pw+0xa8>
mov    $0xffffffff,%ebx
jmp    11f8 <UI_UTIL_read_pw+0xa8>
mov    %r14,%rdi
call   1050 <UI_free@plt>
mov    %ebx,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @UI_UTIL_read_pw(i8* %0, i8* %1, i32 %2, i8* %3, i32 %4) {
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32*
store i8* %0, i8** %7
store i8* %1, i8** %8
store i32 %2, i32* %9
store i8* %3, i8** %10
store i32 %4, i32* %11
store i32 0, i32* %12
%14 = load i32, i32* %9
%15 = icmp slt i32 %14, 1
br i1 %15, label %16, label %17
16: ; preds = %5
store i32 -1, i32* %6
br label %56
17: ; preds = %5
%18 = call i32* (...) @UI_new()
store i32* %18, i32** %13
%19 = load i32*, i32** %13
%20 = icmp ne i32* %19, null
br i1 %20, label %21, label %50
21: ; preds = %17
%22 = load i32*, i32** %13
%23 = load i8*, i8** %10
%24 = load i8*, i8** %7
%25 = load i32, i32* %9
%26 = sub nsw i32 %25, 1
%27 = call i32 @UI_add_input_string(i32* %22, i8* %23, i32 0, i8* %24, i32 0, i32 %26)
store i32 %27, i32* %12
%28 = load i32, i32* %12
%29 = icmp sge i32 %28, 0
br i1 %29, label %30, label %41
30: ; preds = %21
%31 = load i32, i32* %11
%32 = icmp ne i32 %31, 0
br i1 %32, label %33, label %41
33: ; preds = %30
%34 = load i32*, i32** %13
%35 = load i8*, i8** %10
%36 = load i8*, i8** %8
%37 = load i32, i32* %9
%38 = sub nsw i32 %37, 1
%39 = load i8*, i8** %7
%40 = call i32 @UI_add_verify_string(i32* %34, i8* %35, i32 0, i8* %36, i32 0, i32 %38, i8* %39)
store i32 %40, i32* %12
br label %41
41: ; preds = %33, %30, %21
%42 = load i32, i32* %12
%43 = icmp sge i32 %42, 0
br i1 %43, label %44, label %47
44: ; preds = %41
%45 = load i32*, i32** %13
%46 = call i32 @UI_process(i32* %45)
store i32 %46, i32* %12
br label %47
47: ; preds = %44, %41
%48 = load i32*, i32** %13
%49 = call i32 @UI_free(i32* %48)
br label %50
50: ; preds = %47, %17
%51 = load i32, i32* %12
%52 = icmp sgt i32 %51, 0
br i1 %52, label %53, label %54
53: ; preds = %50
store i32 0, i32* %12
br label %54
54: ; preds = %53, %50
%55 = load i32, i32* %12
store i32 %55, i32* %6
br label %56
56: ; preds = %54, %16
%57 = load i32, i32* %6
ret i32 %57
}

LLVM IR (-O2):
define i32 @UI_UTIL_read_pw(i8* %0, i8* %1, i32 %2, i8* %3, i32 %4) {
%6 = icmp slt i32 %2, 1
br i1 %6, label %29, label %7
7: ; preds = %5
%8 = tail call i32* (...) @UI_new()
%9 = icmp eq i32* %8, null
br i1 %9, label %29, label %10
10: ; preds = %7
%11 = add nsw i32 %2, -1
%12 = tail call i32 @UI_add_input_string(i32* %8, i8* %3, i32 0, i8* %0, i32 0, i32 %11)
%13 = icmp sgt i32 %12, -1
%14 = icmp ne i32 %4, 0
%15 = and i1 %14, %13
br i1 %15, label %16, label %18
16: ; preds = %10
%17 = tail call i32 @UI_add_verify_string(i32* %8, i8* %3, i32 0, i8* %1, i32 0, i32 %11, i8* %0)
br label %18
18: ; preds = %16, %10
%19 = phi i32 [ %17, %16 ], [ %12, %10 ]
%20 = icmp sgt i32 %19, -1
br i1 %20, label %23, label %21
21: ; preds = %18
%22 = tail call i32 @UI_free(i32* %8)
br label %27
23: ; preds = %18
%24 = tail call i32 @UI_process(i32* %8)
%25 = tail call i32 @UI_free(i32* %8)
%26 = icmp slt i32 %24, 0
br i1 %26, label %27, label %29
27: ; preds = %21, %23
%28 = phi i32 [ %19, %21 ], [ %24, %23 ]
br label %29
29: ; preds = %7, %27, %23, %5
%30 = phi i32 [ -1, %5 ], [ %28, %27 ], [ 0, %23 ], [ 0, %7 ]
ret i32 %30
}