#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 */
char *BUF_strdup(char const *);
int /*<<< orphan*/ ERR_R_MALLOC_FAILURE;
int /*<<< orphan*/ OPENSSL_free(char *);
int /*<<< orphan*/ UIT_BOOLEAN;
int /*<<< orphan*/ UI_F_UI_DUP_INPUT_BOOLEAN;
int /*<<< orphan*/ UIerr(int /*<<< orphan*/, int /*<<< orphan*/);
int general_allocate_boolean(int /*<<< orphan*/ *, char *, char *, char *,
                             char *, int, int /*<<< orphan*/, int, char *);
int UI_dup_input_boolean(UI *ui, const char *prompt, const char *action_desc,
                         const char *ok_chars, const char *cancel_chars,
                         int flags, char *result_buf) {
  char *prompt_copy = NULL;
  char *action_desc_copy = NULL;
  char *ok_chars_copy = NULL;
  char *cancel_chars_copy = NULL;
  if (prompt) {
    prompt_copy = BUF_strdup(prompt);
    if (prompt_copy == NULL) {
      UIerr(UI_F_UI_DUP_INPUT_BOOLEAN, ERR_R_MALLOC_FAILURE);
      goto err;
    }
  }
  if (action_desc) {
    action_desc_copy = BUF_strdup(action_desc);
    if (action_desc_copy == NULL) {
      UIerr(UI_F_UI_DUP_INPUT_BOOLEAN, ERR_R_MALLOC_FAILURE);
      goto err;
    }
  }
  if (ok_chars) {
    ok_chars_copy = BUF_strdup(ok_chars);
    if (ok_chars_copy == NULL) {
      UIerr(UI_F_UI_DUP_INPUT_BOOLEAN, ERR_R_MALLOC_FAILURE);
      goto err;
    }
  }
  if (cancel_chars) {
    cancel_chars_copy = BUF_strdup(cancel_chars);
    if (cancel_chars_copy == NULL) {
      UIerr(UI_F_UI_DUP_INPUT_BOOLEAN, ERR_R_MALLOC_FAILURE);
      goto err;
    }
  }
  return general_allocate_boolean(ui, prompt_copy, action_desc_copy,
                                  ok_chars_copy, cancel_chars_copy, 1,
                                  UIT_BOOLEAN, flags, result_buf);
err:
  if (prompt_copy)
    OPENSSL_free(prompt_copy);
  if (action_desc_copy)
    OPENSSL_free(action_desc_copy);
  if (ok_chars_copy)
    OPENSSL_free(ok_chars_copy);
  if (cancel_chars_copy)
    OPENSSL_free(cancel_chars_copy);
  return -1;
}


