#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;

/* 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 *,
                            void **);
scalar_t__ ffi_prep_cif(int /*<<< orphan*/ *, int /*<<< orphan*/, int,
                        int /*<<< orphan*/ *, int /*<<< orphan*/ **);
int /*<<< orphan*/ ffi_type_pointer;
int /*<<< orphan*/ ffi_type_uint;
int /*<<< orphan*/ puts;
int main(int argc, char *argv[]) {
  ffi_cif cif;
  ffi_type *args[1];
  void *values[1];
  char *s;
  int rc;
  (void)argc;
  (void)argv;
  args[0] = &ffi_type_pointer;
  values[0] = &s;
  if (ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1, &ffi_type_uint, args) == FFI_OK) {
    s = "Hello World!";
    ffi_call(&cif, FFI_FN(puts), &rc, values);
    s = "Goodbye!";
    ffi_call(&cif, FFI_FN(puts), &rc, values);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e83(%rip),%rax
mov    %rax,-0x20(%rbp)
lea    -0x30(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    0x2e58(%rip),%rax
mov    (%rax),%esi
lea    -0x20(%rbp),%r8
lea    -0x14(%rbp),%rdi
mov    $0x1,%edx
mov    0x2e52(%rip),%rcx
call   1030 <ffi_prep_cif@plt>
mov    0x2e66(%rip),%rcx
cmp    (%rcx),%rax
jne    11e3 <main+0xb3>
lea    0xe6e(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0x2e43(%rip),%rax
mov    (%rax),%edi
call   1040 <FFI_FN@plt>
mov    %eax,%esi
lea    -0x28(%rbp),%rcx
lea    -0x14(%rbp),%rdi
lea    -0x34(%rbp),%rdx
call   1050 <ffi_call@plt>
lea    0xe4f(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0x2e17(%rip),%rax
mov    (%rax),%edi
call   1040 <FFI_FN@plt>
mov    %eax,%esi
lea    -0x28(%rbp),%rcx
lea    -0x14(%rbp),%rdi
lea    -0x34(%rbp),%rdx
call   1050 <ffi_call@plt>
xor    %eax,%eax
add    $0x40,%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_uint = global i32 0
@FFI_OK = global i64 0
@.str = [13 x i8] c"Hello World!\00"
@puts = global i32 0
@.str.1 = [9 x i8] c"Goodbye!\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca [1 x i32*]
%8 = alloca [1 x i8*]
%9 = alloca i8*
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i32, i32* %4
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds [1 x i32*], [1 x i32*]* %7, i64 0, i64 0
store i32* @ffi_type_pointer, i32** %13
%14 = bitcast i8** %9 to i8*
%15 = getelementptr inbounds [1 x i8*], [1 x i8*]* %8, i64 0, i64 0
store i8* %14, i8** %15
%16 = load i32, i32* @FFI_DEFAULT_ABI
%17 = getelementptr inbounds [1 x i32*], [1 x i32*]* %7, i64 0, i64 0
%18 = call i64 @ffi_prep_cif(i32* %6, i32 %16, i32 1, i32* @ffi_type_uint, i32** %17)
%19 = load i64, i64* @FFI_OK
%20 = icmp eq i64 %18, %19
br i1 %20, label %21, label %30
21: ; preds = %2
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8** %9
%22 = load i32, i32* @puts
%23 = call i32 @FFI_FN(i32 %22)
%24 = getelementptr inbounds [1 x i8*], [1 x i8*]* %8, i64 0, i64 0
%25 = call i32 @ffi_call(i32* %6, i32 %23, i32* %10, i8** %24)
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8** %9
%26 = load i32, i32* @puts
%27 = call i32 @FFI_FN(i32 %26)
%28 = getelementptr inbounds [1 x i8*], [1 x i8*]* %8, i64 0, i64 0
%29 = call i32 @ffi_call(i32* %6, i32 %27, i32* %10, i8** %28)
br label %30
30: ; preds = %21, %2
ret i32 0
}

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