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

/* Variables and functions */
struct katcp_type *find_name_type_katcp(struct katcp_dispatch *, char *);
void *pop_data_type_stack_katcp(struct katcp_stack *, struct katcp_type *);
void *pop_data_expecting_stack_katcp(struct katcp_dispatch *d,
                                     struct katcp_stack *s, char *type) {
  struct katcp_type *t;
  t = find_name_type_katcp(d, type);
  if (t == NULL)
    return NULL;
  return pop_data_type_stack_katcp(s, t);
}


x86 assembly (clang, -O0):
<pop_data_expecting_stack_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    -0x20(%rbp),%rsi
call   1030 <find_name_type_katcp@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    115d <pop_data_expecting_stack_katcp+0x3d>
movq   $0x0,-0x8(%rbp)
jmp    116e <pop_data_expecting_stack_katcp+0x4e>
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1040 <pop_data_type_stack_katcp@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pop_data_expecting_stack_katcp>:
push   %rbx
mov    %rsi,%rbx
mov    %rdx,%rsi
call   1030 <find_name_type_katcp@plt>
test   %rax,%rax
je     113d <pop_data_expecting_stack_katcp+0x1d>
mov    %rbx,%rdi
mov    %rax,%rsi
pop    %rbx
jmp    1040 <pop_data_type_stack_katcp@plt>
xor    %eax,%eax
pop    %rbx
ret

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

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