#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*/ gets(char *);
int /*<<< orphan*/ printf(char *, ...);
int strtoken(char *, char *, int);
int main() {
  char string[100];
  char token_string[20];
  int pos;
  printf("请输入字符串 ==>");
  gets(string);
  pos = 0;
  printf("分割结果:\n");
  while ((pos = strtoken(string, token_string, pos)) != -1)
    printf("%s\n", token_string);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeb7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x70(%rbp),%rdi
call   1040 <gets@plt>
movl   $0x0,-0x94(%rbp)
lea    0xead(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x70(%rbp),%rdi
lea    -0x90(%rbp),%rsi
mov    -0x94(%rbp),%edx
call   1050 <strtoken@plt>
mov    %eax,-0x94(%rbp)
cmp    $0xffffffff,%eax
je     11b0 <main+0x80>
lea    -0x90(%rbp),%rsi
lea    0xe82(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1171 <main+0x41>
xor    %eax,%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x90,%rsp
lea    0xead(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x20(%rsp),%rbx
mov    %rbx,%rdi
call   1050 <gets@plt>
lea    0xea9(%rip),%rdi
call   1030 <puts@plt>
mov    %rsp,%rsi
mov    %rbx,%rdi
xor    %edx,%edx
call   1060 <strtoken@plt>
cmp    $0xffffffff,%eax
je     11ac <main+0x6c>
mov    %eax,%ebx
mov    %rsp,%r14
lea    0x20(%rsp),%r15
nop
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
mov    %r14,%rsi
mov    %ebx,%edx
call   1060 <strtoken@plt>
mov    %eax,%ebx
cmp    $0xffffffff,%eax
jne    1190 <main+0x50>
xor    %eax,%eax
add    $0x90,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [23 x i8] c"\E8\AF\B7\E8\BE\93\E5\85\A5\E5\AD\97\E7\AC\A6\E4\B8\B2 ==>\00"
@.str.1 = [15 x i8] c"\E5\88\86\E5\89\B2\E7\BB\93\E6\9E\9C:\0A\00"
@.str.2 = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x i8]
%3 = alloca [20 x i8]
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%6 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%7 = call i32 @gets(i8* %6)
store i32 0, i32* %4
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
br label %9
9: ; preds = %15, %0
%10 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%11 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%12 = load i32, i32* %4
%13 = call i32 @strtoken(i8* %10, i8* %11, i32 %12)
store i32 %13, i32* %4
%14 = icmp ne i32 %13, -1
br i1 %14, label %15, label %18
15: ; preds = %9
%16 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %16)
br label %9
18: ; preds = %9
ret i32 0
}

LLVM IR (-O2):
@.str = [23 x i8] c"\E8\AF\B7\E8\BE\93\E5\85\A5\E5\AD\97\E7\AC\A6\E4\B8\B2 ==>\00"
@str = [14 x i8] c"\E5\88\86\E5\89\B2\E7\BB\93\E6\9E\9C:\00"
define i32 @main() {
%1 = alloca [100 x i8]
%2 = alloca [20 x i8]
%3 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @gets(i8* %3)
%7 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str, i64 0, i64 0))
%8 = call i32 @strtoken(i8* %3, i8* %4, i32 0)
%9 = icmp eq i32 %8, -1
br i1 %9, label %15, label %10
10: ; preds = %0, %10
%11 = phi i32 [ %13, %10 ], [ %8, %0 ]
%12 = call i32 @puts(i8* %4)
%13 = call i32 @strtoken(i8* %3, i8* %4, i32 %11)
%14 = icmp eq i32 %13, -1
br i1 %14, label %15, label %10
15: ; preds = %10, %0
ret i32 0
}