#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 */
int /*<<< orphan*/ append_char(unsigned char **, int *, int *, char);
int /*<<< orphan*/ append_string(unsigned char **, int *, int *, char *);
int /*<<< orphan*/ append_string_quoted(unsigned char **, int *, int *, char *);
scalar_t__ need_quotes(char *);
unsigned char *strdup(char *);
unsigned char *unparse_str_array(int arr_u, char **arr_v) {
  int i, a = 0, u = 0;
  unsigned char *t = NULL;
  if (arr_u <= 0 || !arr_v)
    return strdup("");
  for (i = 0; i < arr_u; ++i) {
    if (i > 0)
      append_char(&t, &a, &u, ' ');
    if (!arr_v[i]) {
      append_string(&t, &a, &u, "(null)");
    } else {
      if (need_quotes(arr_v[i])) {
        append_char(&t, &a, &u, '\"');
        append_string_quoted(&t, &a, &u, arr_v[i]);
        append_char(&t, &a, &u, '\"');
      } else {
        append_string(&t, &a, &u, arr_v[i]);
      }
    }
  }
  append_char(&t, &a, &u, 0);
  return t;
}


x86 assembly (clang, -O0):
<unparse_str_array>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0xc(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movq   $0x0,-0x30(%rbp)
cmpl   $0x0,-0xc(%rbp)
jle    118a <unparse_str_array+0x3a>
cmpq   $0x0,-0x18(%rbp)
jne    119f <unparse_str_array+0x4f>
lea    0xe75(%rip),%rdi
call   1060 <strdup@plt>
mov    %rax,-0x8(%rbp)
jmp    12bb <unparse_str_array+0x16b>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    12a0 <unparse_str_array+0x150>
cmpl   $0x0,-0x1c(%rbp)
jle    11d2 <unparse_str_array+0x82>
lea    -0x30(%rbp),%rdi
lea    -0x20(%rbp),%rsi
lea    -0x24(%rbp),%rdx
mov    $0x20,%ecx
call   1050 <append_char@plt>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
jne    1202 <unparse_str_array+0xb2>
lea    -0x30(%rbp),%rdi
lea    -0x20(%rbp),%rsi
lea    -0x24(%rbp),%rdx
lea    0xe08(%rip),%rcx
call   1030 <append_string@plt>
jmp    128d <unparse_str_array+0x13d>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1040 <need_quotes@plt>
cmp    $0x0,%rax
je     126b <unparse_str_array+0x11b>
lea    -0x30(%rbp),%rdi
lea    -0x20(%rbp),%rsi
lea    -0x24(%rbp),%rdx
mov    $0x22,%ecx
call   1050 <append_char@plt>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rcx
lea    -0x30(%rbp),%rdi
lea    -0x20(%rbp),%rsi
lea    -0x24(%rbp),%rdx
call   1070 <append_string_quoted@plt>
lea    -0x30(%rbp),%rdi
lea    -0x20(%rbp),%rsi
lea    -0x24(%rbp),%rdx
mov    $0x22,%ecx
call   1050 <append_char@plt>
jmp    1288 <unparse_str_array+0x138>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rcx
lea    -0x30(%rbp),%rdi
lea    -0x20(%rbp),%rsi
lea    -0x24(%rbp),%rdx
call   1030 <append_string@plt>
jmp    128d <unparse_str_array+0x13d>
jmp    1292 <unparse_str_array+0x142>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11a6 <unparse_str_array+0x56>
lea    -0x30(%rbp),%rdi
lea    -0x20(%rbp),%rsi
lea    -0x24(%rbp),%rdx
xor    %ecx,%ecx
call   1050 <append_char@plt>
mov    -0x30(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<unparse_str_array>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
movl   $0x0,0xc(%rsp)
movl   $0x0,0x8(%rsp)
movq   $0x0,0x10(%rsp)
test   %edi,%edi
jle    11e4 <unparse_str_array+0x94>
mov    %rsi,%r14
test   %rsi,%rsi
je     11e4 <unparse_str_array+0x94>
mov    %edi,%ebp
mov    (%r14),%rdi
test   %rdi,%rdi
je     11fe <unparse_str_array+0xae>
call   1040 <need_quotes@plt>
test   %rax,%rax
je     1207 <unparse_str_array+0xb7>
lea    0x10(%rsp),%rbx
lea    0xc(%rsp),%r15
lea    0x8(%rsp),%r12
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
mov    $0x22,%ecx
call   1050 <append_char@plt>
mov    (%r14),%rcx
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
call   1070 <append_string_quoted@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
mov    $0x22,%ecx
call   1050 <append_char@plt>
cmp    $0x1,%ebp
je     1223 <unparse_str_array+0xd3>
jmp    124d <unparse_str_array+0xfd>
lea    0xe1b(%rip),%rdi
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1060 <strdup@plt>
lea    0xdfb(%rip),%rcx
jmp    120a <unparse_str_array+0xba>
mov    (%r14),%rcx
lea    0x10(%rsp),%rdi
lea    0xc(%rsp),%rsi
lea    0x8(%rsp),%rdx
call   1030 <append_string@plt>
cmp    $0x1,%ebp
jne    124d <unparse_str_array+0xfd>
lea    0x10(%rsp),%rdi
lea    0xc(%rsp),%rsi
lea    0x8(%rsp),%rdx
xor    %ecx,%ecx
call   1050 <append_char@plt>
mov    0x10(%rsp),%rax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %ebp,%r13d
mov    $0x1,%r12d
lea    0x10(%rsp),%r15
lea    0xc(%rsp),%rbx
lea    0x8(%rsp),%rbp
jmp    128e <unparse_str_array+0x13e>
nopw   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %rbp,%rdx
lea    0xd80(%rip),%rcx
call   1030 <append_string@plt>
add    $0x1,%r12
cmp    %r12,%r13
je     1223 <unparse_str_array+0xd3>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %rbp,%rdx
mov    $0x20,%ecx
call   1050 <append_char@plt>
mov    (%r14,%r12,8),%rdi
test   %rdi,%rdi
je     1270 <unparse_str_array+0x120>
call   1040 <need_quotes@plt>
test   %rax,%rax
je     12f0 <unparse_str_array+0x1a0>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %rbp,%rdx
mov    $0x22,%ecx
call   1050 <append_char@plt>
mov    (%r14,%r12,8),%rcx
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %rbp,%rdx
call   1070 <append_string_quoted@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %rbp,%rdx
mov    $0x22,%ecx
call   1050 <append_char@plt>
jmp    1285 <unparse_str_array+0x135>
xchg   %ax,%ax
mov    (%r14,%r12,8),%rcx
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %rbp,%rdx
jmp    1280 <unparse_str_array+0x130>

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
@.str.1 = [7 x i8] c"(null)\00"
define i8* @unparse_str_array(i32 %0, i8** %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8*
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %7
store i32 0, i32* %8
store i8* null, i8** %9
%10 = load i32, i32* %4
%11 = icmp sle i32 %10, 0
br i1 %11, label %15, label %12
12: ; preds = %2
%13 = load i8**, i8*** %5
%14 = icmp ne i8** %13, null
br i1 %14, label %17, label %15
15: ; preds = %12, %2
%16 = call i8* @strdup(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
store i8* %16, i8** %3
br label %68
17: ; preds = %12
store i32 0, i32* %6
br label %18
18: ; preds = %62, %17
%19 = load i32, i32* %6
%20 = load i32, i32* %4
%21 = icmp slt i32 %19, %20
br i1 %21, label %22, label %65
22: ; preds = %18
%23 = load i32, i32* %6
%24 = icmp sgt i32 %23, 0
br i1 %24, label %25, label %27
25: ; preds = %22
%26 = call i32 @append_char(i8** %9, i32* %7, i32* %8, i8 signext 32)
br label %27
27: ; preds = %25, %22
%28 = load i8**, i8*** %5
%29 = load i32, i32* %6
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8*, i8** %28, i64 %30
%32 = load i8*, i8** %31
%33 = icmp ne i8* %32, null
br i1 %33, label %36, label %34
34: ; preds = %27
%35 = call i32 @append_string(i8** %9, i32* %7, i32* %8, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
br label %61
36: ; preds = %27
%37 = load i8**, i8*** %5
%38 = load i32, i32* %6
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i8*, i8** %37, i64 %39
%41 = load i8*, i8** %40
%42 = call i64 @need_quotes(i8* %41)
%43 = icmp ne i64 %42, 0
br i1 %43, label %44, label %53
44: ; preds = %36
%45 = call i32 @append_char(i8** %9, i32* %7, i32* %8, i8 signext 34)
%46 = load i8**, i8*** %5
%47 = load i32, i32* %6
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds i8*, i8** %46, i64 %48
%50 = load i8*, i8** %49
%51 = call i32 @append_string_quoted(i8** %9, i32* %7, i32* %8, i8* %50)
%52 = call i32 @append_char(i8** %9, i32* %7, i32* %8, i8 signext 34)
br label %60
53: ; preds = %36
%54 = load i8**, i8*** %5
%55 = load i32, i32* %6
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds i8*, i8** %54, i64 %56
%58 = load i8*, i8** %57
%59 = call i32 @append_string(i8** %9, i32* %7, i32* %8, i8* %58)
br label %60
60: ; preds = %53, %44
br label %61
61: ; preds = %60, %34
br label %62
62: ; preds = %61
%63 = load i32, i32* %6
%64 = add nsw i32 %63, 1
store i32 %64, i32* %6
br label %18
65: ; preds = %18
%66 = call i32 @append_char(i8** %9, i32* %7, i32* %8, i8 signext 0)
%67 = load i8*, i8** %9
store i8* %67, i8** %3
br label %68
68: ; preds = %65, %15
%69 = load i8*, i8** %3
ret i8* %69
}

LLVM IR (-O2):
@.str = [1 x i8] zeroinitializer
@.str.1 = [7 x i8] c"(null)\00"
define i8* @unparse_str_array(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
%6 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%7 = bitcast i32* %4 to i8*
store i32 0, i32* %4
%8 = bitcast i8** %5 to i8*
store i8* null, i8** %5
%9 = icmp sgt i32 %0, 0
%10 = icmp ne i8** %1, null
%11 = and i1 %9, %10
br i1 %11, label %12, label %31
12: ; preds = %2
%13 = zext i32 %0 to i64
%14 = load i8*, i8** %1
%15 = icmp eq i8* %14, null
br i1 %15, label %27, label %16
16: ; preds = %12
%17 = call i64 @need_quotes(i8* %14)
%18 = icmp eq i64 %17, 0
br i1 %18, label %24, label %19
19: ; preds = %16
%20 = call i32 @append_char(i8** %5, i32* %3, i32* %4, i8 signext 34)
%21 = load i8*, i8** %1
%22 = call i32 @append_string_quoted(i8** %5, i32* %3, i32* %4, i8* %21)
%23 = call i32 @append_char(i8** %5, i32* %3, i32* %4, i8 signext 34)
br label %29
24: ; preds = %16
%25 = load i8*, i8** %1
%26 = call i32 @append_string(i8** %5, i32* %3, i32* %4, i8* %25)
br label %29
27: ; preds = %12
%28 = call i32 @append_string(i8** %5, i32* %3, i32* %4, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
br label %29
29: ; preds = %27, %24, %19
%30 = icmp eq i32 %0, 1
br i1 %30, label %55, label %33
31: ; preds = %2
%32 = tail call dereferenceable_or_null(1) i8* @strdup(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
br label %58
33: ; preds = %29, %52
%34 = phi i64 [ %53, %52 ], [ 1, %29 ]
%35 = call i32 @append_char(i8** %5, i32* %3, i32* %4, i8 signext 32)
%36 = getelementptr inbounds i8*, i8** %1, i64 %34
%37 = load i8*, i8** %36
%38 = icmp eq i8* %37, null
br i1 %38, label %39, label %41
39: ; preds = %33
%40 = call i32 @append_string(i8** %5, i32* %3, i32* %4, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
br label %52
41: ; preds = %33
%42 = call i64 @need_quotes(i8* %37)
%43 = icmp eq i64 %42, 0
br i1 %43, label %49, label %44
44: ; preds = %41
%45 = call i32 @append_char(i8** %5, i32* %3, i32* %4, i8 signext 34)
%46 = load i8*, i8** %36
%47 = call i32 @append_string_quoted(i8** %5, i32* %3, i32* %4, i8* %46)
%48 = call i32 @append_char(i8** %5, i32* %3, i32* %4, i8 signext 34)
br label %52
49: ; preds = %41
%50 = load i8*, i8** %36
%51 = call i32 @append_string(i8** %5, i32* %3, i32* %4, i8* %50)
br label %52
52: ; preds = %39, %49, %44
%53 = add nuw nsw i64 %34, 1
%54 = icmp eq i64 %53, %13
br i1 %54, label %55, label %33
55: ; preds = %52, %29
%56 = call i32 @append_char(i8** %5, i32* %3, i32* %4, i8 signext 0)
%57 = load i8*, i8** %5
br label %58
58: ; preds = %55, %31
%59 = phi i8* [ %57, %55 ], [ %32, %31 ]
ret i8* %59
}