#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*/ printf(char *, int);
int selectK(int *, int, int);
void selectKmain(void) {
  int nums[1000] = {0};
  int i = 0;
  for (i = 1000; i > 0; i--) {
    nums[1000 - i] = i;
  }
  printf("%d\n", selectK(nums, 1000, 98));
}


x86 assembly (clang, -O0):
<selectKmain>:
push   %rbp
mov    %rsp,%rbp
sub    $0xfb0,%rsp
lea    -0xfa0(%rbp),%rdi
xor    %esi,%esi
mov    $0xfa0,%edx
call   1050 <memset@plt>
movl   $0x0,-0xfa4(%rbp)
movl   $0x3e8,-0xfa4(%rbp)
cmpl   $0x0,-0xfa4(%rbp)
jle    119d <selectKmain+0x6d>
mov    -0xfa4(%rbp),%ecx
mov    $0x3e8,%eax
sub    -0xfa4(%rbp),%eax
cltq
mov    %ecx,-0xfa0(%rbp,%rax,4)
mov    -0xfa4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xfa4(%rbp)
jmp    1162 <selectKmain+0x32>
lea    -0xfa0(%rbp),%rdi
mov    $0x3e8,%esi
mov    $0x62,%edx
call   1030 <selectK@plt>
mov    %eax,%esi
lea    0xe44(%rip),%rdi
call   1040 <printf@plt>
add    $0xfb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<selectKmain>:
push   %rbx
sub    $0xfa0,%rsp
mov    %rsp,%rdi
xor    %ebx,%ebx
mov    $0xfa0,%edx
xor    %esi,%esi
call   1050 <memset@plt>
movdqa 0xeaf(%rip),%xmm0
movdqa 0xeb6(%rip),%xmm8
movdqa 0xebd(%rip),%xmm9
movdqa 0xec4(%rip),%xmm10
movdqa 0xecb(%rip),%xmm11
movdqa 0xed2(%rip),%xmm12
movdqa 0xeda(%rip),%xmm6
movdqa 0xee2(%rip),%xmm7
movdqa 0xeea(%rip),%xmm1
movdqa 0xef2(%rip),%xmm2
movdqa 0xefa(%rip),%xmm3
cs nopw 0x0(%rax,%rax,1)
movdqa %xmm0,%xmm4
paddd  %xmm8,%xmm4
movdqa %xmm0,(%rsp,%rbx,4)
movdqa %xmm4,0x10(%rsp,%rbx,4)
movdqa %xmm0,%xmm4
paddd  %xmm9,%xmm4
movdqa %xmm0,%xmm5
paddd  %xmm10,%xmm5
movdqa %xmm4,0x20(%rsp,%rbx,4)
movdqa %xmm5,0x30(%rsp,%rbx,4)
movdqa %xmm0,%xmm4
paddd  %xmm11,%xmm4
movdqa %xmm0,%xmm5
paddd  %xmm12,%xmm5
movdqa %xmm4,0x40(%rsp,%rbx,4)
movdqa %xmm5,0x50(%rsp,%rbx,4)
movdqa %xmm0,%xmm4
paddd  %xmm6,%xmm4
movdqa %xmm0,%xmm5
paddd  %xmm7,%xmm5
movdqa %xmm4,0x60(%rsp,%rbx,4)
movdqa %xmm5,0x70(%rsp,%rbx,4)
movdqa %xmm0,%xmm4
paddd  %xmm1,%xmm4
movdqa %xmm0,%xmm5
paddd  %xmm2,%xmm5
movdqa %xmm4,0x80(%rsp,%rbx,4)
movdqa %xmm5,0x90(%rsp,%rbx,4)
add    $0x28,%rbx
paddd  %xmm3,%xmm0
cmp    $0x3e8,%rbx
jne    11b0 <selectKmain+0x80>
mov    %rsp,%rdi
mov    $0x3e8,%esi
mov    $0x62,%edx
call   1030 <selectK@plt>
lea    0xe44(%rip),%rdi
mov    %eax,%esi
call   1040 <printf@plt>
add    $0xfa0,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%d\0A\00"
define void @selectKmain() {
%1 = alloca [1000 x i32]
%2 = alloca i32
%3 = bitcast [1000 x i32]* %1 to i8*
store i32 0, i32* %2
store i32 1000, i32* %2
br label %4
4: ; preds = %13, %0
%5 = load i32, i32* %2
%6 = icmp sgt i32 %5, 0
br i1 %6, label %7, label %16
7: ; preds = %4
%8 = load i32, i32* %2
%9 = load i32, i32* %2
%10 = sub nsw i32 1000, %9
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds [1000 x i32], [1000 x i32]* %1, i64 0, i64 %11
store i32 %8, i32* %12
br label %13
13: ; preds = %7
%14 = load i32, i32* %2
%15 = add nsw i32 %14, -1
store i32 %15, i32* %2
br label %4
16: ; preds = %4
%17 = getelementptr inbounds [1000 x i32], [1000 x i32]* %1, i64 0, i64 0
%18 = call i32 @selectK(i32* %17, i32 1000, i32 98)
%19 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %18)
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d\0A\00"
define void @selectKmain() {
%1 = alloca [1000 x i32]
%2 = bitcast [1000 x i32]* %1 to i8*
br label %3
3: ; preds = %3, %0
%4 = phi i64 [ 0, %0 ], [ %39, %3 ]
%5 = phi <4 x i32> [ <i32 1000, i32 999, i32 998, i32 997>, %0 ], [ %40, %3 ]
%6 = add <4 x i32> %5, <i32 -4, i32 -4, i32 -4, i32 -4>
%7 = getelementptr inbounds [1000 x i32], [1000 x i32]* %1, i64 0, i64 %4
%8 = bitcast i32* %7 to <4 x i32>*
store <4 x i32> %5, <4 x i32>* %8
%9 = getelementptr inbounds i32, i32* %7, i64 4
%10 = bitcast i32* %9 to <4 x i32>*
store <4 x i32> %6, <4 x i32>* %10
%11 = add nuw nsw i64 %4, 8
%12 = add <4 x i32> %5, <i32 -8, i32 -8, i32 -8, i32 -8>
%13 = add <4 x i32> %5, <i32 -12, i32 -12, i32 -12, i32 -12>
%14 = getelementptr inbounds [1000 x i32], [1000 x i32]* %1, i64 0, i64 %11
%15 = bitcast i32* %14 to <4 x i32>*
store <4 x i32> %12, <4 x i32>* %15
%16 = getelementptr inbounds i32, i32* %14, i64 4
%17 = bitcast i32* %16 to <4 x i32>*
store <4 x i32> %13, <4 x i32>* %17
%18 = add nuw nsw i64 %4, 16
%19 = add <4 x i32> %5, <i32 -16, i32 -16, i32 -16, i32 -16>
%20 = add <4 x i32> %5, <i32 -20, i32 -20, i32 -20, i32 -20>
%21 = getelementptr inbounds [1000 x i32], [1000 x i32]* %1, i64 0, i64 %18
%22 = bitcast i32* %21 to <4 x i32>*
store <4 x i32> %19, <4 x i32>* %22
%23 = getelementptr inbounds i32, i32* %21, i64 4
%24 = bitcast i32* %23 to <4 x i32>*
store <4 x i32> %20, <4 x i32>* %24
%25 = add nuw nsw i64 %4, 24
%26 = add <4 x i32> %5, <i32 -24, i32 -24, i32 -24, i32 -24>
%27 = add <4 x i32> %5, <i32 -28, i32 -28, i32 -28, i32 -28>
%28 = getelementptr inbounds [1000 x i32], [1000 x i32]* %1, i64 0, i64 %25
%29 = bitcast i32* %28 to <4 x i32>*
store <4 x i32> %26, <4 x i32>* %29
%30 = getelementptr inbounds i32, i32* %28, i64 4
%31 = bitcast i32* %30 to <4 x i32>*
store <4 x i32> %27, <4 x i32>* %31
%32 = add nuw nsw i64 %4, 32
%33 = add <4 x i32> %5, <i32 -32, i32 -32, i32 -32, i32 -32>
%34 = add <4 x i32> %5, <i32 -36, i32 -36, i32 -36, i32 -36>
%35 = getelementptr inbounds [1000 x i32], [1000 x i32]* %1, i64 0, i64 %32
%36 = bitcast i32* %35 to <4 x i32>*
store <4 x i32> %33, <4 x i32>* %36
%37 = getelementptr inbounds i32, i32* %35, i64 4
%38 = bitcast i32* %37 to <4 x i32>*
store <4 x i32> %34, <4 x i32>* %38
%39 = add nuw nsw i64 %4, 40
%40 = add <4 x i32> %5, <i32 -40, i32 -40, i32 -40, i32 -40>
%41 = icmp eq i64 %39, 1000
br i1 %41, label %42, label %3
42: ; preds = %3
%43 = getelementptr inbounds [1000 x i32], [1000 x i32]* %1, i64 0, i64 0
%44 = call i32 @selectK(i32* %43, i32 1000, i32 98)
%45 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %44)
ret void
}