#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 omp_get_thread_num();
int /*<<< orphan*/ printf(char *, int, ...);
char *strtok(char *, char *);
void Tokenize(char *lines[], int line_count, int thread_count) {
  int my_rank, i, j;
  char *my_token;
#pragma omp parallel num_threads(thread_count) default(none) private(          \
    my_rank, i, j, my_token) shared(lines, line_count)
  {
    my_rank = omp_get_thread_num();
#pragma omp for schedule(static, 1)
    for (i = 0; i < line_count; i++) {
      printf("Thread %d > line %d = %s", my_rank, i, lines[i]);
      j = 0;
      my_token = strtok(lines[i], " \t\n");
      while (my_token != NULL) {
        printf("Thread %d > token %d = %s\n", my_rank, j, my_token);
        my_token = strtok(NULL, " \t\n");
        j++;
      }
      if (lines[i] != NULL)
        printf("Thread %d > After tokenizing, my line = %s\n", my_rank,
               lines[i]);
    }
  }
}


x86 assembly (clang, -O0):
<Tokenize>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    $0x0,%al
call   1030 <omp_get_thread_num@plt>
mov    %eax,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    122a <Tokenize+0xfa>
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rcx
lea    0xe88(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xe80(%rip),%rsi
call   1050 <strtok@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     11e7 <Tokenize+0xb7>
mov    -0x14(%rbp),%esi
mov    -0x1c(%rbp),%edx
mov    -0x28(%rbp),%rcx
lea    0xe5f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
lea    0xe49(%rip),%rsi
call   1050 <strtok@plt>
mov    %rax,-0x28(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11a2 <Tokenize+0x72>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     1217 <Tokenize+0xe7>
mov    -0x14(%rbp),%esi
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xe28(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    121c <Tokenize+0xec>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1153 <Tokenize+0x23>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Tokenize>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %rdi,%r15
xor    %eax,%eax
call   1030 <omp_get_thread_num@plt>
test   %ebx,%ebx
jle    11f0 <Tokenize+0xc0>
mov    %eax,%ebp
mov    %ebx,%eax
mov    %rax,(%rsp)
lea    0xebb(%rip),%rbx
lea    0xeb8(%rip),%r13
xor    %r12d,%r12d
jmp    117a <Tokenize+0x4a>
nopw   0x0(%rax,%rax,1)
add    $0x1,%r12
cmp    (%rsp),%r12
je     11f0 <Tokenize+0xc0>
mov    (%r15,%r12,8),%rcx
lea    0xe7b(%rip),%rdi
mov    %ebp,%esi
mov    %r12d,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%r15,%r12,8),%rdi
mov    %rbx,%rsi
call   1050 <strtok@plt>
test   %rax,%rax
je     11d5 <Tokenize+0xa5>
xor    %r14d,%r14d
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r13,%rdi
mov    %ebp,%esi
mov    %r14d,%edx
mov    %rax,%rcx
xor    %eax,%eax
call   1040 <printf@plt>
xor    %edi,%edi
mov    %rbx,%rsi
call   1050 <strtok@plt>
add    $0x1,%r14d
test   %rax,%rax
jne    11b0 <Tokenize+0x80>
mov    (%r15,%r12,8),%rdx
test   %rdx,%rdx
je     1170 <Tokenize+0x40>
lea    0xe53(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1170 <Tokenize+0x40>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [25 x i8] c"Thread %d > line %d = %s\00"
@.str.1 = [4 x i8] c" \09\0A\00"
@.str.2 = [27 x i8] c"Thread %d > token %d = %s\0A\00"
@.str.3 = [44 x i8] c"Thread %d > After tokenizing, my line = %s\0A\00"
define void @Tokenize(i8** %0, i32 %1, i32 %2) {
%4 = alloca i8**
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8*
store i8** %0, i8*** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%11 = call i32 (...) @omp_get_thread_num()
store i32 %11, i32* %7
store i32 0, i32* %8
br label %12
12: ; preds = %58, %3
%13 = load i32, i32* %8
%14 = load i32, i32* %5
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %61
16: ; preds = %12
%17 = load i32, i32* %7
%18 = load i32, i32* %8
%19 = load i8**, i8*** %4
%20 = load i32, i32* %8
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8*, i8** %19, i64 %21
%23 = load i8*, i8** %22
%24 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 %17, i32 %18, i8* %23)
store i32 0, i32* %9
%25 = load i8**, i8*** %4
%26 = load i32, i32* %8
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i8*, i8** %25, i64 %27
%29 = load i8*, i8** %28
%30 = call i8* @strtok(i8* %29, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
store i8* %30, i8** %10
br label %31
31: ; preds = %34, %16
%32 = load i8*, i8** %10
%33 = icmp ne i8* %32, null
br i1 %33, label %34, label %42
34: ; preds = %31
%35 = load i32, i32* %7
%36 = load i32, i32* %9
%37 = load i8*, i8** %10
%38 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i32 %35, i32 %36, i8* %37)
%39 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
store i8* %39, i8** %10
%40 = load i32, i32* %9
%41 = add nsw i32 %40, 1
store i32 %41, i32* %9
br label %31
42: ; preds = %31
%43 = load i8**, i8*** %4
%44 = load i32, i32* %8
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds i8*, i8** %43, i64 %45
%47 = load i8*, i8** %46
%48 = icmp ne i8* %47, null
br i1 %48, label %49, label %57
49: ; preds = %42
%50 = load i32, i32* %7
%51 = load i8**, i8*** %4
%52 = load i32, i32* %8
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds i8*, i8** %51, i64 %53
%55 = load i8*, i8** %54
%56 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.3, i64 0, i64 0), i32 %50, i8* %55)
br label %57
57: ; preds = %49, %42
br label %58
58: ; preds = %57
%59 = load i32, i32* %8
%60 = add nsw i32 %59, 1
store i32 %60, i32* %8
br label %12
61: ; preds = %12
ret void
}

