#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 */
unsigned int *activate(unsigned int *);
unsigned int *create_task(unsigned int *stack, void (*start)(void)) {
  static int first = 1;
  stack += 256 - 32;
  if (first) {
    stack[8] = (unsigned int)start;
    first = 0;
  } else {
    stack[8] = (unsigned int)0xFFFFFFFD;
    stack[15] = (unsigned int)start;
    stack[16] = (unsigned int)0x01000000;
  }
  stack = activate(stack);
  return stack;
}


x86 assembly (clang, -O0):
<create_task>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
add    $0x380,%rax
mov    %rax,-0x8(%rbp)
cmpl   $0x0,0x2ef3(%rip)
je     1157 <create_task+0x47>
mov    -0x10(%rbp),%rax
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x20(%rax)
movl   $0x0,0x2ed6(%rip)
jmp    117a <create_task+0x6a>
mov    -0x8(%rbp),%rax
movl   $0xfffffffd,0x20(%rax)
mov    -0x10(%rbp),%rax
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x3c(%rax)
mov    -0x8(%rbp),%rax
movl   $0x1000000,0x40(%rax)
mov    -0x8(%rbp),%rdi
call   1030 <activate@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<create_task>:
cmpb   $0x0,0x2f15(%rip)
je     1130 <create_task+0x20>
mov    %esi,0x3bc(%rdi)
movl   $0x1000000,0x3c0(%rdi)
mov    $0xfffffffd,%esi
jmp    1137 <create_task+0x27>
movb   $0x1,0x2ef5(%rip)
mov    %esi,0x3a0(%rdi)
add    $0x380,%rdi
jmp    1030 <activate@plt>

LLVM IR (-O0):
@create_task.first = internal global i32 1
define i32* @create_task(i32* %0, void ()* %1) {
%3 = alloca i32*
%4 = alloca void ()*
store i32* %0, i32** %3
store void ()* %1, void ()** %4
%5 = load i32*, i32** %3
%6 = getelementptr inbounds i32, i32* %5, i64 224
store i32* %6, i32** %3
%7 = load i32, i32* @create_task.first
%8 = icmp ne i32 %7, 0
br i1 %8, label %9, label %14
9: ; preds = %2
%10 = load void ()*, void ()** %4
%11 = ptrtoint void ()* %10 to i32
%12 = load i32*, i32** %3
%13 = getelementptr inbounds i32, i32* %12, i64 8
store i32 %11, i32* %13
store i32 0, i32* @create_task.first
br label %23
14: ; preds = %2
%15 = load i32*, i32** %3
%16 = getelementptr inbounds i32, i32* %15, i64 8
store i32 -3, i32* %16
%17 = load void ()*, void ()** %4
%18 = ptrtoint void ()* %17 to i32
%19 = load i32*, i32** %3
%20 = getelementptr inbounds i32, i32* %19, i64 15
store i32 %18, i32* %20
%21 = load i32*, i32** %3
%22 = getelementptr inbounds i32, i32* %21, i64 16
store i32 16777216, i32* %22
br label %23
23: ; preds = %14, %9
%24 = load i32*, i32** %3
%25 = call i32* @activate(i32* %24)
store i32* %25, i32** %3
%26 = load i32*, i32** %3
ret i32* %26
}

LLVM IR (-O2):
@create_task.first = internal unnamed_addr global i1 false
define i32* @create_task(i32* %0, void ()* %1) {
%3 = load i1, i1* @create_task.first
%4 = ptrtoint void ()* %1 to i64
%5 = trunc i64 %4 to i32
br i1 %3, label %7, label %6
6: ; preds = %2
store i1 true, i1* @create_task.first
br label %10
7: ; preds = %2
%8 = getelementptr inbounds i32, i32* %0, i64 239
store i32 %5, i32* %8
%9 = getelementptr inbounds i32, i32* %0, i64 240
store i32 16777216, i32* %9
br label %10
10: ; preds = %7, %6
%11 = phi i32 [ -3, %7 ], [ %5, %6 ]
%12 = getelementptr inbounds i32, i32* %0, i64 232
store i32 %11, i32* %12
%13 = getelementptr inbounds i32, i32* %0, i64 224
%14 = tail call i32* @activate(i32* %13)
ret i32* %14
}