int exit_handler(func) void (*func)();
{
  struct EX_CB {
    struct EX_CB *flink;
    long hndlrpt;
    char numarg;
    char fill[3];
    long *statargpt;
  };
  static struct EX_CB excb;
  static int code;
  int status;
  excb.flink = 0;
  excb.fill[0] = excb.fill[1] = excb.fill[2] = 0;
  excb.hndlrpt = func;
  excb.numarg = 1;
  excb.statargpt = &code;
  return sys$dclexh(&excb);
}


x86 assembly (clang, -O0):
<exit_handler>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x0,0x2f09(%rip)
movb   $0x0,0x2f15(%rip)
movb   $0x0,0x2f0d(%rip)
movb   $0x0,0x2f05(%rip)
mov    -0x8(%rbp),%rax
mov    %rax,0x2ef1(%rip)
movb   $0x1,0x2ef2(%rip)
lea    0x2efb(%rip),%rax
mov    %rax,0x2eec(%rip)
lea    0x2ecd(%rip),%rdi
mov    $0x0,%al
call   1030 <sys$dclexh@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<exit_handler>:
movq   $0x0,0x2f15(%rip)
lea    0x2f0e(%rip),%rax
mov    %rdi,0x2f0f(%rip)
movl   $0x1,0x2f0d(%rip)
lea    0x2f16(%rip),%rcx
mov    %rcx,0x2f07(%rip)
mov    %rax,%rdi
xor    %eax,%eax
jmp    1030 <sys$dclexh@plt>

LLVM IR (-O0):
%struct.EX_CB = type { %struct.EX_CB*, i64, i8, [3 x i8], i64* }
@exit_handler.excb = internal global %struct.EX_CB zeroinitializer
@exit_handler.code = internal global i32 0
define i32 @exit_handler(void (...)* %0) {
%2 = alloca void (...)*
%3 = alloca i32
store void (...)* %0, void (...)** %2
store %struct.EX_CB* null, %struct.EX_CB** getelementptr inbounds (%struct.EX_CB, %struct.EX_CB* @exit_handler.excb, i32 0, i32 0)
store i8 0, i8* getelementptr inbounds (%struct.EX_CB, %struct.EX_CB* @exit_handler.excb, i32 0, i32 3, i64 2)
store i8 0, i8* getelementptr inbounds (%struct.EX_CB, %struct.EX_CB* @exit_handler.excb, i32 0, i32 3, i64 1)
store i8 0, i8* getelementptr inbounds (%struct.EX_CB, %struct.EX_CB* @exit_handler.excb, i32 0, i32 3, i64 0)
%4 = load void (...)*, void (...)** %2
%5 = ptrtoint void (...)* %4 to i64
store i64 %5, i64* getelementptr inbounds (%struct.EX_CB, %struct.EX_CB* @exit_handler.excb, i32 0, i32 1)
store i8 1, i8* getelementptr inbounds (%struct.EX_CB, %struct.EX_CB* @exit_handler.excb, i32 0, i32 2)
store i64* bitcast (i32* @exit_handler.code to i64*), i64** getelementptr inbounds (%struct.EX_CB, %struct.EX_CB* @exit_handler.excb, i32 0, i32 4)
%6 = call i32 (%struct.EX_CB*, ...) bitcast (i32 (...)* @"sys$dclexh" to i32 (%struct.EX_CB*, ...)*)(%struct.EX_CB* @exit_handler.excb)
ret i32 %6
}

LLVM IR (-O2):
%struct.EX_CB = type { %struct.EX_CB*, i64, i8, [3 x i8], i64* }
@exit_handler.excb = internal global %struct.EX_CB zeroinitializer
@exit_handler.code = internal global i32 0
define i32 @exit_handler(void (...)* %0) {
store %struct.EX_CB* null, %struct.EX_CB** getelementptr inbounds (%struct.EX_CB, %struct.EX_CB* @exit_handler.excb, i64 0, i32 0)
store i8 0, i8* getelementptr inbounds (%struct.EX_CB, %struct.EX_CB* @exit_handler.excb, i64 0, i32 3, i64 2)
store i8 0, i8* getelementptr inbounds (%struct.EX_CB, %struct.EX_CB* @exit_handler.excb, i64 0, i32 3, i64 1)
store i8 0, i8* getelementptr inbounds (%struct.EX_CB, %struct.EX_CB* @exit_handler.excb, i64 0, i32 3, i64 0)
%2 = ptrtoint void (...)* %0 to i64
store i64 %2, i64* getelementptr inbounds (%struct.EX_CB, %struct.EX_CB* @exit_handler.excb, i64 0, i32 1)
store i8 1, i8* getelementptr inbounds (%struct.EX_CB, %struct.EX_CB* @exit_handler.excb, i64 0, i32 2)
store i64* bitcast (i32* @exit_handler.code to i64*), i64** getelementptr inbounds (%struct.EX_CB, %struct.EX_CB* @exit_handler.excb, i64 0, i32 4)
%3 = tail call i32 (%struct.EX_CB*, ...) bitcast (i32 (...)* @"sys$dclexh" to i32 (%struct.EX_CB*, ...)*)(%struct.EX_CB* @exit_handler.excb)
ret i32 %3
}