#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 CountNumWordsInString(char *);
int /*<<< orphan*/ printf(char *, char *, int);
int main() {
  char *teststring = "HELLO  WORLD";
  printf("\'%s\' has  %i words.\n", teststring,
         CountNumWordsInString(teststring));
  teststring = "HEL LO WORL D";
  printf("\'%s\' has  %i words.\n", teststring,
         CountNumWordsInString(teststring));
  teststring = "HELLO WO  RLD";
  printf("\'%s\' has  %i words.\n", teststring,
         CountNumWordsInString(teststring));
  teststring = "HELLO  WORLD";
  printf("\'%s\' has  %i words.\n", teststring,
         CountNumWordsInString(teststring));
  teststring = " HELLO WOR LD ";
  printf("\'%s\' has  %i words.\n", teststring,
         CountNumWordsInString(teststring));
  teststring = "A BIG DOG";
  printf("\'%s\' has  %i words.\n", teststring,
         CountNumWordsInString(teststring));
  teststring = "A";
  printf("\'%s\' has  %i words.\n", teststring,
         CountNumWordsInString(teststring));
  teststring = " BC ";
  printf("\'%s\' has  %i words.\n", teststring,
         CountNumWordsInString(teststring));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <CountNumWordsInString@plt>
mov    -0x50(%rbp),%rsi
mov    %eax,%edx
lea    0xeb5(%rip),%rdi
call   1040 <printf@plt>
lea    0xebe(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <CountNumWordsInString@plt>
mov    -0x48(%rbp),%rsi
mov    %eax,%edx
lea    0xe87(%rip),%rdi
call   1040 <printf@plt>
lea    0xe9e(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <CountNumWordsInString@plt>
mov    -0x40(%rbp),%rsi
mov    %eax,%edx
lea    0xe59(%rip),%rdi
call   1040 <printf@plt>
lea    0xe40(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <CountNumWordsInString@plt>
mov    -0x38(%rbp),%rsi
mov    %eax,%edx
lea    0xe2b(%rip),%rdi
call   1040 <printf@plt>
lea    0xe50(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <CountNumWordsInString@plt>
mov    -0x30(%rbp),%rsi
mov    %eax,%edx
lea    0xdfd(%rip),%rdi
call   1040 <printf@plt>
lea    0xe31(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <CountNumWordsInString@plt>
mov    -0x28(%rbp),%rsi
mov    %eax,%edx
lea    0xdcf(%rip),%rdi
call   1040 <printf@plt>
lea    0xe0d(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <CountNumWordsInString@plt>
mov    -0x20(%rbp),%rsi
mov    %eax,%edx
lea    0xda1(%rip),%rdi
call   1040 <printf@plt>
lea    0xde1(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <CountNumWordsInString@plt>
mov    -0x18(%rbp),%rsi
mov    %eax,%edx
lea    0xd73(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
lea    0xed4(%rip),%r14
mov    %r14,%rdi
call   1030 <CountNumWordsInString@plt>
lea    0xed2(%rip),%r15
mov    %r15,%rdi
mov    %r14,%rsi
mov    %eax,%edx
call   1040 <printf@plt>
lea    0xed3(%rip),%rbx
mov    %rbx,%rdi
call   1030 <CountNumWordsInString@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1040 <printf@plt>
lea    0xec5(%rip),%rbx
mov    %rbx,%rdi
call   1030 <CountNumWordsInString@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1040 <printf@plt>
mov    %r14,%rdi
call   1030 <CountNumWordsInString@plt>
mov    %r15,%rdi
mov    %r14,%rsi
mov    %eax,%edx
call   1040 <printf@plt>
lea    0xea2(%rip),%rbx
mov    %rbx,%rdi
call   1030 <CountNumWordsInString@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1040 <printf@plt>
lea    0xe95(%rip),%rbx
mov    %rbx,%rdi
call   1030 <CountNumWordsInString@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1040 <printf@plt>
lea    0xe83(%rip),%rbx
mov    %rbx,%rdi
call   1030 <CountNumWordsInString@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1040 <printf@plt>
lea    0xe69(%rip),%rbx
mov    %rbx,%rdi
call   1030 <CountNumWordsInString@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [13 x i8] c"HELLO WORLD\00"
@.str.1 = [21 x i8] c"'%s' has %i words.\0A\00"
@.str.2 = [14 x i8] c"HEL LO WORL D\00"
@.str.3 = [14 x i8] c"HELLO WO RLD\00"
@.str.4 = [15 x i8] c" HELLO WOR LD \00"
@.str.5 = [10 x i8] c"A BIG DOG\00"
@.str.6 = [2 x i8] c"A\00"
@.str.7 = [5 x i8] c" BC \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
store i32 0, i32* %1
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8** %2
%3 = load i8*, i8** %2
%4 = load i8*, i8** %2
%5 = call i32 @CountNumWordsInString(i8* %4)
%6 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8* %3, i32 %5)
store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8** %2
%7 = load i8*, i8** %2
%8 = load i8*, i8** %2
%9 = call i32 @CountNumWordsInString(i8* %8)
%10 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8* %7, i32 %9)
store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8** %2
%11 = load i8*, i8** %2
%12 = load i8*, i8** %2
%13 = call i32 @CountNumWordsInString(i8* %12)
%14 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8* %11, i32 %13)
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8** %2
%15 = load i8*, i8** %2
%16 = load i8*, i8** %2
%17 = call i32 @CountNumWordsInString(i8* %16)
%18 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8* %15, i32 %17)
store i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i8** %2
%19 = load i8*, i8** %2
%20 = load i8*, i8** %2
%21 = call i32 @CountNumWordsInString(i8* %20)
%22 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8* %19, i32 %21)
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i8** %2
%23 = load i8*, i8** %2
%24 = load i8*, i8** %2
%25 = call i32 @CountNumWordsInString(i8* %24)
%26 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8* %23, i32 %25)
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0), i8** %2
%27 = load i8*, i8** %2
%28 = load i8*, i8** %2
%29 = call i32 @CountNumWordsInString(i8* %28)
%30 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8* %27, i32 %29)
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i8** %2
%31 = load i8*, i8** %2
%32 = load i8*, i8** %2
%33 = call i32 @CountNumWordsInString(i8* %32)
%34 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8* %31, i32 %33)
ret i32 0
}

LLVM IR (-O2):
@.str = [13 x i8] c"HELLO WORLD\00"
@.str.1 = [21 x i8] c"'%s' has %i words.\0A\00"
@.str.2 = [14 x i8] c"HEL LO WORL D\00"
@.str.3 = [14 x i8] c"HELLO WO RLD\00"
@.str.4 = [15 x i8] c" HELLO WOR LD \00"
@.str.5 = [10 x i8] c"A BIG DOG\00"
@.str.6 = [2 x i8] c"A\00"
@.str.7 = [5 x i8] c" BC \00"
define i32 @main() {
%1 = tail call i32 @CountNumWordsInString(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%2 = tail call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %1)
%3 = tail call i32 @CountNumWordsInString(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
%4 = tail call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 %3)
%5 = tail call i32 @CountNumWordsInString(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
%6 = tail call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 %5)
%7 = tail call i32 @CountNumWordsInString(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%8 = tail call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = tail call i32 @CountNumWordsInString(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
%10 = tail call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i32 %9)
%11 = tail call i32 @CountNumWordsInString(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0))
%12 = tail call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i32 %11)
%13 = tail call i32 @CountNumWordsInString(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%14 = tail call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0), i32 %13)
%15 = tail call i32 @CountNumWordsInString(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
%16 = tail call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i32 %15)
ret i32 0
}