#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 */
scalar_t__ EOF;
int findkthnum(int *, int, int);
int /*<<< orphan*/ printf(char *, int, int);
scalar_t__ scanf(char *, int *);
int main(int argc, char *argv[]) {
  int n;
  int array[100];
  n = 0;
  while (scanf("%d", &array[n]) != EOF)
    n++;
  printf("The %dth number is %d\n", n / 2, findkthnum(array, n, n / 2));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1c0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movslq -0x14(%rbp),%rax
lea    -0x1b0(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe97(%rip),%rdi
call   1050 <scanf@plt>
mov    0x2e73(%rip),%rcx
cmp    (%rcx),%rax
je     118c <main+0x5c>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1150 <main+0x20>
mov    -0x14(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x1b4(%rbp)
lea    -0x1b0(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x14(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%edx
call   1040 <findkthnum@plt>
mov    -0x1b4(%rbp),%esi
mov    %eax,%edx
lea    0xe3b(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x1c0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x198,%rsp
mov    $0xffffffff,%ebp
mov    %rsp,%rbx
lea    0xeb4(%rip),%r14
mov    0x2e95(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
add    $0x1,%ebp
add    $0x4,%rbx
cmp    (%r15),%rax
jne    1160 <main+0x30>
mov    %ebp,%ebx
shr    %ebx
mov    %rsp,%rdi
mov    %ebp,%esi
mov    %ebx,%edx
call   1040 <findkthnum@plt>
lea    0xe75(%rip),%rdi
mov    %ebx,%esi
mov    %eax,%edx
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x198,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@EOF = global i64 0
@.str.1 = [23 x i8] c"The %dth number is %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca [100 x i32]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
br label %8
8: ; preds = %15, %2
%9 = load i32, i32* %6
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds [100 x i32], [100 x i32]* %7, i64 0, i64 %10
%12 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %11)
%13 = load i64, i64* @EOF
%14 = icmp ne i64 %12, %13
br i1 %14, label %15, label %18
15: ; preds = %8
%16 = load i32, i32* %6
%17 = add nsw i32 %16, 1
store i32 %17, i32* %6
br label %8
18: ; preds = %8
%19 = load i32, i32* %6
%20 = sdiv i32 %19, 2
%21 = getelementptr inbounds [100 x i32], [100 x i32]* %7, i64 0, i64 0
%22 = load i32, i32* %6
%23 = load i32, i32* %6
%24 = sdiv i32 %23, 2
%25 = call i32 @findkthnum(i32* %21, i32 %22, i32 %24)
%26 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 %20, i32 %25)
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@EOF = global i64 0
@.str.1 = [23 x i8] c"The %dth number is %d\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [100 x i32]
%4 = bitcast [100 x i32]* %3 to i8*
br label %5
5: ; preds = %5, %2
%6 = phi i64 [ %11, %5 ], [ 0, %2 ]
%7 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 %6
%8 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %7)
%9 = load i64, i64* @EOF
%10 = icmp eq i64 %8, %9
%11 = add nuw i64 %6, 1
br i1 %10, label %12, label %5
12: ; preds = %5
%13 = trunc i64 %6 to i32
%14 = lshr i32 %13, 1
%15 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 0
%16 = call i32 @findkthnum(i32* %15, i32 %13, i32 %14)
%17 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 %14, i32 %16)
ret i32 0
}