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

/* Variables and functions */
char *_str_replace(char const *, char *, char *);
int /*<<< orphan*/ free(char *);
char *strdup(char *);
char *_fi_unparse_string(const char *hosts) {
  char *str1 = NULL;
  char *str2 = NULL;
  char *rv = NULL;
  if (!(str1 = _str_replace(hosts, "@l@", "[")))
    goto cleanup;
  if (!(str2 = _str_replace(str1, "@r@", "]")))
    goto cleanup;
  rv = strdup(str2);
cleanup:
  free(str1);
  free(str2);
  return (rv);
}


x86 assembly (clang, -O0):
<_fi_unparse_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xea1(%rip),%rsi
lea    0xe9e(%rip),%rdx
call   1040 <_str_replace@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
jne    117e <_fi_unparse_string+0x4e>
jmp    11b5 <_fi_unparse_string+0x85>
mov    -0x10(%rbp),%rdi
lea    0xe7d(%rip),%rsi
lea    0xe7a(%rip),%rdx
call   1040 <_str_replace@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    11a8 <_fi_unparse_string+0x78>
jmp    11b5 <_fi_unparse_string+0x85>
mov    -0x18(%rbp),%rdi
call   1050 <strdup@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x20(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_fi_unparse_string>:
push   %r15
push   %r14
push   %rbx
lea    0xec4(%rip),%rsi
lea    0xec1(%rip),%rdx
call   1040 <_str_replace@plt>
mov    %rax,%r14
test   %rax,%rax
je     117b <_fi_unparse_string+0x4b>
lea    0xeaf(%rip),%rsi
lea    0xeac(%rip),%rdx
mov    %r14,%rdi
call   1040 <_str_replace@plt>
test   %rax,%rax
je     117b <_fi_unparse_string+0x4b>
mov    %rax,%rbx
mov    %rax,%rdi
call   1050 <strdup@plt>
mov    %rax,%r15
jmp    1180 <_fi_unparse_string+0x50>
xor    %ebx,%ebx
xor    %r15d,%r15d
mov    %r14,%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r15,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [4 x i8] c"@l@\00"
@.str.1 = [2 x i8] c"[\00"
@.str.2 = [4 x i8] c"@r@\00"
@.str.3 = [2 x i8] c"]\00"
define i8* @_fi_unparse_string(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
store i8* %0, i8** %2
store i8* null, i8** %3
store i8* null, i8** %4
store i8* null, i8** %5
%6 = load i8*, i8** %2
%7 = call i8* @_str_replace(i8* %6, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i8* %7, i8** %3
%8 = icmp ne i8* %7, null
br i1 %8, label %10, label %9
9: ; preds = %1
br label %18
10: ; preds = %1
%11 = load i8*, i8** %3
%12 = call i8* @_str_replace(i8* %11, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i8* %12, i8** %4
%13 = icmp ne i8* %12, null
br i1 %13, label %15, label %14
14: ; preds = %10
br label %18
15: ; preds = %10
%16 = load i8*, i8** %4
%17 = call i8* @strdup(i8* %16)
store i8* %17, i8** %5
br label %18
18: ; preds = %15, %14, %9
%19 = load i8*, i8** %3
%20 = call i32 @free(i8* %19)
%21 = load i8*, i8** %4
%22 = call i32 @free(i8* %21)
%23 = load i8*, i8** %5
ret i8* %23
}

LLVM IR (-O2):
@.str = [4 x i8] c"@l@\00"
@.str.1 = [2 x i8] c"[\00"
@.str.2 = [4 x i8] c"@r@\00"
@.str.3 = [2 x i8] c"]\00"
define noalias i8* @_fi_unparse_string(i8* %0) {
%2 = tail call i8* @_str_replace(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%3 = icmp eq i8* %2, null
br i1 %3, label %9, label %4
4: ; preds = %1
%5 = tail call i8* @_str_replace(i8* %2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%6 = icmp eq i8* %5, null
br i1 %6, label %9, label %7
7: ; preds = %4
%8 = tail call i8* @strdup(i8* %5)
br label %9
9: ; preds = %4, %1, %7
%10 = phi i8* [ %5, %7 ], [ null, %4 ], [ null, %1 ]
%11 = phi i8* [ %8, %7 ], [ null, %4 ], [ null, %1 ]
%12 = tail call i32 @free(i8* %2)
%13 = tail call i32 @free(i8* %10)
ret i8* %11
}