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

/* Variables and functions */
struct katcp_tobject *create_tobject_katcp(void *, struct katcp_type *,
                                           int /*<<< orphan*/);
int push_tobject_katcp(struct katcp_stack *, struct katcp_tobject *);
int push_stack_katcp(struct katcp_stack *s, void *data,
                     struct katcp_type *type) {
  struct katcp_tobject *o;
  if (s == NULL)
    return -1;
  o = create_tobject_katcp(data, type, 0);
  if (o == NULL)
    return -1;
  return push_tobject_katcp(s, o);
}


x86 assembly (clang, -O0):
<push_stack_katcp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    114b <push_stack_katcp+0x2b>
movl   $0xffffffff,-0x4(%rbp)
jmp    1185 <push_stack_katcp+0x65>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
xor    %edx,%edx
call   1030 <create_tobject_katcp@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1175 <push_stack_katcp+0x55>
movl   $0xffffffff,-0x4(%rbp)
jmp    1185 <push_stack_katcp+0x65>
mov    -0x10(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1040 <push_tobject_katcp@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<push_stack_katcp>:
push   %rbx
test   %rdi,%rdi
je     1147 <push_stack_katcp+0x27>
mov    %rdi,%rbx
mov    %rsi,%rdi
mov    %rdx,%rsi
xor    %edx,%edx
call   1030 <create_tobject_katcp@plt>
test   %rax,%rax
je     1147 <push_stack_katcp+0x27>
mov    %rbx,%rdi
mov    %rax,%rsi
pop    %rbx
jmp    1040 <push_tobject_katcp@plt>
mov    $0xffffffff,%eax
pop    %rbx
ret

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

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