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


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1c0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xec7(%rip),%rax
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x1b4(%rbp)
movl   $0x0,-0x1b8(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xeb1(%rip),%rdi
call   1040 <printf@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x1a8(%rbp)
mov    -0x1a8(%rbp),%rax
mov    %rax,-0x1b0(%rbp)
mov    -0x1a8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     127a <main+0x15a>
mov    -0x1a8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
jne    1254 <main+0x134>
movslq -0x1b8(%rbp),%rax
lea    -0x1a0(%rbp),%rdi
imul   $0x14,%rax,%rax
add    %rax,%rdi
mov    -0x1b0(%rbp),%rsi
mov    -0x1b4(%rbp),%edx
call   1030 <strncpy@plt>
movslq -0x1b8(%rbp),%rax
lea    -0x1a0(%rbp),%rsi
imul   $0x14,%rax,%rax
add    %rax,%rsi
lea    0xe2a(%rip),%rdi
call   1040 <printf@plt>
movslq -0x1b8(%rbp),%rcx
lea    -0x1a0(%rbp),%rax
imul   $0x14,%rcx,%rcx
add    %rcx,%rax
movslq -0x1b4(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x1b8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1b8(%rbp)
mov    -0x1b0(%rbp),%rax
movslq -0x1b4(%rbp),%rcx
add    %rcx,%rax
add    $0x1,%rax
mov    %rax,-0x1b0(%rbp)
movl   $0x0,-0x1b4(%rbp)
mov    -0x1a8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x1a8(%rbp)
jmp    117a <main+0x5a>
mov    -0x1b4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1b4(%rbp)
mov    -0x1a8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x1a8(%rbp)
jmp    117a <main+0x5a>
movslq -0x1b8(%rbp),%rax
lea    -0x1a0(%rbp),%rdi
imul   $0x14,%rax,%rax
add    %rax,%rdi
mov    -0x1b0(%rbp),%rsi
mov    -0x1b4(%rbp),%edx
call   1030 <strncpy@plt>
movslq -0x1b8(%rbp),%rcx
lea    -0x1a0(%rbp),%rax
imul   $0x14,%rcx,%rcx
add    %rcx,%rax
movslq -0x1b4(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
movslq -0x1b8(%rbp),%rax
lea    -0x1a0(%rbp),%rsi
imul   $0x14,%rax,%rax
add    %rax,%rsi
lea    0xd30(%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
sub    $0x198,%rsp
lea    0xed5(%rip),%rdi
lea    0xec1(%rip),%rbx
mov    %rbx,%rsi
call   1040 <printf@plt>
mov    %rsp,%r14
xor    %ebp,%ebp
mov    %rbx,%r15
add    $0x1,%rbx
xor    %r12d,%r12d
cs nopw 0x0(%rax,%rax,1)
movzbl -0x1(%rbx),%eax
test   %al,%al
je     11c2 <main+0xa2>
cmp    $0x20,%al
je     1180 <main+0x60>
add    $0x1,%rbx
add    $0x1,%r12
jmp    1160 <main+0x40>
cs nopw 0x0(%rax,%rax,1)
lea    0x0(,%rbp,4),%rax
add    %rbp,%rax
lea    (%rsp,%rax,4),%r13
mov    %r13,%rdi
mov    %r15,%rsi
mov    %r12d,%edx
call   1030 <strncpy@plt>
lea    0xe69(%rip),%rdi
mov    %r13,%rsi
call   1040 <printf@plt>
movb   $0x0,(%r14,%r12,1)
add    $0x1,%rbp
add    %r12,%r15
add    $0x1,%r15
add    $0x14,%r14
jmp    114f <main+0x2f>
mov    %ebp,%eax
lea    (%rax,%rax,4),%rax
lea    (%rsp,%rax,4),%rbx
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r12d,%edx
call   1030 <strncpy@plt>
mov    %ebp,%eax
lea    (%rax,%rax,4),%rax
lea    (%rsp,%rax,4),%rax
movb   $0x0,(%r12,%rax,1)
lea    0xe1d(%rip),%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x198,%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 = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca [20 x [20 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
%9 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %8)
%10 = load i8*, i8** %2
store i8* %10, i8** %4
%11 = load i8*, i8** %4
store i8* %11, i8** %5
br label %12
12: ; preds = %50, %22, %0
%13 = load i8*, i8** %4
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %55
17: ; preds = %12
%18 = load i8*, i8** %4
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp eq i32 %20, 32
br i1 %21, label %22, label %50
22: ; preds = %17
%23 = load i32, i32* %7
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [20 x [20 x i8]], [20 x [20 x i8]]* %3, i64 0, i64 %24
%26 = getelementptr inbounds [20 x i8], [20 x i8]* %25, i64 0, i64 0
%27 = load i8*, i8** %5
%28 = load i32, i32* %6
%29 = call i32 @strncpy(i8* %26, i8* %27, i32 %28)
%30 = load i32, i32* %7
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [20 x [20 x i8]], [20 x [20 x i8]]* %3, i64 0, i64 %31
%33 = getelementptr inbounds [20 x i8], [20 x i8]* %32, i64 0, i64 0
%34 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %33)
%35 = load i32, i32* %7
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [20 x [20 x i8]], [20 x [20 x i8]]* %3, i64 0, i64 %36
%38 = load i32, i32* %6
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds [20 x i8], [20 x i8]* %37, i64 0, i64 %39
store i8 0, i8* %40
%41 = load i32, i32* %7
%42 = add nsw i32 %41, 1
store i32 %42, i32* %7
%43 = load i8*, i8** %5
%44 = load i32, i32* %6
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds i8, i8* %43, i64 %45
%47 = getelementptr inbounds i8, i8* %46, i64 1
store i8* %47, i8** %5
store i32 0, i32* %6
%48 = load i8*, i8** %4
%49 = getelementptr inbounds i8, i8* %48, i32 1
store i8* %49, i8** %4
br label %12
50: ; preds = %17
%51 = load i32, i32* %6
%52 = add nsw i32 %51, 1
store i32 %52, i32* %6
%53 = load i8*, i8** %4
%54 = getelementptr inbounds i8, i8* %53, i32 1
store i8* %54, i8** %4
br label %12
55: ; preds = %12
%56 = load i32, i32* %7
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds [20 x [20 x i8]], [20 x [20 x i8]]* %3, i64 0, i64 %57
%59 = getelementptr inbounds [20 x i8], [20 x i8]* %58, i64 0, i64 0
%60 = load i8*, i8** %5
%61 = load i32, i32* %6
%62 = call i32 @strncpy(i8* %59, i8* %60, i32 %61)
%63 = load i32, i32* %7
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds [20 x [20 x i8]], [20 x [20 x i8]]* %3, i64 0, i64 %64
%66 = load i32, i32* %6
%67 = sext i32 %66 to i64
%68 = getelementptr inbounds [20 x i8], [20 x i8]* %65, i64 0, i64 %67
store i8 0, i8* %68
%69 = load i32, i32* %7
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds [20 x [20 x i8]], [20 x [20 x i8]]* %3, i64 0, i64 %70
%72 = getelementptr inbounds [20 x i8], [20 x i8]* %71, i64 0, i64 0
%73 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %72)
ret i32 0
}

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