#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 EDOM;
int ENOMEM;
int /*<<< orphan*/ free(char *);
char *linearray_to_str(char const **);
scalar_t__ strcmp(char *, char const *);
int test_linearray_to_str(const char **lines, const char *expectstr) {
  char *str = linearray_to_str(lines);
  if (!str)
    return -ENOMEM;
  if (strcmp(str, expectstr)) {
    free(str);
    return -EDOM;
  }
  free(str);
  return 0;
}


x86 assembly (clang, -O0):
<test_linearray_to_str>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <linearray_to_str@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    116b <test_linearray_to_str+0x3b>
xor    %eax,%eax
mov    0x2e77(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x4(%rbp)
jmp    11ae <test_linearray_to_str+0x7e>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
je     119e <test_linearray_to_str+0x6e>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
mov    0x2e54(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x4(%rbp)
jmp    11ae <test_linearray_to_str+0x7e>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_linearray_to_str>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
call   1050 <linearray_to_str@plt>
test   %rax,%rax
je     1168 <test_linearray_to_str+0x38>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r14,%rsi
call   1040 <strcmp@plt>
mov    %rax,%r14
mov    %rbx,%rdi
call   1030 <free@plt>
test   %r14,%r14
je     1175 <test_linearray_to_str+0x45>
mov    0x2e82(%rip),%rcx
jmp    116f <test_linearray_to_str+0x3f>
mov    0x2e69(%rip),%rcx
xor    %eax,%eax
sub    (%rcx),%eax
jmp    1177 <test_linearray_to_str+0x47>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@ENOMEM = global i32 0
@EDOM = global i32 0
define i32 @test_linearray_to_str(i8** %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i8*
%6 = alloca i8*
store i8** %0, i8*** %4
store i8* %1, i8** %5
%7 = load i8**, i8*** %4
%8 = call i8* @linearray_to_str(i8** %7)
store i8* %8, i8** %6
%9 = load i8*, i8** %6
%10 = icmp ne i8* %9, null
br i1 %10, label %14, label %11
11: ; preds = %2
%12 = load i32, i32* @ENOMEM
%13 = sub nsw i32 0, %12
store i32 %13, i32* %3
br label %27
14: ; preds = %2
%15 = load i8*, i8** %6
%16 = load i8*, i8** %5
%17 = call i64 @strcmp(i8* %15, i8* %16)
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %24
19: ; preds = %14
%20 = load i8*, i8** %6
%21 = call i32 @free(i8* %20)
%22 = load i32, i32* @EDOM
%23 = sub nsw i32 0, %22
store i32 %23, i32* %3
br label %27
24: ; preds = %14
%25 = load i8*, i8** %6
%26 = call i32 @free(i8* %25)
store i32 0, i32* %3
br label %27
27: ; preds = %24, %19, %11
%28 = load i32, i32* %3
ret i32 %28
}

LLVM IR (-O2):
@ENOMEM = global i32 0
@EDOM = global i32 0
define i32 @test_linearray_to_str(i8** %0, i8* %1) {
%3 = tail call i8* @linearray_to_str(i8** %0)
%4 = icmp eq i8* %3, null
br i1 %4, label %5, label %8
5: ; preds = %2
%6 = load i32, i32* @ENOMEM
%7 = sub nsw i32 0, %6
br label %15
8: ; preds = %2
%9 = tail call i64 @strcmp(i8* %3, i8* %1)
%10 = icmp eq i64 %9, 0
%11 = tail call i32 @free(i8* %3)
br i1 %10, label %15, label %12
12: ; preds = %8
%13 = load i32, i32* @EDOM
%14 = sub nsw i32 0, %13
br label %15
15: ; preds = %8, %12, %5
%16 = phi i32 [ %14, %12 ], [ %7, %5 ], [ 0, %8 ]
ret i32 %16
}