#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 *strtok_r(char *, char *, char **);
void print_walnut_list(char *msg) {
  char *walnut, *walnut_str, *walnut_info;
  char *saveptr1, *saveptr2;
  int field;
  for (;; msg = NULL) {
    walnut = strtok_r(msg, "\30", &saveptr1);
    if (walnut == NULL)
      break;
    for (field = 0, walnut_str = walnut;; ++field, walnut_str = NULL) {
      walnut_info = strtok_r(walnut_str, "\31", &saveptr2);
      if (walnut_info == NULL)
        break;
      if (field == 0)
        printf("%s\t", walnut_info);
      else
        printf("(%s) ", walnut_info);
    }
    printf("\n");
  }
}


x86 assembly (clang, -O0):
<print_walnut_list>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xec9(%rip),%rsi
lea    -0x28(%rbp),%rdx
call   1040 <strtok_r@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1154 <print_walnut_list+0x34>
jmp    11f4 <print_walnut_list+0xd4>
movl   $0x0,-0x34(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe94(%rip),%rsi
lea    -0x30(%rbp),%rdx
call   1040 <strtok_r@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    118b <print_walnut_list+0x6b>
jmp    11d9 <print_walnut_list+0xb9>
cmpl   $0x0,-0x34(%rbp)
jne    11ac <print_walnut_list+0x8c>
mov    -0x20(%rbp),%rsi
lea    0xe64(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11be <print_walnut_list+0x9e>
mov    -0x20(%rbp),%rsi
lea    0xe51(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11c3 <print_walnut_list+0xa3>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
movq   $0x0,-0x18(%rbp)
jmp    1163 <print_walnut_list+0x43>
lea    0xe2e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movq   $0x0,-0x8(%rbp)
jmp    112c <print_walnut_list+0xc>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_walnut_list>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xebb(%rip),%rsi
lea    0x8(%rsp),%rdx
call   1050 <strtok_r@plt>
test   %rax,%rax
je     11e1 <print_walnut_list+0xb1>
lea    0xea3(%rip),%r14
lea    0x10(%rsp),%rbx
lea    0xe95(%rip),%r15
lea    0x8(%rsp),%r12
lea    0xe8d(%rip),%r13
lea    0xe8a(%rip),%rbp
jmp    119c <print_walnut_list+0x6c>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %edi,%edi
mov    %r15,%rsi
mov    %r12,%rdx
call   1050 <strtok_r@plt>
test   %rax,%rax
je     11e1 <print_walnut_list+0xb1>
mov    %rax,%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
call   1050 <strtok_r@plt>
test   %rax,%rax
je     1180 <print_walnut_list+0x50>
mov    %r13,%rdi
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %rax,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %edi,%edi
mov    %r14,%rsi
mov    %rbx,%rdx
call   1050 <strtok_r@plt>
test   %rax,%rax
je     1180 <print_walnut_list+0x50>
mov    %rbp,%rdi
jmp    11c0 <print_walnut_list+0x90>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"\18\00"
@.str.1 = [2 x i8] c"\19\00"
@.str.2 = [4 x i8] c"%s\09\00"
@.str.3 = [6 x i8] c"(%s) \00"
@.str.4 = [2 x i8] c"\0A\00"
define void @print_walnut_list(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
store i8* %0, i8** %2
br label %9
9: ; preds = %38, %1
%10 = load i8*, i8** %2
%11 = call i8* @strtok_r(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8** %6)
store i8* %11, i8** %3
%12 = load i8*, i8** %3
%13 = icmp eq i8* %12, null
br i1 %13, label %14, label %15
14: ; preds = %9
br label %39
15: ; preds = %9
store i32 0, i32* %8
%16 = load i8*, i8** %3
store i8* %16, i8** %4
br label %17
17: ; preds = %33, %15
%18 = load i8*, i8** %4
%19 = call i8* @strtok_r(i8* %18, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8** %7)
store i8* %19, i8** %5
%20 = load i8*, i8** %5
%21 = icmp eq i8* %20, null
br i1 %21, label %22, label %23
22: ; preds = %17
br label %36
23: ; preds = %17
%24 = load i32, i32* %8
%25 = icmp eq i32 %24, 0
br i1 %25, label %26, label %29
26: ; preds = %23
%27 = load i8*, i8** %5
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %27)
br label %32
29: ; preds = %23
%30 = load i8*, i8** %5
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8* %30)
br label %32
32: ; preds = %29, %26
br label %33
33: ; preds = %32
%34 = load i32, i32* %8
%35 = add nsw i32 %34, 1
store i32 %35, i32* %8
store i8* null, i8** %4
br label %17
36: ; preds = %22
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %38
38: ; preds = %36
store i8* null, i8** %2
br label %9
39: ; preds = %14
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"\18\00"
@.str.1 = [2 x i8] c"\19\00"
@.str.2 = [4 x i8] c"%s\09\00"
@.str.3 = [6 x i8] c"(%s) \00"
define void @print_walnut_list(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = bitcast i8** %2 to i8*
%5 = bitcast i8** %3 to i8*
%6 = call i8* @strtok_r(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8** %2)
%7 = icmp eq i8* %6, null
br i1 %7, label %25, label %8
8: ; preds = %1, %21
%9 = phi i8* [ %23, %21 ], [ %6, %1 ]
%10 = call i8* @strtok_r(i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8** %3)
%11 = icmp eq i8* %10, null
br i1 %11, label %21, label %12
12: ; preds = %8
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %10)
%14 = call i8* @strtok_r(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8** %3)
%15 = icmp eq i8* %14, null
br i1 %15, label %21, label %16
16: ; preds = %12, %16
%17 = phi i8* [ %19, %16 ], [ %14, %12 ]
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8* %17)
%19 = call i8* @strtok_r(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8** %3)
%20 = icmp eq i8* %19, null
br i1 %20, label %21, label %16
21: ; preds = %16, %12, %8
%22 = call i32 @putchar(i32 10)
%23 = call i8* @strtok_r(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8** %2)
%24 = icmp eq i8* %23, null
br i1 %24, label %25, label %8
25: ; preds = %21, %1
ret void
}