#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*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ free(char *);
scalar_t__ malloc(int);
int /*<<< orphan*/ sprintf(char *, char *, char *);
int /*<<< orphan*/ stderr;
char *strtok_r(char *, char *, char **);
main() {
  char *str[6] = {"2..9", "0..-1", "24", "-2", "-23..-7", "-23..32"};
  char *save_ptr, *token;
  int i;
  char *temp = (char *)malloc(20);
  for (i = 0; i < 6; i++) {
    fprintf(stderr, "str[%d] = %s\n", i, str[i]);
    sprintf(temp, "%s", str[i]);
    token = strtok_r(temp, "..", &save_ptr);
    while (token != NULL) {
      fprintf(stderr, "\ttoken = %s\n", token);
      token = strtok_r(NULL, "..", &save_ptr);
    }
  }
  free(temp);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x30,%edx
call   1040 <memset@plt>
lea    0xe7a(%rip),%rax
mov    %rax,-0x40(%rbp)
lea    0xe74(%rip),%rax
mov    %rax,-0x38(%rbp)
lea    0xe6f(%rip),%rax
mov    %rax,-0x30(%rbp)
lea    0xe67(%rip),%rax
mov    %rax,-0x28(%rbp)
lea    0xe5f(%rip),%rax
mov    %rax,-0x20(%rbp)
lea    0xe5c(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    $0x14,%edi
call   1070 <malloc@plt>
mov    %rax,-0x60(%rbp)
movl   $0x0,-0x54(%rbp)
cmpl   $0x6,-0x54(%rbp)
jge    128a <main+0x12a>
mov    0x2df9(%rip),%rax
mov    (%rax),%edi
mov    -0x54(%rbp),%edx
movslq -0x54(%rbp),%rax
mov    -0x40(%rbp,%rax,8),%rcx
lea    0xe25(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x60(%rbp),%rdi
movslq -0x54(%rbp),%rax
mov    -0x40(%rbp,%rax,8),%rdx
lea    0xe18(%rip),%rsi
call   1080 <sprintf@plt>
mov    -0x60(%rbp),%rdi
lea    0xe0b(%rip),%rsi
lea    -0x48(%rbp),%rdx
call   1050 <strtok_r@plt>
mov    %rax,-0x50(%rbp)
cmpq   $0x0,-0x50(%rbp)
je     1277 <main+0x117>
mov    0x2d9a(%rip),%rax
mov    (%rax),%edi
mov    -0x50(%rbp),%rdx
lea    0xde2(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
xor    %eax,%eax
mov    %eax,%edi
lea    0xdcd(%rip),%rsi
lea    -0x48(%rbp),%rdx
call   1050 <strtok_r@plt>
mov    %rax,-0x50(%rbp)
jmp    1234 <main+0xd4>
jmp    127c <main+0x11c>
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    11d6 <main+0x76>
mov    -0x60(%rbp),%rdi
call   1030 <free@plt>
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
lea    0xe9b(%rip),%r14
mov    %r14,0x10(%rsp)
lea    0xe94(%rip),%rax
mov    %rax,0x18(%rsp)
lea    0xe8e(%rip),%rax
mov    %rax,0x20(%rsp)
lea    0xe85(%rip),%rax
mov    %rax,0x28(%rsp)
lea    0xe7c(%rip),%rax
mov    %rax,0x30(%rsp)
lea    0xe78(%rip),%rax
mov    %rax,0x38(%rsp)
mov    $0x14,%edi
call   1070 <malloc@plt>
mov    %rax,0x8(%rsp)
mov    0x2e24(%rip),%r15
lea    0xe6c(%rip),%r12
lea    0x40(%rsp),%rbx
lea    0xe63(%rip),%r13
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    (%r15),%edi
lea    0xe37(%rip),%rsi
mov    %ebp,%edx
mov    %r14,%rcx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    %r14,%rsi
mov    0x8(%rsp),%r14
mov    %r14,%rdi
call   1040 <strcpy@plt>
mov    %r14,%rdi
nopl   0x0(%rax)
mov    %r12,%rsi
mov    %rbx,%rdx
call   1050 <strtok_r@plt>
test   %rax,%rax
je     1240 <main+0xf0>
mov    (%r15),%edi
mov    %r13,%rsi
mov    %rax,%rdx
xor    %eax,%eax
call   1060 <fprintf@plt>
xor    %edi,%edi
jmp    1210 <main+0xc0>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%rbp
cmp    $0x6,%rbp
je     1251 <main+0x101>
mov    0x10(%rsp,%rbp,8),%r14
jmp    11e0 <main+0x90>
mov    0x8(%rsp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"2..9\00"
@.str.1 = [6 x i8] c"0..-1\00"
@.str.2 = [3 x i8] c"24\00"
@.str.3 = [3 x i8] c"-2\00"
@.str.4 = [8 x i8] c"-23..-7\00"
@.str.5 = [8 x i8] c"-23..32\00"
@stderr = global i32 0
@.str.6 = [14 x i8] c"str[%d] = %s\0A\00"
@.str.7 = [3 x i8] c"%s\00"
@.str.8 = [3 x i8] c"..\00"
@.str.9 = [13 x i8] c"\09token = %s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [6 x i8*]
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i8*
store i32 0, i32* %1
%7 = bitcast [6 x i8*]* %2 to i8*
%8 = bitcast i8* %7 to [6 x i8*]*
%9 = getelementptr inbounds [6 x i8*], [6 x i8*]* %8, i32 0, i32 0
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i32 0, i32 0), i8** %9
%10 = getelementptr inbounds [6 x i8*], [6 x i8*]* %8, i32 0, i32 1
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i32 0, i32 0), i8** %10
%11 = getelementptr inbounds [6 x i8*], [6 x i8*]* %8, i32 0, i32 2
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i32 0, i32 0), i8** %11
%12 = getelementptr inbounds [6 x i8*], [6 x i8*]* %8, i32 0, i32 3
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i32 0, i32 0), i8** %12
%13 = getelementptr inbounds [6 x i8*], [6 x i8*]* %8, i32 0, i32 4
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i32 0, i32 0), i8** %13
%14 = getelementptr inbounds [6 x i8*], [6 x i8*]* %8, i32 0, i32 5
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i32 0, i32 0), i8** %14
%15 = call i64 @malloc(i32 20)
%16 = inttoptr i64 %15 to i8*
store i8* %16, i8** %6
store i32 0, i32* %5
br label %17
17: ; preds = %45, %0
%18 = load i32, i32* %5
%19 = icmp slt i32 %18, 6
br i1 %19, label %20, label %48
20: ; preds = %17
%21 = load i32, i32* @stderr
%22 = load i32, i32* %5
%23 = load i32, i32* %5
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [6 x i8*], [6 x i8*]* %2, i64 0, i64 %24
%26 = load i8*, i8** %25
%27 = call i32 (i32, i8*, ...) @fprintf(i32 %21, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0), i32 %22, i8* %26)
%28 = load i8*, i8** %6
%29 = load i32, i32* %5
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [6 x i8*], [6 x i8*]* %2, i64 0, i64 %30
%32 = load i8*, i8** %31
%33 = call i32 @sprintf(i8* %28, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i8* %32)
%34 = load i8*, i8** %6
%35 = call i8* @strtok_r(i8* %34, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i8** %3)
store i8* %35, i8** %4
br label %36
36: ; preds = %39, %20
%37 = load i8*, i8** %4
%38 = icmp ne i8* %37, null
br i1 %38, label %39, label %44
39: ; preds = %36
%40 = load i32, i32* @stderr
%41 = load i8*, i8** %4
%42 = call i32 (i32, i8*, ...) @fprintf(i32 %40, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.9, i64 0, i64 0), i8* %41)
%43 = call i8* @strtok_r(i8* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i8** %3)
store i8* %43, i8** %4
br label %36
44: ; preds = %36
br label %45
45: ; preds = %44
%46 = load i32, i32* %5
%47 = add nsw i32 %46, 1
store i32 %47, i32* %5
br label %17
48: ; preds = %17
%49 = load i8*, i8** %6
%50 = call i32 @free(i8* %49)
%51 = load i32, i32* %1
ret i32 %51
}

