#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*/ number_of_tasks_running_2(int **, int *, int *, int, int *,
                                             int);
int /*<<< orphan*/ printf(char *, int);
int main() {
  int n = 3, m = 4, start[] = {0, 5, 2}, end[] = {4, 7, 8},
      query[] = {1, 9, 4, 3};
  int output[m];
  number_of_tasks_running_2(&output, start, end, n, query, m);
  for (int i = 0; i < m; i++) {
    printf("%d ", *(output + i));
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x3,-0x8(%rbp)
movl   $0x4,-0xc(%rbp)
mov    0xec5(%rip),%eax
mov    %eax,-0x10(%rbp)
mov    0xeb3(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xebd(%rip),%eax
mov    %eax,-0x20(%rbp)
mov    0xeab(%rip),%rax
mov    %rax,-0x28(%rbp)
movaps 0xeb4(%rip),%xmm0
movaps %xmm0,-0x40(%rbp)
mov    -0xc(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x48(%rbp)
lea    0xf(,%rax,4),%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x60(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x50(%rbp)
lea    -0x18(%rbp),%rsi
lea    -0x28(%rbp),%rdx
mov    -0x8(%rbp),%ecx
lea    -0x40(%rbp),%r8
mov    -0xc(%rbp),%r9d
call   1040 <number_of_tasks_running_2@plt>
movl   $0x0,-0x54(%rbp)
mov    -0x54(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11e7 <main+0xc7>
mov    -0x60(%rbp),%rax
movslq -0x54(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe5c(%rip),%rdi
call   1030 <printf@plt>
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    11b6 <main+0x96>
mov    -0x48(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x48,%rsp
mov    %rsp,%r14
mov    0xed8(%rip),%eax
mov    %eax,0x28(%rsp)
mov    0xec5(%rip),%rax
mov    %rax,0x20(%rsp)
mov    0xece(%rip),%eax
mov    %eax,0x18(%rsp)
mov    0xebb(%rip),%rax
mov    %rax,0x10(%rsp)
movaps 0xec3(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
mov    %rsp,%rdi
lea    0x20(%rsp),%rsi
lea    0x10(%rsp),%rdx
lea    0x30(%rsp),%r8
mov    $0x3,%ecx
mov    $0x4,%r9d
call   1040 <number_of_tasks_running_2@plt>
mov    (%rsp),%esi
lea    0xea2(%rip),%rbx
mov    %rbx,%rdi
call   1030 <printf@plt>
mov    0x4(%rsp),%esi
mov    %rbx,%rdi
call   1030 <printf@plt>
mov    0x8(%rsp),%esi
mov    %rbx,%rdi
call   1030 <printf@plt>
mov    0xc(%rsp),%esi
mov    %rbx,%rdi
call   1030 <printf@plt>
mov    %r14,%rsp
xor    %eax,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.main.start = [3 x i32] [i32 0, i32 5, i32 2]
@__const.main.end = [3 x i32] [i32 4, i32 7, i32 8]
@__const.main.query = [4 x i32] [i32 1, i32 9, i32 4, i32 3]
@.str = [4 x i8] c"%d \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [3 x i32]
%5 = alloca [3 x i32]
%6 = alloca [4 x i32]
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i32
store i32 0, i32* %1
store i32 3, i32* %2
store i32 4, i32* %3
%10 = bitcast [3 x i32]* %4 to i8*
%11 = bitcast [3 x i32]* %5 to i8*
%12 = bitcast [4 x i32]* %6 to i8*
%13 = load i32, i32* %3
%14 = zext i32 %13 to i64
%15 = call i8* @llvm.stacksave()
store i8* %15, i8** %7
%16 = alloca i32, i64 %14
store i64 %14, i64* %8
%17 = bitcast i32* %16 to i32**
%18 = getelementptr inbounds [3 x i32], [3 x i32]* %4, i64 0, i64 0
%19 = getelementptr inbounds [3 x i32], [3 x i32]* %5, i64 0, i64 0
%20 = load i32, i32* %2
%21 = getelementptr inbounds [4 x i32], [4 x i32]* %6, i64 0, i64 0
%22 = load i32, i32* %3
%23 = call i32 @number_of_tasks_running_2(i32** %17, i32* %18, i32* %19, i32 %20, i32* %21, i32 %22)
store i32 0, i32* %9
br label %24
24: ; preds = %34, %0
%25 = load i32, i32* %9
%26 = load i32, i32* %3
%27 = icmp slt i32 %25, %26
br i1 %27, label %28, label %37
28: ; preds = %24
%29 = load i32, i32* %9
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i32, i32* %16, i64 %30
%32 = load i32, i32* %31
%33 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %32)
br label %34
34: ; preds = %28
%35 = load i32, i32* %9
%36 = add nsw i32 %35, 1
store i32 %36, i32* %9
br label %24
37: ; preds = %24
%38 = load i8*, i8** %7
%39 = load i32, i32* %1
ret i32 %39
}

LLVM IR (-O2):
@__const.main.start = [3 x i32] [i32 0, i32 5, i32 2]
@__const.main.end = [3 x i32] [i32 4, i32 7, i32 8]
@__const.main.query = [4 x i32] [i32 1, i32 9, i32 4, i32 3]
@.str = [4 x i8] c"%d \00"
define i32 @main() {
%1 = alloca [3 x i32]
%2 = alloca [3 x i32]
%3 = alloca [4 x i32]
%4 = bitcast [3 x i32]* %1 to i8*
%5 = bitcast [3 x i32]* %2 to i8*
%6 = bitcast [4 x i32]* %3 to i8*
%7 = tail call i8* @llvm.stacksave()
%8 = alloca [4 x i32]
%9 = bitcast [4 x i32]* %8 to i32**
%10 = getelementptr inbounds [3 x i32], [3 x i32]* %1, i64 0, i64 0
%11 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 0
%12 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 0
%13 = call i32 @number_of_tasks_running_2(i32** %9, i32* %10, i32* %11, i32 3, i32* %12, i32 4)
%14 = getelementptr inbounds [4 x i32], [4 x i32]* %8, i64 0, i64 0
%15 = load i32, i32* %14
%16 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %15)
%17 = getelementptr inbounds [4 x i32], [4 x i32]* %8, i64 0, i64 1
%18 = load i32, i32* %17
%19 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %18)
%20 = getelementptr inbounds [4 x i32], [4 x i32]* %8, i64 0, i64 2
%21 = load i32, i32* %20
%22 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %21)
%23 = getelementptr inbounds [4 x i32], [4 x i32]* %8, i64 0, i64 3
%24 = load i32, i32* %23
%25 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %24)
ret i32 0
}