#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_dispatch {
  int dummy;
};

/* Variables and functions */
struct katcp_tobject *create_tobject_katcp(void *, struct katcp_type *, int);
struct katcp_type *find_name_type_katcp(struct katcp_dispatch *, char *);
struct katcp_tobject *create_named_tobject_katcp(struct katcp_dispatch *d,
                                                 void *data, char *type,
                                                 int flagman) {
  struct katcp_type *t;
  if (type == NULL || data == NULL)
    return NULL;
  t = find_name_type_katcp(d, type);
  if (t == NULL)
    return NULL;
  return create_tobject_katcp(data, t, flagman);
}


x86 assembly (clang, -O0):
<create_named_tobject_katcp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     114d <create_named_tobject_katcp+0x2d>
cmpq   $0x0,-0x18(%rbp)
jne    115a <create_named_tobject_katcp+0x3a>
movq   $0x0,-0x8(%rbp)
jmp    1197 <create_named_tobject_katcp+0x77>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1030 <find_name_type_katcp@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    1183 <create_named_tobject_katcp+0x63>
movq   $0x0,-0x8(%rbp)
jmp    1197 <create_named_tobject_katcp+0x77>
mov    -0x18(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x24(%rbp),%edx
call   1040 <create_tobject_katcp@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<create_named_tobject_katcp>:
push   %rbp
push   %rbx
push   %rax
test   %rsi,%rsi
je     1152 <create_named_tobject_katcp+0x32>
test   %rdx,%rdx
je     1152 <create_named_tobject_katcp+0x32>
mov    %ecx,%ebp
mov    %rsi,%rbx
mov    %rdx,%rsi
call   1030 <find_name_type_katcp@plt>
test   %rax,%rax
je     1152 <create_named_tobject_katcp+0x32>
mov    %rbx,%rdi
mov    %rax,%rsi
mov    %ebp,%edx
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1040 <create_tobject_katcp@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

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

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