#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*/ puts(char *);
int /*<<< orphan*/ *strtok(char *, char *);
int main(void) {
  char buf[1] = {0};
  int result = 0;
  if (strtok(buf, " ") != NULL) {
    puts("first strtok call did not return NULL");
    result = 1;
  } else if (strtok(NULL, " ") != NULL) {
    puts("second strtok call did not return NULL");
    result = 1;
  }
  return result;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x5(%rbp),%rdi
xor    %esi,%esi
mov    $0x1,%edx
call   1040 <memset@plt>
movl   $0x0,-0xc(%rbp)
lea    -0x5(%rbp),%rdi
lea    0xe9f(%rip),%rsi
call   1050 <strtok@plt>
cmp    $0x0,%rax
je     1188 <main+0x58>
lea    0xe8b(%rip),%rdi
call   1030 <puts@plt>
movl   $0x1,-0xc(%rbp)
jmp    11ba <main+0x8a>
xor    %eax,%eax
mov    %eax,%edi
lea    0xe6d(%rip),%rsi
call   1050 <strtok@plt>
cmp    $0x0,%rax
je     11b5 <main+0x85>
lea    0xe7f(%rip),%rdi
call   1030 <puts@plt>
movl   $0x1,-0xc(%rbp)
jmp    11ba <main+0x8a>
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
movb   $0x0,0xf(%rsp)
lea    0xecf(%rip),%rsi
lea    0xf(%rsp),%rdi
call   1040 <strtok@plt>
test   %rax,%rax
je     1149 <main+0x29>
lea    0xebb(%rip),%rdi
jmp    1165 <main+0x45>
lea    0xeb0(%rip),%rsi
xor    %ebx,%ebx
xor    %edi,%edi
call   1040 <strtok@plt>
test   %rax,%rax
je     116f <main+0x4f>
lea    0xec3(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [2 x i8] c" \00"
@.str.1 = [38 x i8] c"first strtok call did not return NULL\00"
@.str.2 = [39 x i8] c"second strtok call did not return NULL\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [1 x i8]
%3 = alloca i32
store i32 0, i32* %1
%4 = bitcast [1 x i8]* %2 to i8*
store i32 0, i32* %3
%5 = getelementptr inbounds [1 x i8], [1 x i8]* %2, i64 0, i64 0
%6 = call i32* @strtok(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%7 = icmp ne i32* %6, null
br i1 %7, label %8, label %10
8: ; preds = %0
%9 = call i32 @puts(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %3
br label %16
10: ; preds = %0
%11 = call i32* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%12 = icmp ne i32* %11, null
br i1 %12, label %13, label %15
13: ; preds = %10
%14 = call i32 @puts(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %3
br label %15
15: ; preds = %13, %10
br label %16
16: ; preds = %15, %8
%17 = load i32, i32* %3
ret i32 %17
}

LLVM IR (-O2):
@.str = [2 x i8] c" \00"
@.str.1 = [38 x i8] c"first strtok call did not return NULL\00"
@.str.2 = [39 x i8] c"second strtok call did not return NULL\00"
define i32 @main() {
%1 = alloca [1 x i8]
%2 = getelementptr inbounds [1 x i8], [1 x i8]* %1, i64 0, i64 0
store i8 0, i8* %2
%3 = call i32* @strtok(i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i32* %3, null
br i1 %4, label %5, label %8
5: ; preds = %0
%6 = call i32* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i32* %6, null
br i1 %7, label %11, label %8
8: ; preds = %5, %0
%9 = phi i8* [ getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0), %0 ], [ getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), %5 ]
%10 = call i32 @puts(i8* dereferenceable(1) %9)
br label %11
11: ; preds = %8, %5
%12 = phi i32 [ 0, %5 ], [ 1, %8 ]
ret i32 %12
}