#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*/ printf(char *, char *);
char *strtok(char *, char const *);
int main() {
  char str[] = "Hello world - this is a string-hello!";
  const char s[] = "-";
  char *token;
  token = strtok(str, s);
  while (token != NULL) {
    printf("%s\n", token);
    token = strtok(NULL, s);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x30(%rbp),%rdi
lea    0xeb6(%rip),%rsi
mov    $0x26,%edx
call   1040 <memcpy@plt>
mov    0xecb(%rip),%ax
mov    %ax,-0x32(%rbp)
lea    -0x30(%rbp),%rdi
lea    -0x32(%rbp),%rsi
call   1050 <strtok@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
je     11a1 <main+0x71>
mov    -0x40(%rbp),%rsi
lea    0xea2(%rip),%rdi
call   1030 <printf@plt>
lea    -0x32(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edi
call   1050 <strtok@plt>
mov    %rax,-0x40(%rbp)
jmp    1170 <main+0x40>
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x38,%rsp
movaps 0xee2(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xec6(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movabs $0x216f6c6c65682d,%rax
mov    %rax,0x2e(%rsp)
movw   $0x2d,0xe(%rsp)
lea    0x10(%rsp),%rdi
lea    0xe(%rsp),%rsi
call   1040 <strtok@plt>
test   %rax,%rax
je     119a <main+0x7a>
lea    0xeb6(%rip),%r14
lea    0xe(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r14,%rdi
mov    %rax,%rsi
call   1030 <printf@plt>
xor    %edi,%edi
mov    %rbx,%rsi
call   1040 <strtok@plt>
test   %rax,%rax
jne    1180 <main+0x60>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.main.str = [38 x i8] c"Hello world - this is a string-hello!\00"
@__const.main.s = [2 x i8] c"-\00"
@.str = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [38 x i8]
%3 = alloca [2 x i8]
%4 = alloca i8*
store i32 0, i32* %1
%5 = bitcast [38 x i8]* %2 to i8*
%6 = bitcast [2 x i8]* %3 to i8*
%7 = getelementptr inbounds [38 x i8], [38 x i8]* %2, i64 0, i64 0
%8 = getelementptr inbounds [2 x i8], [2 x i8]* %3, i64 0, i64 0
%9 = call i8* @strtok(i8* %7, i8* %8)
store i8* %9, i8** %4
br label %10
10: ; preds = %13, %0
%11 = load i8*, i8** %4
%12 = icmp ne i8* %11, null
br i1 %12, label %13, label %18
13: ; preds = %10
%14 = load i8*, i8** %4
%15 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %14)
%16 = getelementptr inbounds [2 x i8], [2 x i8]* %3, i64 0, i64 0
%17 = call i8* @strtok(i8* null, i8* %16)
store i8* %17, i8** %4
br label %10
18: ; preds = %10
%19 = load i32, i32* %1
ret i32 %19
}

LLVM IR (-O2):
@__const.main.str = [38 x i8] c"Hello world - this is a string-hello!\00"
@.str = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca [38 x i8]
%2 = alloca i16
%3 = getelementptr inbounds [38 x i8], [38 x i8]* %1, i64 0, i64 0
%4 = bitcast i16* %2 to i8*
store i16 45, i16* %2
%5 = call i8* @strtok(i8* %3, i8* %4)
%6 = icmp eq i8* %5, null
br i1 %6, label %12, label %7
7: ; preds = %0, %7
%8 = phi i8* [ %10, %7 ], [ %5, %0 ]
%9 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = call i8* @strtok(i8* null, i8* %4)
%11 = icmp eq i8* %10, null
br i1 %11, label %12, label %7
12: ; preds = %7, %0
ret i32 0
}