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

/* Variables and functions */
struct katcp_tag *get_key_data_type_katcp(struct katcp_dispatch *, char *,
                                          char *);
int tag_tobject_katcp(struct katcp_dispatch *, struct katcp_tag *,
                      struct katcp_tobject *);
int tag_named_tobject_katcp(struct katcp_dispatch *d, char *tag,
                            struct katcp_tobject *to) {
  struct katcp_tag *t;
  t = get_key_data_type_katcp(d, "tag", tag);
  if (t == NULL)
    return -1;
  return tag_tobject_katcp(d, t, to);
}


x86 assembly (clang, -O0):
<tag_named_tobject_katcp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xebd(%rip),%rsi
call   1040 <get_key_data_type_katcp@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1163 <tag_named_tobject_katcp+0x43>
movl   $0xffffffff,-0x4(%rbp)
jmp    1177 <tag_named_tobject_katcp+0x57>
mov    -0x10(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1030 <tag_tobject_katcp@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tag_named_tobject_katcp>:
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%rdx
mov    %rdi,%rbx
lea    0xecc(%rip),%rsi
call   1040 <get_key_data_type_katcp@plt>
test   %rax,%rax
je     1153 <tag_named_tobject_katcp+0x33>
mov    %rbx,%rdi
mov    %rax,%rsi
mov    %r14,%rdx
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <tag_tobject_katcp@plt>
mov    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.katcp_dispatch = type { i32 }
%struct.katcp_tobject = type { i32 }
%struct.katcp_tag = type { i32 }
@.str = [4 x i8] c"tag\00"
define i32 @tag_named_tobject_katcp(%struct.katcp_dispatch* %0, i8* %1, %struct.katcp_tobject* %2) {
%4 = alloca i32
%5 = alloca %struct.katcp_dispatch*
%6 = alloca i8*
%7 = alloca %struct.katcp_tobject*
%8 = alloca %struct.katcp_tag*
store %struct.katcp_dispatch* %0, %struct.katcp_dispatch** %5
store i8* %1, i8** %6
store %struct.katcp_tobject* %2, %struct.katcp_tobject** %7
%9 = load %struct.katcp_dispatch*, %struct.katcp_dispatch** %5
%10 = load i8*, i8** %6
%11 = call %struct.katcp_tag* @get_key_data_type_katcp(%struct.katcp_dispatch* %9, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %10)
store %struct.katcp_tag* %11, %struct.katcp_tag** %8
%12 = load %struct.katcp_tag*, %struct.katcp_tag** %8
%13 = icmp eq %struct.katcp_tag* %12, null
br i1 %13, label %14, label %15
14: ; preds = %3
store i32 -1, i32* %4
br label %20
15: ; preds = %3
%16 = load %struct.katcp_dispatch*, %struct.katcp_dispatch** %5
%17 = load %struct.katcp_tag*, %struct.katcp_tag** %8
%18 = load %struct.katcp_tobject*, %struct.katcp_tobject** %7
%19 = call i32 @tag_tobject_katcp(%struct.katcp_dispatch* %16, %struct.katcp_tag* %17, %struct.katcp_tobject* %18)
store i32 %19, i32* %4
br label %20
20: ; preds = %15, %14
%21 = load i32, i32* %4
ret i32 %21
}

LLVM IR (-O2):
%struct.katcp_dispatch = type { i32 }
%struct.katcp_tobject = type { i32 }
%struct.katcp_tag = type { i32 }
@.str = [4 x i8] c"tag\00"
define i32 @tag_named_tobject_katcp(%struct.katcp_dispatch* %0, i8* %1, %struct.katcp_tobject* %2) {
%4 = tail call %struct.katcp_tag* @get_key_data_type_katcp(%struct.katcp_dispatch* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %1)
%5 = icmp eq %struct.katcp_tag* %4, null
br i1 %5, label %8, label %6
6: ; preds = %3
%7 = tail call i32 @tag_tobject_katcp(%struct.katcp_dispatch* %0, %struct.katcp_tag* %4, %struct.katcp_tobject* %2)
br label %8
8: ; preds = %3, %6
%9 = phi i32 [ %7, %6 ], [ -1, %3 ]
ret i32 %9
}