#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 */
char EOF;
char getchar();
int /*<<< orphan*/ printf(char *, ...);
int main(void) {
  const int max_out = 500;
  char out_str[max_out];
  char ch;
  int pos = 0;
  int spaces = 0;
  int max_spaces = 0;
  printf("\n_____BLANKS_____\n\n");
  while ((ch = getchar()) != EOF) {
    if (ch != ' ') {
      out_str[pos] = ch;
      pos++;
      spaces = 0;
    } else if (ch == ' ' && out_str[pos - 1] != ' ') {
      out_str[pos] = ch;
      pos++;
      spaces++;
    } else {
      spaces++;
    }
    if (spaces > max_spaces) {
      max_spaces = spaces;
    }
  }
  printf("\n\n%s\n", out_str);
  printf("\nThe maximum number of consecutive spaces is %d\n\n", max_spaces);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x220,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1f4,-0x8(%rbp)
mov    %rsp,%rax
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
lea    0xea4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %al,-0x11(%rbp)
movsbl %al,%eax
mov    0x2e71(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     1222 <main+0x102>
movsbl -0x11(%rbp),%eax
cmp    $0x20,%eax
je     11b2 <main+0x92>
mov    -0x11(%rbp),%cl
movslq -0x18(%rbp),%rax
mov    %cl,-0x220(%rbp,%rax,1)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
jmp    120b <main+0xeb>
movsbl -0x11(%rbp),%eax
cmp    $0x20,%eax
jne    11fd <main+0xdd>
mov    -0x18(%rbp),%eax
sub    $0x1,%eax
cltq
movsbl -0x220(%rbp,%rax,1),%eax
ff
cmp    $0x20,%eax
je     11fd <main+0xdd>
mov    -0x11(%rbp),%cl
movslq -0x18(%rbp),%rax
mov    %cl,-0x220(%rbp,%rax,1)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1206 <main+0xe6>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    120b <main+0xeb>
mov    -0x1c(%rbp),%eax
cmp    -0x20(%rbp),%eax
jle    121d <main+0xfd>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x20(%rbp)
jmp    1163 <main+0x43>
lea    0xdeb(%rip),%rdi
lea    -0x220(%rbp),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%esi
lea    0xdd9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
add    $0x220,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x200,%rsp
lea    0xef2(%rip),%rdi
call   1030 <puts@plt>
xor    %ebx,%ebx
xor    %eax,%eax
call   1050 <getchar@plt>
mov    0x2e8d(%rip),%r14
cmp    (%r14),%al
jne    1193 <main+0x63>
lea    0xe99(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe8e(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x200,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %rsp,%r15
xor    %ebx,%ebx
xor    %ebp,%ebp
xor    %r12d,%r12d
jmp    11b4 <main+0x84>
nop
add    $0x1,%ebp
cmp    %ebx,%ebp
cmovg  %ebp,%ebx
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    (%r14),%al
je     1160 <main+0x30>
cmp    $0x20,%al
jne    11d0 <main+0xa0>
movslq %r12d,%rax
cmpb   $0x20,-0x1(%rax,%r15,1)
je     11a0 <main+0x70>
movb   $0x20,(%rsp,%rax,1)
add    $0x1,%r12d
jmp    11a0 <main+0x70>
nopl   (%rax)
movslq %r12d,%r12
mov    %al,(%rsp,%r12,1)
add    $0x1,%r12d
xor    %ebp,%ebp
jmp    11a3 <main+0x73>

LLVM IR (-O0):
@.str = [20 x i8] c"\0A_____BLANKS_____\0A\0A\00"
@EOF = global i8 0
@.str.1 = [6 x i8] c"\0A\0A%s\0A\00"
@.str.2 = [50 x i8] c"\0AThe maximum number of consecutive spaces is %d\0A\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
store i32 500, i32* %2
%8 = call i8* @llvm.stacksave()
store i8* %8, i8** %3
%9 = alloca i8, i64 500
store i32 0, i32* %5
store i32 0, i32* %6
store i32 0, i32* %7
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
br label %11
11: ; preds = %59, %0
%12 = call signext i8 (...) @getchar()
store i8 %12, i8* %4
%13 = sext i8 %12 to i32
%14 = load i8, i8* @EOF
%15 = sext i8 %14 to i32
%16 = icmp ne i32 %13, %15
br i1 %16, label %17, label %60
17: ; preds = %11
%18 = load i8, i8* %4
%19 = sext i8 %18 to i32
%20 = icmp ne i32 %19, 32
br i1 %20, label %21, label %28
21: ; preds = %17
%22 = load i8, i8* %4
%23 = load i32, i32* %5
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8, i8* %9, i64 %24
store i8 %22, i8* %25
%26 = load i32, i32* %5
%27 = add nsw i32 %26, 1
store i32 %27, i32* %5
store i32 0, i32* %6
br label %53
28: ; preds = %17
%29 = load i8, i8* %4
%30 = sext i8 %29 to i32
%31 = icmp eq i32 %30, 32
br i1 %31, label %32, label %49
32: ; preds = %28
%33 = load i32, i32* %5
%34 = sub nsw i32 %33, 1
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i8, i8* %9, i64 %35
%37 = load i8, i8* %36
%38 = sext i8 %37 to i32
%39 = icmp ne i32 %38, 32
br i1 %39, label %40, label %49
40: ; preds = %32
%41 = load i8, i8* %4
%42 = load i32, i32* %5
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i8, i8* %9, i64 %43
store i8 %41, i8* %44
%45 = load i32, i32* %5
%46 = add nsw i32 %45, 1
store i32 %46, i32* %5
%47 = load i32, i32* %6
%48 = add nsw i32 %47, 1
store i32 %48, i32* %6
br label %52
49: ; preds = %32, %28
%50 = load i32, i32* %6
%51 = add nsw i32 %50, 1
store i32 %51, i32* %6
br label %52
52: ; preds = %49, %40
br label %53
53: ; preds = %52, %21
%54 = load i32, i32* %6
%55 = load i32, i32* %7
%56 = icmp sgt i32 %54, %55
br i1 %56, label %57, label %59
57: ; preds = %53
%58 = load i32, i32* %6
store i32 %58, i32* %7
br label %59
59: ; preds = %57, %53
br label %11
60: ; preds = %11
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %9)
%62 = load i32, i32* %7
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.2, i64 0, i64 0), i32 %62)
store i32 0, i32* %1
%64 = load i8*, i8** %3
%65 = load i32, i32* %1
ret i32 %65
}

