struct toplevel *node_toplevel(struct node *node) {
  return __builtin_choose_expr(
      __builtin_types_compatible_p(__typeof__(node_toplevel_const(node)),
                                   const struct node *),
      (struct node *)(node_toplevel_const(node)),
      __builtin_choose_expr(
          __builtin_types_compatible_p(__typeof__(node_toplevel_const(node)),
                                       const struct module *),
          (struct module *)(node_toplevel_const(node)),
          __builtin_choose_expr(
              __builtin_types_compatible_p(
                  __typeof__(node_toplevel_const(node)), const struct typ *),
              (struct typ *)(node_toplevel_const(node)),
              __builtin_choose_expr(
                  __builtin_types_compatible_p(
                      __typeof__(node_toplevel_const(node)),
                      const struct toplevel *),
                  (struct toplevel *)(node_toplevel_const(node)),
                  __builtin_choose_expr(
                      __builtin_types_compatible_p(
                          __typeof__(node_toplevel_const(node)),
                          const struct scope *),
                      (struct scope *)(node_toplevel_const(node)),
                      __builtin_choose_expr(
                          __builtin_types_compatible_p(
                              __typeof__(node_toplevel_const(node)),
                              const struct typset *),
                          (struct typset *)(node_toplevel_const(node)),
                          __builtin_choose_expr(
                              __builtin_types_compatible_p(
                                  __typeof__(node_toplevel_const(node)),
                                  const struct constraint *),
                              (struct constraint *)(node_toplevel_const(node)),
                              __builtin_choose_expr(
                                  __builtin_types_compatible_p(
                                      __typeof__(node_toplevel_const(node)),
                                      const struct vecancestor *),
                                  (struct vecancestor *)(node_toplevel_const(
                                      node)),
                                  (node_toplevel_const(node))))))))));
}


x86 assembly (clang, -O0):
<node_toplevel>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x0,%al
call   1030 <node_toplevel_const@plt>
cltq
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<node_toplevel>:
push   %rax
xor    %eax,%eax
call   1030 <node_toplevel_const@plt>
cltq
pop    %rcx
ret

LLVM IR (-O0):
%struct.toplevel = type opaque
%struct.node = type opaque
define %struct.toplevel* @node_toplevel(%struct.node* %0) {
%2 = alloca %struct.node*
store %struct.node* %0, %struct.node** %2
%3 = load %struct.node*, %struct.node** %2
%4 = call i32 (%struct.node*, ...) bitcast (i32 (...)* @node_toplevel_const to i32 (%struct.node*, ...)*)(%struct.node* %3)
%5 = sext i32 %4 to i64
%6 = inttoptr i64 %5 to %struct.toplevel*
ret %struct.toplevel* %6
}

LLVM IR (-O2):
%struct.toplevel = type opaque
%struct.node = type opaque
define %struct.toplevel* @node_toplevel(%struct.node* %0) {
%2 = tail call i32 (%struct.node*, ...) bitcast (i32 (...)* @node_toplevel_const to i32 (%struct.node*, ...)*)(%struct.node* %0)
%3 = sext i32 %2 to i64
%4 = inttoptr i64 %3 to %struct.toplevel*
ret %struct.toplevel* %4
}