#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;
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, puts, &rc, values);
    s = "This is cool!";
    ffi_call(&cif, puts, &rc, values);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e9a(%rip),%rax
mov    %rax,-0x10(%rbp)
lea    -0x20(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    0x2e6f(%rip),%rax
mov    (%rax),%esi
lea    -0x10(%rbp),%r8
lea    -0x8(%rbp),%rdi
mov    $0x1,%edx
mov    0x2e69(%rip),%rcx
call   1030 <ffi_prep_cif@plt>
mov    0x2e7d(%rip),%rcx
cmp    (%rcx),%rax
jne    11be <main+0x9e>
lea    0xe85(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0x2e5a(%rip),%rax
mov    (%rax),%esi
lea    -0x18(%rbp),%rcx
lea    -0x8(%rbp),%rdi
lea    -0x24(%rbp),%rdx
call   1040 <ffi_call@plt>
lea    0xe6d(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0x2e35(%rip),%rax
mov    (%rax),%esi
lea    -0x18(%rbp),%rcx
lea    -0x8(%rbp),%rdi
lea    -0x24(%rbp),%rdx
call   1040 <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    0x2e9e(%rip),%rax
mov    %rax,0x18(%rsp)
lea    0x8(%rsp),%rax
mov    %rax,0x10(%rsp)
mov    0x2e70(%rip),%rax
mov    (%rax),%esi
mov    0x2e77(%rip),%rcx
lea    0x4(%rsp),%rdi
lea    0x18(%rsp),%r8
mov    $0x1,%edx
call   1030 <ffi_prep_cif@plt>
mov    0x2e7c(%rip),%rcx
cmp    (%rcx),%rax
jne    11c3 <main+0xa3>
lea    0xe88(%rip),%rax
mov    %rax,0x8(%rsp)
mov    0x2e5c(%rip),%r12
mov    (%r12),%esi
lea    0x4(%rsp),%rbx
lea    0x24(%rsp),%r14
lea    0x10(%rsp),%r15
mov    %rbx,%rdi
mov    %r14,%rdx
mov    %r15,%rcx
call   1040 <ffi_call@plt>
lea    0xe61(%rip),%rax
mov    %rax,0x8(%rsp)
mov    (%r12),%esi
mov    %rbx,%rdi
mov    %r14,%rdx
mov    %r15,%rcx
call   1040 <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 %22
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 = getelementptr inbounds [1 x i8*], [1 x i8*]* %4, i64 0, i64 0
%18 = call i32 @ffi_call(i32* %2, i32 %16, i32* %6, i8** %17)
store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8** %5
%19 = load i32, i32* @puts
%20 = getelementptr inbounds [1 x i8*], [1 x i8*]* %4, i64 0, i64 0
%21 = call i32 @ffi_call(i32* %2, i32 %19, i32* %6, i8** %20)
br label %22
22: ; 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 %23
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_call(i32* %1, i32 %19, i32* %5, i8** %12)
store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8** %4
%21 = load i32, i32* @puts
%22 = call i32 @ffi_call(i32* %1, i32 %21, i32* %5, i8** %12)
br label %23
23: ; preds = %18, %0
ret i32 0
}