#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*/ gets(char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ puts(char *);
int main(void) {
  char acSStr[100], acDStr1[100], acDStr2[100];
  int i = 0, j = 0, iSpcount = 0;
  char cCurChar;
  printf("\n*******************************************************************"
         "******");
  printf(
      "\n*\tPROGRAM TO REPLACE MULTIPLE WHITESPACES WITH A SINGLE BLANK\t*\n");
  printf("*********************************************************************"
         "****");
  printf("\nEnter a Sentence\n");
  gets(acSStr);
  j = 0;
  for (i = 0; acSStr[i] != '\0'; i++) {
    cCurChar = acSStr[i];
    if (cCurChar == '\t') {
      cCurChar = ' ';
    }
    acDStr1[j++] = cCurChar;
  }
  acDStr1[j] = '\0';
  j = 0;
  for (i = 0; acDStr1[i] != '\0'; i++) {
    cCurChar = acDStr1[i];
    if (cCurChar == ' ') {
      iSpcount++;
      if (iSpcount == 1)
        acDStr2[j++] = cCurChar;
    } else {
      iSpcount = 0;
      acDStr2[j++] = cCurChar;
    }
  }
  acDStr2[j] = '\0';
  printf("\nThe Original String is\n");
  puts(acSStr);
  printf("\nThe String without spaces is\n");
  puts(acDStr2);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x160,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x154(%rbp)
movl   $0x0,-0x158(%rbp)
movl   $0x0,-0x15c(%rbp)
lea    0xe99(%rip),%rdi
call   1040 <printf@plt>
lea    0xed8(%rip),%rdi
call   1040 <printf@plt>
lea    0xe82(%rip),%rdi
call   1040 <printf@plt>
lea    0xf02(%rip),%rdi
call   1040 <printf@plt>
lea    -0x70(%rbp),%rdi
call   1050 <gets@plt>
movl   $0x0,-0x158(%rbp)
movl   $0x0,-0x154(%rbp)
movslq -0x154(%rbp),%rax
movsbl -0x70(%rbp,%rax,1),%eax
cmp    $0x0,%eax
je     121e <main+0xee>
movslq -0x154(%rbp),%rax
mov    -0x70(%rbp,%rax,1),%al
mov    %al,-0x15d(%rbp)
movsbl -0x15d(%rbp),%eax
cmp    $0x9,%eax
jne    11ea <main+0xba>
movb   $0x20,-0x15d(%rbp)
mov    -0x15d(%rbp),%cl
mov    -0x158(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x158(%rbp)
cltq
mov    %cl,-0xe0(%rbp,%rax,1)
mov    -0x154(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x154(%rbp)
jmp    11ad <main+0x7d>
movslq -0x158(%rbp),%rax
movb   $0x0,-0xe0(%rbp,%rax,1)
movl   $0x0,-0x158(%rbp)
movl   $0x0,-0x154(%rbp)
movslq -0x154(%rbp),%rax
movsbl -0xe0(%rbp,%rax,1),%eax
ff
cmp    $0x0,%eax
je     1301 <main+0x1d1>
movslq -0x154(%rbp),%rax
mov    -0xe0(%rbp,%rax,1),%al
mov    %al,-0x15d(%rbp)
movsbl -0x15d(%rbp),%eax
cmp    $0x20,%eax
jne    12be <main+0x18e>
mov    -0x15c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x15c(%rbp)
cmpl   $0x1,-0x15c(%rbp)
jne    12b9 <main+0x189>
mov    -0x15d(%rbp),%cl
mov    -0x158(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x158(%rbp)
cltq
mov    %cl,-0x150(%rbp,%rax,1)
jmp    12e8 <main+0x1b8>
movl   $0x0,-0x15c(%rbp)
mov    -0x15d(%rbp),%cl
mov    -0x158(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x158(%rbp)
cltq
mov    %cl,-0x150(%rbp,%rax,1)
jmp    12ed <main+0x1bd>
mov    -0x154(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x154(%rbp)
jmp    1241 <main+0x111>
movslq -0x158(%rbp),%rax
movb   $0x0,-0x150(%rbp,%rax,1)
lea    0xd89(%rip),%rdi
call   1040 <printf@plt>
lea    -0x70(%rbp),%rdi
call   1030 <puts@plt>
lea    0xd8d(%rip),%rdi
call   1040 <printf@plt>
lea    -0x150(%rbp),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x160,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x148,%rsp
lea    0xec2(%rip),%rdi
call   1040 <printf@plt>
lea    0xf01(%rip),%rdi
call   1030 <puts@plt>
lea    0xeab(%rip),%rdi
call   1040 <printf@plt>
lea    0xf2a(%rip),%rdi
call   1030 <puts@plt>
mov    %rsp,%rdi
call   1050 <gets@plt>
mov    (%rsp),%cl
xor    %esi,%esi
test   %cl,%cl
je     11a1 <main+0x71>
xor    %edx,%edx
mov    $0x20,%eax
nop
cmp    $0x9,%cl
movzbl %cl,%ecx
cmove  %eax,%ecx
mov    %cl,0xe0(%rsp,%rdx,1)
movzbl 0x1(%rsp,%rdx,1),%ecx
add    $0x1,%rdx
test   %cl,%cl
jne    1180 <main+0x50>
mov    %edx,%eax
jmp    11a3 <main+0x73>
xor    %eax,%eax
movb   $0x0,0xe0(%rsp,%rax,1)
lea    0xe0(%rsp),%rcx
xor    %edx,%edx
jmp    11d4 <main+0xa4>
nopw   0x0(%rax,%rax,1)
xor    %edx,%edx
test   %al,%al
je     11f1 <main+0xc1>
movslq %esi,%rdi
add    $0x1,%esi
mov    %al,0x70(%rsp,%rdi,1)
add    $0x1,%rcx
movzbl (%rcx),%eax
cmp    $0x20,%al
jne    11c0 <main+0x90>
test   %edx,%edx
je     11e8 <main+0xb8>
add    $0x1,%edx
add    $0x1,%rcx
jmp    11d4 <main+0xa4>
mov    $0x1,%edx
mov    $0x20,%al
jmp    11c6 <main+0x96>
movslq %esi,%rax
movb   $0x0,0x70(%rsp,%rax,1)
lea    0xe9e(%rip),%rdi
call   1030 <puts@plt>
mov    %rsp,%rdi
call   1030 <puts@plt>
lea    0xea2(%rip),%rdi
call   1030 <puts@plt>
lea    0x70(%rsp),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x148,%rsp
ret

LLVM IR (-O0):
@.str = [75 x i8] c"\0A*************************************************************************\00"
@.str.1 = [66 x i8] c"\0A*\09PROGRAM TO REPLACE MULTIPLE WHITESPACES WITH A SINGLE BLANK\09*\0A\00"
@.str.2 = [74 x i8] c"*************************************************************************\00"
@.str.3 = [19 x i8] c"\0AEnter a Sentence\0A\00"
@.str.4 = [25 x i8] c"\0AThe Original String is\0A\00"
@.str.5 = [31 x i8] c"\0AThe String without spaces is\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x i8]
%3 = alloca [100 x i8]
%4 = alloca [100 x i8]
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8
store i32 0, i32* %1
store i32 0, i32* %5
store i32 0, i32* %6
store i32 0, i32* %7
%9 = call i32 @printf(i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @printf(i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str.1, i64 0, i64 0))
%11 = call i32 @printf(i8* getelementptr inbounds ([74 x i8], [74 x i8]* @.str.2, i64 0, i64 0))
%12 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0))
%13 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%14 = call i32 @gets(i8* %13)
store i32 0, i32* %6
store i32 0, i32* %5
br label %15
15: ; preds = %37, %0
%16 = load i32, i32* %5
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %17
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %40
22: ; preds = %15
%23 = load i32, i32* %5
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %24
%26 = load i8, i8* %25
store i8 %26, i8* %8
%27 = load i8, i8* %8
%28 = sext i8 %27 to i32
%29 = icmp eq i32 %28, 9
br i1 %29, label %30, label %31
30: ; preds = %22
store i8 32, i8* %8
br label %31
31: ; preds = %30, %22
%32 = load i8, i8* %8
%33 = load i32, i32* %6
%34 = add nsw i32 %33, 1
store i32 %34, i32* %6
%35 = sext i32 %33 to i64
%36 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 %35
store i8 %32, i8* %36
br label %37
37: ; preds = %31
%38 = load i32, i32* %5
%39 = add nsw i32 %38, 1
store i32 %39, i32* %5
br label %15
40: ; preds = %15
%41 = load i32, i32* %6
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 %42
store i8 0, i8* %43
store i32 0, i32* %6
store i32 0, i32* %5
br label %44
44: ; preds = %78, %40
%45 = load i32, i32* %5
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 %46
%48 = load i8, i8* %47
%49 = sext i8 %48 to i32
%50 = icmp ne i32 %49, 0
br i1 %50, label %51, label %81
51: ; preds = %44
%52 = load i32, i32* %5
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 %53
%55 = load i8, i8* %54
store i8 %55, i8* %8
%56 = load i8, i8* %8
%57 = sext i8 %56 to i32
%58 = icmp eq i32 %57, 32
br i1 %58, label %59, label %71
59: ; preds = %51
%60 = load i32, i32* %7
%61 = add nsw i32 %60, 1
store i32 %61, i32* %7
%62 = load i32, i32* %7
%63 = icmp eq i32 %62, 1
br i1 %63, label %64, label %70
64: ; preds = %59
%65 = load i8, i8* %8
%66 = load i32, i32* %6
%67 = add nsw i32 %66, 1
store i32 %67, i32* %6
%68 = sext i32 %66 to i64
%69 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 %68
store i8 %65, i8* %69
br label %70
70: ; preds = %64, %59
br label %77
71: ; preds = %51
store i32 0, i32* %7
%72 = load i8, i8* %8
%73 = load i32, i32* %6
%74 = add nsw i32 %73, 1
store i32 %74, i32* %6
%75 = sext i32 %73 to i64
%76 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 %75
store i8 %72, i8* %76
br label %77
77: ; preds = %71, %70
br label %78
78: ; preds = %77
%79 = load i32, i32* %5
%80 = add nsw i32 %79, 1
store i32 %80, i32* %5
br label %44
81: ; preds = %44
%82 = load i32, i32* %6
%83 = sext i32 %82 to i64
%84 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 %83
store i8 0, i8* %84
%85 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0))
%86 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%87 = call i32 @puts(i8* %86)
%88 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.5, i64 0, i64 0))
%89 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%90 = call i32 @puts(i8* %89)
ret i32 0
}

