#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*/ app_exit();
int /*<<< orphan*/ app_init();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ task_start(int, int, int);
int /*<<< orphan*/ task_wait(int /*<<< orphan*/, int);
int main(int argc, char *argv[]) {
  app_init();
  printf("Init done\n");
  task_start(0, 0, 1);
  task_start(1, 0, 1);
  task_start(0, 1, 5);
  task_start(0, 0, 2);
  task_wait(0, 1);
  task_wait(0, 0);
  app_exit();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1030 <app_init@plt>
lea    0xe8c(%rip),%rdi
call   1050 <printf@plt>
xor    %esi,%esi
mov    $0x1,%edx
mov    %esi,%edi
call   1040 <task_start@plt>
mov    $0x1,%edx
xor    %esi,%esi
mov    %edx,%edi
call   1040 <task_start@plt>
xor    %edi,%edi
mov    $0x1,%esi
mov    $0x5,%edx
call   1040 <task_start@plt>
xor    %esi,%esi
mov    $0x2,%edx
mov    %esi,%edi
call   1040 <task_start@plt>
xor    %edi,%edi
mov    $0x1,%esi
call   1060 <task_wait@plt>
xor    %esi,%esi
mov    %esi,%edi
call   1060 <task_wait@plt>
mov    $0x0,%al
call   1070 <app_exit@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
xor    %eax,%eax
call   1030 <app_init@plt>
lea    0xea1(%rip),%rdi
call   1040 <puts@plt>
xor    %edi,%edi
xor    %esi,%esi
mov    $0x1,%edx
call   1050 <task_start@plt>
mov    $0x1,%edi
xor    %esi,%esi
mov    $0x1,%edx
call   1050 <task_start@plt>
xor    %edi,%edi
mov    $0x1,%esi
mov    $0x5,%edx
call   1050 <task_start@plt>
xor    %edi,%edi
xor    %esi,%esi
mov    $0x2,%edx
call   1050 <task_start@plt>
xor    %edi,%edi
mov    $0x1,%esi
call   1060 <task_wait@plt>
xor    %edi,%edi
xor    %esi,%esi
call   1060 <task_wait@plt>
xor    %eax,%eax
call   1070 <app_exit@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [11 x i8] c"Init done\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%6 = call i32 (...) @app_init()
%7 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @task_start(i32 0, i32 0, i32 1)
%9 = call i32 @task_start(i32 1, i32 0, i32 1)
%10 = call i32 @task_start(i32 0, i32 1, i32 5)
%11 = call i32 @task_start(i32 0, i32 0, i32 2)
%12 = call i32 @task_wait(i32 0, i32 1)
%13 = call i32 @task_wait(i32 0, i32 0)
%14 = call i32 (...) @app_exit()
ret i32 0
}

LLVM IR (-O2):
@str = [10 x i8] c"Init done\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 (...) @app_init()
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str, i64 0, i64 0))
%5 = tail call i32 @task_start(i32 0, i32 0, i32 1)
%6 = tail call i32 @task_start(i32 1, i32 0, i32 1)
%7 = tail call i32 @task_start(i32 0, i32 1, i32 5)
%8 = tail call i32 @task_start(i32 0, i32 0, i32 2)
%9 = tail call i32 @task_wait(i32 0, i32 1)
%10 = tail call i32 @task_wait(i32 0, i32 0)
%11 = tail call i32 (...) @app_exit()
ret i32 0
}