#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*/ DiziOlarakAl(int /*<<< orphan*/, int *, int, int);
int /*<<< orphan*/ EkranaGoster(int *, int, int /*<<< orphan*/);
int /*<<< orphan*/ ElemanEkle(int *, int *, int, int);
int /*<<< orphan*/ ElemanSil(int *, int, int);
int /*<<< orphan*/ InOrderAl(int /*<<< orphan*/, int *, int);
int /*<<< orphan*/ PostOrderAl(int /*<<< orphan*/, int *, int);
int /*<<< orphan*/ PreOrderAl(int /*<<< orphan*/, int *, int);
int UsAl(int, int);
int /*<<< orphan*/ free(int *);
char getch();
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int eklenecekEleman;
  int elemanSayisi;
  int i;
  int derinlik;
  int *BST;
  int programdanCik;
  char secim1, secim2;
  int BST_Alindi;
  int girilenEleman;
  int index;
  printf("Olusturacaginiz Binary Search Tree'nin derinligi nedir> ");
  scanf("%d", &derinlik);
  elemanSayisi = UsAl(2, derinlik + 1) - 1;
  printf("Bu durumda toplam %d eleman olacak. \n\n", elemanSayisi);
  BST = (int *)malloc(elemanSayisi * sizeof(int));
  for (i = 0; i < elemanSayisi; i++)
    BST[i] = -1;
  printf("Lutfen istediginiz secenegin tusuna basin: \n\n");
  BST_Alindi = 0;
  while (BST_Alindi == 0) {
    printf("[1] Dizi olarak gir. (Direkt atama yapilir, bilgisayar islem "
           "yapmaz) \n");
    printf("[2] Dizi olarak gir. (Agaci bilgisayar olusturur ama 'balance' "
           "yapilmaz, duzgun calismasi 'balanced' tree girmelisiniz) \n");
    printf("[3] Pre-order gir.\n");
    printf("[4] In-order gir.\n");
    printf("[5] Post-order gir.\n");
    secim1 = getch();
    switch (secim1) {
    case '1': {
      printf("\nBST'nin elemanlarini sirayla giriniz. Eger gozu bos birakmak "
             "isterseniz eleman yerine %d yazin. \n",
             -1);
      for (i = 0; i < elemanSayisi; i++) {
        printf("%d. elemani giriniz> ", i);
        scanf("%d", &BST[i]);
      }
      BST_Alindi = 1;
      break;
    }
    case '2': {
      printf("\nBST'nin elemanlarini sirayla giriniz. Elemanlariniz bittikten "
             "sonra gozu bos birakmak icin eleman yerine %d yazin. \n",
             -1);
      for (i = 0; i < elemanSayisi; i++) {
        printf("%d. elemani giriniz> ", i + 1);
        scanf("%d", &girilenEleman);
        DiziOlarakAl(0, BST, elemanSayisi, girilenEleman);
      }
      BST_Alindi = 1;
      break;
    }
    case '3': {
      PreOrderAl(0, BST, elemanSayisi);
      BST_Alindi = 1;
      break;
    }
    case '4': {
      InOrderAl(0, BST, elemanSayisi);
      BST_Alindi = 1;
      break;
    }
    case '5': {
      PostOrderAl(0, BST, elemanSayisi);
      BST_Alindi = 1;
      break;
    }
    default: {
      printf("Yanlis bir secenek sectiniz lutfen tekrar deneyin. \n\n");
      break;
    }
    }
  }
  EkranaGoster(BST, elemanSayisi, 0);
  programdanCik = 0;
  while (programdanCik == 0) {
    printf("\n\nLutfen uygun secenegin tusuna basin: \n");
    printf("----  MENU  ----\n\n");
    printf("[1] Binary Search Tree'yi goster. \n");
    printf("[2] Eleman ekle. \n");
    printf("[3] Eleman sil. \n");
    printf("[4] Programdan cik. \n\n\n");
    secim2 = getch();
    switch (secim2) {
    case '1': {
      EkranaGoster(BST, elemanSayisi, 0);
      break;
    }
    case '2': {
      printf("Eklemek istediginiz elemani giriniz> ");
      scanf("%d", &eklenecekEleman);
      ElemanEkle(BST, &elemanSayisi, eklenecekEleman, derinlik);
      break;
    }
    case '3': {
      printf("Index  Dizi\n");
      printf("-----  ----\n");
      for (i = 0; i < elemanSayisi; i++) {
        printf(" %0.2d:    %d\n", i, BST[i]);
      }
      printf("\nSilmek istediginiz elemanin index'ini giriniz> ");
      scanf("%d", &index);
      ElemanSil(BST, elemanSayisi, index);
      break;
    }
    case '4': {
      printf("\n\nCikiliyor..\n");
      free(BST);
      programdanCik = 1;
      break;
    }
    default: {
      printf("Yanlis bir secenek sectiniz lutfen tekrar deneyin. \n\n");
      break;
    }
    }
  }
  getch();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe3e(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xe69(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   10b0 <scanf@plt>
mov    -0x14(%rbp),%esi
add    $0x1,%esi
mov    $0x2,%edi
call   1080 <UsAl@plt>
sub    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xe43(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movslq -0xc(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1090 <malloc@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1267 <main+0x97>
mov    -0x20(%rbp),%rax
movslq -0x10(%rbp),%rcx
movl   $0xffffffff,(%rax,%rcx,4)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    123e <main+0x6e>
lea    0xe19(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x0,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jne    144a <main+0x27a>
lea    0xe28(%rip),%rdi
xor    %eax,%eax
mov    %al,-0x41(%rbp)
call   1060 <printf@plt>
mov    -0x41(%rbp),%al
lea    0xe5b(%rip),%rdi
call   1060 <printf@plt>
mov    -0x41(%rbp),%al
lea    0xec6(%rip),%rdi
call   1060 <printf@plt>
mov    -0x41(%rbp),%al
lea    0xecb(%rip),%rdi
call   1060 <printf@plt>
mov    -0x41(%rbp),%al
lea    0xecf(%rip),%rdi
call   1060 <printf@plt>
mov    -0x41(%rbp),%al
call   10c0 <getch@plt>
mov    %al,-0x25(%rbp)
movsbl -0x25(%rbp),%eax
add    $0xffffffcf,%eax
mov    %eax,%ecx
mov    %rcx,-0x40(%rbp)
sub    $0x4,%eax
ja     1437 <main+0x267>
mov    -0x40(%rbp),%rax
lea    0xd11(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xea3(%rip),%rdi
mov    $0xffffffff,%esi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1368 <main+0x198>
mov    -0x10(%rbp),%esi
lea    0xedd(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x20(%rbp),%rsi
movslq -0x10(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xd08(%rip),%rdi
call   10b0 <scanf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1322 <main+0x152>
movl   $0x1,-0x2c(%rbp)
jmp    1445 <main+0x275>
lea    0xeb0(%rip),%rdi
mov    $0xffffffff,%esi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    13dd <main+0x20d>
mov    -0x10(%rbp),%esi
add    $0x1,%esi
lea    0xe6e(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xca8(%rip),%rdi
lea    -0x30(%rbp),%rsi
call   10b0 <scanf@plt>
mov    -0x20(%rbp),%rsi
mov    -0xc(%rbp),%edx
mov    -0x30(%rbp),%ecx
xor    %edi,%edi
call   1040 <DiziOlarakAl@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    138e <main+0x1be>
movl   $0x1,-0x2c(%rbp)
jmp    1445 <main+0x275>
mov    -0x20(%rbp),%rsi
mov    -0xc(%rbp),%edx
xor    %edi,%edi
call   10e0 <PreOrderAl@plt>
movl   $0x1,-0x2c(%rbp)
jmp    1445 <main+0x275>
mov    -0x20(%rbp),%rsi
mov    -0xc(%rbp),%edx
xor    %edi,%edi
call   10d0 <InOrderAl@plt>
movl   $0x1,-0x2c(%rbp)
jmp    1445 <main+0x275>
mov    -0x20(%rbp),%rsi
mov    -0xc(%rbp),%edx
xor    %edi,%edi
call   1070 <PostOrderAl@plt>
movl   $0x1,-0x2c(%rbp)
jmp    1445 <main+0x275>
lea    0xe63(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    127c <main+0xac>
mov    -0x20(%rbp),%rdi
mov    -0xc(%rbp),%esi
xor    %edx,%edx
call   10a0 <EkranaGoster@plt>
movl   $0x0,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jne    1604 <main+0x434>
lea    0xe67(%rip),%rdi
xor    %eax,%eax
mov    %al,-0x51(%rbp)
call   1060 <printf@plt>
mov    -0x51(%rbp),%al
lea    0xe7c(%rip),%rdi
call   1060 <printf@plt>
mov    -0x51(%rbp),%al
lea    0xe80(%rip),%rdi
call   1060 <printf@plt>
mov    -0x51(%rbp),%al
lea    0xe95(%rip),%rdi
call   1060 <printf@plt>
mov    -0x51(%rbp),%al
lea    0xe99(%rip),%rdi
call   1060 <printf@plt>
mov    -0x51(%rbp),%al
lea    0xe9c(%rip),%rdi
call   1060 <printf@plt>
mov    -0x51(%rbp),%al
call   10c0 <getch@plt>
mov    %al,-0x26(%rbp)
movsbl -0x26(%rbp),%eax
add    $0xffffffcf,%eax
mov    %eax,%ecx
mov    %rcx,-0x50(%rbp)
sub    $0x3,%eax
ja     15f1 <main+0x421>
mov    -0x50(%rbp),%rax
lea    0xb0f(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x20(%rbp),%rdi
mov    -0xc(%rbp),%esi
xor    %edx,%edx
call   10a0 <EkranaGoster@plt>
jmp    15ff <main+0x42f>
lea    0xe60(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xb3b(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   10b0 <scanf@plt>
mov    -0x20(%rbp),%rdi
mov    -0x8(%rbp),%edx
mov    -0x14(%rbp),%ecx
lea    -0xc(%rbp),%rsi
call   10f0 <ElemanEkle@plt>
jmp    15ff <main+0x42f>
lea    0xe50(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xe4f(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    159c <main+0x3cc>
mov    -0x10(%rbp),%esi
mov    -0x20(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
lea    0xe2d(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1566 <main+0x396>
lea    0xe20(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xaac(%rip),%rdi
lea    -0x34(%rbp),%rsi
call   10b0 <scanf@plt>
mov    -0x20(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x34(%rbp),%edx
call   1050 <ElemanSil@plt>
jmp    15ff <main+0x42f>
lea    0xe1f(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
movl   $0x1,-0x24(%rbp)
jmp    15ff <main+0x42f>
lea    0xca9(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    145f <main+0x28f>
mov    $0x0,%al
call   10c0 <getch@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xe2f(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xe5a(%rip),%rdi
lea    0x8(%rsp),%rsi
call   10c0 <scanf@plt>
mov    0x8(%rsp),%esi
add    $0x1,%esi
mov    $0x2,%edi
call   1090 <UsAl@plt>
mov    %eax,%ebp
lea    -0x1(%rbp),%r14d
mov    %r14d,0x4(%rsp)
lea    0xe30(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1070 <printf@plt>
lea    -0x4(,%rbp,4),%edi
call   10a0 <malloc@plt>
mov    %rax,%rbx
cmp    $0x2,%ebp
jl     1265 <main+0x85>
xor    %eax,%eax
movl   $0xffffffff,(%rbx,%rax,4)
add    $0x1,%rax
movslq 0x4(%rsp),%r14
cmp    %r14,%rax
jl     1250 <main+0x70>
lea    0xf70(%rip),%rdi
lea    0x1112(%rip),%r13
lea    0x111e(%rip),%rbp
lea    0x1129(%rip),%r15
lea    0x1136(%rip),%r12
nopl   0x0(%rax,%rax,1)
call   1050 <puts@plt>
lea    0x102a(%rip),%rdi
call   1050 <puts@plt>
lea    0x1064(%rip),%rdi
call   1050 <puts@plt>
mov    %r13,%rdi
call   1050 <puts@plt>
mov    %rbp,%rdi
call   1050 <puts@plt>
mov    %r15,%rdi
call   1050 <puts@plt>
xor    %eax,%eax
call   10d0 <getch@plt>
movsbl %al,%eax
add    $0xffffffcf,%eax
mov    %r12,%rdi
cmp    $0x4,%eax
ja     1290 <main+0xb0>
lea    0xd1f(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xd96(%rip),%rdi
mov    $0xffffffff,%esi
xor    %eax,%eax
call   1070 <printf@plt>
test   %r14d,%r14d
jle    13dd <main+0x1fd>
movslq %r14d,%r15
lea    0xd4d(%rip),%r12
mov    %rbx,%r13
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nop
lea    0xdc3(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %r12,%rdi
mov    %r13,%rsi
call   10c0 <scanf@plt>
add    $0x1,%rbp
add    $0x4,%r13
cmp    %r15,%rbp
jl     1320 <main+0x140>
jmp    13dd <main+0x1fd>
lea    0xdac(%rip),%rdi
mov    $0xffffffff,%esi
xor    %eax,%eax
call   1070 <printf@plt>
test   %r14d,%r14d
jle    13dd <main+0x1fd>
lea    0xd7e(%rip),%r15
lea    0xcea(%rip),%r12
lea    0x10(%rsp),%r13
xor    %ebp,%ebp
nopw   0x0(%rax,%rax,1)
add    $0x1,%ebp
mov    %r15,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %r12,%rdi
mov    %r13,%rsi
call   10c0 <scanf@plt>
mov    0x10(%rsp),%ecx
xor    %edi,%edi
mov    %rbx,%rsi
mov    %r14d,%edx
call   1040 <DiziOlarakAl@plt>
cmp    %r14d,%ebp
jl     1380 <main+0x1a0>
jmp    13dd <main+0x1fd>
xor    %edi,%edi
mov    %rbx,%rsi
mov    %r14d,%edx
call   10f0 <PreOrderAl@plt>
jmp    13dd <main+0x1fd>
xor    %edi,%edi
mov    %rbx,%rsi
mov    %r14d,%edx
call   10e0 <InOrderAl@plt>
jmp    13dd <main+0x1fd>
xor    %edi,%edi
mov    %rbx,%rsi
mov    %r14d,%edx
call   1080 <PostOrderAl@plt>
mov    %rbx,%rdi
mov    %r14d,%esi
xor    %edx,%edx
call   10b0 <EkranaGoster@plt>
lea    0xe18(%rip),%r12
lea    0xe39(%rip),%r14
lea    0xe44(%rip),%r13
lea    0xe60(%rip),%rbp
lea    0xd8f(%rip),%r15
jmp    1444 <main+0x264>
nop
lea    0xd5f(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xc38(%rip),%rdi
lea    0x14(%rsp),%rsi
call   10c0 <scanf@plt>
mov    0x14(%rsp),%edx
mov    0x8(%rsp),%ecx
mov    %rbx,%rdi
lea    0x4(%rsp),%rsi
call   1100 <ElemanEkle@plt>
mov    %r12,%rdi
call   1050 <puts@plt>
mov    %r14,%rdi
call   1050 <puts@plt>
mov    %r13,%rdi
call   1050 <puts@plt>
mov    %rbp,%rdi
call   1050 <puts@plt>
lea    0xe0d(%rip),%rdi
call   1050 <puts@plt>
lea    0xe12(%rip),%rdi
call   1050 <puts@plt>
xor    %eax,%eax
call   10d0 <getch@plt>
movsbl %al,%eax
add    $0xffffffcf,%eax
cmp    $0x3,%eax
ja     14b0 <main+0x2d0>
lea    0xb7f(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    0x4(%rsp),%esi
mov    %rbx,%rdi
xor    %edx,%edx
call   10b0 <EkranaGoster@plt>
jmp    1444 <main+0x264>
xchg   %ax,%ax
lea    0xf07(%rip),%rdi
call   1050 <puts@plt>
jmp    1444 <main+0x264>
xchg   %ax,%ax
mov    %r12,%rbp
lea    0xde4(%rip),%rdi
call   1050 <puts@plt>
lea    0xde4(%rip),%rdi
call   1050 <puts@plt>
cmpl   $0x0,0x4(%rsp)
jle    150f <main+0x32f>
xor    %r12d,%r12d
cs nopw 0x0(%rax,%rax,1)
nop
mov    (%rbx,%r12,4),%edx
mov    %r15,%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1070 <printf@plt>
add    $0x1,%r12
movslq 0x4(%rsp),%rax
cmp    %rax,%r12
jl     14f0 <main+0x310>
lea    0xc95(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xb39(%rip),%rdi
lea    0xc(%rsp),%rsi
call   10c0 <scanf@plt>
mov    0x4(%rsp),%esi
mov    0xc(%rsp),%edx
mov    %rbx,%rdi
call   1060 <ElemanSil@plt>
mov    %rbp,%r12
lea    0xd1e(%rip),%rbp
jmp    1444 <main+0x264>
lea    0xd4c(%rip),%rdi
call   1050 <puts@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
call   10d0 <getch@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [57 x i8] c"Olusturacaginiz Binary Search Tree'nin derinligi nedir> \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [39 x i8] c"Bu durumda toplam %d eleman olacak. \0A\0A\00"
@.str.3 = [46 x i8] c"Lutfen istediginiz secenegin tusuna basin: \0A\0A\00"
@.str.4 = [71 x i8] c"[1] Dizi olarak gir. (Direkt atama yapilir, bilgisayar islem yapmaz) \0A\00"
@.str.5 = [122 x i8] c"[2] Dizi olarak gir. (Agaci bilgisayar olusturur ama 'balance' yapilmaz, duzgun calismasi 'balanced' tree girmelisiniz) \0A\00"
@.str.6 = [20 x i8] c"[3] Pre-order gir.\0A\00"
@.str.7 = [19 x i8] c"[4] In-order gir.\0A\00"
@.str.8 = [21 x i8] c"[5] Post-order gir.\0A\00"
@.str.9 = [99 x i8] c"\0ABST'nin elemanlarini sirayla giriniz. Eger gozu bos birakmak isterseniz eleman yerine %d yazin. \0A\00"
@.str.10 = [22 x i8] c"%d. elemani giriniz> \00"
@.str.11 = [118 x i8] c"\0ABST'nin elemanlarini sirayla giriniz. Elemanlariniz bittikten sonra gozu bos birakmak icin eleman yerine %d yazin. \0A\00"
@.str.12 = [54 x i8] c"Yanlis bir secenek sectiniz lutfen tekrar deneyin. \0A\0A\00"
@.str.13 = [41 x i8] c"\0A\0ALutfen uygun secenegin tusuna basin: \0A\00"
@.str.14 = [19 x i8] c"---- MENU ----\0A\0A\00"
@.str.15 = [36 x i8] c"[1] Binary Search Tree'yi goster. \0A\00"
@.str.16 = [19 x i8] c"[2] Eleman ekle. \0A\00"
@.str.17 = [18 x i8] c"[3] Eleman sil. \0A\00"
@.str.18 = [24 x i8] c"[4] Programdan cik. \0A\0A\0A\00"
@.str.19 = [38 x i8] c"Eklemek istediginiz elemani giriniz> \00"
@.str.20 = [13 x i8] c"Index Dizi\0A\00"
@.str.21 = [13 x i8] c"----- ----\0A\00"
@.str.22 = [15 x i8] c" %0.2d: %d\0A\00"
@.str.23 = [49 x i8] c"\0ASilmek istediginiz elemanin index'ini giriniz> \00"
@.str.24 = [15 x i8] c"\0A\0ACikiliyor..\0A\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
%8 = alloca i8
%9 = alloca i8
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i32 0, i32* %1
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str, i64 0, i64 0))
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %5)
%15 = load i32, i32* %5
%16 = add nsw i32 %15, 1
%17 = call i32 @UsAl(i32 2, i32 %16)
%18 = sub nsw i32 %17, 1
store i32 %18, i32* %3
%19 = load i32, i32* %3
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), i32 %19)
%21 = load i32, i32* %3
%22 = sext i32 %21 to i64
%23 = mul i64 %22, 4
%24 = trunc i64 %23 to i32
%25 = call i64 @malloc(i32 %24)
%26 = inttoptr i64 %25 to i32*
store i32* %26, i32** %6
store i32 0, i32* %4
br label %27
27: ; preds = %36, %0
%28 = load i32, i32* %4
%29 = load i32, i32* %3
%30 = icmp slt i32 %28, %29
br i1 %30, label %31, label %39
31: ; preds = %27
%32 = load i32*, i32** %6
%33 = load i32, i32* %4
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i32, i32* %32, i64 %34
store i32 -1, i32* %35
br label %36
36: ; preds = %31
%37 = load i32, i32* %4
%38 = add nsw i32 %37, 1
store i32 %38, i32* %4
br label %27
39: ; preds = %27
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %10
br label %41
41: ; preds = %104, %39
%42 = load i32, i32* %10
%43 = icmp eq i32 %42, 0
br i1 %43, label %44, label %105
44: ; preds = %41
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str.4, i64 0, i64 0))
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([122 x i8], [122 x i8]* @.str.5, i64 0, i64 0))
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0))
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0))
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.8, i64 0, i64 0))
%50 = call signext i8 (...) @getch()
store i8 %50, i8* %8
%51 = load i8, i8* %8
%52 = sext i8 %51 to i32
switch i32 %52, label %102 [
i32 49, label %53
i32 50, label %71
i32 51, label %90
i32 52, label %94
i32 53, label %98
]
53: ; preds = %44
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([99 x i8], [99 x i8]* @.str.9, i64 0, i64 0), i32 -1)
store i32 0, i32* %4
br label %55
55: ; preds = %67, %53
%56 = load i32, i32* %4
%57 = load i32, i32* %3
%58 = icmp slt i32 %56, %57
br i1 %58, label %59, label %70
59: ; preds = %55
%60 = load i32, i32* %4
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.10, i64 0, i64 0), i32 %60)
%62 = load i32*, i32** %6
%63 = load i32, i32* %4
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds i32, i32* %62, i64 %64
%66 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %65)
br label %67
67: ; preds = %59
%68 = load i32, i32* %4
%69 = add nsw i32 %68, 1
store i32 %69, i32* %4
br label %55
70: ; preds = %55
store i32 1, i32* %10
br label %104
71: ; preds = %44
%72 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([118 x i8], [118 x i8]* @.str.11, i64 0, i64 0), i32 -1)
store i32 0, i32* %4
br label %73
73: ; preds = %86, %71
%74 = load i32, i32* %4
%75 = load i32, i32* %3
%76 = icmp slt i32 %74, %75
br i1 %76, label %77, label %89
77: ; preds = %73
%78 = load i32, i32* %4
%79 = add nsw i32 %78, 1
%80 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.10, i64 0, i64 0), i32 %79)
%81 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %11)
%82 = load i32*, i32** %6
%83 = load i32, i32* %3
%84 = load i32, i32* %11
%85 = call i32 @DiziOlarakAl(i32 0, i32* %82, i32 %83, i32 %84)
br label %86
86: ; preds = %77
%87 = load i32, i32* %4
%88 = add nsw i32 %87, 1
store i32 %88, i32* %4
br label %73
89: ; preds = %73
store i32 1, i32* %10
br label %104
90: ; preds = %44
%91 = load i32*, i32** %6
%92 = load i32, i32* %3
%93 = call i32 @PreOrderAl(i32 0, i32* %91, i32 %92)
store i32 1, i32* %10
br label %104
94: ; preds = %44
%95 = load i32*, i32** %6
%96 = load i32, i32* %3
%97 = call i32 @InOrderAl(i32 0, i32* %95, i32 %96)
store i32 1, i32* %10
br label %104
98: ; preds = %44
%99 = load i32*, i32** %6
%100 = load i32, i32* %3
%101 = call i32 @PostOrderAl(i32 0, i32* %99, i32 %100)
store i32 1, i32* %10
br label %104
102: ; preds = %44
%103 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.12, i64 0, i64 0))
br label %104
104: ; preds = %102, %98, %94, %90, %89, %70
br label %41
105: ; preds = %41
%106 = load i32*, i32** %6
%107 = load i32, i32* %3
%108 = call i32 @EkranaGoster(i32* %106, i32 %107, i32 0)
store i32 0, i32* %7
br label %109
109: ; preds = %164, %105
%110 = load i32, i32* %7
%111 = icmp eq i32 %110, 0
br i1 %111, label %112, label %165
112: ; preds = %109
%113 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.13, i64 0, i64 0))
%114 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.14, i64 0, i64 0))
%115 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.15, i64 0, i64 0))
%116 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.16, i64 0, i64 0))
%117 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.17, i64 0, i64 0))
%118 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.18, i64 0, i64 0))
%119 = call signext i8 (...) @getch()
store i8 %119, i8* %9
%120 = load i8, i8* %9
%121 = sext i8 %120 to i32
switch i32 %121, label %162 [
i32 49, label %122
i32 50, label %126
i32 51, label %133
i32 52, label %158
]
122: ; preds = %112
%123 = load i32*, i32** %6
%124 = load i32, i32* %3
%125 = call i32 @EkranaGoster(i32* %123, i32 %124, i32 0)
br label %164
126: ; preds = %112
%127 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.19, i64 0, i64 0))
%128 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%129 = load i32*, i32** %6
%130 = load i32, i32* %2
%131 = load i32, i32* %5
%132 = call i32 @ElemanEkle(i32* %129, i32* %3, i32 %130, i32 %131)
br label %164
133: ; preds = %112
%134 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.20, i64 0, i64 0))
%135 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.21, i64 0, i64 0))
store i32 0, i32* %4
br label %136
136: ; preds = %148, %133
%137 = load i32, i32* %4
%138 = load i32, i32* %3
%139 = icmp slt i32 %137, %138
br i1 %139, label %140, label %151
140: ; preds = %136
%141 = load i32, i32* %4
%142 = load i32*, i32** %6
%143 = load i32, i32* %4
%144 = sext i32 %143 to i64
%145 = getelementptr inbounds i32, i32* %142, i64 %144
%146 = load i32, i32* %145
%147 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.22, i64 0, i64 0), i32 %141, i32 %146)
br label %148
148: ; preds = %140
%149 = load i32, i32* %4
%150 = add nsw i32 %149, 1
store i32 %150, i32* %4
br label %136
151: ; preds = %136
%152 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.23, i64 0, i64 0))
%153 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %12)
%154 = load i32*, i32** %6
%155 = load i32, i32* %3
%156 = load i32, i32* %12
%157 = call i32 @ElemanSil(i32* %154, i32 %155, i32 %156)
br label %164
158: ; preds = %112
%159 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.24, i64 0, i64 0))
%160 = load i32*, i32** %6
%161 = call i32 @free(i32* %160)
store i32 1, i32* %7
br label %164
162: ; preds = %112
%163 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.12, i64 0, i64 0))
br label %164
164: ; preds = %162, %158, %151, %126, %122
br label %109
165: ; preds = %109
%166 = call signext i8 (...) @getch()
ret i32 0
}

