#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 __UTAC__EXCEPTION {
  int dummy;
};
struct __UTAC__CFLOW_FUNC {
  int dummy;
};

/* Variables and functions */
void *malloc(unsigned long);
void __utac__exception__cf_handler_set(void *exception,
                                       int (*cflow_func)(int, int), int val) {
  struct __UTAC__EXCEPTION *excep;
  struct __UTAC__CFLOW_FUNC *cf;
  void *tmp;
  unsigned long __cil_tmp7;
  unsigned long __cil_tmp8;
  unsigned long __cil_tmp9;
  unsigned long __cil_tmp10;
  unsigned long __cil_tmp11;
  unsigned long __cil_tmp12;
  unsigned long __cil_tmp13;
  unsigned long __cil_tmp14;
  int (**mem_15)(int, int);
  int *mem_16;
  struct __UTAC__CFLOW_FUNC **mem_17;
  struct __UTAC__CFLOW_FUNC **mem_18;
  struct __UTAC__CFLOW_FUNC **mem_19;
  {
    {
      excep = (struct __UTAC__EXCEPTION *)exception;
      tmp = malloc(24UL);
      cf = (struct __UTAC__CFLOW_FUNC *)tmp;
      mem_15 = (int (**)(int, int))cf;
      *mem_15 = cflow_func;
      __cil_tmp7 = (unsigned long)cf;
      __cil_tmp8 = __cil_tmp7 + 8;
      mem_16 = (int *)__cil_tmp8;
      *mem_16 = val;
      __cil_tmp9 = (unsigned long)cf;
      __cil_tmp10 = __cil_tmp9 + 16;
      __cil_tmp11 = (unsigned long)excep;
      __cil_tmp12 = __cil_tmp11 + 24;
      mem_17 = (struct __UTAC__CFLOW_FUNC **)__cil_tmp10;
      mem_18 = (struct __UTAC__CFLOW_FUNC **)__cil_tmp12;
      *mem_17 = *mem_18;
      __cil_tmp13 = (unsigned long)excep;
      __cil_tmp14 = __cil_tmp13 + 24;
      mem_19 = (struct __UTAC__CFLOW_FUNC **)__cil_tmp14;
      *mem_19 = cf;
    }
    return;
  }
}


