#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*/ get_str(char *);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  unsigned int flag = 0;
  int i = 0, j = 0;
  char str[100] = {0};
  char new_str[100] = {0};
  printf("Enter string:\n");
  get_str(str);
  printf("%s\n", str);
  while (str[i] != '\0') {
    if (str[i] != ' ') {
      new_str[j++] = str[i++];
      flag = 0;
    } else {
      if (flag == 1) {
        i++;
        continue;
      } else {
        new_str[j++] = str[i++];
        flag = 1;
      }
    }
  }
  new_str[j] = '\0';
  printf("%s\n", new_str);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
lea    -0x80(%rbp),%rdi
xor    %esi,%esi
mov    $0x64,%edx
call   1040 <memset@plt>
lea    -0xf0(%rbp),%rdi
xor    %esi,%esi
mov    $0x64,%edx
call   1040 <memset@plt>
lea    0xe7f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x80(%rbp),%rdi
call   1050 <get_str@plt>
lea    -0x80(%rbp),%rsi
lea    0xe73(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movslq -0xc(%rbp),%rax
movsbl -0x80(%rbp,%rax,1),%eax
cmp    $0x0,%eax
je     1246 <main+0x116>
movslq -0xc(%rbp),%rax
movsbl -0x80(%rbp,%rax,1),%eax
cmp    $0x20,%eax
je     11f8 <main+0xc8>
mov    -0xc(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0xc(%rbp)
cltq
mov    -0x80(%rbp,%rax,1),%cl
mov    -0x10(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x10(%rbp)
cltq
mov    %cl,-0xf0(%rbp,%rax,1)
movl   $0x0,-0x8(%rbp)
jmp    1241 <main+0x111>
cmpl   $0x1,-0x8(%rbp)
jne    1210 <main+0xe0>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11a3 <main+0x73>
mov    -0xc(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0xc(%rbp)
cltq
mov    -0x80(%rbp,%rax,1),%cl
mov    -0x10(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x10(%rbp)
cltq
mov    %cl,-0xf0(%rbp,%rax,1)
movl   $0x1,-0x8(%rbp)
jmp    1241 <main+0x111>
jmp    11a3 <main+0x73>
movslq -0x10(%rbp),%rax
movb   $0x0,-0xf0(%rbp,%rax,1)
lea    -0xf0(%rbp),%rsi
lea    0xdaf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0xf0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0xe0,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0xc0(%rsp)
movaps %xmm0,0xb0(%rsp)
movaps %xmm0,0xa0(%rsp)
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x70(%rsp)
movl   $0x0,0xd0(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
movl   $0x0,0x60(%rsp)
lea    0xe71(%rip),%rdi
call   1030 <puts@plt>
lea    0x70(%rsp),%rbx
mov    %rbx,%rdi
call   1040 <get_str@plt>
mov    %rbx,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
xor    %edx,%edx
xor    %ecx,%ecx
movslq %ecx,%rcx
add    $0x1,%rcx
cs nopw 0x0(%rax,%rax,1)
movzbl 0x6f(%rsp,%rcx,1),%ebx
cmp    $0x20,%bl
jne    11e0 <main+0xc0>
cmp    $0x1,%edx
jne    11f0 <main+0xd0>
add    $0x1,%rcx
mov    $0x1,%edx
jmp    11c0 <main+0xa0>
nopw   0x0(%rax,%rax,1)
xor    %edx,%edx
test   %bl,%bl
je     1200 <main+0xe0>
jmp    11f7 <main+0xd7>
nopl   0x0(%rax,%rax,1)
mov    $0x1,%edx
mov    $0x20,%bl
mov    %bl,(%rsp,%rax,1)
add    $0x1,%rax
jmp    11af <main+0x8f>
mov    %eax,%eax
movb   $0x0,(%rsp,%rax,1)
mov    %rsp,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0xe0,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
@str = [14 x i8] c"Enter string:\00"
define i32 @main() {
%1 = alloca [100 x i8]
%2 = alloca [100 x i8]
%3 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str, i64 0, i64 0))
%6 = call i32 @get_str(i8* %3)
%7 = call i32 @puts(i8* %3)
br label %8
8: ; preds = %23, %0
%9 = phi i64 [ %27, %23 ], [ 0, %0 ]
%10 = phi i32 [ %25, %23 ], [ 0, %0 ]
%11 = phi i64 [ %28, %23 ], [ 0, %0 ]
%12 = shl i64 %11, 32
%13 = ashr exact i64 %12, 32
br label %14
14: ; preds = %8, %21
%15 = phi i64 [ %13, %8 ], [ %22, %21 ]
%16 = phi i32 [ %10, %8 ], [ 1, %21 ]
%17 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %15
%18 = load i8, i8* %17
switch i8 %18, label %23 [
i8 0, label %29
i8 32, label %19
]
19: ; preds = %14
%20 = icmp eq i32 %16, 1
br i1 %20, label %21, label %23
21: ; preds = %19
%22 = add i64 %15, 1
br label %14
23: ; preds = %19, %14
%24 = phi i8 [ %18, %14 ], [ 32, %19 ]
%25 = phi i32 [ 0, %14 ], [ 1, %19 ]
%26 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %9
store i8 %24, i8* %26
%27 = add nuw i64 %9, 1
%28 = add i64 %15, 1
br label %8
29: ; preds = %14
%30 = and i64 %9, 4294967295
%31 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %30
store i8 0, i8* %31
%32 = call i32 @puts(i8* %4)
ret i32 0
}