#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*/ assert(int);
int /*<<< orphan*/ parse_desktop_category(char *, char *, char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ sprintf(char *, char *, char *);
scalar_t__ strcmp(char *, char *);
scalar_t__ strlen(char *);
int valid_additional_category(char *);
int valid_main_category(char *);
void test_categories() {
  char categories[512];
  char main_category[512];
  char additional_category[512];
  printf("test_categories...");
  sprintf(categories, "%s", "test1;test2");
  parse_desktop_category(categories, main_category, additional_category);
  assert(strcmp(main_category, "test1") == 0);
  assert(strcmp(additional_category, "test2") == 0);
  sprintf(categories, "%s", "test1");
  parse_desktop_category(categories, main_category, additional_category);
  assert(strcmp(main_category, "test1") == 0);
  assert(strlen(additional_category) == 0);
  assert(valid_main_category("test123") == -1);
  assert(valid_main_category("Audio") != -1);
  assert(valid_main_category("Utility") != -1);
  assert(valid_additional_category("Profiling") != -1);
  assert(valid_additional_category("Database") != -1);
  assert(valid_additional_category("test123") == -1);
  assert(valid_additional_category("ConsoleOnly") != -1);
  assert(valid_additional_category("foo") == -1);
  printf("Ok\n");
}


x86 assembly (clang, -O0):
<test_categories>:
push   %rbp
mov    %rsp,%rbp
sub    $0x600,%rsp
lea    0xe6e(%rip),%rdi
call   1050 <printf@plt>
lea    -0x200(%rbp),%rdi
lea    0xe6e(%rip),%rsi
lea    0xe6a(%rip),%rdx
call   10a0 <sprintf@plt>
lea    -0x200(%rbp),%rdi
lea    -0x400(%rbp),%rsi
lea    -0x600(%rbp),%rdx
call   1080 <parse_desktop_category@plt>
lea    -0x400(%rbp),%rdi
lea    0xe49(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
lea    -0x600(%rbp),%rdi
lea    0xe1f(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
lea    -0x200(%rbp),%rdi
lea    0xdf2(%rip),%rsi
lea    0xdfa(%rip),%rdx
call   10a0 <sprintf@plt>
lea    -0x200(%rbp),%rdi
lea    -0x400(%rbp),%rsi
lea    -0x600(%rbp),%rdx
call   1080 <parse_desktop_category@plt>
lea    -0x400(%rbp),%rdi
lea    0xdcd(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
lea    -0x600(%rbp),%rdi
call   1040 <strlen@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
lea    0xd99(%rip),%rdi
call   1090 <valid_main_category@plt>
cmp    $0xffffffff,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
lea    0xd85(%rip),%rdi
call   1090 <valid_main_category@plt>
cmp    $0xffffffff,%eax
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
lea    0xd6f(%rip),%rdi
call   1090 <valid_main_category@plt>
cmp    $0xffffffff,%eax
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
lea    0xd5b(%rip),%rdi
call   1030 <valid_additional_category@plt>
cmp    $0xffffffff,%eax
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
lea    0xd49(%rip),%rdi
call   1030 <valid_additional_category@plt>
cmp    $0xffffffff,%eax
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
lea    0xd0d(%rip),%rdi
call   1030 <valid_additional_category@plt>
cmp    $0xffffffff,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
lea    0xd1a(%rip),%rdi
call   1030 <valid_additional_category@plt>
cmp    $0xffffffff,%eax
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
lea    0xd0a(%rip),%rdi
call   1030 <valid_additional_category@plt>
cmp    $0xffffffff,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
lea    0xcf2(%rip),%rdi
call   1050 <printf@plt>
add    $0x600,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_categories>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x608,%rsp
lea    0xe7b(%rip),%rdi
call   1050 <printf@plt>
movabs $0x65743b3174736574,%rax
3b 74 65
mov    %rax,(%rsp)
movl   $0x327473,0x8(%rsp)
mov    %rsp,%r14
lea    0x400(%rsp),%rbx
lea    0x200(%rsp),%r15
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %r15,%rdx
call   1080 <parse_desktop_category@plt>
lea    0xe57(%rip),%r12
mov    %rbx,%rdi
mov    %r12,%rsi
call   1060 <strcmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1070 <assert@plt>
lea    0xe31(%rip),%rsi
mov    %r15,%rdi
call   1060 <strcmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1070 <assert@plt>
movl   $0x74736574,(%rsp)
movw   $0x31,0x4(%rsp)
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %r15,%rdx
call   1080 <parse_desktop_category@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1060 <strcmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1070 <assert@plt>
xor    %edi,%edi
cmpb   $0x0,0x200(%rsp)
sete   %dil
call   1070 <assert@plt>
lea    0xdd8(%rip),%rbx
mov    %rbx,%rdi
call   1090 <valid_main_category@plt>
xor    %edi,%edi
cmp    $0xffffffff,%eax
sete   %dil
call   1070 <assert@plt>
lea    0xdc3(%rip),%rdi
call   1090 <valid_main_category@plt>
xor    %edi,%edi
cmp    $0xffffffff,%eax
setne  %dil
call   1070 <assert@plt>
lea    0xdaf(%rip),%rdi
call   1090 <valid_main_category@plt>
xor    %edi,%edi
cmp    $0xffffffff,%eax
setne  %dil
call   1070 <assert@plt>
lea    0xd9d(%rip),%rdi
call   1040 <valid_additional_category@plt>
xor    %edi,%edi
cmp    $0xffffffff,%eax
setne  %dil
call   1070 <assert@plt>
lea    0xd8d(%rip),%rdi
call   1040 <valid_additional_category@plt>
xor    %edi,%edi
cmp    $0xffffffff,%eax
setne  %dil
call   1070 <assert@plt>
mov    %rbx,%rdi
call   1040 <valid_additional_category@plt>
xor    %edi,%edi
cmp    $0xffffffff,%eax
sete   %dil
call   1070 <assert@plt>
lea    0xd66(%rip),%rdi
call   1040 <valid_additional_category@plt>
xor    %edi,%edi
cmp    $0xffffffff,%eax
setne  %dil
call   1070 <assert@plt>
lea    0xd58(%rip),%rdi
call   1040 <valid_additional_category@plt>
xor    %edi,%edi
cmp    $0xffffffff,%eax
sete   %dil
call   1070 <assert@plt>
lea    0xd42(%rip),%rdi
call   1030 <puts@plt>
add    $0x608,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [19 x i8] c"test_categories...\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [12 x i8] c"test1;test2\00"
@.str.3 = [6 x i8] c"test1\00"
@.str.4 = [6 x i8] c"test2\00"
@.str.5 = [8 x i8] c"test123\00"
@.str.6 = [6 x i8] c"Audio\00"
@.str.7 = [8 x i8] c"Utility\00"
@.str.8 = [10 x i8] c"Profiling\00"
@.str.9 = [9 x i8] c"Database\00"
@.str.10 = [12 x i8] c"ConsoleOnly\00"
@.str.11 = [4 x i8] c"foo\00"
@.str.12 = [4 x i8] c"Ok\0A\00"
define void @test_categories() {
%1 = alloca [512 x i8]
%2 = alloca [512 x i8]
%3 = alloca [512 x i8]
%4 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%5 = getelementptr inbounds [512 x i8], [512 x i8]* %1, i64 0, i64 0
%6 = call i32 @sprintf(i8* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%7 = getelementptr inbounds [512 x i8], [512 x i8]* %1, i64 0, i64 0
%8 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 0
%9 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%10 = call i32 @parse_desktop_category(i8* %7, i8* %8, i8* %9)
%11 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 0
%12 = call i64 @strcmp(i8* %11, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
%14 = zext i1 %13 to i32
%15 = call i32 @assert(i32 %14)
%16 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%17 = call i64 @strcmp(i8* %16, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
%19 = zext i1 %18 to i32
%20 = call i32 @assert(i32 %19)
%21 = getelementptr inbounds [512 x i8], [512 x i8]* %1, i64 0, i64 0
%22 = call i32 @sprintf(i8* %21, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%23 = getelementptr inbounds [512 x i8], [512 x i8]* %1, i64 0, i64 0
%24 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 0
%25 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%26 = call i32 @parse_desktop_category(i8* %23, i8* %24, i8* %25)
%27 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 0
%28 = call i64 @strcmp(i8* %27, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%29 = icmp eq i64 %28, 0
%30 = zext i1 %29 to i32
%31 = call i32 @assert(i32 %30)
%32 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%33 = call i64 @strlen(i8* %32)
%34 = icmp eq i64 %33, 0
%35 = zext i1 %34 to i32
%36 = call i32 @assert(i32 %35)
%37 = call i32 @valid_main_category(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0))
%38 = icmp eq i32 %37, -1
%39 = zext i1 %38 to i32
%40 = call i32 @assert(i32 %39)
%41 = call i32 @valid_main_category(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
%42 = icmp ne i32 %41, -1
%43 = zext i1 %42 to i32
%44 = call i32 @assert(i32 %43)
%45 = call i32 @valid_main_category(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0))
%46 = icmp ne i32 %45, -1
%47 = zext i1 %46 to i32
%48 = call i32 @assert(i32 %47)
%49 = call i32 @valid_additional_category(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.8, i64 0, i64 0))
%50 = icmp ne i32 %49, -1
%51 = zext i1 %50 to i32
%52 = call i32 @assert(i32 %51)
%53 = call i32 @valid_additional_category(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.9, i64 0, i64 0))
%54 = icmp ne i32 %53, -1
%55 = zext i1 %54 to i32
%56 = call i32 @assert(i32 %55)
%57 = call i32 @valid_additional_category(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0))
%58 = icmp eq i32 %57, -1
%59 = zext i1 %58 to i32
%60 = call i32 @assert(i32 %59)
%61 = call i32 @valid_additional_category(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.10, i64 0, i64 0))
%62 = icmp ne i32 %61, -1
%63 = zext i1 %62 to i32
%64 = call i32 @assert(i32 %63)
%65 = call i32 @valid_additional_category(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i64 0, i64 0))
%66 = icmp eq i32 %65, -1
%67 = zext i1 %66 to i32
%68 = call i32 @assert(i32 %67)
%69 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.12, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [19 x i8] c"test_categories...\00"
@.str.2 = [12 x i8] c"test1;test2\00"
@.str.3 = [6 x i8] c"test1\00"
@.str.4 = [6 x i8] c"test2\00"
@.str.5 = [8 x i8] c"test123\00"
@.str.6 = [6 x i8] c"Audio\00"
@.str.7 = [8 x i8] c"Utility\00"
@.str.8 = [10 x i8] c"Profiling\00"
@.str.9 = [9 x i8] c"Database\00"
@.str.10 = [12 x i8] c"ConsoleOnly\00"
@.str.11 = [4 x i8] c"foo\00"
@str = [3 x i8] c"Ok\00"
define void @test_categories() {
%1 = alloca [512 x i8]
%2 = alloca [512 x i8]
%3 = alloca [512 x i8]
%4 = getelementptr inbounds [512 x i8], [512 x i8]* %1, i64 0, i64 0
%5 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 0
%6 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%7 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @parse_desktop_category(i8* %4, i8* %5, i8* %6)
%9 = call i64 @strcmp(i8* %5, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%10 = icmp eq i64 %9, 0
%11 = zext i1 %10 to i32
%12 = call i32 @assert(i32 %11)
%13 = call i64 @strcmp(i8* %6, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%14 = icmp eq i64 %13, 0
%15 = zext i1 %14 to i32
%16 = call i32 @assert(i32 %15)
%17 = call i32 @parse_desktop_category(i8* %4, i8* %5, i8* %6)
%18 = call i64 @strcmp(i8* %5, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
%20 = zext i1 %19 to i32
%21 = call i32 @assert(i32 %20)
%22 = load i8, i8* %6
%23 = icmp eq i8 %22, 0
%24 = zext i1 %23 to i32
%25 = call i32 @assert(i32 %24)
%26 = call i32 @valid_main_category(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0))
%27 = icmp eq i32 %26, -1
%28 = zext i1 %27 to i32
%29 = call i32 @assert(i32 %28)
%30 = call i32 @valid_main_category(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
%31 = icmp ne i32 %30, -1
%32 = zext i1 %31 to i32
%33 = call i32 @assert(i32 %32)
%34 = call i32 @valid_main_category(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0))
%35 = icmp ne i32 %34, -1
%36 = zext i1 %35 to i32
%37 = call i32 @assert(i32 %36)
%38 = call i32 @valid_additional_category(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.8, i64 0, i64 0))
%39 = icmp ne i32 %38, -1
%40 = zext i1 %39 to i32
%41 = call i32 @assert(i32 %40)
%42 = call i32 @valid_additional_category(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.9, i64 0, i64 0))
%43 = icmp ne i32 %42, -1
%44 = zext i1 %43 to i32
%45 = call i32 @assert(i32 %44)
%46 = call i32 @valid_additional_category(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0))
%47 = icmp eq i32 %46, -1
%48 = zext i1 %47 to i32
%49 = call i32 @assert(i32 %48)
%50 = call i32 @valid_additional_category(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.10, i64 0, i64 0))
%51 = icmp ne i32 %50, -1
%52 = zext i1 %51 to i32
%53 = call i32 @assert(i32 %52)
%54 = call i32 @valid_additional_category(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i64 0, i64 0))
%55 = icmp eq i32 %54, -1
%56 = zext i1 %55 to i32
%57 = call i32 @assert(i32 %56)
%58 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @str, i64 0, i64 0))
ret void
}