#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, int);
void count_wordsandnum(char a[50]) {
  int i, j, count = 0, count2 = 1;
  for (i = 0; a[i] != '\0'; i++) {
    if (a[i] != 32)
      count++;
  }
  for (j = 0; a[j] != '\0'; j++) {
    if (a[j] == 32)
      count2++;
  }
  printf("The number of of words and characters are %d and %d respectively.\n",
         count2, count);
}


x86 assembly (clang, -O0):
<count_wordsandnum>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x1,-0x18(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     1177 <count_wordsandnum+0x67>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x20,%eax
je     1164 <count_wordsandnum+0x54>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1169 <count_wordsandnum+0x59>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1131 <count_wordsandnum+0x21>
movl   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     11c4 <count_wordsandnum+0xb4>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x20,%eax
jne    11b1 <count_wordsandnum+0xa1>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11b6 <count_wordsandnum+0xa6>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    117e <count_wordsandnum+0x6e>
mov    -0x18(%rbp),%esi
mov    -0x14(%rbp),%edx
lea    0xe2f(%rip),%rdi
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<count_wordsandnum>:
xor    %edx,%edx
mov    %rdi,%rax
jmp    1124 <count_wordsandnum+0x14>
nopw   0x0(%rax,%rax,1)
add    $0x1,%rax
movzbl (%rax),%ecx
cmp    $0x20,%cl
je     1120 <count_wordsandnum+0x10>
test   %cl,%cl
je     1135 <count_wordsandnum+0x25>
add    $0x1,%edx
jmp    1120 <count_wordsandnum+0x10>
mov    $0x1,%esi
jmp    1147 <count_wordsandnum+0x37>
nopl   0x0(%rax)
add    $0x1,%esi
add    $0x1,%rdi
movzbl (%rdi),%eax
cmp    $0x20,%al
je     1140 <count_wordsandnum+0x30>
test   %al,%al
jne    1143 <count_wordsandnum+0x33>
lea    0xea7(%rip),%rdi
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [67 x i8] c"The number of of words and characters are %d and %d respectively.\0A\00"
define void @count_wordsandnum(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %5
store i32 1, i32* %6
store i32 0, i32* %3
br label %7
7: ; preds = %27, %1
%8 = load i8*, i8** %2
%9 = load i32, i32* %3
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds i8, i8* %8, i64 %10
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %30
15: ; preds = %7
%16 = load i8*, i8** %2
%17 = load i32, i32* %3
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8, i8* %16, i64 %18
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = icmp ne i32 %21, 32
br i1 %22, label %23, label %26
23: ; preds = %15
%24 = load i32, i32* %5
%25 = add nsw i32 %24, 1
store i32 %25, i32* %5
br label %26
26: ; preds = %23, %15
br label %27
27: ; preds = %26
%28 = load i32, i32* %3
%29 = add nsw i32 %28, 1
store i32 %29, i32* %3
br label %7
30: ; preds = %7
store i32 0, i32* %4
br label %31
31: ; preds = %51, %30
%32 = load i8*, i8** %2
%33 = load i32, i32* %4
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i8, i8* %32, i64 %34
%36 = load i8, i8* %35
%37 = sext i8 %36 to i32
%38 = icmp ne i32 %37, 0
br i1 %38, label %39, label %54
39: ; preds = %31
%40 = load i8*, i8** %2
%41 = load i32, i32* %4
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i8, i8* %40, i64 %42
%44 = load i8, i8* %43
%45 = sext i8 %44 to i32
%46 = icmp eq i32 %45, 32
br i1 %46, label %47, label %50
47: ; preds = %39
%48 = load i32, i32* %6
%49 = add nsw i32 %48, 1
store i32 %49, i32* %6
br label %50
50: ; preds = %47, %39
br label %51
51: ; preds = %50
%52 = load i32, i32* %4
%53 = add nsw i32 %52, 1
store i32 %53, i32* %4
br label %31
54: ; preds = %31
%55 = load i32, i32* %6
%56 = load i32, i32* %5
%57 = call i32 @printf(i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str, i64 0, i64 0), i32 %55, i32 %56)
ret void
}

LLVM IR (-O2):
@.str = [67 x i8] c"The number of of words and characters are %d and %d respectively.\0A\00"
define void @count_wordsandnum(i8* nocapture %0) {
br label %2
2: ; preds = %9, %1
%3 = phi i64 [ %11, %9 ], [ 0, %1 ]
%4 = phi i32 [ %10, %9 ], [ 0, %1 ]
%5 = getelementptr inbounds i8, i8* %0, i64 %3
%6 = load i8, i8* %5
switch i8 %6, label %7 [
i8 0, label %12
i8 32, label %9
]
7: ; preds = %2
%8 = add nsw i32 %4, 1
br label %9
9: ; preds = %2, %7
%10 = phi i32 [ %8, %7 ], [ %4, %2 ]
%11 = add nuw i64 %3, 1
br label %2
12: ; preds = %2, %19
%13 = phi i64 [ %21, %19 ], [ 0, %2 ]
%14 = phi i32 [ %20, %19 ], [ 1, %2 ]
%15 = getelementptr inbounds i8, i8* %0, i64 %13
%16 = load i8, i8* %15
switch i8 %16, label %19 [
i8 0, label %22
i8 32, label %17
]
17: ; preds = %12
%18 = add nsw i32 %14, 1
br label %19
19: ; preds = %12, %17
%20 = phi i32 [ %18, %17 ], [ %14, %12 ]
%21 = add nuw i64 %13, 1
br label %12
22: ; preds = %12
%23 = tail call i32 @printf(i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str, i64 0, i64 0), i32 %14, i32 %4)
ret void
}