#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*/ printf(char *);
scalar_t__ strcmp(char *, char *);
char **strparse(char *, char *);
int test_strparse(void) {
  char **strv;
  printf("\tstrparse");
  strv = strparse("abc def:ghi alphabet-rhombus", " :");
  if (!strv)
    return 1;
  if (!strv[3] || strv[4])
    return 1;
  if (strcmp(strv[0], "abc"))
    return 1;
  if (strcmp(strv[1], "def"))
    return 1;
  if (strcmp(strv[2], "ghi"))
    return 1;
  if (strcmp(strv[3], "alphabet-rhombus"))
    return 1;
  printf("\tpassed.\n");
  return 0;
}


x86 assembly (clang, -O0):
<test_strparse>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xec1(%rip),%rdi
call   1030 <printf@plt>
lea    0xebf(%rip),%rdi
lea    0xed5(%rip),%rsi
call   1050 <strparse@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1172 <test_strparse+0x42>
movl   $0x1,-0x4(%rbp)
jmp    1256 <test_strparse+0x126>
mov    -0x10(%rbp),%rax
cmpq   $0x0,0x18(%rax)
je     1190 <test_strparse+0x60>
mov    -0x10(%rbp),%rax
cmpq   $0x0,0x20(%rax)
je     119c <test_strparse+0x6c>
movl   $0x1,-0x4(%rbp)
jmp    1256 <test_strparse+0x126>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xe80(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
je     11c5 <test_strparse+0x95>
movl   $0x1,-0x4(%rbp)
jmp    1256 <test_strparse+0x126>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe5a(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
je     11ef <test_strparse+0xbf>
movl   $0x1,-0x4(%rbp)
jmp    1256 <test_strparse+0x126>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe34(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
je     1219 <test_strparse+0xe9>
movl   $0x1,-0x4(%rbp)
jmp    1256 <test_strparse+0x126>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
lea    0xdee(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
je     1243 <test_strparse+0x113>
movl   $0x1,-0x4(%rbp)
jmp    1256 <test_strparse+0x126>
lea    0xdec(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_strparse>:
push   %rbp
push   %rbx
push   %rax
lea    0xeb6(%rip),%rdi
call   1040 <printf@plt>
lea    0xeb4(%rip),%rdi
lea    0xeca(%rip),%rsi
call   1060 <strparse@plt>
mov    $0x1,%ebp
test   %rax,%rax
je     11de <test_strparse+0x9e>
mov    %rax,%rbx
cmpq   $0x0,0x18(%rax)
je     11de <test_strparse+0x9e>
cmpq   $0x0,0x20(%rbx)
jne    11de <test_strparse+0x9e>
mov    (%rbx),%rdi
lea    0xea3(%rip),%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
jne    11de <test_strparse+0x9e>
mov    0x8(%rbx),%rdi
lea    0xe92(%rip),%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
jne    11de <test_strparse+0x9e>
mov    0x10(%rbx),%rdi
lea    0xe81(%rip),%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
jne    11de <test_strparse+0x9e>
mov    0x18(%rbx),%rdi
lea    0xe50(%rip),%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
jne    11de <test_strparse+0x9e>
lea    0xe5f(%rip),%rdi
call   1030 <puts@plt>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [10 x i8] c"\09strparse\00"
@.str.1 = [29 x i8] c"abc def:ghi alphabet-rhombus\00"
@.str.2 = [3 x i8] c" :\00"
@.str.3 = [4 x i8] c"abc\00"
@.str.4 = [4 x i8] c"def\00"
@.str.5 = [4 x i8] c"ghi\00"
@.str.6 = [17 x i8] c"alphabet-rhombus\00"
@.str.7 = [10 x i8] c"\09passed.\0A\00"
define i32 @test_strparse() {
%1 = alloca i32
%2 = alloca i8**
%3 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%4 = call i8** @strparse(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
store i8** %4, i8*** %2
%5 = load i8**, i8*** %2
%6 = icmp ne i8** %5, null
br i1 %6, label %8, label %7
7: ; preds = %0
store i32 1, i32* %1
br label %49
8: ; preds = %0
%9 = load i8**, i8*** %2
%10 = getelementptr inbounds i8*, i8** %9, i64 3
%11 = load i8*, i8** %10
%12 = icmp ne i8* %11, null
br i1 %12, label %13, label %18
13: ; preds = %8
%14 = load i8**, i8*** %2
%15 = getelementptr inbounds i8*, i8** %14, i64 4
%16 = load i8*, i8** %15
%17 = icmp ne i8* %16, null
br i1 %17, label %18, label %19
18: ; preds = %13, %8
store i32 1, i32* %1
br label %49
19: ; preds = %13
%20 = load i8**, i8*** %2
%21 = getelementptr inbounds i8*, i8** %20, i64 0
%22 = load i8*, i8** %21
%23 = call i64 @strcmp(i8* %22, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%24 = icmp ne i64 %23, 0
br i1 %24, label %25, label %26
25: ; preds = %19
store i32 1, i32* %1
br label %49
26: ; preds = %19
%27 = load i8**, i8*** %2
%28 = getelementptr inbounds i8*, i8** %27, i64 1
%29 = load i8*, i8** %28
%30 = call i64 @strcmp(i8* %29, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%31 = icmp ne i64 %30, 0
br i1 %31, label %32, label %33
32: ; preds = %26
store i32 1, i32* %1
br label %49
33: ; preds = %26
%34 = load i8**, i8*** %2
%35 = getelementptr inbounds i8*, i8** %34, i64 2
%36 = load i8*, i8** %35
%37 = call i64 @strcmp(i8* %36, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
%38 = icmp ne i64 %37, 0
br i1 %38, label %39, label %40
39: ; preds = %33
store i32 1, i32* %1
br label %49
40: ; preds = %33
%41 = load i8**, i8*** %2
%42 = getelementptr inbounds i8*, i8** %41, i64 3
%43 = load i8*, i8** %42
%44 = call i64 @strcmp(i8* %43, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0))
%45 = icmp ne i64 %44, 0
br i1 %45, label %46, label %47
46: ; preds = %40
store i32 1, i32* %1
br label %49
47: ; preds = %40
%48 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0))
store i32 0, i32* %1
br label %49
49: ; preds = %47, %46, %39, %32, %25, %18, %7
%50 = load i32, i32* %1
ret i32 %50
}

LLVM IR (-O2):
@.str = [10 x i8] c"\09strparse\00"
@.str.1 = [29 x i8] c"abc def:ghi alphabet-rhombus\00"
@.str.2 = [3 x i8] c" :\00"
@.str.3 = [4 x i8] c"abc\00"
@.str.4 = [4 x i8] c"def\00"
@.str.5 = [4 x i8] c"ghi\00"
@.str.6 = [17 x i8] c"alphabet-rhombus\00"
@str = [9 x i8] c"\09passed.\00"
define i32 @test_strparse() {
%1 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%2 = tail call i8** @strparse(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%3 = icmp eq i8** %2, null
br i1 %3, label %32, label %4
4: ; preds = %0
%5 = getelementptr inbounds i8*, i8** %2, i64 3
%6 = load i8*, i8** %5
%7 = icmp eq i8* %6, null
br i1 %7, label %32, label %8
8: ; preds = %4
%9 = getelementptr inbounds i8*, i8** %2, i64 4
%10 = load i8*, i8** %9
%11 = icmp eq i8* %10, null
br i1 %11, label %12, label %32
12: ; preds = %8
%13 = load i8*, i8** %2
%14 = tail call i64 @strcmp(i8* %13, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %32
16: ; preds = %12
%17 = getelementptr inbounds i8*, i8** %2, i64 1
%18 = load i8*, i8** %17
%19 = tail call i64 @strcmp(i8* %18, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %32
21: ; preds = %16
%22 = getelementptr inbounds i8*, i8** %2, i64 2
%23 = load i8*, i8** %22
%24 = tail call i64 @strcmp(i8* %23, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %32
26: ; preds = %21
%27 = load i8*, i8** %5
%28 = tail call i64 @strcmp(i8* %27, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0))
%29 = icmp eq i64 %28, 0
br i1 %29, label %30, label %32
30: ; preds = %26
%31 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str, i64 0, i64 0))
br label %32
32: ; preds = %26, %21, %16, %12, %4, %8, %0, %30
%33 = phi i32 [ 0, %30 ], [ 1, %0 ], [ 1, %8 ], [ 1, %4 ], [ 1, %12 ], [ 1, %16 ], [ 1, %21 ], [ 1, %26 ]
ret i32 %33
}