#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*/ FindMedian(int *, int /*<<< orphan*/, int, int);
int /*<<< orphan*/ free(int *);
int /*<<< orphan*/ getch();
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int *dizi;
  int elemanSayisi;
  int i, j;
  int temp;
  int pivot;
  printf("Diziniz kac elemanli olacak> ");
  scanf("%d", &elemanSayisi);
  dizi = (int *)malloc(elemanSayisi * sizeof(int));
  for (i = 0; i < elemanSayisi; i++) {
    printf("%d. elemani giriniz> ", i + 1);
    scanf("%d", &dizi[i]);
  }
  FindMedian(dizi, 0, elemanSayisi - 1, elemanSayisi);
  for (i = 0; i < elemanSayisi; i++)
    printf("%d ", dizi[i]);
  getch();
  free(dizi);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe8a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe9a(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1070 <scanf@plt>
movslq -0x14(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11f0 <main+0x90>
mov    -0x18(%rbp),%esi
add    $0x1,%esi
lea    0xe61(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x10(%rbp),%rsi
movslq -0x18(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe41(%rip),%rdi
call   1070 <scanf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11a7 <main+0x47>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%edx
sub    $0x1,%edx
mov    -0x14(%rbp),%ecx
xor    %esi,%esi
call   1040 <FindMedian@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    123e <main+0xde>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe0e(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    120b <main+0xab>
mov    $0x0,%al
call   1080 <getch@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xe8c(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe9c(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1070 <scanf@plt>
mov    0xc(%rsp),%edi
shl    $0x2,%edi
call   1060 <malloc@plt>
mov    %rax,%r12
mov    0xc(%rsp),%ecx
test   %ecx,%ecx
jle    11e9 <main+0x89>
lea    0xe77(%rip),%r14
lea    0xe6d(%rip),%r15
mov    %r12,%r13
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%rbx
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r15,%rdi
mov    %r13,%rsi
call   1070 <scanf@plt>
movslq 0xc(%rsp),%rcx
add    $0x4,%r13
cmp    %rcx,%rbx
jl     11c0 <main+0x60>
lea    -0x1(%rcx),%edx
mov    %r12,%rdi
xor    %esi,%esi
call   1040 <FindMedian@plt>
cmpl   $0x0,0xc(%rsp)
jle    122c <main+0xcc>
lea    0xe33(%rip),%r14
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
mov    (%r12,%rbx,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbx
movslq 0xc(%rsp),%rax
cmp    %rax,%rbx
jl     1210 <main+0xb0>
xor    %eax,%eax
call   1080 <getch@plt>
mov    %r12,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [30 x i8] c"Diziniz kac elemanli olacak> \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [22 x i8] c"%d. elemani giriniz> \00"
@.str.3 = [4 x i8] c"%d \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%10 = load i32, i32* %3
%11 = sext i32 %10 to i64
%12 = mul i64 %11, 4
%13 = trunc i64 %12 to i32
%14 = call i64 @malloc(i32 %13)
%15 = inttoptr i64 %14 to i32*
store i32* %15, i32** %2
store i32 0, i32* %4
br label %16
16: ; preds = %29, %0
%17 = load i32, i32* %4
%18 = load i32, i32* %3
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %32
20: ; preds = %16
%21 = load i32, i32* %4
%22 = add nsw i32 %21, 1
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i32 %22)
%24 = load i32*, i32** %2
%25 = load i32, i32* %4
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i32, i32* %24, i64 %26
%28 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %27)
br label %29
29: ; preds = %20
%30 = load i32, i32* %4
%31 = add nsw i32 %30, 1
store i32 %31, i32* %4
br label %16
32: ; preds = %16
%33 = load i32*, i32** %2
%34 = load i32, i32* %3
%35 = sub nsw i32 %34, 1
%36 = load i32, i32* %3
%37 = call i32 @FindMedian(i32* %33, i32 0, i32 %35, i32 %36)
store i32 0, i32* %4
br label %38
38: ; preds = %49, %32
%39 = load i32, i32* %4
%40 = load i32, i32* %3
%41 = icmp slt i32 %39, %40
br i1 %41, label %42, label %52
42: ; preds = %38
%43 = load i32*, i32** %2
%44 = load i32, i32* %4
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds i32, i32* %43, i64 %45
%47 = load i32, i32* %46
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %47)
br label %49
49: ; preds = %42
%50 = load i32, i32* %4
%51 = add nsw i32 %50, 1
store i32 %51, i32* %4
br label %38
52: ; preds = %38
%53 = call i32 (...) @getch()
%54 = load i32*, i32** %2
%55 = call i32 @free(i32* %54)
ret i32 0
}

LLVM IR (-O2):
@.str = [30 x i8] c"Diziniz kac elemanli olacak> \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [22 x i8] c"%d. elemani giriniz> \00"
@.str.3 = [4 x i8] c"%d \00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%5 = load i32, i32* %1
%6 = shl i32 %5, 2
%7 = call i64 @malloc(i32 %6)
%8 = inttoptr i64 %7 to i32*
%9 = load i32, i32* %1
%10 = icmp sgt i32 %9, 0
br i1 %10, label %11, label %21
11: ; preds = %0, %11
%12 = phi i64 [ %13, %11 ], [ 0, %0 ]
%13 = add nuw nsw i64 %12, 1
%14 = trunc i64 %13 to i32
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i32 %14)
%16 = getelementptr inbounds i32, i32* %8, i64 %12
%17 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %16)
%18 = load i32, i32* %1
%19 = sext i32 %18 to i64
%20 = icmp slt i64 %13, %19
br i1 %20, label %11, label %21
21: ; preds = %11, %0
%22 = phi i32 [ %9, %0 ], [ %18, %11 ]
%23 = add nsw i32 %22, -1
%24 = call i32 @FindMedian(i32* %8, i32 0, i32 %23, i32 %22)
%25 = load i32, i32* %1
%26 = icmp sgt i32 %25, 0
br i1 %26, label %27, label %36
27: ; preds = %21, %27
%28 = phi i64 [ %32, %27 ], [ 0, %21 ]
%29 = getelementptr inbounds i32, i32* %8, i64 %28
%30 = load i32, i32* %29
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %30)
%32 = add nuw nsw i64 %28, 1
%33 = load i32, i32* %1
%34 = sext i32 %33 to i64
%35 = icmp slt i64 %32, %34
br i1 %35, label %27, label %36
36: ; preds = %27, %21
%37 = call i32 (...) @getch()
%38 = call i32 @free(i32* %8)
ret i32 0
}