#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 ENOMEM;
int /*<<< orphan*/ free(char *);
char *strappend(char *, char const *);
int strv_push(char ***, char *);
int strv_extend_strv_concat(char ***a, char **b, const char *suffix) {
  int r;
  char **s;
  for ((s) = (b); (s) && *(s); (s)++) {
    char *v;
    v = strappend(*s, suffix);
    if (!v)
      return -ENOMEM;
    r = strv_push(a, v);
    if (r < 0) {
      free(v);
      return r;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<strv_extend_strv_concat>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x30(%rbp)
mov    %al,-0x39(%rbp)
je     116a <strv_extend_strv_concat+0x3a>
mov    -0x30(%rbp),%rax
cmpq   $0x0,(%rax)
setne  %al
mov    %al,-0x39(%rbp)
mov    -0x39(%rbp),%al
test   $0x1,%al
jne    117a <strv_extend_strv_concat+0x4a>
jmp    11f0 <strv_extend_strv_concat+0xc0>
mov    -0x30(%rbp),%rax
mov    (%rax),%rdi
mov    -0x20(%rbp),%rsi
call   1050 <strappend@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    11ac <strv_extend_strv_concat+0x7c>
xor    %eax,%eax
mov    0x2e3e(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x4(%rbp)
jmp    11f7 <strv_extend_strv_concat+0xc7>
mov    -0x10(%rbp),%rdi
mov    -0x38(%rbp),%rsi
call   1040 <strv_push@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jge    11da <strv_extend_strv_concat+0xaa>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11f7 <strv_extend_strv_concat+0xc7>
jmp    11df <strv_extend_strv_concat+0xaf>
mov    -0x30(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x30(%rbp)
jmp    114c <strv_extend_strv_concat+0x1c>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strv_extend_strv_concat>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %r14d,%r14d
test   %rsi,%rsi
je     11aa <strv_extend_strv_concat+0x7a>
mov    %rsi,%r13
mov    %rdi,%r12
mov    (%rsi),%rdi
test   %rdi,%rdi
je     11aa <strv_extend_strv_concat+0x7a>
mov    %rdx,%r15
add    $0x8,%r13
nopl   0x0(%rax,%rax,1)
mov    %r15,%rsi
call   1050 <strappend@plt>
test   %rax,%rax
je     118e <strv_extend_strv_concat+0x5e>
mov    %rax,%rbx
mov    %r12,%rdi
mov    %rax,%rsi
call   1040 <strv_push@plt>
test   %eax,%eax
js     119d <strv_extend_strv_concat+0x6d>
mov    0x0(%r13),%rdi
add    $0x8,%r13
test   %rdi,%rdi
jne    1160 <strv_extend_strv_concat+0x30>
jmp    11aa <strv_extend_strv_concat+0x7a>
mov    0x2e4b(%rip),%rax
xor    %r14d,%r14d
sub    (%rax),%r14d
jmp    11aa <strv_extend_strv_concat+0x7a>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %ebp,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@ENOMEM = global i32 0
define i32 @strv_extend_strv_concat(i8*** %0, i8** %1, i8* %2) {
%4 = alloca i32
%5 = alloca i8***
%6 = alloca i8**
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i8**
%10 = alloca i8*
store i8*** %0, i8**** %5
store i8** %1, i8*** %6
store i8* %2, i8** %7
%11 = load i8**, i8*** %6
store i8** %11, i8*** %9
br label %12
12: ; preds = %42, %3
%13 = load i8**, i8*** %9
%14 = icmp ne i8** %13, null
br i1 %14, label %15, label %19
15: ; preds = %12
%16 = load i8**, i8*** %9
%17 = load i8*, i8** %16
%18 = icmp ne i8* %17, null
br label %19
19: ; preds = %15, %12
%20 = phi i1 [ false, %12 ], [ %18, %15 ]
br i1 %20, label %21, label %45
21: ; preds = %19
%22 = load i8**, i8*** %9
%23 = load i8*, i8** %22
%24 = load i8*, i8** %7
%25 = call i8* @strappend(i8* %23, i8* %24)
store i8* %25, i8** %10
%26 = load i8*, i8** %10
%27 = icmp ne i8* %26, null
br i1 %27, label %31, label %28
28: ; preds = %21
%29 = load i32, i32* @ENOMEM
%30 = sub nsw i32 0, %29
store i32 %30, i32* %4
br label %46
31: ; preds = %21
%32 = load i8***, i8**** %5
%33 = load i8*, i8** %10
%34 = call i32 @strv_push(i8*** %32, i8* %33)
store i32 %34, i32* %8
%35 = load i32, i32* %8
%36 = icmp slt i32 %35, 0
br i1 %36, label %37, label %41
37: ; preds = %31
%38 = load i8*, i8** %10
%39 = call i32 @free(i8* %38)
%40 = load i32, i32* %8
store i32 %40, i32* %4
br label %46
41: ; preds = %31
br label %42
42: ; preds = %41
%43 = load i8**, i8*** %9
%44 = getelementptr inbounds i8*, i8** %43, i32 1
store i8** %44, i8*** %9
br label %12
45: ; preds = %19
store i32 0, i32* %4
br label %46
46: ; preds = %45, %37, %28
%47 = load i32, i32* %4
ret i32 %47
}

LLVM IR (-O2):
@ENOMEM = global i32 0
define i32 @strv_extend_strv_concat(i8*** %0, i8** %1, i8* %2) {
%4 = icmp eq i8** %1, null
br i1 %4, label %25, label %5
5: ; preds = %3
%6 = load i8*, i8** %1
%7 = icmp eq i8* %6, null
br i1 %7, label %25, label %11
8: ; preds = %19
%9 = load i8*, i8** %22
%10 = icmp eq i8* %9, null
br i1 %10, label %25, label %11
11: ; preds = %5, %8
%12 = phi i8* [ %9, %8 ], [ %6, %5 ]
%13 = phi i8** [ %22, %8 ], [ %1, %5 ]
%14 = tail call i8* @strappend(i8* %12, i8* %2)
%15 = icmp eq i8* %14, null
br i1 %15, label %16, label %19
16: ; preds = %11
%17 = load i32, i32* @ENOMEM
%18 = sub nsw i32 0, %17
br label %25
19: ; preds = %11
%20 = tail call i32 @strv_push(i8*** %0, i8* %14)
%21 = icmp slt i32 %20, 0
%22 = getelementptr inbounds i8*, i8** %13, i64 1
br i1 %21, label %23, label %8
23: ; preds = %19
%24 = tail call i32 @free(i8* %14)
br label %25
25: ; preds = %8, %5, %3, %16, %23
%26 = phi i32 [ %18, %16 ], [ %20, %23 ], [ 0, %3 ], [ 0, %5 ], [ 0, %8 ]
ret i32 %26
}