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

/* Variables and functions */
char *keyvals_get_val(struct keyval const *, char *);
scalar_t__ strcmp(char const *, char *);
int /*<<< orphan*/ track_is_compilation(struct keyval const *);
scalar_t__ track_is_va_compilation(struct keyval const *);
const char *comments_get_artistsort(const struct keyval *comments) {
  const char *val;
  if (track_is_va_compilation(comments))
    return NULL;
  val = keyvals_get_val(comments, "albumartistsort");
  if (!track_is_compilation(comments)) {
    if (!val || strcmp(val, "") == 0)
      val = keyvals_get_val(comments, "artistsort");
  }
  if (!val || strcmp(val, "") == 0)
    return NULL;
  return val;
}


x86 assembly (clang, -O0):
<comments_get_artistsort>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <track_is_va_compilation@plt>
cmp    $0x0,%rax
je     116c <comments_get_artistsort+0x2c>
movq   $0x0,-0x8(%rbp)
jmp    120a <comments_get_artistsort+0xca>
mov    -0x10(%rbp),%rdi
lea    0xe89(%rip),%rsi
call   1060 <keyvals_get_val@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <track_is_compilation@plt>
cmp    $0x0,%eax
jne    11d0 <comments_get_artistsort+0x90>
cmpq   $0x0,-0x18(%rbp)
je     11b7 <comments_get_artistsort+0x77>
mov    -0x18(%rbp),%rdi
lea    0xe67(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11cb <comments_get_artistsort+0x8b>
mov    -0x10(%rbp),%rdi
lea    0xe43(%rip),%rsi
call   1060 <keyvals_get_val@plt>
mov    %rax,-0x18(%rbp)
jmp    11d0 <comments_get_artistsort+0x90>
cmpq   $0x0,-0x18(%rbp)
je     11f5 <comments_get_artistsort+0xb5>
mov    -0x18(%rbp),%rdi
lea    0xe29(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1202 <comments_get_artistsort+0xc2>
movq   $0x0,-0x8(%rbp)
jmp    120a <comments_get_artistsort+0xca>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<comments_get_artistsort>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1030 <track_is_va_compilation@plt>
test   %rax,%rax
je     1156 <comments_get_artistsort+0x16>
xor    %r14d,%r14d
jmp    11c1 <comments_get_artistsort+0x81>
lea    0xea3(%rip),%rsi
mov    %rbx,%rdi
call   1060 <keyvals_get_val@plt>
mov    %rax,%r14
mov    %rbx,%rdi
call   1050 <track_is_compilation@plt>
test   %eax,%eax
je     117b <comments_get_artistsort+0x3b>
test   %r14,%r14
jne    11ab <comments_get_artistsort+0x6b>
jmp    1151 <comments_get_artistsort+0x11>
test   %r14,%r14
je     1194 <comments_get_artistsort+0x54>
lea    0xe88(%rip),%rsi
mov    %r14,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
jne    11ab <comments_get_artistsort+0x6b>
lea    0xe6a(%rip),%rsi
mov    %rbx,%rdi
call   1060 <keyvals_get_val@plt>
mov    %rax,%r14
test   %r14,%r14
je     1151 <comments_get_artistsort+0x11>
lea    0xe5d(%rip),%rsi
mov    %r14,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
cmove  %rax,%r14
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.keyval = type { i32 }
@.str = [16 x i8] c"albumartistsort\00"
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [11 x i8] c"artistsort\00"
define i8* @comments_get_artistsort(%struct.keyval* %0) {
%2 = alloca i8*
%3 = alloca %struct.keyval*
%4 = alloca i8*
store %struct.keyval* %0, %struct.keyval** %3
%5 = load %struct.keyval*, %struct.keyval** %3
%6 = call i64 @track_is_va_compilation(%struct.keyval* %5)
%7 = icmp ne i64 %6, 0
br i1 %7, label %8, label %9
8: ; preds = %1
store i8* null, i8** %2
br label %36
9: ; preds = %1
%10 = load %struct.keyval*, %struct.keyval** %3
%11 = call i8* @keyvals_get_val(%struct.keyval* %10, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
store i8* %11, i8** %4
%12 = load %struct.keyval*, %struct.keyval** %3
%13 = call i32 @track_is_compilation(%struct.keyval* %12)
%14 = icmp ne i32 %13, 0
br i1 %14, label %26, label %15
15: ; preds = %9
%16 = load i8*, i8** %4
%17 = icmp ne i8* %16, null
br i1 %17, label %18, label %22
18: ; preds = %15
%19 = load i8*, i8** %4
%20 = call i64 @strcmp(i8* %19, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %25
22: ; preds = %18, %15
%23 = load %struct.keyval*, %struct.keyval** %3
%24 = call i8* @keyvals_get_val(%struct.keyval* %23, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
store i8* %24, i8** %4
br label %25
25: ; preds = %22, %18
br label %26
26: ; preds = %25, %9
%27 = load i8*, i8** %4
%28 = icmp ne i8* %27, null
br i1 %28, label %29, label %33
29: ; preds = %26
%30 = load i8*, i8** %4
%31 = call i64 @strcmp(i8* %30, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
%32 = icmp eq i64 %31, 0
br i1 %32, label %33, label %34
33: ; preds = %29, %26
store i8* null, i8** %2
br label %36
34: ; preds = %29
%35 = load i8*, i8** %4
store i8* %35, i8** %2
br label %36
36: ; preds = %34, %33, %8
%37 = load i8*, i8** %2
ret i8* %37
}

LLVM IR (-O2):
%struct.keyval = type { i32 }
@.str = [16 x i8] c"albumartistsort\00"
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [11 x i8] c"artistsort\00"
define i8* @comments_get_artistsort(%struct.keyval* %0) {
%2 = tail call i64 @track_is_va_compilation(%struct.keyval* %0)
%3 = icmp eq i64 %2, 0
br i1 %3, label %4, label %23
4: ; preds = %1
%5 = tail call i8* @keyvals_get_val(%struct.keyval* %0, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%6 = tail call i32 @track_is_compilation(%struct.keyval* %0)
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %15
8: ; preds = %4
%9 = icmp eq i8* %5, null
br i1 %9, label %13, label %10
10: ; preds = %8
%11 = tail call i64 @strcmp(i8* %5, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %18
13: ; preds = %10, %8
%14 = tail call i8* @keyvals_get_val(%struct.keyval* %0, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
br label %15
15: ; preds = %13, %4
%16 = phi i8* [ %5, %4 ], [ %14, %13 ]
%17 = icmp eq i8* %16, null
br i1 %17, label %23, label %18
18: ; preds = %10, %15
%19 = phi i8* [ %16, %15 ], [ %5, %10 ]
%20 = tail call i64 @strcmp(i8* %19, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
%21 = icmp eq i64 %20, 0
%22 = select i1 %21, i8* null, i8* %19
br label %23
23: ; preds = %18, %15, %1
%24 = phi i8* [ null, %1 ], [ null, %15 ], [ %22, %18 ]
ret i8* %24
}