#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 pevent {
  int dummy;
};

/* Variables and functions */
void extract_trace_clock(struct pevent *, char *);
char *strtok_r(char *, char *, char **);
void parse_trace_clock(struct pevent *pevent, char *file,
                       int size __attribute__((unused))) {
  char *line;
  char *next = NULL;
  line = strtok_r(file, " ", &next);
  while (line) {
    if (*line == '[')
      return extract_trace_clock(pevent, line);
    line = strtok_r(NULL, " ", &next);
  }
}


x86 assembly (clang, -O0):
<parse_trace_clock>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xeba(%rip),%rsi
lea    -0x28(%rbp),%rdx
call   1030 <strtok_r@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     119d <parse_trace_clock+0x7d>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5b,%eax
jne    1180 <parse_trace_clock+0x60>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1040 <extract_trace_clock@plt>
jmp    119d <parse_trace_clock+0x7d>
xor    %eax,%eax
mov    %eax,%edi
lea    0xe75(%rip),%rsi
lea    -0x28(%rbp),%rdx
call   1030 <strtok_r@plt>
mov    %rax,-0x20(%rbp)
jmp    1153 <parse_trace_clock+0x33>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_trace_clock>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rax
mov    %rdi,%r14
movq   $0x0,0x8(%rsp)
lea    0xec1(%rip),%rsi
lea    0x8(%rsp),%rdx
mov    %rax,%rdi
call   1030 <strtok_r@plt>
test   %rax,%rax
je     1184 <parse_trace_clock+0x64>
lea    0xea8(%rip),%r15
lea    0x8(%rsp),%rbx
nopl   (%rax)
cmpb   $0x5b,(%rax)
je     1179 <parse_trace_clock+0x59>
xor    %edi,%edi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1030 <strtok_r@plt>
test   %rax,%rax
jne    1160 <parse_trace_clock+0x40>
jmp    1184 <parse_trace_clock+0x64>
mov    %r14,%rdi
mov    %rax,%rsi
call   1040 <extract_trace_clock@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.pevent = type { i32 }
@.str = [2 x i8] c" \00"
define void @parse_trace_clock(%struct.pevent* %0, i8* %1, i32 %2) {
%4 = alloca %struct.pevent*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
store %struct.pevent* %0, %struct.pevent** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
store i8* null, i8** %8
%9 = load i8*, i8** %5
%10 = call i8* @strtok_r(i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8** %8)
store i8* %10, i8** %7
br label %11
11: ; preds = %22, %3
%12 = load i8*, i8** %7
%13 = icmp ne i8* %12, null
br i1 %13, label %14, label %24
14: ; preds = %11
%15 = load i8*, i8** %7
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp eq i32 %17, 91
br i1 %18, label %19, label %22
19: ; preds = %14
%20 = load %struct.pevent*, %struct.pevent** %4
%21 = load i8*, i8** %7
br label %24
22: ; preds = %14
%23 = call i8* @strtok_r(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8** %8)
store i8* %23, i8** %7
br label %11
24: ; preds = %19, %11
ret void
}

LLVM IR (-O2):
%struct.pevent = type { i32 }
@.str = [2 x i8] c" \00"
define void @parse_trace_clock(%struct.pevent* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = bitcast i8** %4 to i8*
store i8* null, i8** %4
%6 = call i8* @strtok_r(i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8** %4)
%7 = icmp eq i8* %6, null
br i1 %7, label %16, label %8
8: ; preds = %3, %13
%9 = phi i8* [ %14, %13 ], [ %6, %3 ]
%10 = load i8, i8* %9
%11 = icmp eq i8 %10, 91
br i1 %11, label %12, label %13
12: ; preds = %8
br label %16
13: ; preds = %8
%14 = call i8* @strtok_r(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8** %4)
%15 = icmp eq i8* %14, null
br i1 %15, label %16, label %8
16: ; preds = %13, %3, %12
ret void
}