#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int harf_sayisi(char *);
int /*<<< orphan*/ printf(char *, ...);
char *strtok(char *, char const *);
int main() {
  FILE *dosya_ornek;
  if ((dosya_ornek = fopen("D:\\SINAV\\quiz81\\ornek.txt", "r")) == NULL) {
    printf("ornek.txt dosya acilamadi!\n");
    exit(1);
  }
  FILE *dosya_sonuc;
  if ((dosya_sonuc = fopen("D:\\SINAV\\quiz81\\sonuc.txt", "w")) == NULL) {
    printf("sonuc.txt dosya acilamadi!\n");
    exit(1);
  }
  char buf[100];
  int sayi = 0;
  int kelime_sayisi = 0;
  fgets(buf, 100, dosya_ornek);
  const char *ayrac = " ";
  char *kelime = strtok(buf, ayrac);
  while (kelime != NULL) {
    printf("%s\n", kelime);
    sayi = harf_sayisi(kelime);
    kelime_sayisi++;
    fprintf(dosya_sonuc, "%s\n%s kelimesindeki harf sayisi=%d\n\n", kelime,
            kelime, sayi);
    kelime = strtok(NULL, ayrac);
  }
  fprintf(dosya_sonuc, "cumledeki toplam kelime sayisi=%d\n", kelime_sayisi);
  int i;
  printf("\n");
  for (i = 0; i < 32; i++) {
    printf("-");
  }
  fclose(dosya_ornek);
  fclose(dosya_sonuc);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe67(%rip),%rdi
lea    0xe7a(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
jne    11cb <main+0x4b>
lea    0xe62(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
lea    0xe66(%rip),%rdi
lea    0xe79(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    1204 <main+0x84>
lea    0xe61(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
movl   $0x0,-0x84(%rbp)
movl   $0x0,-0x88(%rbp)
lea    -0x80(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x64,%esi
call   1060 <fgets@plt>
lea    0xe3f(%rip),%rax
mov    %rax,-0x90(%rbp)
lea    -0x80(%rbp),%rdi
mov    -0x90(%rbp),%rsi
call   1090 <strtok@plt>
mov    %rax,-0x98(%rbp)
cmpq   $0x0,-0x98(%rbp)
je     12d6 <main+0x156>
mov    -0x98(%rbp),%rsi
lea    0xe07(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x98(%rbp),%rdi
call   1030 <harf_sayisi@plt>
mov    %eax,-0x84(%rbp)
mov    -0x88(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x88(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x98(%rbp),%rdx
mov    -0x98(%rbp),%rcx
mov    -0x84(%rbp),%r8d
lea    0xdc3(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x90(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edi
call   1090 <strtok@plt>
mov    %rax,-0x98(%rbp)
jmp    124f <main+0xcf>
mov    -0x18(%rbp),%rdi
mov    -0x88(%rbp),%edx
lea    0xdb4(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
lea    0xda4(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x9c(%rbp)
cmpl   $0x20,-0x9c(%rbp)
jge    1335 <main+0x1b5>
lea    0xda4(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x9c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x9c(%rbp)
jmp    1306 <main+0x186>
mov    -0x10(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
lea    0xe5b(%rip),%rdi
lea    0xe6e(%rip),%rsi
call   1090 <fopen@plt>
test   %rax,%rax
je     13dd <main+0x24d>
mov    %rax,%r14
lea    0xe58(%rip),%rdi
lea    0xe6b(%rip),%rsi
call   1090 <fopen@plt>
test   %rax,%rax
je     13e6 <main+0x256>
mov    %rax,%r15
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x64,%esi
mov    %r14,%rdx
call   1070 <fgets@plt>
lea    0xe42(%rip),%rsi
mov    %rbx,%rdi
call   10a0 <strtok@plt>
test   %rax,%rax
je     125d <main+0xcd>
mov    %rax,%rbx
lea    0xe2d(%rip),%r12
lea    0xe24(%rip),%r13
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1050 <puts@plt>
mov    %rbx,%rdi
call   1040 <harf_sayisi@plt>
add    $0x1,%ebp
mov    %r15,%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
mov    %rbx,%rcx
mov    %eax,%r8d
xor    %eax,%eax
call   1080 <fprintf@plt>
xor    %edi,%edi
mov    %r13,%rsi
call   10a0 <strtok@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1220 <main+0x90>
jmp    125f <main+0xcf>
xor    %ebp,%ebp
lea    0xdf9(%rip),%rsi
mov    %r15,%rdi
mov    %ebp,%edx
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    %r14,%rdi
call   1060 <fclose@plt>
mov    %r15,%rdi
call   1060 <fclose@plt>
xor    %eax,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xcb9(%rip),%rdi
jmp    13ed <main+0x25d>
lea    0xc95(%rip),%rdi
call   1050 <puts@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>

LLVM IR (-O0):
@.str = [26 x i8] c"D:\\SINAV\\quiz81\\ornek.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [28 x i8] c"ornek.txt dosya acilamadi!\0A\00"
@.str.3 = [26 x i8] c"D:\\SINAV\\quiz81\\sonuc.txt\00"
@.str.4 = [2 x i8] c"w\00"
@.str.5 = [28 x i8] c"sonuc.txt dosya acilamadi!\0A\00"
@.str.6 = [2 x i8] c" \00"
@.str.7 = [4 x i8] c"%s\0A\00"
@.str.8 = [37 x i8] c"%s\0A%s kelimesindeki harf sayisi=%d\0A\0A\00"
@.str.9 = [35 x i8] c"cumledeki toplam kelime sayisi=%d\0A\00"
@.str.10 = [2 x i8] c"\0A\00"
@.str.11 = [2 x i8] c"-\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32*
%4 = alloca [100 x i8]
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
store i32 0, i32* %1
%10 = call i32* @fopen(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %10, i32** %2
%11 = icmp eq i32* %10, null
br i1 %11, label %12, label %15
12: ; preds = %0
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
%14 = call i32 @exit(i32 1)
unreachable
15: ; preds = %0
%16 = call i32* @fopen(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i32* %16, i32** %3
%17 = icmp eq i32* %16, null
br i1 %17, label %18, label %21
18: ; preds = %15
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0))
%20 = call i32 @exit(i32 1)
unreachable
21: ; preds = %15
store i32 0, i32* %5
store i32 0, i32* %6
%22 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%23 = load i32*, i32** %2
%24 = call i32 @fgets(i8* %22, i32 100, i32* %23)
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0), i8** %7
%25 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%26 = load i8*, i8** %7
%27 = call i8* @strtok(i8* %25, i8* %26)
store i8* %27, i8** %8
br label %28
28: ; preds = %31, %21
%29 = load i8*, i8** %8
%30 = icmp ne i8* %29, null
br i1 %30, label %31, label %45
31: ; preds = %28
%32 = load i8*, i8** %8
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i8* %32)
%34 = load i8*, i8** %8
%35 = call i32 @harf_sayisi(i8* %34)
store i32 %35, i32* %5
%36 = load i32, i32* %6
%37 = add nsw i32 %36, 1
store i32 %37, i32* %6
%38 = load i32*, i32** %3
%39 = load i8*, i8** %8
%40 = load i8*, i8** %8
%41 = load i32, i32* %5
%42 = call i32 (i32*, i8*, ...) @fprintf(i32* %38, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.8, i64 0, i64 0), i8* %39, i8* %40, i32 %41)
%43 = load i8*, i8** %7
%44 = call i8* @strtok(i8* null, i8* %43)
store i8* %44, i8** %8
br label %28
45: ; preds = %28
%46 = load i32*, i32** %3
%47 = load i32, i32* %6
%48 = call i32 (i32*, i8*, ...) @fprintf(i32* %46, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.9, i64 0, i64 0), i32 %47)
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0))
store i32 0, i32* %9
br label %50
50: ; preds = %55, %45
%51 = load i32, i32* %9
%52 = icmp slt i32 %51, 32
br i1 %52, label %53, label %58
53: ; preds = %50
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.11, i64 0, i64 0))
br label %55
55: ; preds = %53
%56 = load i32, i32* %9
%57 = add nsw i32 %56, 1
store i32 %57, i32* %9
br label %50
58: ; preds = %50
%59 = load i32*, i32** %2
%60 = call i32 @fclose(i32* %59)
%61 = load i32*, i32** %3
%62 = call i32 @fclose(i32* %61)
ret i32 0
}

LLVM IR (-O2):
@.str = [26 x i8] c"D:\\SINAV\\quiz81\\ornek.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.3 = [26 x i8] c"D:\\SINAV\\quiz81\\sonuc.txt\00"
@.str.4 = [2 x i8] c"w\00"
@.str.6 = [2 x i8] c" \00"
@.str.8 = [37 x i8] c"%s\0A%s kelimesindeki harf sayisi=%d\0A\0A\00"
@.str.9 = [35 x i8] c"cumledeki toplam kelime sayisi=%d\0A\00"
@str = [27 x i8] c"sonuc.txt dosya acilamadi!\00"
@str.12 = [27 x i8] c"ornek.txt dosya acilamadi!\00"
define i32 @main() {
%1 = alloca [100 x i8]
%2 = tail call i32* @fopen(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%3 = icmp eq i32* %2, null
br i1 %3, label %4, label %7
4: ; preds = %0
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.12, i64 0, i64 0))
%6 = tail call i32 @exit(i32 1)
unreachable
7: ; preds = %0
%8 = tail call i32* @fopen(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%9 = icmp eq i32* %8, null
br i1 %9, label %10, label %13
10: ; preds = %7
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str, i64 0, i64 0))
%12 = tail call i32 @exit(i32 1)
unreachable
13: ; preds = %7
%14 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%15 = call i32 @fgets(i8* %14, i32 100, i32* %2)
%16 = call i8* @strtok(i8* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%17 = icmp eq i8* %16, null
br i1 %17, label %27, label %18
18: ; preds = %13, %18
%19 = phi i8* [ %25, %18 ], [ %16, %13 ]
%20 = phi i32 [ %23, %18 ], [ 0, %13 ]
%21 = call i32 @puts(i8* %19)
%22 = call i32 @harf_sayisi(i8* %19)
%23 = add nuw nsw i32 %20, 1
%24 = call i32 (i32*, i8*, ...) @fprintf(i32* %8, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.8, i64 0, i64 0), i8* %19, i8* %19, i32 %22)
%25 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%26 = icmp eq i8* %25, null
br i1 %26, label %27, label %18
27: ; preds = %18, %13
%28 = phi i32 [ 0, %13 ], [ %23, %18 ]
%29 = call i32 (i32*, i8*, ...) @fprintf(i32* %8, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.9, i64 0, i64 0), i32 %28)
%30 = call i32 @putchar(i32 10)
%31 = call i32 @putchar(i32 45)
%32 = call i32 @putchar(i32 45)
%33 = call i32 @putchar(i32 45)
%34 = call i32 @putchar(i32 45)
%35 = call i32 @putchar(i32 45)
%36 = call i32 @putchar(i32 45)
%37 = call i32 @putchar(i32 45)
%38 = call i32 @putchar(i32 45)
%39 = call i32 @putchar(i32 45)
%40 = call i32 @putchar(i32 45)
%41 = call i32 @putchar(i32 45)
%42 = call i32 @putchar(i32 45)
%43 = call i32 @putchar(i32 45)
%44 = call i32 @putchar(i32 45)
%45 = call i32 @putchar(i32 45)
%46 = call i32 @putchar(i32 45)
%47 = call i32 @putchar(i32 45)
%48 = call i32 @putchar(i32 45)
%49 = call i32 @putchar(i32 45)
%50 = call i32 @putchar(i32 45)
%51 = call i32 @putchar(i32 45)
%52 = call i32 @putchar(i32 45)
%53 = call i32 @putchar(i32 45)
%54 = call i32 @putchar(i32 45)
%55 = call i32 @putchar(i32 45)
%56 = call i32 @putchar(i32 45)
%57 = call i32 @putchar(i32 45)
%58 = call i32 @putchar(i32 45)
%59 = call i32 @putchar(i32 45)
%60 = call i32 @putchar(i32 45)
%61 = call i32 @putchar(i32 45)
%62 = call i32 @putchar(i32 45)
%63 = call i32 @fclose(i32* %2)
%64 = call i32 @fclose(i32* %8)
ret i32 0
}