#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 karakter_sayisi(char const *);
int /*<<< orphan*/ printf(char *, ...);
int kelime_sayisi(const char *s) {
  int i;
  int kelime_say = 1;
  int karakter_say = karakter_sayisi(s);
  printf("Cumledeki kelimeler:\n");
  for (i = 0; s[i] != '\0'; i++) {
    if (s[i] == ' ') {
      printf("\n");
      kelime_say++;
    } else {
      printf("%c", s[i]);
    }
  }
  printf("\n\n");
  return kelime_say;
}


x86 assembly (clang, -O0):
<kelime_sayisi>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x1,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <karakter_sayisi@plt>
mov    %eax,-0x14(%rbp)
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     11c7 <kelime_sayisi+0xa7>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x20,%eax
jne    119a <kelime_sayisi+0x7a>
lea    0xe95(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11b4 <kelime_sayisi+0x94>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%esi
lea    0xe69(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11b9 <kelime_sayisi+0x99>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1154 <kelime_sayisi+0x34>
lea    0xe4b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<kelime_sayisi>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1050 <karakter_sayisi@plt>
lea    0xebe(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%ebp
jmp    1161 <kelime_sayisi+0x31>
xchg   %ax,%ax
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%ebp
add    $0x1,%rbx
movsbl (%rbx),%edi
cmp    $0x20,%edi
je     1150 <kelime_sayisi+0x20>
test   %dil,%dil
je     1179 <kelime_sayisi+0x49>
call   1030 <putchar@plt>
add    $0x1,%rbx
jmp    1161 <kelime_sayisi+0x31>
lea    0xe95(%rip),%rdi
call   1040 <puts@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [22 x i8] c"Cumledeki kelimeler:\0A\00"
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [3 x i8] c"%c\00"
@.str.3 = [3 x i8] c"\0A\0A\00"
define i32 @kelime_sayisi(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %2
store i32 1, i32* %4
%6 = load i8*, i8** %2
%7 = call i32 @karakter_sayisi(i8* %6)
store i32 %7, i32* %5
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %3
br label %9
9: ; preds = %38, %1
%10 = load i8*, i8** %2
%11 = load i32, i32* %3
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds i8, i8* %10, i64 %12
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %41
17: ; preds = %9
%18 = load i8*, i8** %2
%19 = load i32, i32* %3
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8, i8* %18, i64 %20
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = icmp eq i32 %23, 32
br i1 %24, label %25, label %29
25: ; preds = %17
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%27 = load i32, i32* %4
%28 = add nsw i32 %27, 1
store i32 %28, i32* %4
br label %37
29: ; preds = %17
%30 = load i8*, i8** %2
%31 = load i32, i32* %3
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i8, i8* %30, i64 %32
%34 = load i8, i8* %33
%35 = sext i8 %34 to i32
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %35)
br label %37
37: ; preds = %29, %25
br label %38
38: ; preds = %37
%39 = load i32, i32* %3
%40 = add nsw i32 %39, 1
store i32 %40, i32* %3
br label %9
41: ; preds = %9
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%43 = load i32, i32* %4
ret i32 %43
}

LLVM IR (-O2):
@str = [21 x i8] c"Cumledeki kelimeler:\00"
@str.4 = [2 x i8] c"\0A\00"
define i32 @kelime_sayisi(i8* %0) {
%2 = tail call i32 @karakter_sayisi(i8* %0)
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0))
br label %4
4: ; preds = %15, %1
%5 = phi i64 [ %17, %15 ], [ 0, %1 ]
%6 = phi i32 [ %16, %15 ], [ 1, %1 ]
%7 = getelementptr inbounds i8, i8* %0, i64 %5
%8 = load i8, i8* %7
switch i8 %8, label %12 [
i8 0, label %18
i8 32, label %9
]
9: ; preds = %4
%10 = tail call i32 @putchar(i32 10)
%11 = add nsw i32 %6, 1
br label %15
12: ; preds = %4
%13 = sext i8 %8 to i32
%14 = tail call i32 @putchar(i32 %13)
br label %15
15: ; preds = %9, %12
%16 = phi i32 [ %11, %9 ], [ %6, %12 ]
%17 = add nuw i64 %5, 1
br label %4
18: ; preds = %4
%19 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str.4, i64 0, i64 0))
ret i32 %6
}