#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;
};
struct katcl_parse {
  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_parse_notice_katcp(struct katcp_dispatch *, char *,
                                               int /*<<< orphan*/,
                                               struct katcl_parse *);
struct katcp_notice *register_parse_notice_katcp(
    struct katcp_dispatch *d, char *name, struct katcl_parse *p,
    int (*call)(struct katcp_dispatch *d, struct katcp_notice *n, void *data),
    void *data) {
  struct katcp_notice *n;
  n = create_parse_notice_katcp(d, name, 0, p);
  if (n == NULL)
    return NULL;
  if (add_notice_katcp(d, n, call, data) < 0)
    return NULL;
  return n;
}


x86 assembly (clang, -O0):
<register_parse_notice_katcp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rcx
xor    %edx,%edx
call   1030 <create_parse_notice_katcp@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    116b <register_parse_notice_katcp+0x4b>
movq   $0x0,-0x8(%rbp)
jmp    119f <register_parse_notice_katcp+0x7f>
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    1197 <register_parse_notice_katcp+0x77>
movq   $0x0,-0x8(%rbp)
jmp    119f <register_parse_notice_katcp+0x7f>
mov    -0x38(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<register_parse_notice_katcp>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %r8,%r14
mov    %rcx,%r15
mov    %rdx,%rcx
mov    %rdi,%r13
xor    %ebx,%ebx
xor    %edx,%edx
call   1030 <create_parse_notice_katcp@plt>
test   %rax,%rax
je     1160 <register_parse_notice_katcp+0x40>
mov    %rax,%r12
mov    %r13,%rdi
mov    %rax,%rsi
mov    %r15,%rdx
mov    %r14,%rcx
call   1040 <add_notice_katcp@plt>
xor    %ebx,%ebx
test   %rax,%rax
cmovns %r12,%rbx
mov    %rbx,%rax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.katcp_notice = type { i32 }
%struct.katcp_dispatch = type { i32 }
%struct.katcl_parse = type { i32 }
define %struct.katcp_notice* @register_parse_notice_katcp(%struct.katcp_dispatch* %0, i8* %1, %struct.katcl_parse* %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 %struct.katcl_parse*
%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 %struct.katcl_parse* %2, %struct.katcl_parse** %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 %struct.katcl_parse*, %struct.katcl_parse** %9
%16 = call %struct.katcp_notice* @create_parse_notice_katcp(%struct.katcp_dispatch* %13, i8* %14, i32 0, %struct.katcl_parse* %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 }
%struct.katcl_parse = type { i32 }
define %struct.katcp_notice* @register_parse_notice_katcp(%struct.katcp_dispatch* %0, i8* %1, %struct.katcl_parse* %2, i32 (%struct.katcp_dispatch*, %struct.katcp_notice*, i8*)* %3, i8* %4) {
%6 = tail call %struct.katcp_notice* @create_parse_notice_katcp(%struct.katcp_dispatch* %0, i8* %1, i32 0, %struct.katcl_parse* %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
}