x86 assembly (clang, -O0):
<__utac__exception__cf_handler_set>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    $0x18,%edi
call   1030 <malloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x78(%rbp)
mov    -0x10(%rbp),%rcx
mov    -0x78(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x28(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rax
mov    %rax,-0x80(%rbp)
mov    -0x14(%rbp),%ecx
mov    -0x80(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x28(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rax
add    $0x10,%rax
mov    %rax,-0x50(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x58(%rbp),%rax
add    $0x18,%rax
mov    %rax,-0x60(%rbp)
mov    -0x50(%rbp),%rax
mov    %rax,-0x88(%rbp)
mov    -0x60(%rbp),%rax
mov    %rax,-0x90(%rbp)
mov    -0x90(%rbp),%rax
mov    (%rax),%rcx
mov    -0x88(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x20(%rbp),%rax
mov    %rax,-0x68(%rbp)
mov    -0x68(%rbp),%rax
add    $0x18,%rax
mov    %rax,-0x70(%rbp)
mov    -0x70(%rbp),%rax
mov    %rax,-0x98(%rbp)
mov    -0x28(%rbp),%rcx
mov    -0x98(%rbp),%rax
mov    %rcx,(%rax)
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__utac__exception__cf_handler_set>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%r14d
mov    %rsi,%rbx
mov    %rdi,%rbp
mov    $0x18,%edi
call   1030 <malloc@plt>
mov    %rbx,(%rax)
mov    %r14d,0x8(%rax)
mov    0x18(%rbp),%rcx
mov    %rcx,0x10(%rax)
mov    %rax,0x18(%rbp)
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.__UTAC__EXCEPTION = type { i32 }
%struct.__UTAC__CFLOW_FUNC = type { i32 }
define void @__utac__exception__cf_handler_set(i8* %0, i32 (i32, i32)* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i32 (i32, i32)*
%6 = alloca i32
%7 = alloca %struct.__UTAC__EXCEPTION*
%8 = alloca %struct.__UTAC__CFLOW_FUNC*
%9 = alloca i8*
%10 = alloca i64
%11 = alloca i64
%12 = alloca i64
%13 = alloca i64
%14 = alloca i64
%15 = alloca i64
%16 = alloca i64
%17 = alloca i64
%18 = alloca i32 (i32, i32)**
%19 = alloca i32*
%20 = alloca %struct.__UTAC__CFLOW_FUNC**
%21 = alloca %struct.__UTAC__CFLOW_FUNC**
%22 = alloca %struct.__UTAC__CFLOW_FUNC**
store i8* %0, i8** %4
store i32 (i32, i32)* %1, i32 (i32, i32)** %5
store i32 %2, i32* %6
%23 = load i8*, i8** %4
%24 = bitcast i8* %23 to %struct.__UTAC__EXCEPTION*
store %struct.__UTAC__EXCEPTION* %24, %struct.__UTAC__EXCEPTION** %7
%25 = call i8* @malloc(i64 24)
store i8* %25, i8** %9
%26 = load i8*, i8** %9
%27 = bitcast i8* %26 to %struct.__UTAC__CFLOW_FUNC*
store %struct.__UTAC__CFLOW_FUNC* %27, %struct.__UTAC__CFLOW_FUNC** %8
%28 = load %struct.__UTAC__CFLOW_FUNC*, %struct.__UTAC__CFLOW_FUNC** %8
%29 = bitcast %struct.__UTAC__CFLOW_FUNC* %28 to i32 (i32, i32)**
store i32 (i32, i32)** %29, i32 (i32, i32)*** %18
%30 = load i32 (i32, i32)*, i32 (i32, i32)** %5
%31 = load i32 (i32, i32)**, i32 (i32, i32)*** %18
store i32 (i32, i32)* %30, i32 (i32, i32)** %31
%32 = load %struct.__UTAC__CFLOW_FUNC*, %struct.__UTAC__CFLOW_FUNC** %8
%33 = ptrtoint %struct.__UTAC__CFLOW_FUNC* %32 to i64
store i64 %33, i64* %10
%34 = load i64, i64* %10
%35 = add i64 %34, 8
store i64 %35, i64* %11
%36 = load i64, i64* %11
%37 = inttoptr i64 %36 to i32*
store i32* %37, i32** %19
%38 = load i32, i32* %6
%39 = load i32*, i32** %19
store i32 %38, i32* %39
%40 = load %struct.__UTAC__CFLOW_FUNC*, %struct.__UTAC__CFLOW_FUNC** %8
%41 = ptrtoint %struct.__UTAC__CFLOW_FUNC* %40 to i64
store i64 %41, i64* %12
%42 = load i64, i64* %12
%43 = add i64 %42, 16
store i64 %43, i64* %13
%44 = load %struct.__UTAC__EXCEPTION*, %struct.__UTAC__EXCEPTION** %7
%45 = ptrtoint %struct.__UTAC__EXCEPTION* %44 to i64
store i64 %45, i64* %14
%46 = load i64, i64* %14
%47 = add i64 %46, 24
store i64 %47, i64* %15
%48 = load i64, i64* %13
%49 = inttoptr i64 %48 to %struct.__UTAC__CFLOW_FUNC**
store %struct.__UTAC__CFLOW_FUNC** %49, %struct.__UTAC__CFLOW_FUNC*** %20
%50 = load i64, i64* %15
%51 = inttoptr i64 %50 to %struct.__UTAC__CFLOW_FUNC**
store %struct.__UTAC__CFLOW_FUNC** %51, %struct.__UTAC__CFLOW_FUNC*** %21
%52 = load %struct.__UTAC__CFLOW_FUNC**, %struct.__UTAC__CFLOW_FUNC*** %21
%53 = load %struct.__UTAC__CFLOW_FUNC*, %struct.__UTAC__CFLOW_FUNC** %52
%54 = load %struct.__UTAC__CFLOW_FUNC**, %struct.__UTAC__CFLOW_FUNC*** %20
store %struct.__UTAC__CFLOW_FUNC* %53, %struct.__UTAC__CFLOW_FUNC** %54
%55 = load %struct.__UTAC__EXCEPTION*, %struct.__UTAC__EXCEPTION** %7
%56 = ptrtoint %struct.__UTAC__EXCEPTION* %55 to i64
store i64 %56, i64* %16
%57 = load i64, i64* %16
%58 = add i64 %57, 24
store i64 %58, i64* %17
%59 = load i64, i64* %17
%60 = inttoptr i64 %59 to %struct.__UTAC__CFLOW_FUNC**
store %struct.__UTAC__CFLOW_FUNC** %60, %struct.__UTAC__CFLOW_FUNC*** %22
%61 = load %struct.__UTAC__CFLOW_FUNC*, %struct.__UTAC__CFLOW_FUNC** %8
%62 = load %struct.__UTAC__CFLOW_FUNC**, %struct.__UTAC__CFLOW_FUNC*** %22
store %struct.__UTAC__CFLOW_FUNC* %61, %struct.__UTAC__CFLOW_FUNC** %62
ret void
}

LLVM IR (-O2):
%struct.__UTAC__CFLOW_FUNC = type { i32 }
define void @__utac__exception__cf_handler_set(i8* %0, i32 (i32, i32)* %1, i32 %2) {
%4 = tail call dereferenceable_or_null(24) i8* @malloc(i64 24)
%5 = bitcast i8* %4 to i32 (i32, i32)**
store i32 (i32, i32)* %1, i32 (i32, i32)** %5
%6 = ptrtoint i8* %4 to i64
%7 = add i64 %6, 8
%8 = inttoptr i64 %7 to i32*
store i32 %2, i32* %8
%9 = add i64 %6, 16
%10 = ptrtoint i8* %0 to i64
%11 = add i64 %10, 24
%12 = inttoptr i64 %9 to %struct.__UTAC__CFLOW_FUNC**
%13 = inttoptr i64 %11 to %struct.__UTAC__CFLOW_FUNC**
%14 = load %struct.__UTAC__CFLOW_FUNC*, %struct.__UTAC__CFLOW_FUNC** %13
store %struct.__UTAC__CFLOW_FUNC* %14, %struct.__UTAC__CFLOW_FUNC** %12
%15 = inttoptr i64 %11 to i8**
store i8* %4, i8** %15
ret void
}