#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 EXIT_SUCCESS;
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
char *umem_alloc(int, int);
int /*<<< orphan*/ umem_free(char *, int);
int /*<<< orphan*/ umem_startup(int /*<<< orphan*/ *, int /*<<< orphan*/,
                                int /*<<< orphan*/, int /*<<< orphan*/ *,
                                int /*<<< orphan*/ *);
int main(int argc, char *argv[]) {
  char *foo;
  umem_startup(NULL, 0, 0, NULL, NULL);
  foo = umem_alloc(32, 0x0000);
  strcpy(foo, "hello there");
  printf("Hello %s\n", foo);
  umem_free(foo, 32);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xor    %eax,%eax
mov    %eax,%r8d
xor    %edx,%edx
mov    %r8,%rdi
mov    %edx,%esi
mov    %r8,%rcx
call   1060 <umem_startup@plt>
mov    $0x20,%edi
xor    %esi,%esi
call   1050 <umem_alloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe6b(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x18(%rbp),%rsi
lea    0xe67(%rip),%rdi
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
mov    $0x20,%esi
call   1070 <umem_free@plt>
mov    0x2e21(%rip),%rax
mov    (%rax),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %edi,%edi
xor    %esi,%esi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1060 <umem_startup@plt>
mov    $0x20,%edi
xor    %esi,%esi
call   1050 <umem_alloc@plt>
mov    %rax,%rbx
lea    0xe89(%rip),%rsi
mov    %rax,%rdi
call   1030 <strcpy@plt>
lea    0xe86(%rip),%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x20,%esi
call   1070 <umem_free@plt>
mov    0x2e3e(%rip),%rax
mov    (%rax),%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [12 x i8] c"hello there\00"
@.str.1 = [10 x i8] c"Hello %s\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = call i32 @umem_startup(i32* null, i32 0, i32 0, i32* null, i32* null)
%8 = call i8* @umem_alloc(i32 32, i32 0)
store i8* %8, i8** %6
%9 = load i8*, i8** %6
%10 = call i32 @strcpy(i8* %9, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%11 = load i8*, i8** %6
%12 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %11)
%13 = load i8*, i8** %6
%14 = call i32 @umem_free(i8* %13, i32 32)
%15 = load i32, i32* @EXIT_SUCCESS
ret i32 %15
}

LLVM IR (-O2):
@.str = [12 x i8] c"hello there\00"
@.str.1 = [10 x i8] c"Hello %s\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 @umem_startup(i32* null, i32 0, i32 0, i32* null, i32* null)
%4 = tail call i8* @umem_alloc(i32 32, i32 0)
%5 = tail call i32 @strcpy(i8* %4, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%6 = tail call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%7 = tail call i32 @umem_free(i8* %4, i32 32)
%8 = load i32, i32* @EXIT_SUCCESS
ret i32 %8
}