#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*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stdin;
int strlen(char *);
char *strstr(char *, char *);
int /*<<< orphan*/ system(char *);
int main() {
  system("clear");
  char kelime[100];
  char ek[100];
  int i;
  printf("kelime girin: ");
  fgets(kelime, 100, stdin);
  kelime[strlen(kelime) - 1] = '\0';
  printf("kontrol edilecek eki girin: ");
  fgets(ek, 100, stdin);
  ek[strlen(ek) - 1] = '\0';
  printf("\n");
  char *adres = strstr(kelime, ek);
  int index = adres - kelime;
  int state = 0;
  if (adres != NULL) {
    while (adres != NULL) {
      if (index == 0) {
        printf("on ektir\n");
        state = 1;
      } else if (index + strlen(ek) == strlen(kelime)) {
        printf("son ektir\n");
        state = 1;
      } else if (state == 0) {
        printf("on ek veya son ek degildir\n");
      }
      adres = strstr(adres + 1, ek);
      index = adres - kelime;
    }
  } else {
    printf("kelime eki degildir\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x100,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe97(%rip),%rdi
call   1040 <system@plt>
lea    0xe91(%rip),%rdi
call   1050 <printf@plt>
lea    -0x70(%rbp),%rdi
mov    0x2e63(%rip),%rax
mov    (%rax),%edx
mov    $0x64,%esi
call   1060 <fgets@plt>
lea    -0x70(%rbp),%rdi
call   1030 <strlen@plt>
sub    $0x1,%eax
cltq
movb   $0x0,-0x70(%rbp,%rax,1)
lea    0xe6a(%rip),%rdi
call   1050 <printf@plt>
lea    -0xe0(%rbp),%rdi
mov    0x2e2a(%rip),%rax
mov    (%rax),%edx
mov    $0x64,%esi
call   1060 <fgets@plt>
lea    -0xe0(%rbp),%rdi
call   1030 <strlen@plt>
sub    $0x1,%eax
cltq
movb   $0x0,-0xe0(%rbp,%rax,1)
lea    0xe82(%rip),%rdi
call   1050 <printf@plt>
lea    -0x70(%rbp),%rdi
lea    -0xe0(%rbp),%rsi
call   1070 <strstr@plt>
mov    %rax,-0xf0(%rbp)
mov    -0xf0(%rbp),%rax
lea    -0x70(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,-0xf4(%rbp)
movl   $0x0,-0xf8(%rbp)
cmpq   $0x0,-0xf0(%rbp)
je     1328 <main+0x1d8>
jmp    1237 <main+0xe7>
cmpq   $0x0,-0xf0(%rbp)
je     1323 <main+0x1d3>
cmpl   $0x0,-0xf4(%rbp)
jne    126d <main+0x11d>
lea    0xdda(%rip),%rdi
call   1050 <printf@plt>
movl   $0x1,-0xf8(%rbp)
jmp    12ec <main+0x19c>
mov    -0xf4(%rbp),%eax
mov    %eax,-0x100(%rbp)
lea    -0xe0(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x100(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0xfc(%rbp)
lea    -0x70(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0xfc(%rbp),%eax
cmp    %ecx,%eax
jne    12c9 <main+0x179>
lea    0xd7d(%rip),%rdi
call   1050 <printf@plt>
movl   $0x1,-0xf8(%rbp)
jmp    12e7 <main+0x197>
cmpl   $0x0,-0xf8(%rbp)
jne    12e2 <main+0x192>
lea    0xd60(%rip),%rdi
call   1050 <printf@plt>
jmp    12e7 <main+0x197>
jmp    12ec <main+0x19c>
mov    -0xf0(%rbp),%rdi
add    $0x1,%rdi
lea    -0xe0(%rbp),%rsi
call   1070 <strstr@plt>
mov    %rax,-0xf0(%rbp)
mov    -0xf0(%rbp),%rax
lea    -0x70(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,-0xf4(%rbp)
jmp    1237 <main+0xe7>
jmp    1334 <main+0x1e4>
lea    0xd2a(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x100,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xd8,%rsp
lea    0xe78(%rip),%rdi
call   1060 <system@plt>
lea    0xe72(%rip),%rdi
call   1070 <printf@plt>
mov    0x2e48(%rip),%rbx
mov    (%rbx),%edx
lea    0x70(%rsp),%r14
mov    %r14,%rdi
mov    $0x64,%esi
call   1080 <fgets@plt>
mov    %r14,%rdi
call   1050 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%r14,1)
lea    0xe4a(%rip),%rdi
call   1070 <printf@plt>
mov    (%rbx),%edx
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x64,%esi
call   1080 <fgets@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%rbx,1)
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1090 <strstr@plt>
test   %rax,%rax
je     1290 <main+0x120>
mov    %rax,%rbx
xor    %r12d,%r12d
lea    0x70(%rsp),%r15
jmp    124b <main+0xdb>
nopl   0x0(%rax)
lea    0xe3b(%rip),%rdi
call   1040 <puts@plt>
add    $0x1,%rbx
mov    %rbx,%rdi
mov    %rsp,%rsi
call   1090 <strstr@plt>
mov    %rax,%rbx
mov    %r13d,%r12d
test   %rax,%rax
lea    0x70(%rsp),%r15
je     129c <main+0x12c>
mov    %ebx,%r14d
mov    $0x1,%r13d
sub    %r15d,%r14d
je     1220 <main+0xb0>
mov    %rsp,%rdi
call   1050 <strlen@plt>
mov    %eax,%ebp
add    %r14d,%ebp
mov    %r15,%rdi
call   1050 <strlen@plt>
lea    0xdec(%rip),%rdi
cmp    %eax,%ebp
je     1227 <main+0xb7>
mov    $0x1,%r13d
test   %r12d,%r12d
jne    122c <main+0xbc>
xor    %r13d,%r13d
lea    0xdb8(%rip),%rdi
jmp    1227 <main+0xb7>
lea    0xd9b(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0xd8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"clear\00"
@.str.1 = [15 x i8] c"kelime girin: \00"
@stdin = global i32 0
@.str.2 = [29 x i8] c"kontrol edilecek eki girin: \00"
@.str.3 = [2 x i8] c"\0A\00"
@.str.4 = [10 x i8] c"on ektir\0A\00"
@.str.5 = [11 x i8] c"son ektir\0A\00"
@.str.6 = [28 x i8] c"on ek veya son ek degildir\0A\00"
@.str.7 = [21 x i8] c"kelime eki degildir\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x i8]
%3 = alloca [100 x i8]
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
%8 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
%10 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%11 = load i32, i32* @stdin
%12 = call i32 @fgets(i8* %10, i32 100, i32 %11)
%13 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%14 = call i32 @strlen(i8* %13)
%15 = sub nsw i32 %14, 1
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %16
store i8 0, i8* %17
%18 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
%19 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%20 = load i32, i32* @stdin
%21 = call i32 @fgets(i8* %19, i32 100, i32 %20)
%22 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%23 = call i32 @strlen(i8* %22)
%24 = sub nsw i32 %23, 1
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 %25
store i8 0, i8* %26
%27 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%28 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%29 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%30 = call i8* @strstr(i8* %28, i8* %29)
store i8* %30, i8** %5
%31 = load i8*, i8** %5
%32 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%33 = ptrtoint i8* %31 to i64
%34 = ptrtoint i8* %32 to i64
%35 = sub i64 %33, %34
%36 = trunc i64 %35 to i32
store i32 %36, i32* %6
store i32 0, i32* %7
%37 = load i8*, i8** %5
%38 = icmp ne i8* %37, null
br i1 %38, label %39, label %77
39: ; preds = %0
br label %40
40: ; preds = %65, %39
%41 = load i8*, i8** %5
%42 = icmp ne i8* %41, null
br i1 %42, label %43, label %76
43: ; preds = %40
%44 = load i32, i32* %6
%45 = icmp eq i32 %44, 0
br i1 %45, label %46, label %48
46: ; preds = %43
%47 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
store i32 1, i32* %7
br label %65
48: ; preds = %43
%49 = load i32, i32* %6
%50 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%51 = call i32 @strlen(i8* %50)
%52 = add nsw i32 %49, %51
%53 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%54 = call i32 @strlen(i8* %53)
%55 = icmp eq i32 %52, %54
br i1 %55, label %56, label %58
56: ; preds = %48
%57 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0))
store i32 1, i32* %7
br label %64
58: ; preds = %48
%59 = load i32, i32* %7
%60 = icmp eq i32 %59, 0
br i1 %60, label %61, label %63
61: ; preds = %58
%62 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0))
br label %63
63: ; preds = %61, %58
br label %64
64: ; preds = %63, %56
br label %65
65: ; preds = %64, %46
%66 = load i8*, i8** %5
%67 = getelementptr inbounds i8, i8* %66, i64 1
%68 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%69 = call i8* @strstr(i8* %67, i8* %68)
store i8* %69, i8** %5
%70 = load i8*, i8** %5
%71 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%72 = ptrtoint i8* %70 to i64
%73 = ptrtoint i8* %71 to i64
%74 = sub i64 %72, %73
%75 = trunc i64 %74 to i32
store i32 %75, i32* %6
br label %40
76: ; preds = %40
br label %79
77: ; preds = %0
%78 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0))
br label %79
79: ; preds = %77, %76
ret i32 0
}

LLVM IR (-O2):
@.str = [6 x i8] c"clear\00"
@.str.1 = [15 x i8] c"kelime girin: \00"
@stdin = global i32 0
@.str.2 = [29 x i8] c"kontrol edilecek eki girin: \00"
@str = [20 x i8] c"kelime eki degildir\00"
@str.8 = [27 x i8] c"on ek veya son ek degildir\00"
@str.9 = [10 x i8] c"son ektir\00"
@str.10 = [9 x i8] c"on ektir\00"
define i32 @main() {
%1 = alloca [100 x i8]
%2 = alloca [100 x i8]
%3 = tail call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%5 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%6 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
%7 = load i32, i32* @stdin
%8 = call i32 @fgets(i8* %4, i32 100, i32 %7)
%9 = call i32 @strlen(i8* %4)
%10 = add nsw i32 %9, -1
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %11
store i8 0, i8* %12
%13 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
%14 = load i32, i32* @stdin
%15 = call i32 @fgets(i8* %5, i32 100, i32 %14)
%16 = call i32 @strlen(i8* %5)
%17 = add nsw i32 %16, -1
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %18
store i8 0, i8* %19
%20 = call i32 @putchar(i32 10)
%21 = call i8* @strstr(i8* %4, i8* %5)
%22 = ptrtoint [100 x i8]* %1 to i64
%23 = icmp eq i8* %21, null
br i1 %23, label %47, label %24
24: ; preds = %0, %42
%25 = phi i32 [ %43, %42 ], [ 0, %0 ]
%26 = phi i8* [ %45, %42 ], [ %21, %0 ]
%27 = ptrtoint i8* %26 to i64
%28 = sub i64 %27, %22
%29 = trunc i64 %28 to i32
%30 = icmp eq i32 %29, 0
br i1 %30, label %38, label %31
31: ; preds = %24
%32 = call i32 @strlen(i8* %5)
%33 = add nsw i32 %32, %29
%34 = call i32 @strlen(i8* %4)
%35 = icmp eq i32 %33, %34
br i1 %35, label %38, label %36
36: ; preds = %31
%37 = icmp eq i32 %25, 0
br i1 %37, label %38, label %42
38: ; preds = %36, %31, %24
%39 = phi i8* [ getelementptr inbounds ([9 x i8], [9 x i8]* @str.10, i64 0, i64 0), %24 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @str.9, i64 0, i64 0), %31 ], [ getelementptr inbounds ([27 x i8], [27 x i8]* @str.8, i64 0, i64 0), %36 ]
%40 = phi i32 [ 1, %24 ], [ 1, %31 ], [ 0, %36 ]
%41 = call i32 @puts(i8* dereferenceable(1) %39)
br label %42
42: ; preds = %38, %36
%43 = phi i32 [ 1, %36 ], [ %40, %38 ]
%44 = getelementptr inbounds i8, i8* %26, i64 1
%45 = call i8* @strstr(i8* %44, i8* %5)
%46 = icmp eq i8* %45, null
br i1 %46, label %49, label %24
47: ; preds = %0
%48 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
br label %49
49: ; preds = %42, %47
ret i32 0
}