#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 */
typedef int /*<<< orphan*/ nums;

/* Variables and functions */
int *countSmaller(int *, int, int *);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  int nums[] = {26, 78, 27, 100, 33, 67, 90, 23, 66, 5,  38,  7,  35, 23,
                52, 22, 83, 51,  98, 69, 81, 32, 78, 28, 94,  13, 2,  97,
                3,  76, 99, 51,  9,  21, 84, 66, 65, 36, 100, 41};
  int i;
  int resultSize;
  int *results =
      countSmaller(nums, sizeof(nums) / sizeof(nums[0]), &resultSize);
  for (i = 0; i < resultSize; i++) {
    printf("%d ", results[i]);
  }
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0xb0(%rbp),%rdi
lea    0xeb0(%rip),%rsi
mov    $0xa0,%edx
call   1040 <memcpy@plt>
lea    -0xb0(%rbp),%rdi
mov    $0x28,%esi
lea    -0xb8(%rbp),%rdx
call   1050 <countSmaller@plt>
mov    %rax,-0xc0(%rbp)
movl   $0x0,-0xb4(%rbp)
mov    -0xb4(%rbp),%eax
cmp    -0xb8(%rbp),%eax
jge    11c8 <main+0x98>
mov    -0xc0(%rbp),%rax
movslq -0xb4(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xef3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xb4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xb4(%rbp)
jmp    1183 <main+0x53>
lea    0xed5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0xb0,%rsp
lea    0xead(%rip),%rsi
lea    0x10(%rsp),%rbx
mov    $0xa0,%edx
mov    %rbx,%rdi
call   1050 <memcpy@plt>
lea    0xc(%rsp),%rdx
mov    %rbx,%rdi
mov    $0x28,%esi
call   1060 <countSmaller@plt>
cmpl   $0x0,0xc(%rsp)
jle    11ac <main+0x6c>
mov    %rax,%r15
lea    0xf18(%rip),%r14
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
mov    (%r15,%rbx,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbx
movslq 0xc(%rsp),%rax
cmp    %rax,%rbx
jl     1190 <main+0x50>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0xb0,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.main.nums = [40 x i32] [i32 26, i32 78, i32 27, i32 100, i32 33, i32 67, i32 90, i32 23, i32 66, i32 5, i32 38, i32 7, i32 35, i32 23, i32 52, i32 22, i32 83, i32 51, i32 98, i32 69, i32 81, i32 32, i32 78, i32 28, i32 94, i32 13, i32 2, i32 97, i32 3, i32 76, i32 99, i32 51, i32 9, i32 21, i32 84, i32 66, i32 65, i32 36, i32 100, i32 41]
@.str = [4 x i8] c"%d \00"
@.str.1 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [40 x i32]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32*
store i32 0, i32* %1
%6 = bitcast [40 x i32]* %2 to i8*
%7 = getelementptr inbounds [40 x i32], [40 x i32]* %2, i64 0, i64 0
%8 = call i32* @countSmaller(i32* %7, i32 40, i32* %4)
store i32* %8, i32** %5
store i32 0, i32* %3
br label %9
9: ; preds = %20, %0
%10 = load i32, i32* %3
%11 = load i32, i32* %4
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %23
13: ; preds = %9
%14 = load i32*, i32** %5
%15 = load i32, i32* %3
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i32, i32* %14, i64 %16
%18 = load i32, i32* %17
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %18)
br label %20
20: ; preds = %13
%21 = load i32, i32* %3
%22 = add nsw i32 %21, 1
store i32 %22, i32* %3
br label %9
23: ; preds = %9
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@__const.main.nums = [40 x i32] [i32 26, i32 78, i32 27, i32 100, i32 33, i32 67, i32 90, i32 23, i32 66, i32 5, i32 38, i32 7, i32 35, i32 23, i32 52, i32 22, i32 83, i32 51, i32 98, i32 69, i32 81, i32 32, i32 78, i32 28, i32 94, i32 13, i32 2, i32 97, i32 3, i32 76, i32 99, i32 51, i32 9, i32 21, i32 84, i32 66, i32 65, i32 36, i32 100, i32 41]
@.str = [4 x i8] c"%d \00"
define i32 @main() {
%1 = alloca [40 x i32]
%2 = alloca i32
%3 = bitcast [40 x i32]* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = getelementptr inbounds [40 x i32], [40 x i32]* %1, i64 0, i64 0
%6 = call i32* @countSmaller(i32* %5, i32 40, i32* %2)
%7 = load i32, i32* %2
%8 = icmp sgt i32 %7, 0
br i1 %8, label %9, label %18
9: ; preds = %0, %9
%10 = phi i64 [ %14, %9 ], [ 0, %0 ]
%11 = getelementptr inbounds i32, i32* %6, i64 %10
%12 = load i32, i32* %11
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %12)
%14 = add nuw nsw i64 %10, 1
%15 = load i32, i32* %2
%16 = sext i32 %15 to i64
%17 = icmp slt i64 %14, %16
br i1 %17, label %9, label %18
18: ; preds = %9, %0
%19 = call i32 @putchar(i32 10)
ret i32 0
}