#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 pane {
  int dummy;
};
struct doc {
  int dummy;
};
struct command {
  int dummy;
};

/* Variables and functions */
struct pane *__pane_register(struct pane *, int /*<<< orphan*/,
                             struct command *, struct doc *, short);
int /*<<< orphan*/ abort();
int /*<<< orphan*/ doc_init(struct doc *);
struct pane *pane_root(struct pane *);
struct pane *__doc_register(struct pane *parent, struct command *handle,
                            struct doc *doc, void *data, short data_size) {
  struct pane *p;
  do {
    if (!(data_size == 0 || data == (void *)doc))
      abort();
  } while (0);
  if (parent)
    parent = pane_root(parent);
  doc_init(doc);
  p = __pane_register(parent, 0, handle, doc, data_size);
  return p;
}


x86 assembly (clang, -O0):
<__doc_register>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %r8w,%ax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %ax,-0x22(%rbp)
movswl -0x22(%rbp),%eax
cmp    $0x0,%eax
je     1185 <__doc_register+0x45>
mov    -0x20(%rbp),%rax
mov    -0x18(%rbp),%rcx
cmp    %rcx,%rax
je     1185 <__doc_register+0x45>
mov    $0x0,%al
call   1030 <abort@plt>
jmp    118a <__doc_register+0x4a>
cmpq   $0x0,-0x8(%rbp)
je     11a2 <__doc_register+0x62>
mov    -0x8(%rbp),%rdi
call   1050 <pane_root@plt>
mov    %rax,-0x8(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <doc_init@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rcx
xor    %esi,%esi
movswl -0x22(%rbp),%r8d
call   1060 <__pane_register@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__doc_register>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %r8d,%r15d
mov    %rdx,%rbx
mov    %rsi,%r14
cmp    %rcx,%rdx
je     115b <__doc_register+0x1b>
test   %r15w,%r15w
jne    1192 <__doc_register+0x52>
test   %rdi,%rdi
je     116a <__doc_register+0x2a>
call   1050 <pane_root@plt>
mov    %rax,%rbp
jmp    116c <__doc_register+0x2c>
xor    %ebp,%ebp
mov    %rbx,%rdi
call   1040 <doc_init@plt>
movswl %r15w,%r8d
mov    %rbp,%rdi
xor    %esi,%esi
mov    %r14,%rdx
mov    %rbx,%rcx
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1060 <__pane_register@plt>
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
%struct.pane = type { i32 }
%struct.command = type { i32 }
%struct.doc = type { i32 }
define %struct.pane* @__doc_register(%struct.pane* %0, %struct.command* %1, %struct.doc* %2, i8* %3, i16 signext %4) {
%6 = alloca %struct.pane*
%7 = alloca %struct.command*
%8 = alloca %struct.doc*
%9 = alloca i8*
%10 = alloca i16
%11 = alloca %struct.pane*
store %struct.pane* %0, %struct.pane** %6
store %struct.command* %1, %struct.command** %7
store %struct.doc* %2, %struct.doc** %8
store i8* %3, i8** %9
store i16 %4, i16* %10
br label %12
12: ; preds = %5
%13 = load i16, i16* %10
%14 = sext i16 %13 to i32
%15 = icmp eq i32 %14, 0
br i1 %15, label %23, label %16
16: ; preds = %12
%17 = load i8*, i8** %9
%18 = load %struct.doc*, %struct.doc** %8
%19 = bitcast %struct.doc* %18 to i8*
%20 = icmp eq i8* %17, %19
br i1 %20, label %23, label %21
21: ; preds = %16
%22 = call i32 (...) @abort()
unreachable
23: ; preds = %16, %12
br label %24
24: ; preds = %23
%25 = load %struct.pane*, %struct.pane** %6
%26 = icmp ne %struct.pane* %25, null
br i1 %26, label %27, label %30
27: ; preds = %24
%28 = load %struct.pane*, %struct.pane** %6
%29 = call %struct.pane* @pane_root(%struct.pane* %28)
store %struct.pane* %29, %struct.pane** %6
br label %30
30: ; preds = %27, %24
%31 = load %struct.doc*, %struct.doc** %8
%32 = call i32 @doc_init(%struct.doc* %31)
%33 = load %struct.pane*, %struct.pane** %6
%34 = load %struct.command*, %struct.command** %7
%35 = load %struct.doc*, %struct.doc** %8
%36 = load i16, i16* %10
%37 = call %struct.pane* @__pane_register(%struct.pane* %33, i32 0, %struct.command* %34, %struct.doc* %35, i16 signext %36)
store %struct.pane* %37, %struct.pane** %11
%38 = load %struct.pane*, %struct.pane** %11
ret %struct.pane* %38
}

LLVM IR (-O2):
%struct.pane = type { i32 }
%struct.command = type { i32 }
%struct.doc = type { i32 }
define %struct.pane* @__doc_register(%struct.pane* %0, %struct.command* %1, %struct.doc* %2, i8* readnone %3, i16 signext %4) {
%6 = icmp eq i16 %4, 0
%7 = bitcast %struct.doc* %2 to i8*
%8 = icmp eq i8* %7, %3
%9 = or i1 %8, %6
br i1 %9, label %12, label %10
10: ; preds = %5
%11 = tail call i32 (...) @abort()
unreachable
12: ; preds = %5
%13 = icmp eq %struct.pane* %0, null
br i1 %13, label %16, label %14
14: ; preds = %12
%15 = tail call %struct.pane* @pane_root(%struct.pane* %0)
br label %16
16: ; preds = %14, %12
%17 = phi %struct.pane* [ %15, %14 ], [ null, %12 ]
%18 = tail call i32 @doc_init(%struct.doc* %2)
%19 = tail call %struct.pane* @__pane_register(%struct.pane* %17, i32 0, %struct.command* %1, %struct.doc* %2, i16 signext %4)
ret %struct.pane* %19
}