#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*/ completeWithSpace(int);
int /*<<< orphan*/ printf(char *, char);
int strlen(char *);
void printColumn(char *string, int length, int turn) {
  int begin = (turn * length);
  int end = ((turn + 1) * length);
  int i;
  printf("%c", '|');
  if (begin > strlen(string))
    completeWithSpace(end - begin);
  else if (end > strlen(string)) {
    for (i = begin; i < strlen(string); i++)
      printf("%c", string[i]);
    completeWithSpace(end - strlen(string));
  } else {
    for (i = begin; i < end; i++)
      printf("%c", string[i]);
  }
}


x86 assembly (clang, -O0):
<printColumn>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0x10(%rbp),%eax
imul   -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
imul   -0xc(%rbp),%eax
mov    %eax,-0x18(%rbp)
lea    0xea0(%rip),%rdi
mov    $0x7c,%esi
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%eax
cmp    %ecx,%eax
jle    1196 <printColumn+0x66>
mov    -0x18(%rbp),%edi
sub    -0x14(%rbp),%edi
call   1050 <completeWithSpace@plt>
jmp    125a <printColumn+0x12a>
mov    -0x18(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x24(%rbp),%eax
cmp    %ecx,%eax
jle    1218 <printColumn+0xe8>
mov    -0x14(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%eax
cmp    %ecx,%eax
jge    11fa <printColumn+0xca>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
lea    0xe1d(%rip),%rdi
movsbl (%rax,%rcx,1),%esi
call   1040 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11b8 <printColumn+0x88>
mov    -0x18(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x2c(%rbp),%edi
sub    %eax,%edi
call   1050 <completeWithSpace@plt>
jmp    1255 <printColumn+0x125>
mov    -0x14(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    1250 <printColumn+0x120>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
lea    0xdc7(%rip),%rdi
movsbl (%rax,%rcx,1),%esi
call   1040 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    121e <printColumn+0xee>
jmp    1255 <printColumn+0x125>
jmp    125a <printColumn+0x12a>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printColumn>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%r15d
mov    %esi,%r14d
mov    %rdi,%rbx
mov    %edx,%ebp
imul   %esi,%ebp
lea    0xeb4(%rip),%rdi
mov    $0x7c,%esi
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
cmp    %eax,%ebp
jg     11bd <printColumn+0x8d>
add    $0x1,%r15d
imul   %r14d,%r15d
mov    %rbx,%rdi
call   1030 <strlen@plt>
cmp    %eax,%r15d
jle    11cf <printColumn+0x9f>
mov    %rbx,%rdi
call   1030 <strlen@plt>
cmp    %eax,%ebp
jge    11af <printColumn+0x7f>
movslq %ebp,%rbp
lea    0xe73(%rip),%r14
nopl   (%rax)
movsbl (%rbx,%rbp,1),%esi
mov    %r14,%rdi
call   1040 <printf@plt>
add    $0x1,%rbp
mov    %rbx,%rdi
call   1030 <strlen@plt>
cltq
cmp    %rax,%rbp
jl     1190 <printColumn+0x60>
mov    %rbx,%rdi
call   1030 <strlen@plt>
sub    %eax,%r15d
mov    %r15d,%r14d
mov    %r14d,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <completeWithSpace@plt>
cmp    %r15d,%ebp
jge    1205 <printColumn+0xd5>
movslq %ebp,%rax
add    %rax,%rbx
mov    %r14d,%r15d
xor    %ebp,%ebp
lea    0xe1a(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
movsbl (%rbx,%rbp,1),%esi
mov    %r14,%rdi
call   1040 <printf@plt>
add    $0x1,%rbp
cmp    %ebp,%r15d
jne    11f0 <printColumn+0xc0>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%c\00"
define void @printColumn(i8* %0, i32 %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%10 = load i32, i32* %6
%11 = load i32, i32* %5
%12 = mul nsw i32 %10, %11
store i32 %12, i32* %7
%13 = load i32, i32* %6
%14 = add nsw i32 %13, 1
%15 = load i32, i32* %5
%16 = mul nsw i32 %14, %15
store i32 %16, i32* %8
%17 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext 124)
%18 = load i32, i32* %7
%19 = load i8*, i8** %4
%20 = call i32 @strlen(i8* %19)
%21 = icmp sgt i32 %18, %20
br i1 %21, label %22, label %27
22: ; preds = %3
%23 = load i32, i32* %8
%24 = load i32, i32* %7
%25 = sub nsw i32 %23, %24
%26 = call i32 @completeWithSpace(i32 %25)
br label %73
27: ; preds = %3
%28 = load i32, i32* %8
%29 = load i8*, i8** %4
%30 = call i32 @strlen(i8* %29)
%31 = icmp sgt i32 %28, %30
br i1 %31, label %32, label %55
32: ; preds = %27
%33 = load i32, i32* %7
store i32 %33, i32* %9
br label %34
34: ; preds = %46, %32
%35 = load i32, i32* %9
%36 = load i8*, i8** %4
%37 = call i32 @strlen(i8* %36)
%38 = icmp slt i32 %35, %37
br i1 %38, label %39, label %49
39: ; preds = %34
%40 = load i8*, i8** %4
%41 = load i32, i32* %9
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i8, i8* %40, i64 %42
%44 = load i8, i8* %43
%45 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %44)
br label %46
46: ; preds = %39
%47 = load i32, i32* %9
%48 = add nsw i32 %47, 1
store i32 %48, i32* %9
br label %34
49: ; preds = %34
%50 = load i32, i32* %8
%51 = load i8*, i8** %4
%52 = call i32 @strlen(i8* %51)
%53 = sub nsw i32 %50, %52
%54 = call i32 @completeWithSpace(i32 %53)
br label %72
55: ; preds = %27
%56 = load i32, i32* %7
store i32 %56, i32* %9
br label %57
57: ; preds = %68, %55
%58 = load i32, i32* %9
%59 = load i32, i32* %8
%60 = icmp slt i32 %58, %59
br i1 %60, label %61, label %71
61: ; preds = %57
%62 = load i8*, i8** %4
%63 = load i32, i32* %9
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds i8, i8* %62, i64 %64
%66 = load i8, i8* %65
%67 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %66)
br label %68
68: ; preds = %61
%69 = load i32, i32* %9
%70 = add nsw i32 %69, 1
store i32 %70, i32* %9
br label %57
71: ; preds = %57
br label %72
72: ; preds = %71, %49
br label %73
73: ; preds = %72, %22
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%c\00"
define void @printColumn(i8* %0, i32 %1, i32 %2) {
%4 = mul i32 %2, %1
%5 = add nsw i32 %2, 1
%6 = mul i32 %5, %1
%7 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext 124)
%8 = tail call i32 @strlen(i8* %0)
%9 = icmp sgt i32 %4, %8
br i1 %9, label %42, label %10
10: ; preds = %3
%11 = tail call i32 @strlen(i8* %0)
%12 = icmp sgt i32 %6, %11
br i1 %12, label %17, label %13
13: ; preds = %10
%14 = icmp slt i32 %4, %6
br i1 %14, label %15, label %45
15: ; preds = %13
%16 = sext i32 %4 to i64
br label %34
17: ; preds = %10
%18 = tail call i32 @strlen(i8* %0)
%19 = icmp slt i32 %4, %18
br i1 %19, label %20, label %31
20: ; preds = %17
%21 = sext i32 %4 to i64
br label %22
22: ; preds = %20, %22
%23 = phi i64 [ %21, %20 ], [ %27, %22 ]
%24 = getelementptr inbounds i8, i8* %0, i64 %23
%25 = load i8, i8* %24
%26 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %25)
%27 = add nsw i64 %23, 1
%28 = tail call i32 @strlen(i8* %0)
%29 = sext i32 %28 to i64
%30 = icmp slt i64 %27, %29
br i1 %30, label %22, label %31
31: ; preds = %22, %17
%32 = tail call i32 @strlen(i8* %0)
%33 = sub nsw i32 %6, %32
br label %42
34: ; preds = %15, %34
%35 = phi i64 [ %16, %15 ], [ %39, %34 ]
%36 = getelementptr inbounds i8, i8* %0, i64 %35
%37 = load i8, i8* %36
%38 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %37)
%39 = add nsw i64 %35, 1
%40 = trunc i64 %39 to i32
%41 = icmp eq i32 %6, %40
br i1 %41, label %45, label %34
42: ; preds = %3, %31
%43 = phi i32 [ %33, %31 ], [ %1, %3 ]
%44 = tail call i32 @completeWithSpace(i32 %43)
br label %45
45: ; preds = %34, %42, %13
ret void
}