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

/* Variables and functions */
int kind_cmp(struct tag const *, struct tag const *);
int visibility_cmp(struct tag const *, struct tag const *);
int tag_cmp(const void *ap, const void *bp) {
  const struct tag *a = *(const struct tag **)ap;
  const struct tag *b = *(const struct tag **)bp;
  int ret;
  ret = visibility_cmp(a, b);
  if (ret)
    return ret;
  return kind_cmp(a, b);
}


x86 assembly (clang, -O0):
<tag_cmp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1030 <visibility_cmp@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
je     116b <tag_cmp+0x4b>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    117b <tag_cmp+0x5b>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1040 <kind_cmp@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tag_cmp>:
push   %r14
push   %rbx
push   %rax
mov    (%rdi),%rbx
mov    (%rsi),%r14
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <visibility_cmp@plt>
test   %eax,%eax
je     1141 <tag_cmp+0x21>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    %rbx,%rdi
mov    %r14,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <kind_cmp@plt>

LLVM IR (-O0):
%struct.tag = type { i32 }
define i32 @tag_cmp(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca %struct.tag*
%7 = alloca %struct.tag*
%8 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
%9 = load i8*, i8** %4
%10 = bitcast i8* %9 to %struct.tag**
%11 = load %struct.tag*, %struct.tag** %10
store %struct.tag* %11, %struct.tag** %6
%12 = load i8*, i8** %5
%13 = bitcast i8* %12 to %struct.tag**
%14 = load %struct.tag*, %struct.tag** %13
store %struct.tag* %14, %struct.tag** %7
%15 = load %struct.tag*, %struct.tag** %6
%16 = load %struct.tag*, %struct.tag** %7
%17 = call i32 @visibility_cmp(%struct.tag* %15, %struct.tag* %16)
store i32 %17, i32* %8
%18 = load i32, i32* %8
%19 = icmp ne i32 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %2
%21 = load i32, i32* %8
store i32 %21, i32* %3
br label %26
22: ; preds = %2
%23 = load %struct.tag*, %struct.tag** %6
%24 = load %struct.tag*, %struct.tag** %7
%25 = call i32 @kind_cmp(%struct.tag* %23, %struct.tag* %24)
store i32 %25, i32* %3
br label %26
26: ; preds = %22, %20
%27 = load i32, i32* %3
ret i32 %27
}

LLVM IR (-O2):
%struct.tag = type { i32 }
define i32 @tag_cmp(i8* nocapture %0, i8* nocapture %1) {
%3 = bitcast i8* %0 to %struct.tag**
%4 = load %struct.tag*, %struct.tag** %3
%5 = bitcast i8* %1 to %struct.tag**
%6 = load %struct.tag*, %struct.tag** %5
%7 = tail call i32 @visibility_cmp(%struct.tag* %4, %struct.tag* %6)
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = tail call i32 @kind_cmp(%struct.tag* %4, %struct.tag* %6)
br label %11
11: ; preds = %2, %9
%12 = phi i32 [ %10, %9 ], [ %7, %2 ]
ret i32 %12
}