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

/* Variables and functions */
int add_type_dict_katcp(struct katcp_dict *, char *, struct katcp_type *,
                        void *);
struct katcp_type *find_name_type_katcp(struct katcp_dispatch *, char *);
int add_named_dict_katcp(struct katcp_dispatch *d, struct katcp_dict *dt,
                         char *key, char *type, void *data) {
  struct katcp_type *t;
  t = find_name_type_katcp(d, type);
  if (t == NULL)
    return -1;
  return add_type_dict_katcp(dt, key, t, data);
}


x86 assembly (clang, -O0):
<add_named_dict_katcp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1030 <find_name_type_katcp@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    1164 <add_named_dict_katcp+0x44>
movl   $0xffffffff,-0x4(%rbp)
jmp    117c <add_named_dict_katcp+0x5c>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x38(%rbp),%rdx
mov    -0x30(%rbp),%rcx
call   1040 <add_type_dict_katcp@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<add_named_dict_katcp>:
push   %r15
push   %r14
push   %rbx
mov    %r8,%r14
mov    %rdx,%r15
mov    %rsi,%rbx
mov    %rcx,%rsi
call   1030 <find_name_type_katcp@plt>
test   %rax,%rax
je     1151 <add_named_dict_katcp+0x31>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %rax,%rdx
mov    %r14,%rcx
pop    %rbx
pop    %r14
pop    %r15
jmp    1040 <add_type_dict_katcp@plt>
mov    $0xffffffff,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

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

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