#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 *, ...);
void main(void) {
  char str[50];
  int i = 0, j = 0;
  printf("Enter string:");
  gets(str);
  printf("\noutput 1: %s\n\n", str);
  printf("Output 2:");
  while (str[i] != '\0') {
    if (str[i] == 32)
      printf("\n \t");
    printf("%c", str[i]);
    i++;
  }
  printf("\n\nOutpur 3:");
  printf("%c", str[0]);
  while (str[j] != '\0') {
    if (str[j] == 32) {
      printf(".");
      printf("%c", str[j + 1]);
    }
    j++;
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x44(%rbp)
movl   $0x0,-0x48(%rbp)
lea    0xec3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x40(%rbp),%rdi
call   1040 <gets@plt>
lea    -0x40(%rbp),%rsi
lea    0xeb6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movslq -0x44(%rbp),%rax
movsbl -0x40(%rbp,%rax,1),%eax
cmp    $0x0,%eax
je     11c4 <main+0xa4>
movslq -0x44(%rbp),%rax
movsbl -0x40(%rbp,%rax,1),%eax
cmp    $0x20,%eax
jne    119f <main+0x7f>
lea    0xe90(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movslq -0x44(%rbp),%rax
movsbl -0x40(%rbp,%rax,1),%esi
lea    0xe7d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    116d <main+0x4d>
lea    0xe64(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movsbl -0x40(%rbp),%esi
lea    0xe4f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movslq -0x48(%rbp),%rax
movsbl -0x40(%rbp,%rax,1),%eax
cmp    $0x0,%eax
je     123f <main+0x11f>
movslq -0x48(%rbp),%rax
movsbl -0x40(%rbp,%rax,1),%eax
cmp    $0x20,%eax
jne    1231 <main+0x111>
lea    0xe2c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x48(%rbp),%eax
add    $0x1,%eax
cltq
movsbl -0x40(%rbp,%rax,1),%esi
lea    0xe02(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x48(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x48(%rbp)
jmp    11e4 <main+0xc4>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x38,%rsp
lea    0xec2(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1050 <gets@plt>
lea    0xeb7(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeb6(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeb2(%rip),%r14
jmp    1199 <main+0x69>
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movzbl (%rbx),%eax
movsbl %al,%edi
call   1030 <putchar@plt>
add    $0x1,%rbx
movzbl (%rbx),%eax
cmp    $0x20,%al
je     1180 <main+0x50>
test   %al,%al
jne    118d <main+0x5d>
lea    0xe81(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <printf@plt>
movsbl (%rsp),%edi
jmp    11d3 <main+0xa3>
nopw   0x0(%rax,%rax,1)
mov    $0x2e,%edi
call   1030 <putchar@plt>
movsbl 0x1(%rsp,%rbx,1),%edi
add    $0x1,%rbx
call   1030 <putchar@plt>
movzbl (%rsp,%rbx,1),%eax
cmp    $0x20,%al
je     11c0 <main+0x90>
test   %al,%al
je     11ea <main+0xba>
add    $0x1,%rbx
jmp    11d8 <main+0xa8>
add    $0x38,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
@.str = [14 x i8] c"Enter string:\00"
@.str.1 = [16 x i8] c"\0Aoutput 1: %s\0A\0A\00"
@.str.2 = [10 x i8] c"Output 2:\00"
@.str.3 = [4 x i8] c"\0A \09\00"
@.str.5 = [12 x i8] c"\0A\0AOutpur 3:\00"
define void @main() {
%1 = alloca [50 x i8]
%2 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 0
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @gets(i8* %2)
%5 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%6 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
br label %7
7: ; preds = %14, %0
%8 = phi i64 [ %18, %14 ], [ 0, %0 ]
%9 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 %8
%10 = load i8, i8* %9
switch i8 %10, label %14 [
i8 0, label %19
i8 32, label %11
]
11: ; preds = %7
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%13 = load i8, i8* %9
br label %14
14: ; preds = %7, %11
%15 = phi i8 [ %10, %7 ], [ %13, %11 ]
%16 = sext i8 %15 to i32
%17 = call i32 @putchar(i32 %16)
%18 = add nuw i64 %8, 1
br label %7
19: ; preds = %7
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0))
%21 = load i8, i8* %2
%22 = sext i8 %21 to i32
%23 = call i32 @putchar(i32 %22)
br label %24
24: ; preds = %30, %19
%25 = phi i64 [ 0, %19 ], [ %31, %30 ]
%26 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 %25
%27 = load i8, i8* %26
switch i8 %27, label %28 [
i8 0, label %39
i8 32, label %32
]
28: ; preds = %24
%29 = add nuw i64 %25, 1
br label %30
30: ; preds = %28, %32
%31 = phi i64 [ %29, %28 ], [ %34, %32 ]
br label %24
32: ; preds = %24
%33 = call i32 @putchar(i32 46)
%34 = add nuw i64 %25, 1
%35 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 %34
%36 = load i8, i8* %35
%37 = sext i8 %36 to i32
%38 = call i32 @putchar(i32 %37)
br label %30
39: ; preds = %24
ret void
}