#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*/ assert(int);
char **dirReduc(char **, int, int *);
int /*<<< orphan*/ free(char *);
char *joinStringsStringArray(char **, int);
int /*<<< orphan*/ printf(char *, char *, char *);
scalar_t__ strcmp(char *, char *);
void doTest(char **arr, int sz, char *expr) {
  int lg = -1;
  char **act = dirReduc(arr, sz, &lg);
  char *sact = joinStringsStringArray(act, lg);
  if (strcmp(sact, expr) != 0)
    printf("Expected:\n%s\nGot:\n%s\n", expr, sact);
  assert(strcmp(sact, expr) == 0);
  act = NULL;
  free(sact);
  sact = NULL;
}


x86 assembly (clang, -O0):
<doTest>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0xffffffff,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
lea    -0x1c(%rbp),%rdx
call   1080 <dirReduc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1040 <joinStringsStringArray@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
je     11c9 <doTest+0x69>
mov    -0x18(%rbp),%rsi
mov    -0x30(%rbp),%rdx
lea    0xe3c(%rip),%rdi
call   1050 <printf@plt>
mov    -0x30(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
movq   $0x0,-0x28(%rbp)
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x30(%rbp)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<doTest>:
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
movl   $0xffffffff,0x4(%rsp)
ff
lea    0x4(%rsp),%rdx
call   1080 <dirReduc@plt>
mov    0x4(%rsp),%esi
mov    %rax,%rdi
call   1040 <joinStringsStringArray@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r14,%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
je     11aa <doTest+0x4a>
lea    0xe61(%rip),%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1060 <strcmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1070 <assert@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [22 x i8] c"Expected:\0A%s\0AGot:\0A%s\0A\00"
define void @doTest(i8** %0, i32 %1, i8* %2) {
%4 = alloca i8**
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8**
%9 = alloca i8*
store i8** %0, i8*** %4
store i32 %1, i32* %5
store i8* %2, i8** %6
store i32 -1, i32* %7
%10 = load i8**, i8*** %4
%11 = load i32, i32* %5
%12 = call i8** @dirReduc(i8** %10, i32 %11, i32* %7)
store i8** %12, i8*** %8
%13 = load i8**, i8*** %8
%14 = load i32, i32* %7
%15 = call i8* @joinStringsStringArray(i8** %13, i32 %14)
store i8* %15, i8** %9
%16 = load i8*, i8** %9
%17 = load i8*, i8** %6
%18 = call i64 @strcmp(i8* %16, i8* %17)
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %24
20: ; preds = %3
%21 = load i8*, i8** %6
%22 = load i8*, i8** %9
%23 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %21, i8* %22)
br label %24
24: ; preds = %20, %3
%25 = load i8*, i8** %9
%26 = load i8*, i8** %6
%27 = call i64 @strcmp(i8* %25, i8* %26)
%28 = icmp eq i64 %27, 0
%29 = zext i1 %28 to i32
%30 = call i32 @assert(i32 %29)
store i8** null, i8*** %8
%31 = load i8*, i8** %9
%32 = call i32 @free(i8* %31)
store i8* null, i8** %9
ret void
}

LLVM IR (-O2):
@.str = [22 x i8] c"Expected:\0A%s\0AGot:\0A%s\0A\00"
define void @doTest(i8** %0, i32 %1, i8* %2) {
%4 = alloca i32
%5 = bitcast i32* %4 to i8*
store i32 -1, i32* %4
%6 = call i8** @dirReduc(i8** %0, i32 %1, i32* %4)
%7 = load i32, i32* %4
%8 = call i8* @joinStringsStringArray(i8** %6, i32 %7)
%9 = call i64 @strcmp(i8* %8, i8* %2)
%10 = icmp eq i64 %9, 0
br i1 %10, label %13, label %11
11: ; preds = %3
%12 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %2, i8* %8)
br label %13
13: ; preds = %11, %3
%14 = call i64 @strcmp(i8* %8, i8* %2)
%15 = icmp eq i64 %14, 0
%16 = zext i1 %15 to i32
%17 = call i32 @assert(i32 %16)
%18 = call i32 @free(i8* %8)
ret void
}