#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 katcp_notice {
  int dummy;
};
struct katcp_dispatch {
  int dummy;
};

/* Variables and functions */
scalar_t__ add_notice_katcp(struct katcp_dispatch *, struct katcp_notice *,
                            int (*)(struct katcp_dispatch *,
                                    struct katcp_notice *, void *),
                            void *);
struct katcp_notice *create_notice_katcp(struct katcp_dispatch *, char *,
                                         unsigned int);
struct katcp_notice *register_notice_katcp(
    struct katcp_dispatch *d, char *name, unsigned int tag,
    int (*call)(struct katcp_dispatch *d, struct katcp_notice *n, void *data),
    void *data) {
  struct katcp_notice *n;
  n = create_notice_katcp(d, name, tag);
  if (n == NULL) {
    return NULL;
  }
  if (add_notice_katcp(d, n, call, data) < 0) {
    return NULL;
  }
  return n;
}


x86 assembly (clang, -O0):
<register_notice_katcp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1030 <create_notice_katcp@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    1167 <register_notice_katcp+0x47>
movq   $0x0,-0x8(%rbp)
jmp    119b <register_notice_katcp+0x7b>
mov    -0x10(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    -0x28(%rbp),%rdx
mov    -0x30(%rbp),%rcx
call   1040 <add_notice_katcp@plt>
cmp    $0x0,%rax
jge    1193 <register_notice_katcp+0x73>
movq   $0x0,-0x8(%rbp)
jmp    119b <register_notice_katcp+0x7b>
mov    -0x38(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<register_notice_katcp>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %r8,%r14
mov    %rcx,%r15
mov    %rdi,%r12
call   1030 <create_notice_katcp@plt>
test   %rax,%rax
je     115d <register_notice_katcp+0x3d>
mov    %rax,%rbx
mov    %r12,%rdi
mov    %rax,%rsi
mov    %r15,%rdx
mov    %r14,%rcx
call   1040 <add_notice_katcp@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
cmovns %rbx,%rax
jmp    115f <register_notice_katcp+0x3f>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.katcp_notice = type { i32 }
%struct.katcp_dispatch = type { i32 }
define %struct.katcp_notice* @register_notice_katcp(%struct.katcp_dispatch* %0, i8* %1, i32 %2, i32 (%struct.katcp_dispatch*, %struct.katcp_notice*, i8*)* %3, i8* %4) {
%6 = alloca %struct.katcp_notice*
%7 = alloca %struct.katcp_dispatch*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32 (%struct.katcp_dispatch*, %struct.katcp_notice*, i8*)*
%11 = alloca i8*
%12 = alloca %struct.katcp_notice*
store %struct.katcp_dispatch* %0, %struct.katcp_dispatch** %7
store i8* %1, i8** %8
store i32 %2, i32* %9
store i32 (%struct.katcp_dispatch*, %struct.katcp_notice*, i8*)* %3, i32 (%struct.katcp_dispatch*, %struct.katcp_notice*, i8*)** %10
store i8* %4, i8** %11
%13 = load %struct.katcp_dispatch*, %struct.katcp_dispatch** %7
%14 = load i8*, i8** %8
%15 = load i32, i32* %9
%16 = call %struct.katcp_notice* @create_notice_katcp(%struct.katcp_dispatch* %13, i8* %14, i32 %15)
store %struct.katcp_notice* %16, %struct.katcp_notice** %12
%17 = load %struct.katcp_notice*, %struct.katcp_notice** %12
%18 = icmp eq %struct.katcp_notice* %17, null
br i1 %18, label %19, label %20
19: ; preds = %5
store %struct.katcp_notice* null, %struct.katcp_notice** %6
br label %30
20: ; preds = %5
%21 = load %struct.katcp_dispatch*, %struct.katcp_dispatch** %7
%22 = load %struct.katcp_notice*, %struct.katcp_notice** %12
%23 = load i32 (%struct.katcp_dispatch*, %struct.katcp_notice*, i8*)*, i32 (%struct.katcp_dispatch*, %struct.katcp_notice*, i8*)** %10
%24 = load i8*, i8** %11
%25 = call i64 @add_notice_katcp(%struct.katcp_dispatch* %21, %struct.katcp_notice* %22, i32 (%struct.katcp_dispatch*, %struct.katcp_notice*, i8*)* %23, i8* %24)
%26 = icmp slt i64 %25, 0
br i1 %26, label %27, label %28
27: ; preds = %20
store %struct.katcp_notice* null, %struct.katcp_notice** %6
br label %30
28: ; preds = %20
%29 = load %struct.katcp_notice*, %struct.katcp_notice** %12
store %struct.katcp_notice* %29, %struct.katcp_notice** %6
br label %30
30: ; preds = %28, %27, %19
%31 = load %struct.katcp_notice*, %struct.katcp_notice** %6
ret %struct.katcp_notice* %31
}

LLVM IR (-O2):
%struct.katcp_notice = type { i32 }
%struct.katcp_dispatch = type { i32 }
define %struct.katcp_notice* @register_notice_katcp(%struct.katcp_dispatch* %0, i8* %1, i32 %2, i32 (%struct.katcp_dispatch*, %struct.katcp_notice*, i8*)* %3, i8* %4) {
%6 = tail call %struct.katcp_notice* @create_notice_katcp(%struct.katcp_dispatch* %0, i8* %1, i32 %2)
%7 = icmp eq %struct.katcp_notice* %6, null
br i1 %7, label %12, label %8
8: ; preds = %5
%9 = tail call i64 @add_notice_katcp(%struct.katcp_dispatch* %0, %struct.katcp_notice* %6, i32 (%struct.katcp_dispatch*, %struct.katcp_notice*, i8*)* %3, i8* %4)
%10 = icmp slt i64 %9, 0
%11 = select i1 %10, %struct.katcp_notice* null, %struct.katcp_notice* %6
br label %12
12: ; preds = %8, %5
%13 = phi %struct.katcp_notice* [ null, %5 ], [ %11, %8 ]
ret %struct.katcp_notice* %13
}