#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*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdin;
int strlen(char *);
void cont_str() {
  char stri[100];
  int cont = 0, maior = 0, i, a;
  printf("digite sua string com ate 100 caracteres: ");
  fgets(stri, 100, stdin);
  stri[strlen(stri) + 1] = 'c';
  for (i = 0; i < (strlen(stri) + 1); i++) {
    if (stri[i] == ' ') {
      cont++;
    } else {
      if (cont > maior) {
        maior = cont;
        cont = 0;
      }
    }
  }
  printf("%d\n", maior);
}


x86 assembly (clang, -O0):
<cont_str>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x74(%rbp)
movl   $0x0,-0x78(%rbp)
lea    0xeb0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x70(%rbp),%rdi
mov    0x2e86(%rip),%rax
mov    (%rax),%edx
mov    $0x64,%esi
call   1050 <fgets@plt>
lea    -0x70(%rbp),%rdi
call   1030 <strlen@plt>
add    $0x1,%eax
cltq
movb   $0x63,-0x70(%rbp,%rax,1)
movl   $0x0,-0x7c(%rbp)
mov    -0x7c(%rbp),%eax
mov    %eax,-0x84(%rbp)
lea    -0x70(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x84(%rbp),%eax
add    $0x1,%ecx
cmp    %ecx,%eax
jge    11fe <cont_str+0xce>
movslq -0x7c(%rbp),%rax
movsbl -0x70(%rbp,%rax,1),%eax
cmp    $0x20,%eax
jne    11cd <cont_str+0x9d>
mov    -0x74(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x74(%rbp)
jmp    11eb <cont_str+0xbb>
mov    -0x74(%rbp),%eax
cmp    -0x78(%rbp),%eax
jle    11e6 <cont_str+0xb6>
mov    -0x74(%rbp),%eax
mov    %eax,-0x78(%rbp)
movl   $0x0,-0x74(%rbp)
jmp    11eb <cont_str+0xbb>
jmp    11f0 <cont_str+0xc0>
mov    -0x7c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x7c(%rbp)
jmp    1188 <cont_str+0x58>
mov    -0x78(%rbp),%esi
lea    0xe23(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cont_str>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x70,%rsp
lea    0xebd(%rip),%rdi
xor    %r12d,%r12d
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2e94(%rip),%rax
mov    (%rax),%edx
mov    %rsp,%r14
mov    %r14,%rdi
mov    $0x64,%esi
call   1050 <fgets@plt>
mov    %r14,%rdi
call   1030 <strlen@plt>
cltq
movb   $0x63,0x1(%rax,%r14,1)
mov    %r14,%rdi
call   1030 <strlen@plt>
test   %eax,%eax
js     11cf <cont_str+0x9f>
xor    %r15d,%r15d
mov    $0xffffffffffffffff,%rbp
mov    %rsp,%r14
xor    %ebx,%ebx
xor    %r12d,%r12d
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
lea    0x1(%rbx),%eax
cmp    %r12d,%ebx
mov    %r12d,%ecx
cmovg  %ebx,%ecx
cmovg  %r15d,%ebx
cmpb   $0x20,0x1(%rsp,%rbp,1)
cmovne %ecx,%r12d
cmove  %eax,%ebx
mov    %r14,%rdi
call   1030 <strlen@plt>
cltq
add    $0x1,%rbp
cmp    %rax,%rbp
jl     11a0 <cont_str+0x70>
lea    0xe55(%rip),%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x70,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [43 x i8] c"digite sua string com ate 100 caracteres: \00"
@stdin = global i32 0
@.str.1 = [4 x i8] c"%d\0A\00"
define void @cont_str() {
%1 = alloca [100 x i8]
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %2
store i32 0, i32* %3
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0))
%7 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%8 = load i32, i32* @stdin
%9 = call i32 @fgets(i8* %7, i32 100, i32 %8)
%10 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%11 = call i32 @strlen(i8* %10)
%12 = add nsw i32 %11, 1
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %13
store i8 99, i8* %14
store i32 0, i32* %4
br label %15
15: ; preds = %39, %0
%16 = load i32, i32* %4
%17 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%18 = call i32 @strlen(i8* %17)
%19 = add nsw i32 %18, 1
%20 = icmp slt i32 %16, %19
br i1 %20, label %21, label %42
21: ; preds = %15
%22 = load i32, i32* %4
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %23
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp eq i32 %26, 32
br i1 %27, label %28, label %31
28: ; preds = %21
%29 = load i32, i32* %2
%30 = add nsw i32 %29, 1
store i32 %30, i32* %2
br label %38
31: ; preds = %21
%32 = load i32, i32* %2
%33 = load i32, i32* %3
%34 = icmp sgt i32 %32, %33
br i1 %34, label %35, label %37
35: ; preds = %31
%36 = load i32, i32* %2
store i32 %36, i32* %3
store i32 0, i32* %2
br label %37
37: ; preds = %35, %31
br label %38
38: ; preds = %37, %28
br label %39
39: ; preds = %38
%40 = load i32, i32* %4
%41 = add nsw i32 %40, 1
store i32 %41, i32* %4
br label %15
42: ; preds = %15
%43 = load i32, i32* %3
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %43)
ret void
}

LLVM IR (-O2):
@.str = [43 x i8] c"digite sua string com ate 100 caracteres: \00"
@stdin = global i32 0
@.str.1 = [4 x i8] c"%d\0A\00"
define void @cont_str() {
%1 = alloca [100 x i8]
%2 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0))
%4 = load i32, i32* @stdin
%5 = call i32 @fgets(i8* %2, i32 100, i32 %4)
%6 = call i32 @strlen(i8* %2)
%7 = add nsw i32 %6, 1
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %8
store i8 99, i8* %9
%10 = call i32 @strlen(i8* %2)
%11 = icmp slt i32 %10, 0
br i1 %11, label %29, label %12
12: ; preds = %0, %12
%13 = phi i64 [ %25, %12 ], [ 0, %0 ]
%14 = phi i32 [ %24, %12 ], [ 0, %0 ]
%15 = phi i32 [ %23, %12 ], [ 0, %0 ]
%16 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %13
%17 = load i8, i8* %16
%18 = icmp eq i8 %17, 32
%19 = add nsw i32 %14, 1
%20 = icmp sgt i32 %14, %15
%21 = select i1 %20, i32 %14, i32 %15
%22 = select i1 %20, i32 0, i32 %14
%23 = select i1 %18, i32 %15, i32 %21
%24 = select i1 %18, i32 %19, i32 %22
%25 = add nuw nsw i64 %13, 1
%26 = call i32 @strlen(i8* %2)
%27 = sext i32 %26 to i64
%28 = icmp slt i64 %13, %27
br i1 %28, label %12, label %29
29: ; preds = %12, %0
%30 = phi i32 [ 0, %0 ], [ %23, %12 ]
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %30)
ret void
}