#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 ceil(int /*<<< orphan*/);
int floor(int /*<<< orphan*/);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, char *);
int /*<<< orphan*/ sqrt(double);
double strlen(char *);
int main() {
  char *s = (char *)malloc(10240 * sizeof(char));
  scanf("%s", s);
  double len = strlen(s);
  int rows = floor(sqrt(len));
  int cols = ceil(sqrt(len));
  for (int j = 0; j < cols; j++) {
    for (int i = 0; i < len; i++) {
      if (i % cols == j) {
        printf("%c", s[i]);
      }
    }
    printf(" ");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x2800,%edi
call   1060 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xe68(%rip),%rdi
call   1070 <scanf@plt>
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1080 <sqrt@plt>
mov    %eax,%edi
call   1090 <floor@plt>
mov    %eax,-0x1c(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1080 <sqrt@plt>
mov    %eax,%edi
call   1030 <ceil@plt>
mov    %eax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    125a <main+0xea>
movl   $0x0,-0x28(%rbp)
cvtsi2sdl -0x28(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    123e <main+0xce>
mov    -0x28(%rbp),%eax
cltd
idivl  -0x20(%rbp)
cmp    -0x24(%rbp),%edx
jne    122b <main+0xbb>
mov    -0x10(%rbp),%rax
movslq -0x28(%rbp),%rcx
movsbl (%rax,%rcx,1),%esi
lea    0xddf(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1230 <main+0xc0>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    11ed <main+0x7d>
lea    0xdc1(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11da <main+0x6a>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    $0x2800,%edi
call   1060 <malloc@plt>
mov    %rax,%r14
lea    0xe7d(%rip),%rdi
mov    %rax,%rsi
call   1070 <scanf@plt>
mov    %r14,%rdi
call   1050 <strlen@plt>
movsd  %xmm0,(%rsp)
call   1080 <sqrt@plt>
mov    %eax,%edi
call   1090 <floor@plt>
movsd  (%rsp),%xmm0
call   1080 <sqrt@plt>
mov    %eax,%edi
call   1040 <ceil@plt>
test   %eax,%eax
jle    122c <main+0xbc>
mov    %eax,%r15d
xor    %ebp,%ebp
jmp    11e2 <main+0x72>
nopl   0x0(%rax,%rax,1)
mov    $0x20,%edi
call   1030 <putchar@plt>
add    $0x1,%ebp
cmp    %r15d,%ebp
je     122c <main+0xbc>
movsd  (%rsp),%xmm0
ucomisd 0xe11(%rip),%xmm0
jbe    11d0 <main+0x60>
xor    %ebx,%ebx
jmp    1216 <main+0xa6>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x1,%rbx
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
movsd  (%rsp),%xmm1
ucomisd %xmm0,%xmm1
jbe    11d0 <main+0x60>
mov    %ebx,%eax
cltd
idiv   %r15d
cmp    %ebp,%edx
jne    1200 <main+0x90>
movsbl (%r14,%rbx,1),%edi
call   1030 <putchar@plt>
jmp    1200 <main+0x90>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@.str.1 = [3 x i8] c"%c\00"
@.str.2 = [2 x i8] c" \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca double
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
%8 = call i64 @malloc(i32 10240)
%9 = inttoptr i64 %8 to i8*
store i8* %9, i8** %2
%10 = load i8*, i8** %2
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %10)
%12 = load i8*, i8** %2
%13 = call double @strlen(i8* %12)
store double %13, double* %3
%14 = load double, double* %3
%15 = call i32 @sqrt(double %14)
%16 = call i32 @floor(i32 %15)
store i32 %16, i32* %4
%17 = load double, double* %3
%18 = call i32 @sqrt(double %17)
%19 = call i32 @ceil(i32 %18)
store i32 %19, i32* %5
store i32 0, i32* %6
br label %20
20: ; preds = %50, %0
%21 = load i32, i32* %6
%22 = load i32, i32* %5
%23 = icmp slt i32 %21, %22
br i1 %23, label %24, label %53
24: ; preds = %20
store i32 0, i32* %7
br label %25
25: ; preds = %45, %24
%26 = load i32, i32* %7
%27 = sitofp i32 %26 to double
%28 = load double, double* %3
%29 = fcmp olt double %27, %28
br i1 %29, label %30, label %48
30: ; preds = %25
%31 = load i32, i32* %7
%32 = load i32, i32* %5
%33 = srem i32 %31, %32
%34 = load i32, i32* %6
%35 = icmp eq i32 %33, %34
br i1 %35, label %36, label %44
36: ; preds = %30
%37 = load i8*, i8** %2
%38 = load i32, i32* %7
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i8, i8* %37, i64 %39
%41 = load i8, i8* %40
%42 = sext i8 %41 to i32
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %42)
br label %44
44: ; preds = %36, %30
br label %45
45: ; preds = %44
%46 = load i32, i32* %7
%47 = add nsw i32 %46, 1
store i32 %47, i32* %7
br label %25
48: ; preds = %25
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %50
50: ; preds = %48
%51 = load i32, i32* %6
%52 = add nsw i32 %51, 1
store i32 %52, i32* %6
br label %20
53: ; preds = %20
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
define i32 @main() {
%1 = tail call i64 @malloc(i32 10240)
%2 = inttoptr i64 %1 to i8*
%3 = tail call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %2)
%4 = tail call double @strlen(i8* %2)
%5 = tail call i32 @sqrt(double %4)
%6 = tail call i32 @floor(i32 %5)
%7 = tail call i32 @sqrt(double %4)
%8 = tail call i32 @ceil(i32 %7)
%9 = icmp sgt i32 %8, 0
br i1 %9, label %10, label %14
10: ; preds = %0
%11 = fcmp ogt double %4, 0.000000e+00
br label %12
12: ; preds = %10, %15
%13 = phi i32 [ 0, %10 ], [ %17, %15 ]
br i1 %11, label %19, label %15
14: ; preds = %15, %0
ret i32 0
15: ; preds = %29, %12
%16 = tail call i32 @putchar(i32 32)
%17 = add nuw nsw i32 %13, 1
%18 = icmp eq i32 %17, %8
br i1 %18, label %14, label %12
19: ; preds = %12, %29
%20 = phi i64 [ %30, %29 ], [ 0, %12 ]
%21 = trunc i64 %20 to i32
%22 = srem i32 %21, %8
%23 = icmp eq i32 %22, %13
br i1 %23, label %24, label %29
24: ; preds = %19
%25 = getelementptr inbounds i8, i8* %2, i64 %20
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = tail call i32 @putchar(i32 %27)
br label %29
29: ; preds = %19, %24
%30 = add nuw i64 %20, 1
%31 = trunc i64 %30 to i32
%32 = sitofp i32 %31 to double
%33 = fcmp ogt double %4, %32
br i1 %33, label %19, label %15
}