#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*/ free(char *);
int /*<<< orphan*/ printf(char *, ...);
char *strdup(char *);
scalar_t__ strlen(char *);
char *strsep(char **, char *);
char *strtok(char *, char *);
int main() {
  char source[] = "a=1, b=10, c=100";
  char d1[] = " ,", d2[] = "=";
  char *t1, *t2;
  char *s = NULL;
  printf("%s\n", source);
  s = strdup(source);
  for (t1 = strtok(s, d1); t1 != NULL; t1 = strtok(NULL, d1)) {
    printf("%s\n", t1);
  }
  free(s);
  s = strdup(source);
  for (t1 = strsep(&s, d1); t1 != NULL; t1 = strsep(&s, d1)) {
    printf("%s\n", t1);
  }
  free(s);
  s = strdup(source);
  for (t1 = strsep(&s, d1); t1 != NULL; t1 = strsep(&s, d1)) {
    if (strlen(t1) == 0)
      continue;
    for (t2 = strsep(&t1, d2); t2 != NULL; t2 = strsep(&t1, d2)) {
      printf("%s\t", t2);
    }
    printf("\n");
  }
  free(s);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xe8a(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xe87(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xe85(%rip),%al
mov    %al,-0x10(%rbp)
mov    0xe7c(%rip),%ax
mov    %ax,-0x23(%rbp)
mov    0xe74(%rip),%al
mov    %al,-0x21(%rbp)
mov    0xe6b(%rip),%ax
mov    %ax,-0x25(%rbp)
movq   $0x0,-0x40(%rbp)
lea    -0x20(%rbp),%rsi
lea    0xe56(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x20(%rbp),%rdi
call   1080 <strdup@plt>
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rdi
lea    -0x23(%rbp),%rsi
call   1070 <strtok@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
je     1218 <main+0xb8>
mov    -0x30(%rbp),%rsi
lea    0xe1b(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x23(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edi
call   1070 <strtok@plt>
mov    %rax,-0x30(%rbp)
jmp    11e5 <main+0x85>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
lea    -0x20(%rbp),%rdi
call   1080 <strdup@plt>
mov    %rax,-0x40(%rbp)
lea    -0x23(%rbp),%rsi
lea    -0x40(%rbp),%rdi
call   1060 <strsep@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
je     1272 <main+0x112>
mov    -0x30(%rbp),%rsi
lea    0xdc1(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x23(%rbp),%rsi
lea    -0x40(%rbp),%rdi
call   1060 <strsep@plt>
mov    %rax,-0x30(%rbp)
jmp    123f <main+0xdf>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
lea    -0x20(%rbp),%rdi
call   1080 <strdup@plt>
mov    %rax,-0x40(%rbp)
lea    -0x23(%rbp),%rsi
lea    -0x40(%rbp),%rdi
call   1060 <strsep@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
je     1324 <main+0x1c4>
mov    -0x30(%rbp),%rdi
call   1040 <strlen@plt>
cmp    $0x0,%rax
jne    12bc <main+0x15c>
jmp    130e <main+0x1ae>
lea    -0x25(%rbp),%rsi
lea    -0x30(%rbp),%rdi
call   1060 <strsep@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
je     1300 <main+0x1a0>
mov    -0x38(%rbp),%rsi
lea    0xd37(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x25(%rbp),%rsi
lea    -0x30(%rbp),%rdi
call   1060 <strsep@plt>
mov    %rax,-0x38(%rbp)
jmp    12cd <main+0x16d>
lea    0xd11(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x23(%rbp),%rsi
lea    -0x40(%rbp),%rdi
call   1060 <strsep@plt>
mov    %rax,-0x30(%rbp)
jmp    1299 <main+0x139>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x40,%rsp
movaps 0xe7c(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movb   $0x0,0x30(%rsp)
movb   $0x0,0x6(%rsp)
movw   $0x2c20,0x4(%rsp)
movw   $0x3d,0x16(%rsp)
lea    0x20(%rsp),%rbx
mov    %rbx,%rdi
call   1050 <puts@plt>
mov    %rbx,%rdi
call   1090 <strdup@plt>
mov    %rax,%r14
lea    0x4(%rsp),%rsi
mov    %rax,%rdi
call   1080 <strtok@plt>
test   %rax,%rax
je     11e7 <main+0x77>
lea    0x4(%rsp),%rbx
mov    %rax,%rdi
call   1050 <puts@plt>
xor    %edi,%edi
mov    %rbx,%rsi
call   1080 <strtok@plt>
test   %rax,%rax
jne    11d0 <main+0x60>
mov    %r14,%rdi
call   1030 <free@plt>
lea    0x20(%rsp),%rdi
call   1090 <strdup@plt>
mov    %rax,0x8(%rsp)
lea    0x8(%rsp),%rdi
lea    0x4(%rsp),%rsi
call   1070 <strsep@plt>
test   %rax,%rax
je     1238 <main+0xc8>
lea    0x8(%rsp),%r14
lea    0x4(%rsp),%rbx
nopl   0x0(%rax)
mov    %rax,%rdi
call   1050 <puts@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1070 <strsep@plt>
test   %rax,%rax
jne    1220 <main+0xb0>
mov    0x8(%rsp),%rdi
call   1030 <free@plt>
lea    0x20(%rsp),%rdi
call   1090 <strdup@plt>
mov    %rax,0x8(%rsp)
lea    0x8(%rsp),%rdi
lea    0x4(%rsp),%rsi
call   1070 <strsep@plt>
mov    %rax,0x18(%rsp)
test   %rax,%rax
je     12df <main+0x16f>
lea    0x8(%rsp),%r14
lea    0x4(%rsp),%r15
lea    0x18(%rsp),%r12
lea    0x16(%rsp),%rbx
lea    0xd8f(%rip),%r13
jmp    12af <main+0x13f>
nopw   0x0(%rax,%rax,1)
mov    $0xa,%edi
call   1040 <putchar@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   1070 <strsep@plt>
mov    %rax,0x18(%rsp)
test   %rax,%rax
je     12df <main+0x16f>
cmpb   $0x0,(%rax)
je     129a <main+0x12a>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r12,%rdi
mov    %rbx,%rsi
call   1070 <strsep@plt>
test   %rax,%rax
je     1290 <main+0x120>
mov    %r13,%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    12c0 <main+0x150>
mov    0x8(%rsp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.main.source = [17 x i8] c"a=1, b=10, c=100\00"
@__const.main.d1 = [3 x i8] c" ,\00"
@__const.main.d2 = [2 x i8] c"=\00"
@.str = [4 x i8] c"%s\0A\00"
@.str.1 = [4 x i8] c"%s\09\00"
@.str.2 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [17 x i8]
%3 = alloca [3 x i8]
%4 = alloca [2 x i8]
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
store i32 0, i32* %1
%8 = bitcast [17 x i8]* %2 to i8*
%9 = bitcast [3 x i8]* %3 to i8*
%10 = bitcast [2 x i8]* %4 to i8*
store i8* null, i8** %7
%11 = getelementptr inbounds [17 x i8], [17 x i8]* %2, i64 0, i64 0
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %11)
%13 = getelementptr inbounds [17 x i8], [17 x i8]* %2, i64 0, i64 0
%14 = call i8* @strdup(i8* %13)
store i8* %14, i8** %7
%15 = load i8*, i8** %7
%16 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 0
%17 = call i8* @strtok(i8* %15, i8* %16)
store i8* %17, i8** %5
br label %18
18: ; preds = %24, %0
%19 = load i8*, i8** %5
%20 = icmp ne i8* %19, null
br i1 %20, label %21, label %27
21: ; preds = %18
%22 = load i8*, i8** %5
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %22)
br label %24
24: ; preds = %21
%25 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 0
%26 = call i8* @strtok(i8* null, i8* %25)
store i8* %26, i8** %5
br label %18
27: ; preds = %18
%28 = load i8*, i8** %7
%29 = call i32 @free(i8* %28)
%30 = getelementptr inbounds [17 x i8], [17 x i8]* %2, i64 0, i64 0
%31 = call i8* @strdup(i8* %30)
store i8* %31, i8** %7
%32 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 0
%33 = call i8* @strsep(i8** %7, i8* %32)
store i8* %33, i8** %5
br label %34
34: ; preds = %40, %27
%35 = load i8*, i8** %5
%36 = icmp ne i8* %35, null
br i1 %36, label %37, label %43
37: ; preds = %34
%38 = load i8*, i8** %5
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %38)
br label %40
40: ; preds = %37
%41 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 0
%42 = call i8* @strsep(i8** %7, i8* %41)
store i8* %42, i8** %5
br label %34
43: ; preds = %34
%44 = load i8*, i8** %7
%45 = call i32 @free(i8* %44)
%46 = getelementptr inbounds [17 x i8], [17 x i8]* %2, i64 0, i64 0
%47 = call i8* @strdup(i8* %46)
store i8* %47, i8** %7
%48 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 0
%49 = call i8* @strsep(i8** %7, i8* %48)
store i8* %49, i8** %5
br label %50
50: ; preds = %72, %43
%51 = load i8*, i8** %5
%52 = icmp ne i8* %51, null
br i1 %52, label %53, label %75
53: ; preds = %50
%54 = load i8*, i8** %5
%55 = call i64 @strlen(i8* %54)
%56 = icmp eq i64 %55, 0
br i1 %56, label %57, label %58
57: ; preds = %53
br label %72
58: ; preds = %53
%59 = getelementptr inbounds [2 x i8], [2 x i8]* %4, i64 0, i64 0
%60 = call i8* @strsep(i8** %5, i8* %59)
store i8* %60, i8** %6
br label %61
61: ; preds = %67, %58
%62 = load i8*, i8** %6
%63 = icmp ne i8* %62, null
br i1 %63, label %64, label %70
64: ; preds = %61
%65 = load i8*, i8** %6
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %65)
br label %67
67: ; preds = %64
%68 = getelementptr inbounds [2 x i8], [2 x i8]* %4, i64 0, i64 0
%69 = call i8* @strsep(i8** %5, i8* %68)
store i8* %69, i8** %6
br label %61
70: ; preds = %61
%71 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %72
72: ; preds = %70, %57
%73 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 0
%74 = call i8* @strsep(i8** %7, i8* %73)
store i8* %74, i8** %5
br label %50
75: ; preds = %50
%76 = load i8*, i8** %7
%77 = call i32 @free(i8* %76)
ret i32 0
}

LLVM IR (-O2):
@__const.main.source = [17 x i8] c"a=1, b=10, c=100\00"
@__const.main.d1 = [3 x i8] c" ,\00"
@.str.1 = [4 x i8] c"%s\09\00"
define i32 @main() {
%1 = alloca [17 x i8]
%2 = alloca [3 x i8]
%3 = alloca i16
%4 = alloca i8*
%5 = alloca i8*
%6 = getelementptr inbounds [17 x i8], [17 x i8]* %1, i64 0, i64 0
%7 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 0
%8 = bitcast i16* %3 to i8*
store i16 61, i16* %3
%9 = bitcast i8** %4 to i8*
%10 = bitcast i8** %5 to i8*
%11 = call i32 @puts(i8* %6)
%12 = call i8* @strdup(i8* %6)
%13 = call i8* @strtok(i8* %12, i8* %7)
%14 = icmp eq i8* %13, null
br i1 %14, label %20, label %15
15: ; preds = %0, %15
%16 = phi i8* [ %18, %15 ], [ %13, %0 ]
%17 = tail call i32 @puts(i8* %16)
%18 = call i8* @strtok(i8* null, i8* %7)
%19 = icmp eq i8* %18, null
br i1 %19, label %20, label %15
20: ; preds = %15, %0
%21 = tail call i32 @free(i8* %12)
%22 = call i8* @strdup(i8* %6)
store i8* %22, i8** %5
%23 = call i8* @strsep(i8** %5, i8* %7)
%24 = icmp eq i8* %23, null
br i1 %24, label %30, label %25
25: ; preds = %20, %25
%26 = phi i8* [ %28, %25 ], [ %23, %20 ]
%27 = call i32 @puts(i8* %26)
%28 = call i8* @strsep(i8** %5, i8* %7)
%29 = icmp eq i8* %28, null
br i1 %29, label %30, label %25
30: ; preds = %25, %20
%31 = load i8*, i8** %5
%32 = call i32 @free(i8* %31)
%33 = call i8* @strdup(i8* %6)
store i8* %33, i8** %5
%34 = call i8* @strsep(i8** %5, i8* %7)
store i8* %34, i8** %4
%35 = icmp eq i8* %34, null
br i1 %35, label %53, label %36
36: ; preds = %30, %50
%37 = phi i8* [ %51, %50 ], [ %34, %30 ]
%38 = load i8, i8* %37
%39 = icmp eq i8 %38, 0
br i1 %39, label %50, label %40
40: ; preds = %36
%41 = call i8* @strsep(i8** %4, i8* %8)
%42 = icmp eq i8* %41, null
br i1 %42, label %48, label %43
43: ; preds = %40, %43
%44 = phi i8* [ %46, %43 ], [ %41, %40 ]
%45 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %44)
%46 = call i8* @strsep(i8** %4, i8* %8)
%47 = icmp eq i8* %46, null
br i1 %47, label %48, label %43
48: ; preds = %43, %40
%49 = call i32 @putchar(i32 10)
br label %50
50: ; preds = %36, %48
%51 = call i8* @strsep(i8** %5, i8* %7)
store i8* %51, i8** %4
%52 = icmp eq i8* %51, null
br i1 %52, label %53, label %36
53: ; preds = %50, %30
%54 = load i8*, i8** %5
%55 = call i32 @free(i8* %54)
ret i32 0
}