LLVM IR (-O2):
@EOF = global i8 0
@.str.1 = [6 x i8] c"\0A\0A%s\0A\00"
@.str.2 = [50 x i8] c"\0AThe maximum number of consecutive spaces is %d\0A\0A\00"
@str = [19 x i8] c"\0A_____BLANKS_____\0A\00"
define i32 @main() {
%1 = alloca [500 x i8]
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str, i64 0, i64 0))
%3 = tail call signext i8 (...) @getchar()
%4 = load i8, i8* @EOF
%5 = icmp eq i8 %3, %4
br i1 %5, label %37, label %6
6: ; preds = %0, %29
%7 = phi i8 [ %34, %29 ], [ %3, %0 ]
%8 = phi i32 [ %33, %29 ], [ 0, %0 ]
%9 = phi i32 [ %31, %29 ], [ 0, %0 ]
%10 = phi i32 [ %30, %29 ], [ 0, %0 ]
%11 = icmp eq i8 %7, 32
br i1 %11, label %16, label %12
12: ; preds = %6
%13 = sext i32 %10 to i64
%14 = getelementptr inbounds [500 x i8], [500 x i8]* %1, i64 0, i64 %13
store i8 %7, i8* %14
%15 = add nsw i32 %10, 1
br label %29
16: ; preds = %6
%17 = add nsw i32 %10, -1
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [500 x i8], [500 x i8]* %1, i64 0, i64 %18
%20 = load i8, i8* %19
%21 = icmp eq i8 %20, 32
br i1 %21, label %27, label %22
22: ; preds = %16
%23 = sext i32 %10 to i64
%24 = getelementptr inbounds [500 x i8], [500 x i8]* %1, i64 0, i64 %23
store i8 32, i8* %24
%25 = add nsw i32 %10, 1
%26 = add nsw i32 %9, 1
br label %29
27: ; preds = %16
%28 = add nsw i32 %9, 1
br label %29
29: ; preds = %22, %27, %12
%30 = phi i32 [ %15, %12 ], [ %25, %22 ], [ %10, %27 ]
%31 = phi i32 [ 0, %12 ], [ %26, %22 ], [ %28, %27 ]
%32 = icmp sgt i32 %31, %8
%33 = select i1 %32, i32 %31, i32 %8
%34 = tail call signext i8 (...) @getchar()
%35 = load i8, i8* @EOF
%36 = icmp eq i8 %34, %35
br i1 %36, label %37, label %6
37: ; preds = %29, %0
%38 = phi i32 [ 0, %0 ], [ %33, %29 ]
%39 = getelementptr inbounds [500 x i8], [500 x i8]* %1, i64 0, i64 0
%40 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %39)
%41 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @.str.2, i64 0, i64 0), i32 %38)
ret i32 0
}