#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*/ __thinthin_dlopen(char *);
int /*<<< orphan*/ __thinthin_syscall(int, int, char *, int);
int fprintf(int /*<<< orphan*/, char *, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
int main(void) {
  __thinthin_syscall(1, 1, "hi0\n", 4);
  __thinthin_dlopen("libc.wasm");
  __thinthin_syscall(1, 1, "hi1\n", 4);
  for (;;) {
    int count = fprintf(stderr, "hey there: %p %p\n", stdout, stderr);
    break;
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x1,%esi
lea    0xebc(%rip),%rdx
mov    $0x4,%ecx
mov    %esi,%edi
call   1030 <__thinthin_syscall@plt>
lea    0xeae(%rip),%rdi
call   1050 <__thinthin_dlopen@plt>
mov    $0x1,%esi
lea    0xea7(%rip),%rdx
mov    $0x4,%ecx
mov    %esi,%edi
call   1030 <__thinthin_syscall@plt>
mov    0x2e65(%rip),%rax
mov    (%rax),%edi
mov    0x2e54(%rip),%rax
mov    (%rax),%edx
mov    0x2e53(%rip),%rax
mov    (%rax),%ecx
lea    0xe7e(%rip),%rsi
call   1040 <fprintf@plt>
mov    %eax,-0x4(%rbp)
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xec8(%rip),%rdx
mov    $0x1,%edi
mov    $0x1,%esi
mov    $0x4,%ecx
call   1030 <__thinthin_syscall@plt>
lea    0xeb2(%rip),%rdi
call   1050 <__thinthin_dlopen@plt>
lea    0xeb0(%rip),%rdx
mov    $0x1,%edi
mov    $0x1,%esi
mov    $0x4,%ecx
call   1030 <__thinthin_syscall@plt>
mov    0x2e66(%rip),%rax
mov    (%rax),%ecx
mov    0x2e55(%rip),%rax
mov    (%rax),%edx
lea    0xe88(%rip),%rsi
mov    %ecx,%edi
call   1040 <fprintf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [5 x i8] c"hi0\0A\00"
@.str.1 = [10 x i8] c"libc.wasm\00"
@.str.2 = [5 x i8] c"hi1\0A\00"
@stderr = global i32 0
@.str.3 = [18 x i8] c"hey there: %p %p\0A\00"
@stdout = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = call i32 @__thinthin_syscall(i32 1, i32 1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 4)
%3 = call i32 @__thinthin_dlopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%4 = call i32 @__thinthin_syscall(i32 1, i32 1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 4)
br label %5
5: ; preds = %0
%6 = load i32, i32* @stderr
%7 = load i32, i32* @stdout
%8 = load i32, i32* @stderr
%9 = call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i32 %7, i32 %8)
store i32 %9, i32* %1
br label %10
10: ; preds = %5
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c"hi0\0A\00"
@.str.1 = [10 x i8] c"libc.wasm\00"
@.str.2 = [5 x i8] c"hi1\0A\00"
@stderr = global i32 0
@.str.3 = [18 x i8] c"hey there: %p %p\0A\00"
@stdout = global i32 0
define i32 @main() {
%1 = tail call i32 @__thinthin_syscall(i32 1, i32 1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 4)
%2 = tail call i32 @__thinthin_dlopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%3 = tail call i32 @__thinthin_syscall(i32 1, i32 1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 4)
%4 = load i32, i32* @stderr
%5 = load i32, i32* @stdout
%6 = tail call i32 @fprintf(i32 %4, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i32 %5, i32 %4)
ret i32 0
}