#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*/ free(char **);
int /*<<< orphan*/ printf(char *, char *);
char **split(char *, char *);
int main(void) {
  char **result;
  char str[] = "1-0:0.0.1(132412515)\n1-0:0.2.3.4(654236517)\n";
  result = split(str, "()\n");
  for (size_t index = 0; *(result + index); index++) {
    printf("%s\n", *(result + index));
  }
  free(result);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x40(%rbp),%rdi
lea    0xea6(%rip),%rsi
mov    $0x2d,%edx
call   1060 <memcpy@plt>
lea    -0x40(%rbp),%rdi
lea    0xebe(%rip),%rsi
call   1050 <split@plt>
mov    %rax,-0x10(%rbp)
movq   $0x0,-0x48(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x48(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     11bc <main+0x7c>
mov    -0x10(%rbp),%rax
mov    -0x48(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xe8b(%rip),%rdi
call   1040 <printf@plt>
mov    -0x48(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x48(%rbp)
jmp    1180 <main+0x40>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x30,%rsp
movups 0xedd(%rip),%xmm0
movups %xmm0,0x1d(%rsp)
movaps 0xec4(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xea8(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    0xeca(%rip),%rsi
mov    %rsp,%rdi
call   1050 <split@plt>
mov    %rax,%r14
mov    (%rax),%rsi
test   %rsi,%rsi
je     11a4 <main+0x74>
mov    %r14,%rbx
add    $0x8,%rbx
lea    0xead(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r15,%rdi
call   1040 <printf@plt>
mov    (%rbx),%rsi
add    $0x8,%rbx
test   %rsi,%rsi
jne    1190 <main+0x60>
mov    %r14,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.main.str = [45 x i8] c"1-0:0.0.1(132412515)\0A1-0:0.2.3.4(654236517)\0A\00"
@.str = [4 x i8] c"()\0A\00"
@.str.1 = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8**
%3 = alloca [45 x i8]
%4 = alloca i64
store i32 0, i32* %1
%5 = bitcast [45 x i8]* %3 to i8*
%6 = getelementptr inbounds [45 x i8], [45 x i8]* %3, i64 0, i64 0
%7 = call i8** @split(i8* %6, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
store i8** %7, i8*** %2
store i64 0, i64* %4
br label %8
8: ; preds = %20, %0
%9 = load i8**, i8*** %2
%10 = load i64, i64* %4
%11 = getelementptr inbounds i8*, i8** %9, i64 %10
%12 = load i8*, i8** %11
%13 = icmp ne i8* %12, null
br i1 %13, label %14, label %23
14: ; preds = %8
%15 = load i8**, i8*** %2
%16 = load i64, i64* %4
%17 = getelementptr inbounds i8*, i8** %15, i64 %16
%18 = load i8*, i8** %17
%19 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %18)
br label %20
20: ; preds = %14
%21 = load i64, i64* %4
%22 = add i64 %21, 1
store i64 %22, i64* %4
br label %8
23: ; preds = %8
%24 = load i8**, i8*** %2
%25 = call i32 @free(i8** %24)
ret i32 0
}

LLVM IR (-O2):
@__const.main.str = [45 x i8] c"1-0:0.0.1(132412515)\0A1-0:0.2.3.4(654236517)\0A\00"
@.str = [4 x i8] c"()\0A\00"
@.str.1 = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca [45 x i8]
%2 = getelementptr inbounds [45 x i8], [45 x i8]* %1, i64 0, i64 0
%3 = call i8** @split(i8* %2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%4 = load i8*, i8** %3
%5 = icmp eq i8* %4, null
br i1 %5, label %6, label %8
6: ; preds = %8, %0
%7 = call i32 @free(i8** %3)
ret i32 0
8: ; preds = %0, %8
%9 = phi i8* [ %14, %8 ], [ %4, %0 ]
%10 = phi i64 [ %12, %8 ], [ 0, %0 ]
%11 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %9)
%12 = add i64 %10, 1
%13 = getelementptr inbounds i8*, i8** %3, i64 %12
%14 = load i8*, i8** %13
%15 = icmp eq i8* %14, null
br i1 %15, label %6, label %8
}