#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_INFO;
int /*<<< orphan*/ UIerror(int /*<<< orphan*/);
int general_allocate_string(int /*<<< orphan*/ *, char *, int,
                            int /*<<< orphan*/, int /*<<< orphan*/,
                            int /*<<< orphan*/ *, int /*<<< orphan*/,
                            int /*<<< orphan*/, int /*<<< orphan*/ *);
char *strdup(char const *);
int UI_dup_info_string(UI *ui, const char *text) {
  char *text_copy = NULL;
  if (text) {
    text_copy = strdup(text);
    if (text_copy == NULL) {
      UIerror(ERR_R_MALLOC_FAILURE);
      return -1;
    }
  }
  return general_allocate_string(ui, text_copy, 1, UIT_INFO, 0, NULL, 0, 0,
                                 NULL);
}


x86 assembly (clang, -O0):
<UI_dup_info_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     118a <UI_dup_info_string+0x5a>
mov    -0x18(%rbp),%rdi
call   1050 <strdup@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1185 <UI_dup_info_string+0x55>
mov    0x2e76(%rip),%rax
mov    (%rax),%edi
call   1030 <UIerror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11c8 <UI_dup_info_string+0x98>
jmp    118a <UI_dup_info_string+0x5a>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    0x2e3f(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%edx
xor    %r8d,%r8d
xor    %eax,%eax
mov    %eax,%r9d
movl   $0x0,(%rsp)
movl   $0x0,0x8(%rsp)
movq   $0x0,0x10(%rsp)
call   1040 <general_allocate_string@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<UI_dup_info_string>:
push   %rbx
mov    %rdi,%rbx
test   %rsi,%rsi
je     115e <UI_dup_info_string+0x2e>
mov    %rsi,%rdi
call   1050 <strdup@plt>
mov    %rax,%rsi
test   %rax,%rax
jne    1160 <UI_dup_info_string+0x30>
mov    0x2e98(%rip),%rax
mov    (%rax),%edi
call   1030 <UIerror@plt>
mov    $0xffffffff,%eax
pop    %rbx
ret
xor    %esi,%esi
mov    0x2e71(%rip),%rax
mov    (%rax),%ecx
sub    $0x8,%rsp
mov    %rbx,%rdi
mov    $0x1,%edx
xor    %r8d,%r8d
xor    %r9d,%r9d
push   $0x0
push   $0x0
push   $0x0
call   1040 <general_allocate_string@plt>
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@ERR_R_MALLOC_FAILURE = global i32 0
@UIT_INFO = global i32 0
define i32 @UI_dup_info_string(i32* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca i8*
store i32* %0, i32** %4
store i8* %1, i8** %5
store i8* null, i8** %6
%7 = load i8*, i8** %5
%8 = icmp ne i8* %7, null
br i1 %8, label %9, label %18
9: ; preds = %2
%10 = load i8*, i8** %5
%11 = call i8* @strdup(i8* %10)
store i8* %11, i8** %6
%12 = load i8*, i8** %6
%13 = icmp eq i8* %12, null
br i1 %13, label %14, label %17
14: ; preds = %9
%15 = load i32, i32* @ERR_R_MALLOC_FAILURE
%16 = call i32 @UIerror(i32 %15)
store i32 -1, i32* %3
br label %23
17: ; preds = %9
br label %18
18: ; preds = %17, %2
%19 = load i32*, i32** %4
%20 = load i8*, i8** %6
%21 = load i32, i32* @UIT_INFO
%22 = call i32 @general_allocate_string(i32* %19, i8* %20, i32 1, i32 %21, i32 0, i32* null, i32 0, i32 0, i32* null)
store i32 %22, i32* %3
br label %23
23: ; preds = %18, %14
%24 = load i32, i32* %3
ret i32 %24
}

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