#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 main() {
  char str[10000], *addr[1000], *p, **pp;
  printf("Please input a string:");
  gets(str);
  pp = addr;
  for (*pp = p = str; *p; p++)
    if (*p == ' ') {
      if (*(p + 1) != ' ')
        *(++pp) = p + 1 ? p + 1 : 0;
      *p = 0;
    }
  *(++pp) = 0;
  printf("The result is:\n");
  for (pp = addr; *pp; pp++)
    printf("%s\n", *pp);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x4680,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xec7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x2720(%rbp),%rdi
call   1040 <gets@plt>
lea    -0x4660(%rbp),%rax
mov    %rax,-0x4670(%rbp)
lea    -0x2720(%rbp),%rcx
mov    %rcx,-0x4668(%rbp)
mov    -0x4670(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x4668(%rbp),%rax
cmpb   $0x0,(%rax)
je     1229 <main+0x109>
mov    -0x4668(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
jne    120d <main+0xed>
mov    -0x4668(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x20,%eax
je     1203 <main+0xe3>
mov    -0x4668(%rbp),%rax
add    $0x1,%rax
cmp    $0x0,%rax
je     11d5 <main+0xb5>
mov    -0x4668(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x4678(%rbp)
jmp    11e3 <main+0xc3>
xor    %eax,%eax
mov    %rax,-0x4678(%rbp)
jmp    11e3 <main+0xc3>
mov    -0x4678(%rbp),%rcx
mov    -0x4670(%rbp),%rax
mov    %rax,%rdx
add    $0x8,%rdx
mov    %rdx,-0x4670(%rbp)
mov    %rcx,0x8(%rax)
mov    -0x4668(%rbp),%rax
movb   $0x0,(%rax)
jmp    1212 <main+0xf2>
mov    -0x4668(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x4668(%rbp)
jmp    1172 <main+0x52>
mov    -0x4670(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x4670(%rbp)
movq   $0x0,0x8(%rax)
lea    0xdca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x4660(%rbp),%rax
mov    %rax,-0x4670(%rbp)
mov    -0x4670(%rbp),%rax
cmpq   $0x0,(%rax)
je     12a2 <main+0x182>
mov    -0x4670(%rbp),%rax
mov    (%rax),%rsi
lea    0xda3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4670(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x4670(%rbp)
jmp    1262 <main+0x142>
xor    %eax,%eax
add    $0x4680,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x4658,%rsp
lea    0xebf(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x1f40(%rsp),%r14
mov    %r14,%rdi
call   1050 <gets@plt>
mov    %rsp,%rax
lea    0x1f41(%rsp),%rcx
jmp    1178 <main+0x48>
cs nopw 0x0(%rax,%rax,1)
nop
test   %dl,%dl
je     1194 <main+0x64>
add    $0x1,%rcx
movzbl -0x1(%rcx),%edx
cmp    $0x20,%dl
jne    1170 <main+0x40>
cmpb   $0x20,(%rcx)
je     118e <main+0x5e>
mov    %rcx,0x8(%rax)
add    $0x8,%rax
movb   $0x0,-0x1(%rcx)
jmp    1174 <main+0x44>
movq   $0x0,0x8(%rax)
lea    0xe74(%rip),%rdi
call   1030 <puts@plt>
lea    0x8(%rsp),%rbx
nopl   (%rax)
mov    %r14,%rdi
call   1030 <puts@plt>
mov    (%rbx),%r14
add    $0x8,%rbx
test   %r14,%r14
jne    11b0 <main+0x80>
xor    %eax,%eax
add    $0x4658,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
@.str = [23 x i8] c"Please input a string:\00"
@str = [15 x i8] c"The result is:\00"
define i32 @main() {
%1 = alloca [10000 x i8]
%2 = alloca [1000 x i8*]
%3 = getelementptr inbounds [10000 x i8], [10000 x i8]* %1, i64 0, i64 0
%4 = bitcast [1000 x i8*]* %2 to i8*
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @gets(i8* %3)
%7 = getelementptr inbounds [1000 x i8*], [1000 x i8*]* %2, i64 0, i64 0
br label %8
8: ; preds = %20, %0
%9 = phi i8* [ %3, %0 ], [ %22, %20 ]
%10 = phi i8** [ %7, %0 ], [ %21, %20 ]
%11 = load i8, i8* %9
switch i8 %11, label %20 [
i8 0, label %23
i8 32, label %12
]
12: ; preds = %8
%13 = getelementptr inbounds i8, i8* %9, i64 1
%14 = load i8, i8* %13
%15 = icmp eq i8 %14, 32
br i1 %15, label %18, label %16
16: ; preds = %12
%17 = getelementptr inbounds i8*, i8** %10, i64 1
store i8* %13, i8** %17
br label %18
18: ; preds = %16, %12
%19 = phi i8** [ %17, %16 ], [ %10, %12 ]
store i8 0, i8* %9
br label %20
20: ; preds = %8, %18
%21 = phi i8** [ %19, %18 ], [ %10, %8 ]
%22 = getelementptr inbounds i8, i8* %9, i64 1
br label %8
23: ; preds = %8
%24 = getelementptr inbounds i8*, i8** %10, i64 1
store i8* null, i8** %24
%25 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str, i64 0, i64 0))
br label %26
26: ; preds = %23, %26
%27 = phi i8* [ %31, %26 ], [ %3, %23 ]
%28 = phi i8** [ %30, %26 ], [ %7, %23 ]
%29 = call i32 @puts(i8* %27)
%30 = getelementptr inbounds i8*, i8** %28, i64 1
%31 = load i8*, i8** %30
%32 = icmp eq i8* %31, null
br i1 %32, label %33, label %26
33: ; preds = %26
ret i32 0
}