int main(void) {
  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));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeca(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xec7(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xec5(%rip),%al
mov    %al,-0x10(%rbp)
mov    0xecb(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0xec8(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    0xec5(%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    0xeab(%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    0xe86(%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
movaps 0xed2(%rip),%xmm0
movaps %xmm0,(%rsp)
movb   $0x0,0x10(%rsp)
movaps 0xee2(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movabs $0x2e6e696167612e,%rax
mov    %rax,0x30(%rsp)
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1040 <countWords@plt>
lea    0xed4(%rip),%r14
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0x20(%rsp),%rbx
mov    %rbx,%rdi
call   1040 <countWords@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__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 = [17 x i8] c"%s - words = %i\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [17 x i8]
%3 = alloca [24 x i8]
store i32 0, i32* %1
%4 = bitcast [17 x i8]* %2 to i8*
%5 = bitcast [24 x i8]* %3 to i8*
%6 = getelementptr inbounds [17 x i8], [17 x i8]* %2, i64 0, i64 0
%7 = getelementptr inbounds [17 x i8], [17 x i8]* %2, i64 0, i64 0
%8 = call i32 @countWords(i8* %7)
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %6, i32 %8)
%10 = getelementptr inbounds [24 x i8], [24 x i8]* %3, i64 0, i64 0
%11 = getelementptr inbounds [24 x i8], [24 x i8]* %3, i64 0, i64 0
%12 = call i32 @countWords(i8* %11)
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %10, i32 %12)
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 = [17 x i8] c"%s - words = %i\0A\00"
define i32 @main() {
%1 = alloca [17 x i8]
%2 = alloca [24 x i8]
%3 = getelementptr inbounds [17 x i8], [17 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [24 x i8], [24 x i8]* %2, i64 0, i64 0
%5 = call i32 @countWords(i8* %3)
%6 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %3, i32 %5)
%7 = call i32 @countWords(i8* %4)
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %4, i32 %7)
ret i32 0
}