#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 */

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
void _xxx_init(void *(*Xalloc)(int), void (*Xfree)(void *)) {
  void *ptr;
  printf("_xxx_init got %p %p\n", Xalloc, Xfree);
  printf("calling\n");
  ptr = Xalloc(32);
  Xfree(ptr);
  printf("calls done, ptr was %p\n", ptr);
}


x86 assembly (clang, -O0):
<_xxx_init>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
lea    0xed1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x20,%edi
call   *-0x8(%rbp)
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rdi
call   *%rax
mov    -0x18(%rbp),%rsi
lea    0xeb9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_xxx_init>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xecf(%rip),%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xee8(%rip),%rdi
call   1030 <puts@plt>
mov    $0x20,%edi
call   *%rbx
mov    %rax,%rbx
mov    %rax,%rdi
call   *%r14
lea    0xeb4(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <printf@plt>

LLVM IR (-O0):
@.str = [21 x i8] c"_xxx_init got %p %p\0A\00"
@.str.1 = [9 x i8] c"calling\0A\00"
@.str.2 = [24 x i8] c"calls done, ptr was %p\0A\00"
define void @_xxx_init(i8* (i32)* %0, void (i8*)* %1) {
%3 = alloca i8* (i32)*
%4 = alloca void (i8*)*
%5 = alloca i8*
store i8* (i32)* %0, i8* (i32)** %3
store void (i8*)* %1, void (i8*)** %4
%6 = load i8* (i32)*, i8* (i32)** %3
%7 = load void (i8*)*, void (i8*)** %4
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* (i32)* %6, void (i8*)* %7)
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%10 = load i8* (i32)*, i8* (i32)** %3
%11 = call i8* %10(i32 32)
store i8* %11, i8** %5
%12 = load void (i8*)*, void (i8*)** %4
%13 = load i8*, i8** %5
%14 = load i8*, i8** %5
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i8* %14)
ret void
}

LLVM IR (-O2):
@.str = [21 x i8] c"_xxx_init got %p %p\0A\00"
@.str.2 = [24 x i8] c"calls done, ptr was %p\0A\00"
@str = [8 x i8] c"calling\00"
define void @_xxx_init(i8* (i32)* %0, void (i8*)* %1) {
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* (i32)* %0, void (i8*)* %1)
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str, i64 0, i64 0))
%5 = tail call i8* %0(i32 32)
tail call void %1(i8* %5)
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i8* %5)
ret void
}