#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*/ parse_allocation_cos(char *);
int /*<<< orphan*/ parse_error(char *, char *);
int strlen(char *);
scalar_t__ strncasecmp(char *, char *, int);
char *strtok_r(char *, char *, char **);
void parse_allocation_class(char *str) {
  char *p = NULL;
  char *saveptr = NULL;
  if (strncasecmp(str, "llc:", 4) != 0)
    parse_error(str, "Unrecognized allocation type");
  for (p = str + strlen("llc:");; p = NULL) {
    char *token = NULL;
    token = strtok_r(p, ",", &saveptr);
    if (token == NULL)
      break;
    parse_allocation_cos(token);
  }
}


x86 assembly (clang, -O0):
<parse_allocation_class>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe89(%rip),%rsi
mov    $0x4,%edx
call   1050 <strncasecmp@plt>
cmp    $0x0,%rax
je     119b <parse_allocation_class+0x4b>
mov    -0x8(%rbp),%rdi
lea    0xe6f(%rip),%rsi
call   1070 <parse_error@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
lea    0xe56(%rip),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x10(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe50(%rip),%rsi
lea    -0x18(%rbp),%rdx
call   1040 <strtok_r@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11ef <parse_allocation_class+0x9f>
jmp    1205 <parse_allocation_class+0xb5>
mov    -0x20(%rbp),%rdi
call   1060 <parse_allocation_cos@plt>
movq   $0x0,-0x10(%rbp)
jmp    11bf <parse_allocation_class+0x6f>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_allocation_class>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
movq   $0x0,(%rsp)
lea    0xe9a(%rip),%rsi
mov    $0x4,%edx
call   1050 <strncasecmp@plt>
test   %rax,%rax
je     1184 <parse_allocation_class+0x34>
lea    0xe89(%rip),%rsi
mov    %rbx,%rdi
call   1070 <parse_error@plt>
lea    0xe75(%rip),%rdi
call   1030 <strlen@plt>
cltq
add    %rax,%rbx
lea    0xe86(%rip),%rsi
mov    %rsp,%rdx
mov    %rbx,%rdi
call   1040 <strtok_r@plt>
test   %rax,%rax
je     11da <parse_allocation_class+0x8a>
lea    0xe6f(%rip),%r14
mov    %rsp,%rbx
cs nopw 0x0(%rax,%rax,1)
mov    %rax,%rdi
call   1060 <parse_allocation_cos@plt>
xor    %edi,%edi
mov    %r14,%rsi
mov    %rbx,%rdx
call   1040 <strtok_r@plt>
test   %rax,%rax
jne    11c0 <parse_allocation_class+0x70>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [5 x i8] c"llc:\00"
@.str.1 = [29 x i8] c"Unrecognized allocation type\00"
@.str.2 = [2 x i8] c",\00"
define void @parse_allocation_class(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
store i8* %0, i8** %2
store i8* null, i8** %3
store i8* null, i8** %4
%6 = load i8*, i8** %2
%7 = call i64 @strncasecmp(i8* %6, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 4)
%8 = icmp ne i64 %7, 0
br i1 %8, label %9, label %12
9: ; preds = %1
%10 = load i8*, i8** %2
%11 = call i32 @parse_error(i8* %10, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
br label %12
12: ; preds = %9, %1
%13 = load i8*, i8** %2
%14 = call i32 @strlen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i8, i8* %13, i64 %15
store i8* %16, i8** %3
br label %17
17: ; preds = %26, %12
store i8* null, i8** %5
%18 = load i8*, i8** %3
%19 = call i8* @strtok_r(i8* %18, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i8** %4)
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 %27
23: ; preds = %17
%24 = load i8*, i8** %5
%25 = call i32 @parse_allocation_cos(i8* %24)
br label %26
26: ; preds = %23
store i8* null, i8** %3
br label %17
27: ; preds = %22
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"llc:\00"
@.str.1 = [29 x i8] c"Unrecognized allocation type\00"
@.str.2 = [2 x i8] c",\00"
define void @parse_allocation_class(i8* %0) {
%2 = alloca i8*
%3 = bitcast i8** %2 to i8*
store i8* null, i8** %2
%4 = tail call i64 @strncasecmp(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 4)
%5 = icmp eq i64 %4, 0
br i1 %5, label %8, label %6
6: ; preds = %1
%7 = tail call i32 @parse_error(i8* %0, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
br label %8
8: ; preds = %6, %1
%9 = tail call i32 @strlen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds i8, i8* %0, i64 %10
%12 = call i8* @strtok_r(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i8** %2)
%13 = icmp eq i8* %12, null
br i1 %13, label %19, label %14
14: ; preds = %8, %14
%15 = phi i8* [ %17, %14 ], [ %12, %8 ]
%16 = call i32 @parse_allocation_cos(i8* %15)
%17 = call i8* @strtok_r(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i8** %2)
%18 = icmp eq i8* %17, null
br i1 %18, label %19, label %14
19: ; preds = %14, %8
ret void
}