#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 main(void) {
  printf("\nwordcount started\n\n");
  const char text1[] = "Well, here goes.";
  const char text2[] = "And here we go... again";
  int countWords(const char string[]);
  printf("%s - words = %i\n", text1, countWords(text1));
  printf("%s - words = %i\n", text2, countWords(text2));
  printf("\nwordcount ended\n\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0xefc(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xef9(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xef7(%rip),%al
mov    %al,-0x10(%rbp)
mov    0xefd(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0xefa(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    0xef7(%rip),%rax
mov    %rax,-0x30(%rbp)
lea    -0x20(%rbp),%rax
mov    %rax,-0x50(%rbp)
lea    -0x20(%rbp),%rdi
call   1040 <countWords@plt>
mov    -0x50(%rbp),%rsi
mov    %eax,%edx
lea    0xe7a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x40(%rbp),%rax
mov    %rax,-0x48(%rbp)
lea    -0x40(%rbp),%rdi
call   1040 <countWords@plt>
mov    -0x48(%rbp),%rsi
mov    %eax,%edx
lea    0xe55(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe58(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x38,%rsp
lea    0xf0b(%rip),%rdi
call   1030 <puts@plt>
movaps 0xeb6(%rip),%xmm0
movaps %xmm0,(%rsp)
movb   $0x0,0x10(%rsp)
movaps 0xec6(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movabs $0x6e69616761202e,%rax
mov    %rax,0x30(%rsp)
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1050 <countWords@plt>
lea    0xeb8(%rip),%r14
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x20(%rsp),%rbx
mov    %rbx,%rdi
call   1050 <countWords@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeab(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [21 x i8] c"\0Awordcount started\0A\0A\00"
@__const.main.text1 = [17 x i8] c"Well, here goes.\00"
@__const.main.text2 = [24 x i8] c"And here we go... again\00"
@.str.1 = [17 x i8] c"%s - words = %i\0A\00"
@.str.2 = [19 x i8] c"\0Awordcount ended\0A\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [17 x i8]
%3 = alloca [24 x i8]
store i32 0, i32* %1
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%5 = bitcast [17 x i8]* %2 to i8*
%6 = bitcast [24 x i8]* %3 to i8*
%7 = getelementptr inbounds [17 x i8], [17 x i8]* %2, i64 0, i64 0
%8 = getelementptr inbounds [17 x i8], [17 x i8]* %2, i64 0, i64 0
%9 = call i32 @countWords(i8* %8)
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8* %7, i32 %9)
%11 = getelementptr inbounds [24 x i8], [24 x i8]* %3, i64 0, i64 0
%12 = getelementptr inbounds [24 x i8], [24 x i8]* %3, i64 0, i64 0
%13 = call i32 @countWords(i8* %12)
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8* %11, i32 %13)
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@__const.main.text1 = [17 x i8] c"Well, here goes.\00"
@__const.main.text2 = [24 x i8] c"And here we go... again\00"
@.str.1 = [17 x i8] c"%s - words = %i\0A\00"
@str = [20 x i8] c"\0Awordcount started\0A\00"
@str.3 = [18 x i8] c"\0Awordcount ended\0A\00"
define i32 @main() {
%1 = alloca [17 x i8]
%2 = alloca [24 x i8]
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
%4 = getelementptr inbounds [17 x i8], [17 x i8]* %1, i64 0, i64 0
%5 = getelementptr inbounds [24 x i8], [24 x i8]* %2, i64 0, i64 0
%6 = call i32 @countWords(i8* %4)
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8* %4, i32 %6)
%8 = call i32 @countWords(i8* %5)
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8* %5, i32 %8)
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.3, i64 0, i64 0))
ret i32 0
}