struct typ *typ_dyn_intf(const struct typ *t) {
  assert(typ_is_dyn(t));
  return __builtin_choose_expr(
      __builtin_types_compatible_p(__typeof__(typ_generic_arg_const(t, 0)),
                                   const struct node *),
      (struct node *)(typ_generic_arg_const(t, 0)),
      __builtin_choose_expr(
          __builtin_types_compatible_p(__typeof__(typ_generic_arg_const(t, 0)),
                                       const struct module *),
          (struct module *)(typ_generic_arg_const(t, 0)),
          __builtin_choose_expr(
              __builtin_types_compatible_p(
                  __typeof__(typ_generic_arg_const(t, 0)), const struct typ *),
              (struct typ *)(typ_generic_arg_const(t, 0)),
              __builtin_choose_expr(
                  __builtin_types_compatible_p(
                      __typeof__(typ_generic_arg_const(t, 0)),
                      const struct toplevel *),
                  (struct toplevel *)(typ_generic_arg_const(t, 0)),
                  __builtin_choose_expr(
                      __builtin_types_compatible_p(
                          __typeof__(typ_generic_arg_const(t, 0)),
                          const struct scope *),
                      (struct scope *)(typ_generic_arg_const(t, 0)),
                      __builtin_choose_expr(
                          __builtin_types_compatible_p(
                              __typeof__(typ_generic_arg_const(t, 0)),
                              const struct typset *),
                          (struct typset *)(typ_generic_arg_const(t, 0)),
                          __builtin_choose_expr(
                              __builtin_types_compatible_p(
                                  __typeof__(typ_generic_arg_const(t, 0)),
                                  const struct constraint *),
                              (struct constraint *)(typ_generic_arg_const(t,
                                                                          0)),
                              __builtin_choose_expr(
                                  __builtin_types_compatible_p(
                                      __typeof__(typ_generic_arg_const(t, 0)),
                                      const struct vecancestor *),
                                  (struct vecancestor *)(typ_generic_arg_const(
                                      t, 0)),
                                  (typ_generic_arg_const(t, 0))))))))));
}


x86 assembly (clang, -O0):
<typ_dyn_intf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x0,%al
call   1030 <typ_is_dyn@plt>
mov    %eax,%edi
mov    $0x0,%al
call   1040 <assert@plt>
mov    -0x8(%rbp),%rdi
xor    %esi,%esi
mov    $0x0,%al
call   1050 <typ_generic_arg_const@plt>
cltq
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<typ_dyn_intf>:
push   %rbx
mov    %rdi,%rbx
xor    %eax,%eax
call   1030 <typ_is_dyn@plt>
mov    %eax,%edi
xor    %eax,%eax
call   1040 <assert@plt>
mov    %rbx,%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1050 <typ_generic_arg_const@plt>
cltq
pop    %rbx
ret

LLVM IR (-O0):
%struct.typ = type opaque
define %struct.typ* @typ_dyn_intf(%struct.typ* %0) {
%2 = alloca %struct.typ*
store %struct.typ* %0, %struct.typ** %2
%3 = load %struct.typ*, %struct.typ** %2
%4 = call i32 (%struct.typ*, ...) bitcast (i32 (...)* @typ_is_dyn to i32 (%struct.typ*, ...)*)(%struct.typ* %3)
%5 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %4)
%6 = load %struct.typ*, %struct.typ** %2
%7 = call i32 (%struct.typ*, i32, ...) bitcast (i32 (...)* @typ_generic_arg_const to i32 (%struct.typ*, i32, ...)*)(%struct.typ* %6, i32 0)
%8 = sext i32 %7 to i64
%9 = inttoptr i64 %8 to %struct.typ*
ret %struct.typ* %9
}

LLVM IR (-O2):
%struct.typ = type opaque
define %struct.typ* @typ_dyn_intf(%struct.typ* %0) {
%2 = tail call i32 (%struct.typ*, ...) bitcast (i32 (...)* @typ_is_dyn to i32 (%struct.typ*, ...)*)(%struct.typ* %0)
%3 = tail call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %2)
%4 = tail call i32 (%struct.typ*, i32, ...) bitcast (i32 (...)* @typ_generic_arg_const to i32 (%struct.typ*, i32, ...)*)(%struct.typ* %0, i32 0)
%5 = sext i32 %4 to i64
%6 = inttoptr i64 %5 to %struct.typ*
ret %struct.typ* %6
}