LLVM IR (-O2):
@.str = [25 x i8] c"Thread %d > line %d = %s\00"
@.str.1 = [4 x i8] c" \09\0A\00"
@.str.2 = [27 x i8] c"Thread %d > token %d = %s\0A\00"
@.str.3 = [44 x i8] c"Thread %d > After tokenizing, my line = %s\0A\00"
define void @Tokenize(i8** nocapture %0, i32 %1, i32 %2) {
%4 = tail call i32 (...) @omp_get_thread_num()
%5 = icmp sgt i32 %1, 0
br i1 %5, label %6, label %32
6: ; preds = %3
%7 = zext i32 %1 to i64
br label %8
8: ; preds = %6, %29
%9 = phi i64 [ 0, %6 ], [ %30, %29 ]
%10 = getelementptr inbounds i8*, i8** %0, i64 %9
%11 = load i8*, i8** %10
%12 = trunc i64 %9 to i32
%13 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 %4, i32 %12, i8* %11)
%14 = load i8*, i8** %10
%15 = tail call i8* @strtok(i8* %14, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%16 = icmp eq i8* %15, null
br i1 %16, label %24, label %17
17: ; preds = %8, %17
%18 = phi i8* [ %21, %17 ], [ %15, %8 ]
%19 = phi i32 [ %22, %17 ], [ 0, %8 ]
%20 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i32 %4, i32 %19, i8* %18)
%21 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%22 = add nuw nsw i32 %19, 1
%23 = icmp eq i8* %21, null
br i1 %23, label %24, label %17
24: ; preds = %17, %8
%25 = load i8*, i8** %10
%26 = icmp eq i8* %25, null
br i1 %26, label %29, label %27
27: ; preds = %24
%28 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.3, i64 0, i64 0), i32 %4, i8* %25)
br label %29
29: ; preds = %24, %27
%30 = add nuw nsw i64 %9, 1
%31 = icmp eq i64 %30, %7
br i1 %31, label %32, label %8
32: ; preds = %29, %3
ret void
}