#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 *);
const char *comments_get_albumartist(const struct keyval *comments) {
  const char *val = keyvals_get_val(comments, "albumartist");
  if (!val || strcmp(val, "") == 0)
    val = keyvals_get_val(comments, "artist");
  return val;
}


x86 assembly (clang, -O0):
<comments_get_albumartist>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xec9(%rip),%rsi
call   1040 <keyvals_get_val@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1165 <comments_get_albumartist+0x45>
mov    -0x10(%rbp),%rdi
lea    0xeb5(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    1179 <comments_get_albumartist+0x59>
mov    -0x8(%rbp),%rdi
lea    0xe95(%rip),%rsi
call   1040 <keyvals_get_val@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<comments_get_albumartist>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
lea    0xed2(%rip),%rsi
call   1040 <keyvals_get_val@plt>
test   %rax,%rax
je     115a <comments_get_albumartist+0x3a>
mov    %rax,%rbx
lea    0xec9(%rip),%rsi
mov    %rax,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     115a <comments_get_albumartist+0x3a>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
lea    0xea4(%rip),%rsi
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <keyvals_get_val@plt>

LLVM IR (-O0):
%struct.keyval = type { i32 }
@.str = [12 x i8] c"albumartist\00"
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [7 x i8] c"artist\00"
define i8* @comments_get_albumartist(%struct.keyval* %0) {
%2 = alloca %struct.keyval*
%3 = alloca i8*
store %struct.keyval* %0, %struct.keyval** %2
%4 = load %struct.keyval*, %struct.keyval** %2
%5 = call i8* @keyvals_get_val(%struct.keyval* %4, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
store i8* %5, i8** %3
%6 = load i8*, i8** %3
%7 = icmp ne i8* %6, null
br i1 %7, label %8, label %12
8: ; preds = %1
%9 = load i8*, i8** %3
%10 = call i64 @strcmp(i8* %9, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %8, %1
%13 = load %struct.keyval*, %struct.keyval** %2
%14 = call i8* @keyvals_get_val(%struct.keyval* %13, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
store i8* %14, i8** %3
br label %15
15: ; preds = %12, %8
%16 = load i8*, i8** %3
ret i8* %16
}

LLVM IR (-O2):
%struct.keyval = type { i32 }
@.str = [12 x i8] c"albumartist\00"
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [7 x i8] c"artist\00"
define i8* @comments_get_albumartist(%struct.keyval* %0) {
%2 = tail call i8* @keyvals_get_val(%struct.keyval* %0, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i8* %2, null
br i1 %3, label %7, label %4
4: ; preds = %1
%5 = tail call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %4, %1
%8 = tail call i8* @keyvals_get_val(%struct.keyval* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
br label %9
9: ; preds = %7, %4
%10 = phi i8* [ %8, %7 ], [ %2, %4 ]
ret i8* %10
}