#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 */
char *chunkify(char *, int, int);
int locate_next_space(char *, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int main() {
  printf("Enter a string : ");
  char str[100];
  scanf("%s", str);
  int low = 0;
  char matrix[25][25];
  int i = 0;
  while (locate_next_space(str, 0) != -1) {
    int pos = locate_next_space(str, low);
    char *sub = chunkify(str, low, pos);
    strcpy(matrix[i], sub);
    printf("%s\n", matrix[i]);
    i++;
    low = pos + 1;
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x300,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe97(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0x70(%rbp),%rsi
lea    0xe97(%rip),%rdi
call   1070 <scanf@plt>
movl   $0x0,-0x74(%rbp)
movl   $0x0,-0x2f4(%rbp)
lea    -0x70(%rbp),%rdi
xor    %esi,%esi
call   1050 <locate_next_space@plt>
cmp    $0xffffffff,%eax
je     1234 <main+0xe4>
lea    -0x70(%rbp),%rdi
mov    -0x74(%rbp),%esi
call   1050 <locate_next_space@plt>
mov    %eax,-0x2f8(%rbp)
lea    -0x70(%rbp),%rdi
mov    -0x74(%rbp),%esi
mov    -0x2f8(%rbp),%edx
call   1030 <chunkify@plt>
mov    %rax,-0x300(%rbp)
movslq -0x2f4(%rbp),%rax
lea    -0x2f0(%rbp),%rdi
imul   $0x19,%rax,%rax
add    %rax,%rdi
mov    -0x300(%rbp),%rsi
call   1040 <strcpy@plt>
movslq -0x2f4(%rbp),%rax
lea    -0x2f0(%rbp),%rsi
imul   $0x19,%rax,%rax
add    %rax,%rsi
lea    0xe08(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x2f4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2f4(%rbp)
mov    -0x2f8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x74(%rbp)
jmp    1191 <main+0x41>
mov    -0x4(%rbp),%eax
add    $0x300,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x2e8,%rsp
lea    0xe8c(%rip),%rdi
xor    %r15d,%r15d
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xe8d(%rip),%rdi
mov    %rsp,%rbx
mov    %rbx,%rsi
call   1080 <scanf@plt>
mov    %rbx,%rdi
xor    %esi,%esi
call   1060 <locate_next_space@plt>
cmp    $0xffffffff,%eax
je     11f6 <main+0x96>
lea    0x70(%rsp),%rbx
mov    %rsp,%r14
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %r15d,%esi
call   1060 <locate_next_space@plt>
mov    %eax,%ebp
mov    %r14,%rdi
mov    %r15d,%esi
mov    %eax,%edx
call   1030 <chunkify@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
call   1040 <strcpy@plt>
mov    %rbx,%rdi
call   1050 <puts@plt>
add    $0x1,%ebp
mov    %r14,%rdi
xor    %esi,%esi
call   1060 <locate_next_space@plt>
add    $0x19,%rbx
mov    %ebp,%r15d
cmp    $0xffffffff,%eax
jne    11b0 <main+0x50>
xor    %eax,%eax
add    $0x2e8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [18 x i8] c"Enter a string : \00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x i8]
%3 = alloca i32
%4 = alloca [25 x [25 x i8]]
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
store i32 0, i32* %1
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%9 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %9)
store i32 0, i32* %3
store i32 0, i32* %5
br label %11
11: ; preds = %15, %0
%12 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%13 = call i32 @locate_next_space(i8* %12, i32 0)
%14 = icmp ne i32 %13, -1
br i1 %14, label %15, label %38
15: ; preds = %11
%16 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%17 = load i32, i32* %3
%18 = call i32 @locate_next_space(i8* %16, i32 %17)
store i32 %18, i32* %6
%19 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%20 = load i32, i32* %3
%21 = load i32, i32* %6
%22 = call i8* @chunkify(i8* %19, i32 %20, i32 %21)
store i8* %22, i8** %7
%23 = load i32, i32* %5
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [25 x [25 x i8]], [25 x [25 x i8]]* %4, i64 0, i64 %24
%26 = getelementptr inbounds [25 x i8], [25 x i8]* %25, i64 0, i64 0
%27 = load i8*, i8** %7
%28 = call i32 @strcpy(i8* %26, i8* %27)
%29 = load i32, i32* %5
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [25 x [25 x i8]], [25 x [25 x i8]]* %4, i64 0, i64 %30
%32 = getelementptr inbounds [25 x i8], [25 x i8]* %31, i64 0, i64 0
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %32)
%34 = load i32, i32* %5
%35 = add nsw i32 %34, 1
store i32 %35, i32* %5
%36 = load i32, i32* %6
%37 = add nsw i32 %36, 1
store i32 %37, i32* %3
br label %11
38: ; preds = %11
%39 = load i32, i32* %1
ret i32 %39
}

LLVM IR (-O2):
@.str = [18 x i8] c"Enter a string : \00"
@.str.1 = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca [100 x i8]
%2 = alloca [25 x [25 x i8]]
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%6 = getelementptr inbounds [25 x [25 x i8]], [25 x [25 x i8]]* %2, i64 0, i64 0, i64 0
%7 = call i32 @locate_next_space(i8* %4, i32 0)
%8 = icmp eq i32 %7, -1
br i1 %8, label %21, label %9
9: ; preds = %0, %9
%10 = phi i64 [ %17, %9 ], [ 0, %0 ]
%11 = phi i32 [ %18, %9 ], [ 0, %0 ]
%12 = call i32 @locate_next_space(i8* %4, i32 %11)
%13 = call i8* @chunkify(i8* %4, i32 %11, i32 %12)
%14 = getelementptr inbounds [25 x [25 x i8]], [25 x [25 x i8]]* %2, i64 0, i64 %10, i64 0
%15 = call i32 @strcpy(i8* %14, i8* %13)
%16 = call i32 @puts(i8* %14)
%17 = add nuw i64 %10, 1
%18 = add nsw i32 %12, 1
%19 = call i32 @locate_next_space(i8* %4, i32 0)
%20 = icmp eq i32 %19, -1
br i1 %20, label %21, label %9
21: ; preds = %9, %0
ret i32 0
}