#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 *strtok(char *, char *);
int split_path(char *s, char **p) {
  int i;
  for (i = 0; i < 8; i++) {
    p[i] = strtok((i == 0) ? s : NULL, "\\");
    if (p[i] == NULL) {
      break;
    }
  }
  return i;
}


x86 assembly (clang, -O0):
<split_path>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x8,-0x14(%rbp)
jge    119d <split_path+0x8d>
cmpl   $0x0,-0x14(%rbp)
jne    1148 <split_path+0x38>
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
jmp    1153 <split_path+0x43>
xor    %eax,%eax
mov    %rax,-0x20(%rbp)
jmp    1153 <split_path+0x43>
mov    -0x20(%rbp),%rdi
lea    0xea2(%rip),%rsi
call   1030 <strtok@plt>
mov    %rax,%rdx
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
jne    118a <split_path+0x7a>
jmp    119d <split_path+0x8d>
jmp    118f <split_path+0x7f>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1127 <split_path+0x17>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<split_path>:
push   %rbx
mov    %rsi,%rbx
lea    0xee5(%rip),%rsi
call   1030 <strtok@plt>
mov    %rax,(%rbx)
test   %rax,%rax
je     11de <split_path+0xce>
lea    0xecd(%rip),%rsi
xor    %edi,%edi
call   1030 <strtok@plt>
mov    %rax,0x8(%rbx)
test   %rax,%rax
je     11e2 <split_path+0xd2>
lea    0xeb2(%rip),%rsi
xor    %edi,%edi
call   1030 <strtok@plt>
mov    %rax,0x10(%rbx)
test   %rax,%rax
je     11e9 <split_path+0xd9>
lea    0xe97(%rip),%rsi
xor    %edi,%edi
call   1030 <strtok@plt>
mov    %rax,0x18(%rbx)
test   %rax,%rax
je     11f0 <split_path+0xe0>
lea    0xe80(%rip),%rsi
xor    %edi,%edi
call   1030 <strtok@plt>
mov    %rax,0x20(%rbx)
test   %rax,%rax
je     11f7 <split_path+0xe7>
lea    0xe69(%rip),%rsi
xor    %edi,%edi
call   1030 <strtok@plt>
mov    %rax,0x28(%rbx)
test   %rax,%rax
je     11fe <split_path+0xee>
lea    0xe52(%rip),%rsi
xor    %edi,%edi
call   1030 <strtok@plt>
mov    %rax,0x30(%rbx)
test   %rax,%rax
je     1205 <split_path+0xf5>
lea    0xe3b(%rip),%rsi
xor    %edi,%edi
call   1030 <strtok@plt>
mov    %rax,0x38(%rbx)
cmp    $0x1,%rax
mov    $0x8,%eax
sbb    $0x0,%eax
pop    %rbx
ret
xor    %eax,%eax
pop    %rbx
ret
mov    $0x1,%eax
pop    %rbx
ret
mov    $0x2,%eax
pop    %rbx
ret
mov    $0x3,%eax
pop    %rbx
ret
mov    $0x4,%eax
pop    %rbx
ret
mov    $0x5,%eax
pop    %rbx
ret
mov    $0x6,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [2 x i8] c"\\\00"
define i32 @split_path(i8* %0, i8** %1) {
%3 = alloca i8*
%4 = alloca i8**
%5 = alloca i32
store i8* %0, i8** %3
store i8** %1, i8*** %4
store i32 0, i32* %5
br label %6
6: ; preds = %30, %2
%7 = load i32, i32* %5
%8 = icmp slt i32 %7, 8
br i1 %8, label %9, label %33
9: ; preds = %6
%10 = load i32, i32* %5
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %9
%13 = load i8*, i8** %3
br label %15
14: ; preds = %9
br label %15
15: ; preds = %14, %12
%16 = phi i8* [ %13, %12 ], [ null, %14 ]
%17 = call i8* @strtok(i8* %16, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%18 = load i8**, i8*** %4
%19 = load i32, i32* %5
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8*, i8** %18, i64 %20
store i8* %17, i8** %21
%22 = load i8**, i8*** %4
%23 = load i32, i32* %5
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8*, i8** %22, i64 %24
%26 = load i8*, i8** %25
%27 = icmp eq i8* %26, null
br i1 %27, label %28, label %29
28: ; preds = %15
br label %33
29: ; preds = %15
br label %30
30: ; preds = %29
%31 = load i32, i32* %5
%32 = add nsw i32 %31, 1
store i32 %32, i32* %5
br label %6
33: ; preds = %28, %6
%34 = load i32, i32* %5
ret i32 %34
}

LLVM IR (-O2):
@.str = [2 x i8] c"\\\00"
define i32 @split_path(i8* %0, i8** nocapture writeonly %1) {
%3 = tail call i8* @strtok(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %3, i8** %1
%4 = icmp eq i8* %3, null
br i1 %4, label %34, label %5
5: ; preds = %2
%6 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%7 = getelementptr inbounds i8*, i8** %1, i64 1
store i8* %6, i8** %7
%8 = icmp eq i8* %6, null
br i1 %8, label %34, label %9
9: ; preds = %5
%10 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%11 = getelementptr inbounds i8*, i8** %1, i64 2
store i8* %10, i8** %11
%12 = icmp eq i8* %10, null
br i1 %12, label %34, label %13
13: ; preds = %9
%14 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%15 = getelementptr inbounds i8*, i8** %1, i64 3
store i8* %14, i8** %15
%16 = icmp eq i8* %14, null
br i1 %16, label %34, label %17
17: ; preds = %13
%18 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%19 = getelementptr inbounds i8*, i8** %1, i64 4
store i8* %18, i8** %19
%20 = icmp eq i8* %18, null
br i1 %20, label %34, label %21
21: ; preds = %17
%22 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%23 = getelementptr inbounds i8*, i8** %1, i64 5
store i8* %22, i8** %23
%24 = icmp eq i8* %22, null
br i1 %24, label %34, label %25
25: ; preds = %21
%26 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%27 = getelementptr inbounds i8*, i8** %1, i64 6
store i8* %26, i8** %27
%28 = icmp eq i8* %26, null
br i1 %28, label %34, label %29
29: ; preds = %25
%30 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%31 = getelementptr inbounds i8*, i8** %1, i64 7
store i8* %30, i8** %31
%32 = icmp eq i8* %30, null
%33 = select i1 %32, i32 7, i32 8
br label %34
34: ; preds = %29, %25, %21, %17, %13, %9, %5, %2
%35 = phi i32 [ 0, %2 ], [ 1, %5 ], [ 2, %9 ], [ 3, %13 ], [ 4, %17 ], [ 5, %21 ], [ 6, %25 ], [ %33, %29 ]
ret i32 %35
}