#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 /*<<< orphan*/ scanf(char *, int *);
int main() {
  int sayi;
  int index = 2;
  printf("Sayi giriniz...\n");
  scanf("%d", &sayi);
  if (sayi < 0) {
    printf("pozitif bir sayi girmelisiniz...\n");
    return 0;
  }
  while (sayi / 2 >= index) {
    if (sayi % index == 0) {
      printf("%d, %d sayisina bolunebildigi icin asal sayi degildir\n", sayi,
             index);
      scanf("%d", &sayi);
      return 0;
    }
    index++;
  }
  printf("%d bir asal sayidir\n", sayi);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x2,-0xc(%rbp)
lea    0xec3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec6(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x0,-0x8(%rbp)
jge    1178 <main+0x58>
lea    0xeaf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    11f7 <main+0xd7>
jmp    117d <main+0x5d>
mov    -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    -0xc(%rbp),%eax
jl     11df <main+0xbf>
mov    -0x8(%rbp),%eax
cltd
idivl  -0xc(%rbp)
cmp    $0x0,%edx
jne    11d1 <main+0xb1>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xe88(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe55(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x0,-0x4(%rbp)
jmp    11f7 <main+0xd7>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    117d <main+0x5d>
mov    -0x8(%rbp),%esi
lea    0xe84(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xf17(%rip),%rdi
call   1030 <puts@plt>
lea    0xebc(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%esi
test   %esi,%esi
js     1197 <main+0x67>
cmp    $0x4,%esi
jb     1187 <main+0x57>
mov    %esi,%edi
shr    %edi
neg    %edi
mov    $0x2,%ecx
cs nopw 0x0(%rax,%rax,1)
mov    %esi,%eax
cltd
idiv   %ecx
test   %edx,%edx
je     11a5 <main+0x75>
lea    (%rdi,%rcx,1),%eax
add    $0x1,%eax
add    $0x1,%ecx
cmp    $0x1,%eax
jne    1170 <main+0x40>
lea    0xeac(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11c6 <main+0x96>
lea    0xec1(%rip),%rdi
call   1030 <puts@plt>
jmp    11c6 <main+0x96>
lea    0xe57(%rip),%rdi
mov    %ecx,%edx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe44(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [17 x i8] c"Sayi giriniz...\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [34 x i8] c"pozitif bir sayi girmelisiniz...\0A\00"
@.str.3 = [55 x i8] c"%d, %d sayisina bolunebildigi icin asal sayi degildir\0A\00"
@.str.4 = [21 x i8] c"%d bir asal sayidir\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
store i32 2, i32* %3
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%6 = load i32, i32* %2
%7 = icmp slt i32 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %0
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %1
br label %32
10: ; preds = %0
br label %11
11: ; preds = %26, %10
%12 = load i32, i32* %2
%13 = sdiv i32 %12, 2
%14 = load i32, i32* %3
%15 = icmp sge i32 %13, %14
br i1 %15, label %16, label %29
16: ; preds = %11
%17 = load i32, i32* %2
%18 = load i32, i32* %3
%19 = srem i32 %17, %18
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %26
21: ; preds = %16
%22 = load i32, i32* %2
%23 = load i32, i32* %3
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.3, i64 0, i64 0), i32 %22, i32 %23)
%25 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
store i32 0, i32* %1
br label %32
26: ; preds = %16
%27 = load i32, i32* %3
%28 = add nsw i32 %27, 1
store i32 %28, i32* %3
br label %11
29: ; preds = %11
%30 = load i32, i32* %2
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i32 %30)
store i32 0, i32* %1
br label %32
32: ; preds = %29, %21, %8
%33 = load i32, i32* %1
ret i32 %33
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@.str.3 = [55 x i8] c"%d, %d sayisina bolunebildigi icin asal sayi degildir\0A\00"
@.str.4 = [21 x i8] c"%d bir asal sayidir\0A\00"
@str = [16 x i8] c"Sayi giriniz...\00"
@str.5 = [33 x i8] c"pozitif bir sayi girmelisiniz...\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 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 = icmp slt i32 %5, 0
br i1 %6, label %11, label %7
7: ; preds = %0
%8 = icmp ult i32 %5, 4
br i1 %8, label %23, label %9
9: ; preds = %7
%10 = lshr i32 %5, 1
br label %13
11: ; preds = %0
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str.5, i64 0, i64 0))
br label %25
13: ; preds = %9, %20
%14 = phi i32 [ %21, %20 ], [ 2, %9 ]
%15 = srem i32 %5, %14
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %20
17: ; preds = %13
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @.str.3, i64 0, i64 0), i32 %5, i32 %14)
%19 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
br label %25
20: ; preds = %13
%21 = add nuw nsw i32 %14, 1
%22 = icmp eq i32 %14, %10
br i1 %22, label %23, label %13
23: ; preds = %20, %7
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i32 %5)
br label %25
25: ; preds = %23, %17, %11
ret i32 0
}