#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 */
char *find_char(char *, char *);
char *skip_char(char *, char *);
void split_line(char *s, char *d, int *n, char **v) {
  int m = 0;
  char *t;
  while (1) {
    s = skip_char(s, d);
    if (*s != '\0') {
      v[m++] = s;
      t = find_char(s, d);
      if (*t == '\0')
        goto end;
      else {
        s = t + 1;
        *t = '\0';
      }
    } else
      goto end;
  }
end:
  *n = m;
}


x86 assembly (clang, -O0):
<split_line>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <skip_char@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11b8 <split_line+0x98>
mov    -0x8(%rbp),%rdx
mov    -0x20(%rbp),%rax
mov    -0x24(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x24(%rbp)
movslq %ecx,%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <find_char@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    11a0 <split_line+0x80>
jmp    11c2 <split_line+0xa2>
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
mov    -0x30(%rbp),%rax
movb   $0x0,(%rax)
jmp    11bd <split_line+0x9d>
jmp    11c2 <split_line+0xa2>
jmp    113f <split_line+0x1f>
mov    -0x24(%rbp),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<split_line>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r15
mov    %rdx,%r14
mov    %rsi,%r12
call   1030 <skip_char@plt>
cmpb   $0x0,(%rax)
je     1177 <split_line+0x57>
xor    %ecx,%ecx
nopl   (%rax)
mov    %rcx,%rbx
mov    %rax,(%r15,%rcx,8)
mov    %rax,%rdi
mov    %r12,%rsi
call   1040 <find_char@plt>
cmpb   $0x0,(%rax)
je     1172 <split_line+0x52>
mov    %rax,%rdi
add    $0x1,%rdi
movb   $0x0,(%rax)
mov    %r12,%rsi
call   1030 <skip_char@plt>
lea    0x1(%rbx),%rcx
cmpb   $0x0,(%rax)
jne    1140 <split_line+0x20>
add    $0x1,%ebx
jmp    1179 <split_line+0x59>
xor    %ebx,%ebx
mov    %ebx,(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @split_line(i8* %0, i8* %1, i32* %2, i8** %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32*
%8 = alloca i8**
%9 = alloca i32
%10 = alloca i8*
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32* %2, i32** %7
store i8** %3, i8*** %8
store i32 0, i32* %9
br label %11
11: ; preds = %4, %40
%12 = load i8*, i8** %5
%13 = load i8*, i8** %6
%14 = call i8* @skip_char(i8* %12, i8* %13)
store i8* %14, i8** %5
%15 = load i8*, i8** %5
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %39
19: ; preds = %11
%20 = load i8*, i8** %5
%21 = load i8**, i8*** %8
%22 = load i32, i32* %9
%23 = add nsw i32 %22, 1
store i32 %23, i32* %9
%24 = sext i32 %22 to i64
%25 = getelementptr inbounds i8*, i8** %21, i64 %24
store i8* %20, i8** %25
%26 = load i8*, i8** %5
%27 = load i8*, i8** %6
%28 = call i8* @find_char(i8* %26, i8* %27)
store i8* %28, i8** %10
%29 = load i8*, i8** %10
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = icmp eq i32 %31, 0
br i1 %32, label %33, label %34
33: ; preds = %19
br label %41
34: ; preds = %19
%35 = load i8*, i8** %10
%36 = getelementptr inbounds i8, i8* %35, i64 1
store i8* %36, i8** %5
%37 = load i8*, i8** %10
store i8 0, i8* %37
br label %38
38: ; preds = %34
br label %40
39: ; preds = %11
br label %41
40: ; preds = %38
br label %11
41: ; preds = %39, %33
%42 = load i32, i32* %9
%43 = load i32*, i32** %7
store i32 %42, i32* %43
ret void
}

LLVM IR (-O2):
define void @split_line(i8* %0, i8* %1, i32* nocapture writeonly %2, i8** nocapture writeonly %3) {
%5 = tail call i8* @skip_char(i8* %0, i8* %1)
%6 = load i8, i8* %5
%7 = icmp eq i8 %6, 0
br i1 %7, label %23, label %8
8: ; preds = %4, %16
%9 = phi i64 [ %11, %16 ], [ 0, %4 ]
%10 = phi i8* [ %18, %16 ], [ %5, %4 ]
%11 = add nuw i64 %9, 1
%12 = getelementptr inbounds i8*, i8** %3, i64 %9
store i8* %10, i8** %12
%13 = tail call i8* @find_char(i8* %10, i8* %1)
%14 = load i8, i8* %13
%15 = icmp eq i8 %14, 0
br i1 %15, label %21, label %16
16: ; preds = %8
%17 = getelementptr inbounds i8, i8* %13, i64 1
store i8 0, i8* %13
%18 = tail call i8* @skip_char(i8* %17, i8* %1)
%19 = load i8, i8* %18
%20 = icmp eq i8 %19, 0
br i1 %20, label %21, label %8
21: ; preds = %16, %8
%22 = trunc i64 %11 to i32
br label %23
23: ; preds = %21, %4
%24 = phi i32 [ 0, %4 ], [ %22, %21 ]
store i32 %24, i32* %2
ret void
}