#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 */
struct task_set {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ evt_activation(int, int, long long);
int /*<<< orphan*/ evt_creation(int, char const *, int, long long);
int /*<<< orphan*/ taskset_add_task(struct task_set *, int, int, void *);
int /*<<< orphan*/ *taskset_find_task(struct task_set *, int, int);
struct task_set *taskset_init();
int create(long long int time, int pid, const char *name, int cpu) {
  static struct task_set *ts;
  if (ts == NULL) {
    ts = taskset_init();
  }
  if (taskset_find_task(ts, pid, cpu) == NULL) {
    taskset_add_task(ts, pid, cpu, (void *)1);
    evt_creation(pid, name, cpu, time);
    evt_activation(pid, cpu, time);
    return 0;
  } else {
    return 1;
  }
}


x86 assembly (clang, -O0):
<create>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
cmpq   $0x0,0x2ee2(%rip)
jne    1182 <create+0x32>
mov    $0x0,%al
call   1060 <taskset_init@plt>
mov    %rax,0x2ece(%rip)
mov    0x2ec7(%rip),%rdi
mov    -0x14(%rbp),%esi
mov    -0x24(%rbp),%edx
call   1050 <taskset_find_task@plt>
cmp    $0x0,%rax
jne    11e3 <create+0x93>
mov    0x2eab(%rip),%rdi
mov    -0x14(%rbp),%esi
mov    -0x24(%rbp),%edx
mov    $0x1,%ecx
call   1040 <taskset_add_task@plt>
mov    -0x14(%rbp),%edi
mov    -0x20(%rbp),%rsi
mov    -0x24(%rbp),%edx
mov    -0x10(%rbp),%rcx
call   1070 <evt_creation@plt>
mov    -0x14(%rbp),%edi
mov    -0x24(%rbp),%esi
mov    -0x10(%rbp),%rdx
call   1030 <evt_activation@plt>
movl   $0x0,-0x4(%rbp)
jmp    11ea <create+0x9a>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<create>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %ecx,%ebx
mov    %rdx,%r15
mov    %esi,%ebp
mov    %rdi,%r14
mov    0x2ee8(%rip),%rdi
test   %rdi,%rdi
jne    117e <create+0x2e>
xor    %eax,%eax
call   1060 <taskset_init@plt>
mov    %rax,%rdi
mov    %rax,0x2ed2(%rip)
mov    %ebp,%esi
mov    %ebx,%edx
call   1050 <taskset_find_task@plt>
mov    %rax,%rcx
mov    $0x1,%eax
test   %rcx,%rcx
jne    11c6 <create+0x76>
mov    0x2eb5(%rip),%rdi
mov    $0x1,%ecx
mov    %ebp,%esi
mov    %ebx,%edx
call   1040 <taskset_add_task@plt>
mov    %ebp,%edi
mov    %r15,%rsi
mov    %ebx,%edx
mov    %r14,%rcx
call   1070 <evt_creation@plt>
mov    %ebp,%edi
mov    %ebx,%esi
mov    %r14,%rdx
call   1030 <evt_activation@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.task_set = type { i32 }
@create.ts = internal global %struct.task_set* null
define i32 @create(i64 %0, i32 %1, i8* %2, i32 %3) {
%5 = alloca i32
%6 = alloca i64
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
store i64 %0, i64* %6
store i32 %1, i32* %7
store i8* %2, i8** %8
store i32 %3, i32* %9
%10 = load %struct.task_set*, %struct.task_set** @create.ts
%11 = icmp eq %struct.task_set* %10, null
br i1 %11, label %12, label %14
12: ; preds = %4
%13 = call %struct.task_set* (...) @taskset_init()
store %struct.task_set* %13, %struct.task_set** @create.ts
br label %14
14: ; preds = %12, %4
%15 = load %struct.task_set*, %struct.task_set** @create.ts
%16 = load i32, i32* %7
%17 = load i32, i32* %9
%18 = call i32* @taskset_find_task(%struct.task_set* %15, i32 %16, i32 %17)
%19 = icmp eq i32* %18, null
br i1 %19, label %20, label %34
20: ; preds = %14
%21 = load %struct.task_set*, %struct.task_set** @create.ts
%22 = load i32, i32* %7
%23 = load i32, i32* %9
%24 = call i32 @taskset_add_task(%struct.task_set* %21, i32 %22, i32 %23, i8* inttoptr (i64 1 to i8*))
%25 = load i32, i32* %7
%26 = load i8*, i8** %8
%27 = load i32, i32* %9
%28 = load i64, i64* %6
%29 = call i32 @evt_creation(i32 %25, i8* %26, i32 %27, i64 %28)
%30 = load i32, i32* %7
%31 = load i32, i32* %9
%32 = load i64, i64* %6
%33 = call i32 @evt_activation(i32 %30, i32 %31, i64 %32)
store i32 0, i32* %5
br label %35
34: ; preds = %14
store i32 1, i32* %5
br label %35
35: ; preds = %34, %20
%36 = load i32, i32* %5
ret i32 %36
}

LLVM IR (-O2):
%struct.task_set = type { i32 }
@create.ts = internal unnamed_addr global %struct.task_set* null
define i32 @create(i64 %0, i32 %1, i8* %2, i32 %3) {
%5 = load %struct.task_set*, %struct.task_set** @create.ts
%6 = icmp eq %struct.task_set* %5, null
br i1 %6, label %7, label %9
7: ; preds = %4
%8 = tail call %struct.task_set* (...) @taskset_init()
store %struct.task_set* %8, %struct.task_set** @create.ts
br label %9
9: ; preds = %7, %4
%10 = phi %struct.task_set* [ %8, %7 ], [ %5, %4 ]
%11 = tail call i32* @taskset_find_task(%struct.task_set* %10, i32 %1, i32 %3)
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %18
13: ; preds = %9
%14 = load %struct.task_set*, %struct.task_set** @create.ts
%15 = tail call i32 @taskset_add_task(%struct.task_set* %14, i32 %1, i32 %3, i8* inttoptr (i64 1 to i8*))
%16 = tail call i32 @evt_creation(i32 %1, i8* %2, i32 %3, i64 %0)
%17 = tail call i32 @evt_activation(i32 %1, i32 %3, i64 %0)
br label %18
18: ; preds = %9, %13
%19 = phi i32 [ 0, %13 ], [ 1, %9 ]
ret i32 %19
}