#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 */
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
int main() {
  char *cmd1 = "wo shi shui?";
  char *cmd2[50];
  char *flag1, *flag2;
  int i = 0;
  int n = 0;
  flag2 = flag1 = cmd1;
  while (*flag1 != '\0') {
    if (*flag1 == ' ') {
      cmd2[i] = (char *)malloc(sizeof(char) * (n + 1));
      strncpy(cmd2[i], flag2, n);
      strcat(cmd2[i], "\0");
      printf("%s\n", cmd2[i]);
      flag2 = flag2 + n + 1;
      i++;
      flag1++;
      n = 0;
      continue;
    }
    flag1++;
    n++;
  }
  cmd2[i] = (char *)malloc(sizeof(char) * (n + 1));
  strncpy(cmd2[i], flag2, n);
  strcat(cmd2[i], "\0");
  printf("%s\n", cmd2[i]);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1c0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xea7(%rip),%rax
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x1b4(%rbp)
movl   $0x0,-0x1b8(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x1a8(%rbp)
mov    %rax,-0x1b0(%rbp)
mov    -0x1a8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     129a <main+0x15a>
mov    -0x1a8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
jne    1274 <main+0x134>
mov    -0x1b8(%rbp),%eax
add    $0x1,%eax
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,%rcx
movslq -0x1b4(%rbp),%rax
mov    %rcx,-0x1a0(%rbp,%rax,8)
ff
movslq -0x1b4(%rbp),%rax
mov    -0x1a0(%rbp,%rax,8),%rdi
ff
mov    -0x1b0(%rbp),%rsi
mov    -0x1b8(%rbp),%edx
call   1030 <strncpy@plt>
movslq -0x1b4(%rbp),%rax
mov    -0x1a0(%rbp,%rax,8),%rdi
lea    0xe09(%rip),%rsi
call   1060 <strcat@plt>
movslq -0x1b4(%rbp),%rax
mov    -0x1a0(%rbp,%rax,8),%rsi
ff
lea    0xdea(%rip),%rdi
call   1040 <printf@plt>
mov    -0x1b0(%rbp),%rax
movslq -0x1b8(%rbp),%rcx
add    %rcx,%rax
add    $0x1,%rax
mov    %rax,-0x1b0(%rbp)
mov    -0x1b4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1b4(%rbp)
mov    -0x1a8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x1a8(%rbp)
movl   $0x0,-0x1b8(%rbp)
jmp    1183 <main+0x43>
mov    -0x1a8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x1a8(%rbp)
mov    -0x1b8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1b8(%rbp)
jmp    1183 <main+0x43>
mov    -0x1b8(%rbp),%eax
add    $0x1,%eax
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,%rcx
movslq -0x1b4(%rbp),%rax
mov    %rcx,-0x1a0(%rbp,%rax,8)
ff
movslq -0x1b4(%rbp),%rax
mov    -0x1a0(%rbp,%rax,8),%rdi
ff
mov    -0x1b0(%rbp),%rsi
mov    -0x1b8(%rbp),%edx
call   1030 <strncpy@plt>
movslq -0x1b4(%rbp),%rax
mov    -0x1a0(%rbp,%rax,8),%rdi
ff
lea    0xd18(%rip),%rsi
call   1060 <strcat@plt>
movslq -0x1b4(%rbp),%rax
mov    -0x1a0(%rbp,%rax,8),%rsi
ff
lea    0xcf9(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x1c0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xeae(%rip),%rbp
lea    0xeb4(%rip),%r14
mov    %rbp,%r15
add    $0x1,%rbp
lea    0x1(%r15),%r12
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
movzbl -0x1(%rbp),%eax
test   %al,%al
je     11c7 <main+0x87>
cmp    $0x20,%al
je     1190 <main+0x50>
add    $0x1,%ebx
add    $0x1,%rbp
add    $0x1,%r12
jmp    1170 <main+0x30>
nopl   0x0(%rax)
lea    0x1(%rbx),%edi
call   1050 <malloc@plt>
mov    %rax,%r13
mov    %rax,%rdi
mov    %r15,%rsi
mov    %ebx,%edx
call   1030 <strncpy@plt>
mov    %r13,%rdi
lea    0xe5f(%rip),%rsi
call   1060 <strcat@plt>
mov    %r14,%rdi
mov    %r13,%rsi
call   1040 <printf@plt>
mov    %r12,%r15
jmp    115c <main+0x1c>
lea    0x1(%rbx),%edi
call   1050 <malloc@plt>
mov    %rax,%r14
mov    %rax,%rdi
mov    %r15,%rsi
mov    %ebx,%edx
call   1030 <strncpy@plt>
lea    0xe2b(%rip),%rsi
mov    %r14,%rdi
call   1060 <strcat@plt>
lea    0xe18(%rip),%rdi
mov    %r14,%rsi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [13 x i8] c"wo shi shui?\00"
@.str.1 = [2 x i8] zeroinitializer
@.str.2 = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca [50 x i8*]
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8** %2
store i32 0, i32* %6
store i32 0, i32* %7
%8 = load i8*, i8** %2
store i8* %8, i8** %4
store i8* %8, i8** %5
br label %9
9: ; preds = %56, %19, %0
%10 = load i8*, i8** %4
%11 = load i8, i8* %10
%12 = sext i8 %11 to i32
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %61
14: ; preds = %9
%15 = load i8*, i8** %4
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp eq i32 %17, 32
br i1 %18, label %19, label %56
19: ; preds = %14
%20 = load i32, i32* %7
%21 = add nsw i32 %20, 1
%22 = sext i32 %21 to i64
%23 = mul i64 1, %22
%24 = trunc i64 %23 to i32
%25 = call i64 @malloc(i32 %24)
%26 = inttoptr i64 %25 to i8*
%27 = load i32, i32* %6
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [50 x i8*], [50 x i8*]* %3, i64 0, i64 %28
store i8* %26, i8** %29
%30 = load i32, i32* %6
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [50 x i8*], [50 x i8*]* %3, i64 0, i64 %31
%33 = load i8*, i8** %32
%34 = load i8*, i8** %5
%35 = load i32, i32* %7
%36 = call i32 @strncpy(i8* %33, i8* %34, i32 %35)
%37 = load i32, i32* %6
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [50 x i8*], [50 x i8*]* %3, i64 0, i64 %38
%40 = load i8*, i8** %39
%41 = call i32 @strcat(i8* %40, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%42 = load i32, i32* %6
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds [50 x i8*], [50 x i8*]* %3, i64 0, i64 %43
%45 = load i8*, i8** %44
%46 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %45)
%47 = load i8*, i8** %5
%48 = load i32, i32* %7
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds i8, i8* %47, i64 %49
%51 = getelementptr inbounds i8, i8* %50, i64 1
store i8* %51, i8** %5
%52 = load i32, i32* %6
%53 = add nsw i32 %52, 1
store i32 %53, i32* %6
%54 = load i8*, i8** %4
%55 = getelementptr inbounds i8, i8* %54, i32 1
store i8* %55, i8** %4
store i32 0, i32* %7
br label %9
56: ; preds = %14
%57 = load i8*, i8** %4
%58 = getelementptr inbounds i8, i8* %57, i32 1
store i8* %58, i8** %4
%59 = load i32, i32* %7
%60 = add nsw i32 %59, 1
store i32 %60, i32* %7
br label %9
61: ; preds = %9
%62 = load i32, i32* %7
%63 = add nsw i32 %62, 1
%64 = sext i32 %63 to i64
%65 = mul i64 1, %64
%66 = trunc i64 %65 to i32
%67 = call i64 @malloc(i32 %66)
%68 = inttoptr i64 %67 to i8*
%69 = load i32, i32* %6
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds [50 x i8*], [50 x i8*]* %3, i64 0, i64 %70
store i8* %68, i8** %71
%72 = load i32, i32* %6
%73 = sext i32 %72 to i64
%74 = getelementptr inbounds [50 x i8*], [50 x i8*]* %3, i64 0, i64 %73
%75 = load i8*, i8** %74
%76 = load i8*, i8** %5
%77 = load i32, i32* %7
%78 = call i32 @strncpy(i8* %75, i8* %76, i32 %77)
%79 = load i32, i32* %6
%80 = sext i32 %79 to i64
%81 = getelementptr inbounds [50 x i8*], [50 x i8*]* %3, i64 0, i64 %80
%82 = load i8*, i8** %81
%83 = call i32 @strcat(i8* %82, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%84 = load i32, i32* %6
%85 = sext i32 %84 to i64
%86 = getelementptr inbounds [50 x i8*], [50 x i8*]* %3, i64 0, i64 %85
%87 = load i8*, i8** %86
%88 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %87)
ret i32 0
}

LLVM IR (-O2):
@.str = [13 x i8] c"wo shi shui?\00"
@.str.1 = [2 x i8] zeroinitializer
@.str.2 = [4 x i8] c"%s\0A\00"
define i32 @main() {
br label %1
1: ; preds = %8, %0
%2 = phi i8* [ %18, %8 ], [ getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), %0 ]
%3 = phi i8* [ %17, %8 ], [ getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), %0 ]
br label %4
4: ; preds = %1, %19
%5 = phi i8* [ %20, %19 ], [ %2, %1 ]
%6 = phi i32 [ %21, %19 ], [ 0, %1 ]
%7 = load i8, i8* %5
switch i8 %7, label %19 [
i8 0, label %22
i8 32, label %8
]
8: ; preds = %4
%9 = add nuw nsw i32 %6, 1
%10 = tail call i64 @malloc(i32 %9)
%11 = inttoptr i64 %10 to i8*
%12 = tail call i32 @strncpy(i8* %11, i8* %3, i32 %6)
%13 = tail call i32 @strcat(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%14 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %11)
%15 = zext i32 %6 to i64
%16 = getelementptr inbounds i8, i8* %3, i64 1
%17 = getelementptr inbounds i8, i8* %16, i64 %15
%18 = getelementptr inbounds i8, i8* %5, i64 1
br label %1
19: ; preds = %4
%20 = getelementptr inbounds i8, i8* %5, i64 1
%21 = add nuw nsw i32 %6, 1
br label %4
22: ; preds = %4
%23 = add nuw nsw i32 %6, 1
%24 = tail call i64 @malloc(i32 %23)
%25 = inttoptr i64 %24 to i8*
%26 = tail call i32 @strncpy(i8* %25, i8* %3, i32 %6)
%27 = tail call i32 @strcat(i8* %25, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%28 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %25)
ret i32 0
}