#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_BOOLEAN;
int /*<<< orphan*/ UIerror(int /*<<< orphan*/);
int /*<<< orphan*/ free(char *);
int general_allocate_boolean(int /*<<< orphan*/ *, char *, char *, char *,
                             char *, int, int /*<<< orphan*/, int, char *);
char *strdup(char const *);
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 = strdup(prompt);
    if (prompt_copy == NULL) {
      UIerror(ERR_R_MALLOC_FAILURE);
      goto err;
    }
  }
  if (action_desc) {
    action_desc_copy = strdup(action_desc);
    if (action_desc_copy == NULL) {
      UIerror(ERR_R_MALLOC_FAILURE);
      goto err;
    }
  }
  if (ok_chars) {
    ok_chars_copy = strdup(ok_chars);
    if (ok_chars_copy == NULL) {
      UIerror(ERR_R_MALLOC_FAILURE);
      goto err;
    }
  }
  if (cancel_chars) {
    cancel_chars_copy = strdup(cancel_chars);
    if (cancel_chars_copy == NULL) {
      UIerror(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:
  free(prompt_copy);
  free(action_desc_copy);
  free(ok_chars_copy);
  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     11bf <UI_dup_input_boolean+0x7f>
mov    -0x18(%rbp),%rdi
call   1060 <strdup@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
jne    11ba <UI_dup_input_boolean+0x7a>
mov    0x2e3a(%rip),%rax
mov    (%rax),%edi
call   1050 <UIerror@plt>
jmp    12b7 <UI_dup_input_boolean+0x177>
jmp    11bf <UI_dup_input_boolean+0x7f>
cmpq   $0x0,-0x20(%rbp)
je     11fa <UI_dup_input_boolean+0xba>
mov    -0x20(%rbp),%rdi
call   1060 <strdup@plt>
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x48(%rbp)
jne    11f5 <UI_dup_input_boolean+0xb5>
mov    0x2dff(%rip),%rax
mov    (%rax),%edi
call   1050 <UIerror@plt>
jmp    12b7 <UI_dup_input_boolean+0x177>
jmp    11fa <UI_dup_input_boolean+0xba>
cmpq   $0x0,-0x28(%rbp)
je     1235 <UI_dup_input_boolean+0xf5>
mov    -0x28(%rbp),%rdi
call   1060 <strdup@plt>
mov    %rax,-0x50(%rbp)
cmpq   $0x0,-0x50(%rbp)
jne    1230 <UI_dup_input_boolean+0xf0>
mov    0x2dc4(%rip),%rax
mov    (%rax),%edi
call   1050 <UIerror@plt>
jmp    12b7 <UI_dup_input_boolean+0x177>
jmp    1235 <UI_dup_input_boolean+0xf5>
cmpq   $0x0,-0x30(%rbp)
je     1270 <UI_dup_input_boolean+0x130>
mov    -0x30(%rbp),%rdi
call   1060 <strdup@plt>
mov    %rax,-0x58(%rbp)
cmpq   $0x0,-0x58(%rbp)
jne    126b <UI_dup_input_boolean+0x12b>
mov    0x2d89(%rip),%rax
mov    (%rax),%edi
call   1050 <UIerror@plt>
jmp    12b7 <UI_dup_input_boolean+0x177>
jmp    1270 <UI_dup_input_boolean+0x130>
mov    -0x10(%rbp),%rdi
mov    -0x40(%rbp),%rsi
mov    -0x48(%rbp),%rdx
mov    -0x50(%rbp),%rcx
mov    -0x58(%rbp),%r8
mov    0x2d4d(%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    12e2 <UI_dup_input_boolean+0x1a2>
mov    -0x40(%rbp),%rdi
call   1040 <free@plt>
mov    -0x48(%rbp),%rdi
call   1040 <free@plt>
mov    -0x50(%rbp),%rdi
call   1040 <free@plt>
mov    -0x58(%rbp),%rdi
call   1040 <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,%r13d
mov    %r8,%r14
mov    %rcx,%r12
mov    %rdx,%rbp
mov    %rdi,%rbx
test   %rsi,%rsi
je     1177 <UI_dup_input_boolean+0x37>
mov    %rsi,%rdi
call   1060 <strdup@plt>
mov    %rax,%r15
test   %rax,%rax
jne    117a <UI_dup_input_boolean+0x3a>
xor    %r15d,%r15d
jmp    11c5 <UI_dup_input_boolean+0x85>
xor    %r15d,%r15d
test   %rbp,%rbp
mov    %r13,0x10(%rsp)
mov    %rbx,0x8(%rsp)
je     1202 <UI_dup_input_boolean+0xc2>
mov    %rbp,%rdi
call   1060 <strdup@plt>
mov    %rax,%r13
test   %rax,%rax
je     11c5 <UI_dup_input_boolean+0x85>
test   %r12,%r12
je     120a <UI_dup_input_boolean+0xca>
mov    %r12,%rdi
call   1060 <strdup@plt>
mov    %rax,%rbx
test   %rax,%rax
je     11c8 <UI_dup_input_boolean+0x88>
test   %r14,%r14
je     1211 <UI_dup_input_boolean+0xd1>
mov    %r14,%rdi
call   1060 <strdup@plt>
mov    %rax,%r8
test   %rax,%rax
jne    1214 <UI_dup_input_boolean+0xd4>
jmp    11ca <UI_dup_input_boolean+0x8a>
xor    %r13d,%r13d
xor    %ebx,%ebx
mov    0x2e17(%rip),%rax
mov    (%rax),%edi
call   1050 <UIerror@plt>
mov    %r15,%rdi
call   1040 <free@plt>
mov    %r13,%rdi
call   1040 <free@plt>
mov    %rbx,%rdi
call   1040 <free@plt>
xor    %edi,%edi
call   1040 <free@plt>
mov    $0xffffffff,%eax
add    $0x18,%rsp
jmp    1247 <UI_dup_input_boolean+0x107>
xor    %r13d,%r13d
test   %r12,%r12
jne    119e <UI_dup_input_boolean+0x5e>
xor    %ebx,%ebx
test   %r14,%r14
jne    11b3 <UI_dup_input_boolean+0x73>
xor    %r8d,%r8d
mov    0x2dbd(%rip),%rax
mov    (%rax),%eax
sub    $0x8,%rsp
mov    0x10(%rsp),%rdi
mov    %r15,%rsi
mov    %r13,%rdx
mov    %rbx,%rcx
mov    $0x1,%r9d
push   0x58(%rsp)
push   0x20(%rsp)
push   %rax
call   1030 <general_allocate_boolean@plt>
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@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 %31
22: ; preds = %7
%23 = load i8*, i8** %10
%24 = call i8* @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 %30
27: ; preds = %22
%28 = load i32, i32* @ERR_R_MALLOC_FAILURE
%29 = call i32 @UIerror(i32 %28)
br label %77
30: ; preds = %22
br label %31
31: ; preds = %30, %7
%32 = load i8*, i8** %11
%33 = icmp ne i8* %32, null
br i1 %33, label %34, label %43
34: ; preds = %31
%35 = load i8*, i8** %11
%36 = call i8* @strdup(i8* %35)
store i8* %36, i8** %17
%37 = load i8*, i8** %17
%38 = icmp eq i8* %37, null
br i1 %38, label %39, label %42
39: ; preds = %34
%40 = load i32, i32* @ERR_R_MALLOC_FAILURE
%41 = call i32 @UIerror(i32 %40)
br label %77
42: ; preds = %34
br label %43
43: ; preds = %42, %31
%44 = load i8*, i8** %12
%45 = icmp ne i8* %44, null
br i1 %45, label %46, label %55
46: ; preds = %43
%47 = load i8*, i8** %12
%48 = call i8* @strdup(i8* %47)
store i8* %48, i8** %18
%49 = load i8*, i8** %18
%50 = icmp eq i8* %49, null
br i1 %50, label %51, label %54
51: ; preds = %46
%52 = load i32, i32* @ERR_R_MALLOC_FAILURE
%53 = call i32 @UIerror(i32 %52)
br label %77
54: ; preds = %46
br label %55
55: ; preds = %54, %43
%56 = load i8*, i8** %13
%57 = icmp ne i8* %56, null
br i1 %57, label %58, label %67
58: ; preds = %55
%59 = load i8*, i8** %13
%60 = call i8* @strdup(i8* %59)
store i8* %60, i8** %19
%61 = load i8*, i8** %19
%62 = icmp eq i8* %61, null
br i1 %62, label %63, label %66
63: ; preds = %58
%64 = load i32, i32* @ERR_R_MALLOC_FAILURE
%65 = call i32 @UIerror(i32 %64)
br label %77
66: ; preds = %58
br label %67
67: ; preds = %66, %55
%68 = load i32*, i32** %9
%69 = load i8*, i8** %16
%70 = load i8*, i8** %17
%71 = load i8*, i8** %18
%72 = load i8*, i8** %19
%73 = load i32, i32* @UIT_BOOLEAN
%74 = load i32, i32* %14
%75 = load i8*, i8** %15
%76 = call i32 @general_allocate_boolean(i32* %68, i8* %69, i8* %70, i8* %71, i8* %72, i32 1, i32 %73, i32 %74, i8* %75)
store i32 %76, i32* %8
br label %86
77: ; preds = %63, %51, %39, %27
%78 = load i8*, i8** %16
%79 = call i32 @free(i8* %78)
%80 = load i8*, i8** %17
%81 = call i32 @free(i8* %80)
%82 = load i8*, i8** %18
%83 = call i32 @free(i8* %82)
%84 = load i8*, i8** %19
%85 = call i32 @free(i8* %84)
store i32 -1, i32* %8
br label %86
86: ; preds = %77, %67
%87 = load i32, i32* %8
ret i32 %87
}

LLVM IR (-O2):
@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 %12, label %9
9: ; preds = %7
%10 = tail call i8* @strdup(i8* %1)
%11 = icmp eq i8* %10, null
br i1 %11, label %34, label %12
12: ; preds = %9, %7
%13 = phi i8* [ %10, %9 ], [ null, %7 ]
%14 = icmp eq i8* %2, null
br i1 %14, label %18, label %15
15: ; preds = %12
%16 = tail call i8* @strdup(i8* %2)
%17 = icmp eq i8* %16, null
br i1 %17, label %34, label %18
18: ; preds = %15, %12
%19 = phi i8* [ %16, %15 ], [ null, %12 ]
%20 = icmp eq i8* %3, null
br i1 %20, label %24, label %21
21: ; preds = %18
%22 = tail call i8* @strdup(i8* %3)
%23 = icmp eq i8* %22, null
br i1 %23, label %34, label %24
24: ; preds = %21, %18
%25 = phi i8* [ %22, %21 ], [ null, %18 ]
%26 = icmp eq i8* %4, null
br i1 %26, label %30, label %27
27: ; preds = %24
%28 = tail call i8* @strdup(i8* %4)
%29 = icmp eq i8* %28, null
br i1 %29, label %34, label %30
30: ; preds = %27, %24
%31 = phi i8* [ %28, %27 ], [ null, %24 ]
%32 = load i32, i32* @UIT_BOOLEAN
%33 = tail call i32 @general_allocate_boolean(i32* %0, i8* %13, i8* %19, i8* %25, i8* %31, i32 1, i32 %32, i32 %5, i8* %6)
br label %44
34: ; preds = %27, %21, %15, %9
%35 = phi i8* [ null, %9 ], [ %13, %15 ], [ %13, %21 ], [ %13, %27 ]
%36 = phi i8* [ null, %9 ], [ null, %15 ], [ %19, %21 ], [ %19, %27 ]
%37 = phi i8* [ null, %9 ], [ null, %15 ], [ null, %21 ], [ %25, %27 ]
%38 = load i32, i32* @ERR_R_MALLOC_FAILURE
%39 = tail call i32 @UIerror(i32 %38)
%40 = tail call i32 @free(i8* %35)
%41 = tail call i32 @free(i8* %36)
%42 = tail call i32 @free(i8* %37)
%43 = tail call i32 @free(i8* null)
br label %44
44: ; preds = %34, %30
%45 = phi i32 [ -1, %34 ], [ %33, %30 ]
ret i32 %45
}