LLVM IR (-O2):
@.str = [5 x i8] c"2..9\00"
@.str.1 = [6 x i8] c"0..-1\00"
@.str.2 = [3 x i8] c"24\00"
@.str.3 = [3 x i8] c"-2\00"
@.str.4 = [8 x i8] c"-23..-7\00"
@.str.5 = [8 x i8] c"-23..32\00"
@stderr = global i32 0
@.str.6 = [14 x i8] c"str[%d] = %s\0A\00"
@.str.8 = [3 x i8] c"..\00"
@.str.9 = [13 x i8] c"\09token = %s\0A\00"
define i32 @main() {
%1 = alloca [6 x i8*]
%2 = alloca i8*
%3 = bitcast [6 x i8*]* %1 to i8*
%4 = getelementptr inbounds [6 x i8*], [6 x i8*]* %1, i64 0, i64 0
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8** %4
%5 = getelementptr inbounds [6 x i8*], [6 x i8*]* %1, i64 0, i64 1
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8** %5
%6 = getelementptr inbounds [6 x i8*], [6 x i8*]* %1, i64 0, i64 2
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8** %6
%7 = getelementptr inbounds [6 x i8*], [6 x i8*]* %1, i64 0, i64 3
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8** %7
%8 = getelementptr inbounds [6 x i8*], [6 x i8*]* %1, i64 0, i64 4
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i8** %8
%9 = getelementptr inbounds [6 x i8*], [6 x i8*]* %1, i64 0, i64 5
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i8** %9
%10 = bitcast i8** %2 to i8*
%11 = tail call i64 @malloc(i32 20)
%12 = inttoptr i64 %11 to i8*
br label %13
13: ; preds = %31, %0
%14 = phi i8* [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), %0 ], [ %33, %31 ]
%15 = phi i64 [ 0, %0 ], [ %29, %31 ]
%16 = load i32, i32* @stderr
%17 = trunc i64 %15 to i32
%18 = call i32 (i32, i8*, ...) @fprintf(i32 %16, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0), i32 %17, i8* %14)
%19 = call i8* @strcpy(i8* dereferenceable(1) %12, i8* dereferenceable(1) %14)
%20 = call i8* @strtok_r(i8* %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i8** %2)
%21 = icmp eq i8* %20, null
br i1 %21, label %28, label %22
22: ; preds = %13, %22
%23 = phi i8* [ %26, %22 ], [ %20, %13 ]
%24 = load i32, i32* @stderr
%25 = call i32 (i32, i8*, ...) @fprintf(i32 %24, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.9, i64 0, i64 0), i8* %23)
%26 = call i8* @strtok_r(i8* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i8** %2)
%27 = icmp eq i8* %26, null
br i1 %27, label %28, label %22
28: ; preds = %22, %13
%29 = add nuw nsw i64 %15, 1
%30 = icmp eq i64 %29, 6
br i1 %30, label %34, label %31
31: ; preds = %28
%32 = getelementptr inbounds [6 x i8*], [6 x i8*]* %1, i64 0, i64 %29
%33 = load i8*, i8** %32
br label %13
34: ; preds = %28
%35 = call i32 @free(i8* %12)
ret i32 0
}