#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 /*<<< orphan*/ ERR_R_MALLOC_FAILURE;
int /*<<< orphan*/ UIT_VERIFY;
int /*<<< orphan*/ UIerror(int /*<<< orphan*/);
int general_allocate_string(int /*<<< orphan*/ *, char *, int,
                            int /*<<< orphan*/, int, char *, int, int,
                            char const *);
char *strdup(char const *);
int UI_dup_verify_string(UI *ui, const char *prompt, int flags,
                         char *result_buf, int minsize, int maxsize,
                         const char *test_buf) {
  char *prompt_copy = NULL;
  if (prompt) {
    prompt_copy = strdup(prompt);
    if (prompt_copy == NULL) {
      UIerror(ERR_R_MALLOC_FAILURE);
      return -1;
    }
  }
  return general_allocate_string(ui, prompt_copy, 1, UIT_VERIFY, flags,
                                 result_buf, minsize, maxsize, test_buf);
}


x86 assembly (clang, -O0):
<UI_dup_verify_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    0x10(%rbp),%rax
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8d,-0x2c(%rbp)
mov    %r9d,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     119d <UI_dup_verify_string+0x6d>
mov    -0x18(%rbp),%rdi
call   1050 <strdup@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    1198 <UI_dup_verify_string+0x68>
mov    0x2e63(%rip),%rax
mov    (%rax),%edi
call   1030 <UIerror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11dd <UI_dup_verify_string+0xad>
jmp    119d <UI_dup_verify_string+0x6d>
mov    -0x10(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    0x2e2c(%rip),%rax
mov    (%rax),%ecx
mov    -0x1c(%rbp),%r8d
mov    -0x28(%rbp),%r9
mov    -0x2c(%rbp),%r11d
mov    -0x30(%rbp),%r10d
mov    0x10(%rbp),%rax
mov    $0x1,%edx
mov    %r11d,(%rsp)
mov    %r10d,0x8(%rsp)
mov    %rax,0x10(%rsp)
call   1040 <general_allocate_string@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<UI_dup_verify_string>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %r9d,%r15d
mov    %r8d,%r14d
mov    %rcx,%r12
mov    %edx,%ebp
mov    %rdi,%rbx
test   %rsi,%rsi
je     1170 <UI_dup_verify_string+0x40>
mov    %rsi,%rdi
call   1050 <strdup@plt>
mov    %rax,%rsi
test   %rax,%rax
jne    1172 <UI_dup_verify_string+0x42>
mov    0x2e86(%rip),%rax
mov    (%rax),%edi
call   1030 <UIerror@plt>
mov    $0xffffffff,%eax
jmp    119e <UI_dup_verify_string+0x6e>
xor    %esi,%esi
mov    0x2e5f(%rip),%rax
mov    (%rax),%ecx
sub    $0x8,%rsp
mov    %rbx,%rdi
mov    $0x1,%edx
mov    %ebp,%r8d
mov    %r12,%r9
push   0x38(%rsp)
push   %r15
push   %r14
call   1040 <general_allocate_string@plt>
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@ERR_R_MALLOC_FAILURE = global i32 0
@UIT_VERIFY = global i32 0
define i32 @UI_dup_verify_string(i32* %0, i8* %1, i32 %2, i8* %3, i32 %4, i32 %5, i8* %6) {
%8 = alloca i32
%9 = alloca i32*
%10 = alloca i8*
%11 = alloca i32
%12 = alloca i8*
%13 = alloca i32
%14 = alloca i32
%15 = alloca i8*
%16 = alloca i8*
store i32* %0, i32** %9
store i8* %1, i8** %10
store i32 %2, i32* %11
store i8* %3, i8** %12
store i32 %4, i32* %13
store i32 %5, i32* %14
store i8* %6, i8** %15
store i8* null, i8** %16
%17 = load i8*, i8** %10
%18 = icmp ne i8* %17, null
br i1 %18, label %19, label %28
19: ; preds = %7
%20 = load i8*, i8** %10
%21 = call i8* @strdup(i8* %20)
store i8* %21, i8** %16
%22 = load i8*, i8** %16
%23 = icmp eq i8* %22, null
br i1 %23, label %24, label %27
24: ; preds = %19
%25 = load i32, i32* @ERR_R_MALLOC_FAILURE
%26 = call i32 @UIerror(i32 %25)
store i32 -1, i32* %8
br label %38
27: ; preds = %19
br label %28
28: ; preds = %27, %7
%29 = load i32*, i32** %9
%30 = load i8*, i8** %16
%31 = load i32, i32* @UIT_VERIFY
%32 = load i32, i32* %11
%33 = load i8*, i8** %12
%34 = load i32, i32* %13
%35 = load i32, i32* %14
%36 = load i8*, i8** %15
%37 = call i32 @general_allocate_string(i32* %29, i8* %30, i32 1, i32 %31, i32 %32, i8* %33, i32 %34, i32 %35, i8* %36)
store i32 %37, i32* %8
br label %38
38: ; preds = %28, %24
%39 = load i32, i32* %8
ret i32 %39
}

LLVM IR (-O2):
@ERR_R_MALLOC_FAILURE = global i32 0
@UIT_VERIFY = global i32 0
define i32 @UI_dup_verify_string(i32* %0, i8* %1, i32 %2, i8* %3, i32 %4, i32 %5, i8* %6) {
%8 = icmp eq i8* %1, null
br i1 %8, label %15, label %9
9: ; preds = %7
%10 = tail call i8* @strdup(i8* %1)
%11 = icmp eq i8* %10, null
br i1 %11, label %12, label %15
12: ; preds = %9
%13 = load i32, i32* @ERR_R_MALLOC_FAILURE
%14 = tail call i32 @UIerror(i32 %13)
br label %19
15: ; preds = %9, %7
%16 = phi i8* [ %10, %9 ], [ null, %7 ]
%17 = load i32, i32* @UIT_VERIFY
%18 = tail call i32 @general_allocate_string(i32* %0, i8* %16, i32 1, i32 %17, i32 %2, i8* %3, i32 %4, i32 %5, i8* %6)
br label %19
19: ; preds = %15, %12
%20 = phi i32 [ -1, %12 ], [ %18, %15 ]
ret i32 %20
}