x86 assembly (clang, -O0):
<UI_dup_input_boolean>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    0x10(%rbp),%rax
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    %r9d,-0x34(%rbp)
movq   $0x0,-0x40(%rbp)
movq   $0x0,-0x48(%rbp)
movq   $0x0,-0x50(%rbp)
movq   $0x0,-0x58(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11c8 <UI_dup_input_boolean+0x88>
mov    -0x18(%rbp),%rdi
call   1050 <BUF_strdup@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
jne    11c3 <UI_dup_input_boolean+0x83>
mov    0x2e42(%rip),%rax
mov    (%rax),%edi
mov    0x2e29(%rip),%rax
mov    (%rax),%esi
call   1040 <UIerr@plt>
jmp    12db <UI_dup_input_boolean+0x19b>
jmp    11c8 <UI_dup_input_boolean+0x88>
cmpq   $0x0,-0x20(%rbp)
je     120c <UI_dup_input_boolean+0xcc>
mov    -0x20(%rbp),%rdi
call   1050 <BUF_strdup@plt>
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x48(%rbp)
jne    1207 <UI_dup_input_boolean+0xc7>
mov    0x2dfe(%rip),%rax
mov    (%rax),%edi
mov    0x2de5(%rip),%rax
mov    (%rax),%esi
call   1040 <UIerr@plt>
jmp    12db <UI_dup_input_boolean+0x19b>
jmp    120c <UI_dup_input_boolean+0xcc>
cmpq   $0x0,-0x28(%rbp)
je     1250 <UI_dup_input_boolean+0x110>
mov    -0x28(%rbp),%rdi
call   1050 <BUF_strdup@plt>
mov    %rax,-0x50(%rbp)
cmpq   $0x0,-0x50(%rbp)
jne    124b <UI_dup_input_boolean+0x10b>
mov    0x2dba(%rip),%rax
mov    (%rax),%edi
mov    0x2da1(%rip),%rax
mov    (%rax),%esi
call   1040 <UIerr@plt>
jmp    12db <UI_dup_input_boolean+0x19b>
jmp    1250 <UI_dup_input_boolean+0x110>
cmpq   $0x0,-0x30(%rbp)
je     1294 <UI_dup_input_boolean+0x154>
mov    -0x30(%rbp),%rdi
call   1050 <BUF_strdup@plt>
mov    %rax,-0x58(%rbp)
cmpq   $0x0,-0x58(%rbp)
jne    128f <UI_dup_input_boolean+0x14f>
mov    0x2d76(%rip),%rax
mov    (%rax),%edi
mov    0x2d5d(%rip),%rax
mov    (%rax),%esi
call   1040 <UIerr@plt>
jmp    12db <UI_dup_input_boolean+0x19b>
jmp    1294 <UI_dup_input_boolean+0x154>
mov    -0x10(%rbp),%rdi
mov    -0x40(%rbp),%rsi
mov    -0x48(%rbp),%rdx
mov    -0x50(%rbp),%rcx
mov    -0x58(%rbp),%r8
mov    0x2d21(%rip),%rax
mov    (%rax),%r11d
mov    -0x34(%rbp),%r10d
mov    0x10(%rbp),%rax
mov    $0x1,%r9d
mov    %r11d,(%rsp)
mov    %r10d,0x8(%rsp)
mov    %rax,0x10(%rsp)
call   1030 <general_allocate_boolean@plt>
mov    %eax,-0x4(%rbp)
jmp    1332 <UI_dup_input_boolean+0x1f2>
cmpq   $0x0,-0x40(%rbp)
je     12ef <UI_dup_input_boolean+0x1af>
mov    -0x40(%rbp),%rdi
call   1060 <OPENSSL_free@plt>
cmpq   $0x0,-0x48(%rbp)
je     1303 <UI_dup_input_boolean+0x1c3>
mov    -0x48(%rbp),%rdi
call   1060 <OPENSSL_free@plt>
cmpq   $0x0,-0x50(%rbp)
je     1317 <UI_dup_input_boolean+0x1d7>
mov    -0x50(%rbp),%rdi
call   1060 <OPENSSL_free@plt>
cmpq   $0x0,-0x58(%rbp)
je     132b <UI_dup_input_boolean+0x1eb>
mov    -0x58(%rbp),%rdi
call   1060 <OPENSSL_free@plt>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<UI_dup_input_boolean>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r9d,%r12d
mov    %r8,%r14
mov    %rcx,%r13
mov    %rdx,%rbp
mov    %rdi,%rbx
test   %rsi,%rsi
je     118e <UI_dup_input_boolean+0x4e>
mov    %rsi,%rdi
call   1050 <BUF_strdup@plt>
mov    %rax,%r15
test   %rax,%rax
jne    1191 <UI_dup_input_boolean+0x51>
mov    0x2e77(%rip),%rax
mov    (%rax),%edi
mov    0x2e5e(%rip),%rax
mov    (%rax),%esi
call   1040 <UIerr@plt>
jmp    1266 <UI_dup_input_boolean+0x126>
xor    %r15d,%r15d
test   %rbp,%rbp
mov    %r12,0x10(%rsp)
mov    %rbx,0x8(%rsp)
je     11dc <UI_dup_input_boolean+0x9c>
mov    %rbp,%rdi
call   1050 <BUF_strdup@plt>
mov    %rax,%r12
test   %rax,%rax
je     1223 <UI_dup_input_boolean+0xe3>
test   %r13,%r13
je     11e4 <UI_dup_input_boolean+0xa4>
mov    %r13,%rdi
call   1050 <BUF_strdup@plt>
mov    %rax,%rbx
test   %rax,%rax
je     1226 <UI_dup_input_boolean+0xe6>
test   %r14,%r14
je     11eb <UI_dup_input_boolean+0xab>
mov    %r14,%rdi
call   1050 <BUF_strdup@plt>
mov    %rax,%r8
test   %rax,%rax
jne    11ee <UI_dup_input_boolean+0xae>
jmp    1228 <UI_dup_input_boolean+0xe8>
xor    %r12d,%r12d
test   %r13,%r13
jne    11b5 <UI_dup_input_boolean+0x75>
xor    %ebx,%ebx
test   %r14,%r14
jne    11ca <UI_dup_input_boolean+0x8a>
xor    %r8d,%r8d
mov    0x2ddb(%rip),%rax
mov    (%rax),%eax
sub    $0x8,%rsp
mov    0x10(%rsp),%rdi
mov    %r15,%rsi
mov    %r12,%rdx
mov    %rbx,%rcx
mov    $0x1,%r9d
push   0x58(%rsp)
push   0x20(%rsp)
push   %rax
call   1030 <general_allocate_boolean@plt>
add    $0x38,%rsp
jmp    126f <UI_dup_input_boolean+0x12f>
xor    %r12d,%r12d
xor    %ebx,%ebx
mov    0x2dc1(%rip),%rax
mov    (%rax),%edi
mov    0x2da8(%rip),%rax
mov    (%rax),%esi
call   1040 <UIerr@plt>
test   %r15,%r15
je     124c <UI_dup_input_boolean+0x10c>
mov    %r15,%rdi
call   1060 <OPENSSL_free@plt>
test   %r12,%r12
je     1259 <UI_dup_input_boolean+0x119>
mov    %r12,%rdi
call   1060 <OPENSSL_free@plt>
test   %rbx,%rbx
je     1266 <UI_dup_input_boolean+0x126>
mov    %rbx,%rdi
call   1060 <OPENSSL_free@plt>
mov    $0xffffffff,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@UI_F_UI_DUP_INPUT_BOOLEAN = global i32 0
@ERR_R_MALLOC_FAILURE = global i32 0
@UIT_BOOLEAN = global i32 0
define i32 @UI_dup_input_boolean(i32* %0, i8* %1, i8* %2, i8* %3, i8* %4, i32 %5, i8* %6) {
%8 = alloca i32
%9 = alloca i32*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca i32
%15 = alloca i8*
%16 = alloca i8*
%17 = alloca i8*
%18 = alloca i8*
%19 = alloca i8*
store i32* %0, i32** %9
store i8* %1, i8** %10
store i8* %2, i8** %11
store i8* %3, i8** %12
store i8* %4, i8** %13
store i32 %5, i32* %14
store i8* %6, i8** %15
store i8* null, i8** %16
store i8* null, i8** %17
store i8* null, i8** %18
store i8* null, i8** %19
%20 = load i8*, i8** %10
%21 = icmp ne i8* %20, null
br i1 %21, label %22, label %32
22: ; preds = %7
%23 = load i8*, i8** %10
%24 = call i8* @BUF_strdup(i8* %23)
store i8* %24, i8** %16
%25 = load i8*, i8** %16
%26 = icmp eq i8* %25, null
br i1 %26, label %27, label %31
27: ; preds = %22
%28 = load i32, i32* @UI_F_UI_DUP_INPUT_BOOLEAN
%29 = load i32, i32* @ERR_R_MALLOC_FAILURE
%30 = call i32 @UIerr(i32 %28, i32 %29)
br label %81
31: ; preds = %22
br label %32
32: ; preds = %31, %7
%33 = load i8*, i8** %11
%34 = icmp ne i8* %33, null
br i1 %34, label %35, label %45
35: ; preds = %32
%36 = load i8*, i8** %11
%37 = call i8* @BUF_strdup(i8* %36)
store i8* %37, i8** %17
%38 = load i8*, i8** %17
%39 = icmp eq i8* %38, null
br i1 %39, label %40, label %44
40: ; preds = %35
%41 = load i32, i32* @UI_F_UI_DUP_INPUT_BOOLEAN
%42 = load i32, i32* @ERR_R_MALLOC_FAILURE
%43 = call i32 @UIerr(i32 %41, i32 %42)
br label %81
44: ; preds = %35
br label %45
45: ; preds = %44, %32
%46 = load i8*, i8** %12
%47 = icmp ne i8* %46, null
br i1 %47, label %48, label %58
48: ; preds = %45
%49 = load i8*, i8** %12
%50 = call i8* @BUF_strdup(i8* %49)
store i8* %50, i8** %18
%51 = load i8*, i8** %18
%52 = icmp eq i8* %51, null
br i1 %52, label %53, label %57
53: ; preds = %48
%54 = load i32, i32* @UI_F_UI_DUP_INPUT_BOOLEAN
%55 = load i32, i32* @ERR_R_MALLOC_FAILURE
%56 = call i32 @UIerr(i32 %54, i32 %55)
br label %81
57: ; preds = %48
br label %58
58: ; preds = %57, %45
%59 = load i8*, i8** %13
%60 = icmp ne i8* %59, null
br i1 %60, label %61, label %71
61: ; preds = %58
%62 = load i8*, i8** %13
%63 = call i8* @BUF_strdup(i8* %62)
store i8* %63, i8** %19
%64 = load i8*, i8** %19
%65 = icmp eq i8* %64, null
br i1 %65, label %66, label %70
66: ; preds = %61
%67 = load i32, i32* @UI_F_UI_DUP_INPUT_BOOLEAN
%68 = load i32, i32* @ERR_R_MALLOC_FAILURE
%69 = call i32 @UIerr(i32 %67, i32 %68)
br label %81
70: ; preds = %61
br label %71
71: ; preds = %70, %58
%72 = load i32*, i32** %9
%73 = load i8*, i8** %16
%74 = load i8*, i8** %17
%75 = load i8*, i8** %18
%76 = load i8*, i8** %19
%77 = load i32, i32* @UIT_BOOLEAN
%78 = load i32, i32* %14
%79 = load i8*, i8** %15
%80 = call i32 @general_allocate_boolean(i32* %72, i8* %73, i8* %74, i8* %75, i8* %76, i32 1, i32 %77, i32 %78, i8* %79)
store i32 %80, i32* %8
br label %106
81: ; preds = %66, %53, %40, %27
%82 = load i8*, i8** %16
%83 = icmp ne i8* %82, null
br i1 %83, label %84, label %87
84: ; preds = %81
%85 = load i8*, i8** %16
%86 = call i32 @OPENSSL_free(i8* %85)
br label %87
87: ; preds = %84, %81
%88 = load i8*, i8** %17
%89 = icmp ne i8* %88, null
br i1 %89, label %90, label %93
90: ; preds = %87
%91 = load i8*, i8** %17
%92 = call i32 @OPENSSL_free(i8* %91)
br label %93
93: ; preds = %90, %87
%94 = load i8*, i8** %18
%95 = icmp ne i8* %94, null
br i1 %95, label %96, label %99
96: ; preds = %93
%97 = load i8*, i8** %18
%98 = call i32 @OPENSSL_free(i8* %97)
br label %99
99: ; preds = %96, %93
%100 = load i8*, i8** %19
%101 = icmp ne i8* %100, null
br i1 %101, label %102, label %105
102: ; preds = %99
%103 = load i8*, i8** %19
%104 = call i32 @OPENSSL_free(i8* %103)
br label %105
105: ; preds = %102, %99
store i32 -1, i32* %8
br label %106
106: ; preds = %105, %71
%107 = load i32, i32* %8
ret i32 %107
}

LLVM IR (-O2):
@UI_F_UI_DUP_INPUT_BOOLEAN = global i32 0
@ERR_R_MALLOC_FAILURE = global i32 0
@UIT_BOOLEAN = global i32 0
define i32 @UI_dup_input_boolean(i32* %0, i8* %1, i8* %2, i8* %3, i8* %4, i32 %5, i8* %6) {
%8 = icmp eq i8* %1, null
br i1 %8, label %16, label %9
9: ; preds = %7
%10 = tail call i8* @BUF_strdup(i8* %1)
%11 = icmp eq i8* %10, null
br i1 %11, label %12, label %16
12: ; preds = %9
%13 = load i32, i32* @UI_F_UI_DUP_INPUT_BOOLEAN
%14 = load i32, i32* @ERR_R_MALLOC_FAILURE
%15 = tail call i32 @UIerr(i32 %13, i32 %14)
br label %55
16: ; preds = %9, %7
%17 = phi i8* [ %10, %9 ], [ null, %7 ]
%18 = icmp eq i8* %2, null
br i1 %18, label %22, label %19
19: ; preds = %16
%20 = tail call i8* @BUF_strdup(i8* %2)
%21 = icmp eq i8* %20, null
br i1 %21, label %38, label %22
22: ; preds = %19, %16
%23 = phi i8* [ %20, %19 ], [ null, %16 ]
%24 = icmp eq i8* %3, null
br i1 %24, label %28, label %25
25: ; preds = %22
%26 = tail call i8* @BUF_strdup(i8* %3)
%27 = icmp eq i8* %26, null
br i1 %27, label %38, label %28
28: ; preds = %25, %22
%29 = phi i8* [ %26, %25 ], [ null, %22 ]
%30 = icmp eq i8* %4, null
br i1 %30, label %34, label %31
31: ; preds = %28
%32 = tail call i8* @BUF_strdup(i8* %4)
%33 = icmp eq i8* %32, null
br i1 %33, label %38, label %34
34: ; preds = %31, %28
%35 = phi i8* [ %32, %31 ], [ null, %28 ]
%36 = load i32, i32* @UIT_BOOLEAN
%37 = tail call i32 @general_allocate_boolean(i32* %0, i8* %17, i8* %23, i8* %29, i8* %35, i32 1, i32 %36, i32 %5, i8* %6)
br label %55
38: ; preds = %31, %25, %19
%39 = phi i8* [ null, %19 ], [ %23, %25 ], [ %23, %31 ]
%40 = phi i8* [ null, %19 ], [ null, %25 ], [ %29, %31 ]
%41 = load i32, i32* @UI_F_UI_DUP_INPUT_BOOLEAN
%42 = load i32, i32* @ERR_R_MALLOC_FAILURE
%43 = tail call i32 @UIerr(i32 %41, i32 %42)
%44 = icmp eq i8* %17, null
br i1 %44, label %47, label %45
45: ; preds = %38
%46 = tail call i32 @OPENSSL_free(i8* %17)
br label %47
47: ; preds = %45, %38
%48 = icmp eq i8* %39, null
br i1 %48, label %51, label %49
49: ; preds = %47
%50 = tail call i32 @OPENSSL_free(i8* %39)
br label %51
51: ; preds = %49, %47
%52 = icmp eq i8* %40, null
br i1 %52, label %55, label %53
53: ; preds = %51
%54 = tail call i32 @OPENSSL_free(i8* %40)
br label %55
55: ; preds = %12, %53, %51, %34
%56 = phi i32 [ %37, %34 ], [ -1, %51 ], [ -1, %53 ], [ -1, %12 ]
ret i32 %56
}