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

/* Variables and functions */
struct katcp_tobject *create_named_tobject_katcp(struct katcp_dispatch *,
                                                 void *, char *,
                                                 int /*<<< orphan*/);
int push_tobject_katcp(struct katcp_stack *, struct katcp_tobject *);
int push_named_stack_katcp(struct katcp_dispatch *d, struct katcp_stack *s,
                           void *data, char *type) {
  struct katcp_tobject *o;
  if (s == NULL || type == NULL)
    return -1;
  o = create_named_tobject_katcp(d, data, type, 0);
  if (o == NULL)
    return -1;
  return push_tobject_katcp(s, o);
}


x86 assembly (clang, -O0):
<push_named_stack_katcp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     114e <push_named_stack_katcp+0x2e>
cmpq   $0x0,-0x28(%rbp)
jne    115a <push_named_stack_katcp+0x3a>
movl   $0xffffffff,-0x4(%rbp)
jmp    1198 <push_named_stack_katcp+0x78>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
xor    %ecx,%ecx
call   1040 <create_named_tobject_katcp@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    1188 <push_named_stack_katcp+0x68>
movl   $0xffffffff,-0x4(%rbp)
jmp    1198 <push_named_stack_katcp+0x78>
mov    -0x18(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1030 <push_tobject_katcp@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<push_named_stack_katcp>:
push   %rbx
test   %rsi,%rsi
je     114c <push_named_stack_katcp+0x2c>
test   %rcx,%rcx
je     114c <push_named_stack_katcp+0x2c>
mov    %rsi,%rbx
mov    %rdx,%rsi
mov    %rcx,%rdx
xor    %ecx,%ecx
call   1040 <create_named_tobject_katcp@plt>
test   %rax,%rax
je     114c <push_named_stack_katcp+0x2c>
mov    %rbx,%rdi
mov    %rax,%rsi
pop    %rbx
jmp    1030 <push_tobject_katcp@plt>
mov    $0xffffffff,%eax
pop    %rbx
ret

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

LLVM IR (-O2):
%struct.katcp_dispatch = type { i32 }
%struct.katcp_stack = type { i32 }
%struct.katcp_tobject = type { i32 }
define i32 @push_named_stack_katcp(%struct.katcp_dispatch* %0, %struct.katcp_stack* %1, i8* %2, i8* %3) {
%5 = icmp eq %struct.katcp_stack* %1, null
%6 = icmp eq i8* %3, null
%7 = or i1 %5, %6
br i1 %7, label %13, label %8
8: ; preds = %4
%9 = tail call %struct.katcp_tobject* @create_named_tobject_katcp(%struct.katcp_dispatch* %0, i8* %2, i8* %3, i32 0)
%10 = icmp eq %struct.katcp_tobject* %9, null
br i1 %10, label %13, label %11
11: ; preds = %8
%12 = tail call i32 @push_tobject_katcp(%struct.katcp_stack* %1, %struct.katcp_tobject* %9)
br label %13
13: ; preds = %8, %4, %11
%14 = phi i32 [ %12, %11 ], [ -1, %4 ], [ -1, %8 ]
ret i32 %14
}