int music_run_once_check(void (*func)(void), void *restrict arg) {
  static struct func_slist {
    struct func_slist *next;
    void (*func)(void);
    void *arg;
  } *first = 0;
  struct func_slist *el = first;
  while (el && (el->func != func || el->arg != arg))
    el = el->next;
  if (el) {
    return 0;
  }
  el = malloc(sizeof *el);
  el->next = first;
  el->func = func;
  el->arg = arg;
  first = el;
  return 1;
}


x86 assembly (clang, -O0):
<music_run_once_check>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    0x2f09(%rip),%rax
mov    %rax,-0x20(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x20(%rbp)
mov    %al,-0x21(%rbp)
je     116a <music_run_once_check+0x5a>
mov    -0x20(%rbp),%rax
mov    0x8(%rax),%rcx
mov    $0x1,%al
cmp    -0x10(%rbp),%rcx
mov    %al,-0x22(%rbp)
jne    1164 <music_run_once_check+0x54>
mov    -0x20(%rbp),%rax
mov    0x10(%rax),%rax
cmp    -0x18(%rbp),%rax
setne  %al
mov    %al,-0x22(%rbp)
mov    -0x22(%rbp),%al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    117a <music_run_once_check+0x6a>
jmp    118a <music_run_once_check+0x7a>
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
jmp    112b <music_run_once_check+0x1b>
cmpq   $0x0,-0x20(%rbp)
je     11a1 <music_run_once_check+0x91>
movl   $0x0,-0x4(%rbp)
jmp    11e7 <music_run_once_check+0xd7>
mov    $0x18,%edi
call   1030 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    0x2e7a(%rip),%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x10(%rbp),%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,0x8(%rax)
mov    -0x18(%rbp),%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,0x10(%rax)
mov    -0x20(%rbp),%rax
mov    %rax,0x2e50(%rip)
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<music_run_once_check>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
mov    0x2f0e(%rip),%r15
test   %r15,%r15
je     1148 <music_run_once_check+0x38>
mov    %r15,%rax
jmp    1138 <music_run_once_check+0x28>
nopl   0x0(%rax)
mov    (%rax),%rax
test   %rax,%rax
je     1148 <music_run_once_check+0x38>
cmp    %rbx,0x8(%rax)
jne    1130 <music_run_once_check+0x20>
cmp    %r14,0x10(%rax)
jne    1130 <music_run_once_check+0x20>
xor    %eax,%eax
jmp    1169 <music_run_once_check+0x59>
mov    $0x18,%edi
call   1030 <malloc@plt>
mov    %r15,(%rax)
mov    %rbx,0x8(%rax)
mov    %r14,0x10(%rax)
mov    %rax,0x2ecc(%rip)
mov    $0x1,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.func_slist = type { %struct.func_slist*, void ()*, i8* }
@music_run_once_check.first = internal global %struct.func_slist* null
define i32 @music_run_once_check(void ()* %0, i8* noalias %1) {
%3 = alloca i32
%4 = alloca void ()*
%5 = alloca i8*
%6 = alloca %struct.func_slist*
store void ()* %0, void ()** %4
store i8* %1, i8** %5
%7 = load %struct.func_slist*, %struct.func_slist** @music_run_once_check.first
store %struct.func_slist* %7, %struct.func_slist** %6
br label %8
8: ; preds = %27, %2
%9 = load %struct.func_slist*, %struct.func_slist** %6
%10 = icmp ne %struct.func_slist* %9, null
br i1 %10, label %11, label %25
11: ; preds = %8
%12 = load %struct.func_slist*, %struct.func_slist** %6
%13 = getelementptr inbounds %struct.func_slist, %struct.func_slist* %12, i32 0, i32 1
%14 = load void ()*, void ()** %13
%15 = load void ()*, void ()** %4
%16 = icmp ne void ()* %14, %15
br i1 %16, label %23, label %17
17: ; preds = %11
%18 = load %struct.func_slist*, %struct.func_slist** %6
%19 = getelementptr inbounds %struct.func_slist, %struct.func_slist* %18, i32 0, i32 2
%20 = load i8*, i8** %19
%21 = load i8*, i8** %5
%22 = icmp ne i8* %20, %21
br label %23
23: ; preds = %17, %11
%24 = phi i1 [ true, %11 ], [ %22, %17 ]
br label %25
25: ; preds = %23, %8
%26 = phi i1 [ false, %8 ], [ %24, %23 ]
br i1 %26, label %27, label %31
27: ; preds = %25
%28 = load %struct.func_slist*, %struct.func_slist** %6
%29 = getelementptr inbounds %struct.func_slist, %struct.func_slist* %28, i32 0, i32 0
%30 = load %struct.func_slist*, %struct.func_slist** %29
store %struct.func_slist* %30, %struct.func_slist** %6
br label %8
31: ; preds = %25
%32 = load %struct.func_slist*, %struct.func_slist** %6
%33 = icmp ne %struct.func_slist* %32, null
br i1 %33, label %34, label %35
34: ; preds = %31
store i32 0, i32* %3
br label %48
35: ; preds = %31
%36 = call i8* @malloc(i64 24)
%37 = bitcast i8* %36 to %struct.func_slist*
store %struct.func_slist* %37, %struct.func_slist** %6
%38 = load %struct.func_slist*, %struct.func_slist** @music_run_once_check.first
%39 = load %struct.func_slist*, %struct.func_slist** %6
%40 = getelementptr inbounds %struct.func_slist, %struct.func_slist* %39, i32 0, i32 0
store %struct.func_slist* %38, %struct.func_slist** %40
%41 = load void ()*, void ()** %4
%42 = load %struct.func_slist*, %struct.func_slist** %6
%43 = getelementptr inbounds %struct.func_slist, %struct.func_slist* %42, i32 0, i32 1
store void ()* %41, void ()** %43
%44 = load i8*, i8** %5
%45 = load %struct.func_slist*, %struct.func_slist** %6
%46 = getelementptr inbounds %struct.func_slist, %struct.func_slist* %45, i32 0, i32 2
store i8* %44, i8** %46
%47 = load %struct.func_slist*, %struct.func_slist** %6
store %struct.func_slist* %47, %struct.func_slist** @music_run_once_check.first
store i32 1, i32* %3
br label %48
48: ; preds = %35, %34
%49 = load i32, i32* %3
ret i32 %49
}

LLVM IR (-O2):
%struct.func_slist = type { %struct.func_slist*, void ()*, i8* }
@music_run_once_check.first = internal unnamed_addr global %struct.func_slist* null
define i32 @music_run_once_check(void ()* %0, i8* noalias %1) {
%3 = load %struct.func_slist*, %struct.func_slist** @music_run_once_check.first
%4 = icmp eq %struct.func_slist* %3, null
br i1 %4, label %18, label %5
5: ; preds = %2, %14
%6 = phi %struct.func_slist* [ %16, %14 ], [ %3, %2 ]
%7 = getelementptr inbounds %struct.func_slist, %struct.func_slist* %6, i64 0, i32 1
%8 = load void ()*, void ()** %7
%9 = icmp eq void ()* %8, %0
br i1 %9, label %10, label %14
10: ; preds = %5
%11 = getelementptr inbounds %struct.func_slist, %struct.func_slist* %6, i64 0, i32 2
%12 = load i8*, i8** %11
%13 = icmp eq i8* %12, %1
br i1 %13, label %24, label %14
14: ; preds = %5, %10
%15 = getelementptr inbounds %struct.func_slist, %struct.func_slist* %6, i64 0, i32 0
%16 = load %struct.func_slist*, %struct.func_slist** %15
%17 = icmp eq %struct.func_slist* %16, null
br i1 %17, label %18, label %5
18: ; preds = %14, %2
%19 = tail call dereferenceable_or_null(24) i8* @malloc(i64 24)
%20 = bitcast i8* %19 to %struct.func_slist*
%21 = getelementptr inbounds %struct.func_slist, %struct.func_slist* %20, i64 0, i32 0
store %struct.func_slist* %3, %struct.func_slist** %21
%22 = getelementptr inbounds %struct.func_slist, %struct.func_slist* %20, i64 0, i32 1
store void ()* %0, void ()** %22
%23 = getelementptr inbounds %struct.func_slist, %struct.func_slist* %20, i64 0, i32 2
store i8* %1, i8** %23
store i8* %19, i8** bitcast (%struct.func_slist** @music_run_once_check.first to i8**)
br label %24
24: ; preds = %10, %18
%25 = phi i32 [ 1, %18 ], [ 0, %10 ]
ret i32 %25
}