LLVM IR (-O2):
@.str = [75 x i8] c"\0A*************************************************************************\00"
@.str.2 = [74 x i8] c"*************************************************************************\00"
@str = [65 x i8] c"\0A*\09PROGRAM TO REPLACE MULTIPLE WHITESPACES WITH A SINGLE BLANK\09*\00"
@str.6 = [18 x i8] c"\0AEnter a Sentence\00"
@str.7 = [24 x i8] c"\0AThe Original String is\00"
@str.8 = [30 x i8] c"\0AThe String without spaces is\00"
define i32 @main() {
%1 = alloca [100 x i8]
%2 = alloca [100 x i8]
%3 = alloca [100 x i8]
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%5 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%6 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%7 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([75 x i8], [75 x i8]* @.str, i64 0, i64 0))
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([65 x i8], [65 x i8]* @str, i64 0, i64 0))
%9 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([74 x i8], [74 x i8]* @.str.2, i64 0, i64 0))
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.6, i64 0, i64 0))
%11 = call i32 @gets(i8* %4)
%12 = load i8, i8* %4
%13 = icmp eq i8 %12, 0
br i1 %13, label %26, label %14
14: ; preds = %0, %14
%15 = phi i64 [ %19, %14 ], [ 0, %0 ]
%16 = phi i8 [ %22, %14 ], [ %12, %0 ]
%17 = icmp eq i8 %16, 9
%18 = select i1 %17, i8 32, i8 %16
%19 = add nuw nsw i64 %15, 1
%20 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %15
store i8 %18, i8* %20
%21 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %19
%22 = load i8, i8* %21
%23 = icmp eq i8 %22, 0
br i1 %23, label %24, label %14
24: ; preds = %14
%25 = and i64 %19, 4294967295
br label %26
26: ; preds = %24, %0
%27 = phi i64 [ 0, %0 ], [ %25, %24 ]
%28 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %27
store i8 0, i8* %28
br label %29
29: ; preds = %44, %26
%30 = phi i64 [ %47, %44 ], [ 0, %26 ]
%31 = phi i32 [ %45, %44 ], [ 0, %26 ]
%32 = phi i32 [ %46, %44 ], [ 0, %26 ]
%33 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %30
%34 = load i8, i8* %33
switch i8 %34, label %38 [
i8 0, label %48
i8 32, label %35
]
35: ; preds = %29
%36 = add nsw i32 %32, 1
%37 = icmp eq i32 %32, 0
br i1 %37, label %38, label %44
38: ; preds = %29, %35
%39 = phi i8 [ 32, %35 ], [ %34, %29 ]
%40 = phi i32 [ 1, %35 ], [ 0, %29 ]
%41 = add nsw i32 %31, 1
%42 = sext i32 %31 to i64
%43 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 %42
store i8 %39, i8* %43
br label %44
44: ; preds = %38, %35
%45 = phi i32 [ %31, %35 ], [ %41, %38 ]
%46 = phi i32 [ %36, %35 ], [ %40, %38 ]
%47 = add nuw i64 %30, 1
br label %29
48: ; preds = %29
%49 = sext i32 %31 to i64
%50 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 %49
store i8 0, i8* %50
%51 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.7, i64 0, i64 0))
%52 = call i32 @puts(i8* %4)
%53 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str.8, i64 0, i64 0))
%54 = call i32 @puts(i8* %6)
ret i32 0
}