LLVM IR (-O2):
@.str = [57 x i8] c"Olusturacaginiz Binary Search Tree'nin derinligi nedir> \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [39 x i8] c"Bu durumda toplam %d eleman olacak. \0A\0A\00"
@.str.9 = [99 x i8] c"\0ABST'nin elemanlarini sirayla giriniz. Eger gozu bos birakmak isterseniz eleman yerine %d yazin. \0A\00"
@.str.10 = [22 x i8] c"%d. elemani giriniz> \00"
@.str.11 = [118 x i8] c"\0ABST'nin elemanlarini sirayla giriniz. Elemanlariniz bittikten sonra gozu bos birakmak icin eleman yerine %d yazin. \0A\00"
@.str.19 = [38 x i8] c"Eklemek istediginiz elemani giriniz> \00"
@.str.22 = [15 x i8] c" %0.2d: %d\0A\00"
@.str.23 = [49 x i8] c"\0ASilmek istediginiz elemanin index'ini giriniz> \00"
@str = [45 x i8] c"Lutfen istediginiz secenegin tusuna basin: \0A\00"
@str.25 = [40 x i8] c"\0A\0ALutfen uygun secenegin tusuna basin: \00"
@str.26 = [18 x i8] c"---- MENU ----\0A\00"
@str.27 = [35 x i8] c"[1] Binary Search Tree'yi goster. \00"
@str.28 = [18 x i8] c"[2] Eleman ekle. \00"
@str.29 = [17 x i8] c"[3] Eleman sil. \00"
@str.30 = [23 x i8] c"[4] Programdan cik. \0A\0A\00"
@str.31 = [14 x i8] c"\0A\0ACikiliyor..\00"
@str.32 = [12 x i8] c"Index Dizi\00"
@str.33 = [12 x i8] c"----- ----\00"
@str.35 = [70 x i8] c"[1] Dizi olarak gir. (Direkt atama yapilir, bilgisayar islem yapmaz) \00"
@str.36 = [121 x i8] c"[2] Dizi olarak gir. (Agaci bilgisayar olusturur ama 'balance' yapilmaz, duzgun calismasi 'balanced' tree girmelisiniz) \00"
@str.37 = [19 x i8] c"[3] Pre-order gir.\00"
@str.38 = [18 x i8] c"[4] In-order gir.\00"
@str.39 = [20 x i8] c"[5] Post-order gir.\00"
@str.40 = [53 x i8] c"Yanlis bir secenek sectiniz lutfen tekrar deneyin. \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = bitcast i32* %1 to i8*
%7 = bitcast i32* %2 to i8*
%8 = bitcast i32* %3 to i8*
%9 = bitcast i32* %4 to i8*
%10 = bitcast i32* %5 to i8*
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([57 x i8], [57 x i8]* @.str, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%13 = load i32, i32* %3
%14 = add nsw i32 %13, 1
%15 = call i32 @UsAl(i32 2, i32 %14)
%16 = add nsw i32 %15, -1
store i32 %16, i32* %2
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), i32 %16)
%18 = shl i32 %16, 2
%19 = call i64 @malloc(i32 %18)
%20 = inttoptr i64 %19 to i32*
%21 = icmp sgt i32 %15, 1
br i1 %21, label %22, label %29
22: ; preds = %0, %22
%23 = phi i64 [ %25, %22 ], [ 0, %0 ]
%24 = getelementptr inbounds i32, i32* %20, i64 %23
store i32 -1, i32* %24
%25 = add nuw nsw i64 %23, 1
%26 = load i32, i32* %2
%27 = sext i32 %26 to i64
%28 = icmp slt i64 %25, %27
br i1 %28, label %22, label %29
29: ; preds = %22, %0
%30 = phi i32 [ %16, %0 ], [ %26, %22 ]
br label %31
31: ; preds = %31, %29
%32 = phi i8* [ getelementptr inbounds ([45 x i8], [45 x i8]* @str, i64 0, i64 0), %29 ], [ getelementptr inbounds ([53 x i8], [53 x i8]* @str.40, i64 0, i64 0), %31 ]
%33 = call i32 @puts(i8* dereferenceable(1) %32)
%34 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([70 x i8], [70 x i8]* @str.35, i64 0, i64 0))
%35 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([121 x i8], [121 x i8]* @str.36, i64 0, i64 0))
%36 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.37, i64 0, i64 0))
%37 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.38, i64 0, i64 0))
%38 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.39, i64 0, i64 0))
%39 = call signext i8 (...) @getch()
%40 = sext i8 %39 to i32
switch i32 %40, label %31 [
i32 49, label %41
i32 50, label %54
i32 51, label %65
i32 52, label %67
i32 53, label %69
]
41: ; preds = %31
%42 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([99 x i8], [99 x i8]* @.str.9, i64 0, i64 0), i32 -1)
%43 = icmp sgt i32 %30, 0
br i1 %43, label %44, label %71
44: ; preds = %41
%45 = sext i32 %30 to i64
br label %46
46: ; preds = %44, %46
%47 = phi i64 [ 0, %44 ], [ %52, %46 ]
%48 = trunc i64 %47 to i32
%49 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.10, i64 0, i64 0), i32 %48)
%50 = getelementptr inbounds i32, i32* %20, i64 %47
%51 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %50)
%52 = add nuw nsw i64 %47, 1
%53 = icmp slt i64 %52, %45
br i1 %53, label %46, label %71
54: ; preds = %31
%55 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([118 x i8], [118 x i8]* @.str.11, i64 0, i64 0), i32 -1)
%56 = icmp sgt i32 %30, 0
br i1 %56, label %57, label %71
57: ; preds = %54, %57
%58 = phi i32 [ %59, %57 ], [ 0, %54 ]
%59 = add nuw nsw i32 %58, 1
%60 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.10, i64 0, i64 0), i32 %59)
%61 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%62 = load i32, i32* %4
%63 = call i32 @DiziOlarakAl(i32 0, i32* %20, i32 %30, i32 %62)
%64 = icmp slt i32 %59, %30
br i1 %64, label %57, label %71
65: ; preds = %31
%66 = call i32 @PreOrderAl(i32 0, i32* %20, i32 %30)
br label %71
67: ; preds = %31
%68 = call i32 @InOrderAl(i32 0, i32* %20, i32 %30)
br label %71
69: ; preds = %31
%70 = call i32 @PostOrderAl(i32 0, i32* %20, i32 %30)
br label %71
71: ; preds = %57, %46, %54, %41, %69, %67, %65
%72 = call i32 @EkranaGoster(i32* %20, i32 %30, i32 0)
br label %73
73: ; preds = %114, %71
%74 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str.25, i64 0, i64 0))
%75 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.26, i64 0, i64 0))
%76 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str.27, i64 0, i64 0))
%77 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.28, i64 0, i64 0))
%78 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.29, i64 0, i64 0))
%79 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.30, i64 0, i64 0))
%80 = call signext i8 (...) @getch()
%81 = sext i8 %80 to i32
switch i32 %81, label %112 [
i32 49, label %82
i32 50, label %85
i32 51, label %91
i32 52, label %115
]
82: ; preds = %73
%83 = load i32, i32* %2
%84 = call i32 @EkranaGoster(i32* %20, i32 %83, i32 0)
br label %114
85: ; preds = %73
%86 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.19, i64 0, i64 0))
%87 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%88 = load i32, i32* %1
%89 = load i32, i32* %3
%90 = call i32 @ElemanEkle(i32* %20, i32* %2, i32 %88, i32 %89)
br label %114
91: ; preds = %73
%92 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.32, i64 0, i64 0))
%93 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.33, i64 0, i64 0))
%94 = load i32, i32* %2
%95 = icmp sgt i32 %94, 0
br i1 %95, label %96, label %106
96: ; preds = %91, %96
%97 = phi i64 [ %102, %96 ], [ 0, %91 ]
%98 = getelementptr inbounds i32, i32* %20, i64 %97
%99 = load i32, i32* %98
%100 = trunc i64 %97 to i32
%101 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.22, i64 0, i64 0), i32 %100, i32 %99)
%102 = add nuw nsw i64 %97, 1
%103 = load i32, i32* %2
%104 = sext i32 %103 to i64
%105 = icmp slt i64 %102, %104
br i1 %105, label %96, label %106
106: ; preds = %96, %91
%107 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @.str.23, i64 0, i64 0))
%108 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %5)
%109 = load i32, i32* %2
%110 = load i32, i32* %5
%111 = call i32 @ElemanSil(i32* %20, i32 %109, i32 %110)
br label %114
112: ; preds = %73
%113 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @str.40, i64 0, i64 0))
br label %114
114: ; preds = %112, %106, %85, %82
br label %73
115: ; preds = %73
%116 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.31, i64 0, i64 0))
%117 = call i32 @free(i32* %20)
%118 = call signext i8 (...) @getch()
ret i32 0
}