#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 */
struct stat {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ show_stat(struct stat *, char *);
char *strtok(char *, char *);
void show_stats(struct stat *sp, char *what) {
  const char *s = "";
  char *w;
  for (w = strtok(what, ","); w != NULL; w = strtok(NULL, ",")) {
    printf("%s", s);
    show_stat(sp, w);
    s = ",";
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<show_stats>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xebf(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xeaa(%rip),%rsi
call   1050 <strtok@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     11ad <show_stats+0x7d>
mov    -0x18(%rbp),%rsi
lea    0xe8d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1040 <show_stat@plt>
lea    0xe70(%rip),%rax
mov    %rax,-0x18(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xe61(%rip),%rsi
call   1050 <strtok@plt>
mov    %rax,-0x20(%rbp)
jmp    115f <show_stats+0x2f>
lea    0xe51(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<show_stats>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%rax
mov    %rdi,%r15
lea    0xebe(%rip),%rsi
mov    %rax,%rdi
call   1050 <strtok@plt>
test   %rax,%rax
je     11a7 <show_stats+0x77>
mov    %r15,%rdi
mov    %rax,%rsi
call   1040 <show_stat@plt>
lea    0xe9f(%rip),%rsi
xor    %edi,%edi
call   1050 <strtok@plt>
test   %rax,%rax
je     11a7 <show_stats+0x77>
mov    %rax,%rbx
lea    0xe89(%rip),%r14
nopw   0x0(%rax,%rax,1)
mov    $0x2c,%edi
call   1030 <putchar@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1040 <show_stat@plt>
xor    %edi,%edi
mov    %r14,%rsi
call   1050 <strtok@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1180 <show_stats+0x50>
mov    $0xa,%edi
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <putchar@plt>

LLVM IR (-O0):
%struct.stat = type { i32 }
@.str = [1 x i8] zeroinitializer
@.str.1 = [2 x i8] c",\00"
@.str.2 = [3 x i8] c"%s\00"
@.str.3 = [2 x i8] c"\0A\00"
define void @show_stats(%struct.stat* %0, i8* %1) {
%3 = alloca %struct.stat*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
store %struct.stat* %0, %struct.stat** %3
store i8* %1, i8** %4
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8** %5
%7 = load i8*, i8** %4
%8 = call i8* @strtok(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i8* %8, i8** %6
br label %9
9: ; preds = %18, %2
%10 = load i8*, i8** %6
%11 = icmp ne i8* %10, null
br i1 %11, label %12, label %20
12: ; preds = %9
%13 = load i8*, i8** %5
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %13)
%15 = load %struct.stat*, %struct.stat** %3
%16 = load i8*, i8** %6
%17 = call i32 @show_stat(%struct.stat* %15, i8* %16)
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8** %5
br label %18
18: ; preds = %12
%19 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i8* %19, i8** %6
br label %9
20: ; preds = %9
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@.str.1 = [2 x i8] c",\00"
define void @show_stats(%struct.stat* %0, i8* %1) {
%3 = tail call i8* @strtok(i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%4 = icmp eq i8* %3, null
br i1 %4, label %15, label %5
5: ; preds = %2
%6 = tail call i32 @show_stat(%struct.stat* %0, i8* %3)
%7 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%8 = icmp eq i8* %7, null
br i1 %8, label %15, label %9
9: ; preds = %5, %9
%10 = phi i8* [ %13, %9 ], [ %7, %5 ]
%11 = tail call i32 @putchar(i32 44)
%12 = tail call i32 @show_stat(%struct.stat* %0, i8* %10)
%13 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%14 = icmp eq i8* %13, null
br i1 %14, label %15, label %9
15: ; preds = %9, %5, %2
%16 = tail call i32 @putchar(i32 10)
ret void
}