#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 */
typedef int /*<<< orphan*/ ffi_type;
typedef int /*<<< orphan*/ ffi_cif;
typedef int /*<<< orphan*/ ffi_arg;

/* Variables and functions */
int /*<<< orphan*/ FFI_DEFAULT_ABI;
int /*<<< orphan*/ FFI_FN(int /*<<< orphan*/);
scalar_t__ FFI_OK;
int /*<<< orphan*/ ffi_call(int /*<<< orphan*/ *, int /*<<< orphan*/,
                            int /*<<< orphan*/ *, void **);
scalar_t__ ffi_prep_cif(int /*<<< orphan*/ *, int /*<<< orphan*/, int,
                        int /*<<< orphan*/ *, int /*<<< orphan*/ **);
int /*<<< orphan*/ ffi_type_pointer;
int /*<<< orphan*/ ffi_type_sint;
int /*<<< orphan*/ puts;
int main() {
  ffi_cif cif;
  ffi_type *args[1];
  void *values[1];
  char *s;
  ffi_arg rc;
  args[0] = &ffi_type_pointer;
  values[0] = &s;
  if (ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1, &ffi_type_sint, args) == FFI_OK) {
    s = "Hello World!";
    ffi_call(&cif, FFI_FN(puts), &rc, values);
    s = "This is cool!";
    ffi_call(&cif, FFI_FN(puts), &rc, values);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e8a(%rip),%rax
mov    %rax,-0x10(%rbp)
lea    -0x20(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    0x2e5f(%rip),%rax
mov    (%rax),%esi
lea    -0x10(%rbp),%r8
lea    -0x8(%rbp),%rdi
mov    $0x1,%edx
mov    0x2e59(%rip),%rcx
call   1030 <ffi_prep_cif@plt>
mov    0x2e6d(%rip),%rcx
cmp    (%rcx),%rax
jne    11dc <main+0xac>
lea    0xe75(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0x2e4a(%rip),%rax
mov    (%rax),%edi
call   1040 <FFI_FN@plt>
mov    %eax,%esi
lea    -0x18(%rbp),%rcx
lea    -0x8(%rbp),%rdi
lea    -0x24(%rbp),%rdx
call   1050 <ffi_call@plt>
lea    0xe56(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0x2e1e(%rip),%rax
mov    (%rax),%edi
call   1040 <FFI_FN@plt>
mov    %eax,%esi
lea    -0x18(%rbp),%rcx
lea    -0x8(%rbp),%rdi
lea    -0x24(%rbp),%rdx
call   1050 <ffi_call@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    0x2e8e(%rip),%rax
mov    %rax,0x18(%rsp)
lea    0x8(%rsp),%rax
mov    %rax,0x10(%rsp)
mov    0x2e60(%rip),%rax
mov    (%rax),%esi
mov    0x2e67(%rip),%rcx
lea    0x4(%rsp),%rdi
lea    0x18(%rsp),%r8
mov    $0x1,%edx
call   1030 <ffi_prep_cif@plt>
mov    0x2e6c(%rip),%rcx
cmp    (%rcx),%rax
jne    11e1 <main+0xb1>
lea    0xe78(%rip),%rax
mov    %rax,0x8(%rsp)
mov    0x2e4c(%rip),%r12
mov    (%r12),%edi
call   1040 <FFI_FN@plt>
lea    0x4(%rsp),%rbx
lea    0x24(%rsp),%r14
lea    0x10(%rsp),%r15
mov    %rbx,%rdi
mov    %eax,%esi
mov    %r14,%rdx
mov    %r15,%rcx
call   1050 <ffi_call@plt>
lea    0xe4a(%rip),%rax
mov    %rax,0x8(%rsp)
mov    (%r12),%edi
call   1040 <FFI_FN@plt>
mov    %rbx,%rdi
mov    %eax,%esi
mov    %r14,%rdx
mov    %r15,%rcx
call   1050 <ffi_call@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@ffi_type_pointer = global i32 0
@FFI_DEFAULT_ABI = global i32 0
@ffi_type_sint = global i32 0
@FFI_OK = global i64 0
@.str = [13 x i8] c"Hello World!\00"
@puts = global i32 0
@.str.1 = [14 x i8] c"This is cool!\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [1 x i32*]
%4 = alloca [1 x i8*]
%5 = alloca i8*
%6 = alloca i32
store i32 0, i32* %1
%7 = getelementptr inbounds [1 x i32*], [1 x i32*]* %3, i64 0, i64 0
store i32* @ffi_type_pointer, i32** %7
%8 = bitcast i8** %5 to i8*
%9 = getelementptr inbounds [1 x i8*], [1 x i8*]* %4, i64 0, i64 0
store i8* %8, i8** %9
%10 = load i32, i32* @FFI_DEFAULT_ABI
%11 = getelementptr inbounds [1 x i32*], [1 x i32*]* %3, i64 0, i64 0
%12 = call i64 @ffi_prep_cif(i32* %2, i32 %10, i32 1, i32* @ffi_type_sint, i32** %11)
%13 = load i64, i64* @FFI_OK
%14 = icmp eq i64 %12, %13
br i1 %14, label %15, label %24
15: ; preds = %0
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8** %5
%16 = load i32, i32* @puts
%17 = call i32 @FFI_FN(i32 %16)
%18 = getelementptr inbounds [1 x i8*], [1 x i8*]* %4, i64 0, i64 0
%19 = call i32 @ffi_call(i32* %2, i32 %17, i32* %6, i8** %18)
store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8** %5
%20 = load i32, i32* @puts
%21 = call i32 @FFI_FN(i32 %20)
%22 = getelementptr inbounds [1 x i8*], [1 x i8*]* %4, i64 0, i64 0
%23 = call i32 @ffi_call(i32* %2, i32 %21, i32* %6, i8** %22)
br label %24
24: ; preds = %15, %0
ret i32 0
}

LLVM IR (-O2):
@ffi_type_pointer = global i32 0
@FFI_DEFAULT_ABI = global i32 0
@ffi_type_sint = global i32 0
@FFI_OK = global i64 0
@.str = [13 x i8] c"Hello World!\00"
@puts = global i32 0
@.str.1 = [14 x i8] c"This is cool!\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [1 x i32*]
%3 = alloca [1 x i8*]
%4 = alloca i8*
%5 = alloca i32
%6 = bitcast i32* %1 to i8*
%7 = bitcast [1 x i32*]* %2 to i8*
%8 = bitcast [1 x i8*]* %3 to i8*
%9 = bitcast i8** %4 to i8*
%10 = bitcast i32* %5 to i8*
%11 = getelementptr inbounds [1 x i32*], [1 x i32*]* %2, i64 0, i64 0
store i32* @ffi_type_pointer, i32** %11
%12 = getelementptr inbounds [1 x i8*], [1 x i8*]* %3, i64 0, i64 0
%13 = bitcast [1 x i8*]* %3 to i8***
store i8** %4, i8*** %13
%14 = load i32, i32* @FFI_DEFAULT_ABI
%15 = call i64 @ffi_prep_cif(i32* %1, i32 %14, i32 1, i32* @ffi_type_sint, i32** %11)
%16 = load i64, i64* @FFI_OK
%17 = icmp eq i64 %15, %16
br i1 %17, label %18, label %25
18: ; preds = %0
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8** %4
%19 = load i32, i32* @puts
%20 = call i32 @FFI_FN(i32 %19)
%21 = call i32 @ffi_call(i32* %1, i32 %20, i32* %5, i8** %12)
store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8** %4
%22 = load i32, i32* @puts
%23 = call i32 @FFI_FN(i32 %22)
%24 = call i32 @ffi_call(i32* %1, i32 %23, i32* %5, i8** %12)
br label %25
25: ; preds = %18, %0
ret i32 0
}