#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*/ isspace(char const);
int /*<<< orphan*/ printf(char *, ...);
int strlen(char const *);
void print_spec_indented_and_max_length(const char *str, int len, int Num,
                                        const char *AddToEnd) {
  int notfirsttime = 0;
  int slen = strlen(str);
  int lo = 0, hi = 0;
  int i;
  while (hi < slen) {
    hi = lo + len;
    if (hi >= slen) {
      for (i = 1; i < Num; i++) {
        printf("    ");
      }
      for (lo += notfirsttime; lo < slen; lo++)
        printf("%c", str[lo]);
      printf("%s\n", AddToEnd);
      return;
    }
    while (!(isspace(str[hi])) && hi > lo)
      hi--;
    if (hi == lo) {
      hi = lo + len;
      while (!(isspace(str[hi])) && hi < slen)
        hi++;
    }
    for (i = 1; i < Num; i++) {
      printf("    ");
    }
    for (lo += notfirsttime; lo < hi; lo++)
      printf("%c", str[lo]);
    printf("\n");
    notfirsttime = 1;
  }
}


x86 assembly (clang, -O0):
<print_spec_indented_and_max_length>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    1346 <print_spec_indented_and_max_length+0x216>
mov    -0x24(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x20(%rbp),%eax
jl     120b <print_spec_indented_and_max_length+0xdb>
movl   $0x1,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11b7 <print_spec_indented_and_max_length+0x87>
lea    0xe5e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    118f <print_spec_indented_and_max_length+0x5f>
mov    -0x1c(%rbp),%eax
add    -0x24(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    11f4 <print_spec_indented_and_max_length+0xc4>
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsbl (%rax,%rcx,1),%esi
lea    0xe26(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11c0 <print_spec_indented_and_max_length+0x90>
mov    -0x18(%rbp),%rsi
lea    0xe09(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1346 <print_spec_indented_and_max_length+0x216>
jmp    1210 <print_spec_indented_and_max_length+0xe0>
mov    -0x8(%rbp),%rax
movslq -0x28(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1050 <isspace@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x2d(%rbp)
jne    123d <print_spec_indented_and_max_length+0x10d>
mov    -0x28(%rbp),%eax
cmp    -0x24(%rbp),%eax
setg   %al
mov    %al,-0x2d(%rbp)
mov    -0x2d(%rbp),%al
test   $0x1,%al
jne    124d <print_spec_indented_and_max_length+0x11d>
jmp    125b <print_spec_indented_and_max_length+0x12b>
mov    -0x28(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x28(%rbp)
jmp    1210 <print_spec_indented_and_max_length+0xe0>
mov    -0x28(%rbp),%eax
cmp    -0x24(%rbp),%eax
jne    12c0 <print_spec_indented_and_max_length+0x190>
mov    -0x24(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x28(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1050 <isspace@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x2e(%rbp)
jne    129d <print_spec_indented_and_max_length+0x16d>
mov    -0x28(%rbp),%eax
cmp    -0x20(%rbp),%eax
setl   %al
mov    %al,-0x2e(%rbp)
mov    -0x2e(%rbp),%al
test   $0x1,%al
jne    12ad <print_spec_indented_and_max_length+0x17d>
jmp    12bb <print_spec_indented_and_max_length+0x18b>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1270 <print_spec_indented_and_max_length+0x140>
jmp    12c0 <print_spec_indented_and_max_length+0x190>
movl   $0x1,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    12ef <print_spec_indented_and_max_length+0x1bf>
lea    0xd26(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    12c7 <print_spec_indented_and_max_length+0x197>
mov    -0x1c(%rbp),%eax
add    -0x24(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x28(%rbp),%eax
jge    132c <print_spec_indented_and_max_length+0x1fc>
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsbl (%rax,%rcx,1),%esi
lea    0xcee(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    12f8 <print_spec_indented_and_max_length+0x1c8>
lea    0xcd7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x1c(%rbp)
jmp    1167 <print_spec_indented_and_max_length+0x37>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_spec_indented_and_max_length>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rcx,0x28(%rsp)
mov    %edx,%ebx
mov    %rsi,0x18(%rsp)
mov    %rdi,%r14
call   1050 <strlen@plt>
test   %eax,%eax
jle    12c8 <print_spec_indented_and_max_length+0x178>
mov    %eax,%r13d
mov    %eax,%ebp
mov    0x18(%rsp),%rax
mov    %eax,%ecx
not    %ecx
mov    %ecx,0x4(%rsp)
add    $0xffffffff,%eax
mov    %rax,0x30(%rsp)
lea    -0x1(%rbx),%eax
mov    %eax,(%rsp)
xor    %r12d,%r12d
xor    %ecx,%ecx
mov    %rbp,0x10(%rsp)
mov    %rbx,0x20(%rsp)
mov    %r13d,0x8(%rsp)
jmp    11d2 <print_spec_indented_and_max_length+0x82>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    $0x1,%ecx
mov    0x8(%rsp),%r13d
cmp    %r13d,%r15d
mov    0x20(%rsp),%rbx
jge    12c8 <print_spec_indented_and_max_length+0x178>
mov    0x18(%rsp),%rax
add    %r12d,%eax
cmp    %r13d,%eax
jge    12d7 <print_spec_indented_and_max_length+0x187>
mov    %ecx,0xc(%rsp)
movslq %eax,%r13
movslq %r12d,%r15
mov    0x4(%rsp),%ebp
mov    %r13,%rbx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsbl (%r14,%rbx,1),%edi
call   1070 <isspace@plt>
add    $0x1,%ebp
test   %eax,%eax
jne    121d <print_spec_indented_and_max_length+0xcd>
lea    -0x1(%rbx),%rax
cmp    %r15,%rbx
mov    %rax,%rbx
jg     1200 <print_spec_indented_and_max_length+0xb0>
test   %ebp,%ebp
je     1230 <print_spec_indented_and_max_length+0xe0>
mov    %r12d,%r15d
sub    %ebp,%r15d
jmp    1260 <print_spec_indented_and_max_length+0x110>
nopl   0x0(%rax)
mov    0x30(%rsp),%rax
lea    (%rax,%r12,1),%r15d
mov    0x10(%rsp),%rbp
xchg   %ax,%ax
movsbl (%r14,%r13,1),%edi
call   1070 <isspace@plt>
add    $0x1,%r15d
test   %eax,%eax
jne    1260 <print_spec_indented_and_max_length+0x110>
lea    0x1(%r13),%rax
cmp    %rbp,%r13
mov    %rax,%r13
jl     1240 <print_spec_indented_and_max_length+0xf0>
xchg   %ax,%ax
cmpl   $0x2,0x20(%rsp)
lea    0xd94(%rip),%r13
jl     128f <print_spec_indented_and_max_length+0x13f>
mov    (%rsp),%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r13,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
add    $0xffffffff,%ebx
jne    1280 <print_spec_indented_and_max_length+0x130>
add    0xc(%rsp),%r12d
cmp    %r15d,%r12d
jge    11b0 <print_spec_indented_and_max_length+0x60>
movslq %r12d,%r12
movslq %r15d,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movsbl (%r14,%r12,1),%edi
call   1030 <putchar@plt>
add    $0x1,%r12
cmp    %rbx,%r12
jl     12b0 <print_spec_indented_and_max_length+0x160>
jmp    11b0 <print_spec_indented_and_max_length+0x60>
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %ecx,%r15d
cmp    $0x2,%ebx
jl     12ff <print_spec_indented_and_max_length+0x1af>
add    $0xffffffff,%ebx
lea    0xd17(%rip),%rbp
nopl   0x0(%rax)
mov    %rbp,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
add    $0xffffffff,%ebx
jne    12f0 <print_spec_indented_and_max_length+0x1a0>
add    %r15d,%r12d
cmp    %r13d,%r12d
mov    0x10(%rsp),%rbp
jge    1323 <print_spec_indented_and_max_length+0x1d3>
movslq %r12d,%rbx
nop
movsbl (%r14,%rbx,1),%edi
call   1030 <putchar@plt>
add    $0x1,%rbx
cmp    %rbp,%rbx
jl     1310 <print_spec_indented_and_max_length+0x1c0>
mov    0x28(%rsp),%rdi
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <puts@plt>

LLVM IR (-O0):
@.str = [5 x i8] c" \00"
@.str.1 = [3 x i8] c"%c\00"
@.str.2 = [4 x i8] c"%s\0A\00"
@.str.3 = [2 x i8] c"\0A\00"
define void @print_spec_indented_and_max_length(i8* %0, i32 %1, i32 %2, i8* %3) {
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
store i8* %0, i8** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i8* %3, i8** %8
store i32 0, i32* %9
%14 = load i8*, i8** %5
%15 = call i32 @strlen(i8* %14)
store i32 %15, i32* %10
store i32 0, i32* %11
store i32 0, i32* %12
br label %16
16: ; preds = %132, %4
%17 = load i32, i32* %12
%18 = load i32, i32* %10
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %134
20: ; preds = %16
%21 = load i32, i32* %11
%22 = load i32, i32* %6
%23 = add nsw i32 %21, %22
store i32 %23, i32* %12
%24 = load i32, i32* %12
%25 = load i32, i32* %10
%26 = icmp sge i32 %24, %25
br i1 %26, label %27, label %59
27: ; preds = %20
store i32 1, i32* %13
br label %28
28: ; preds = %34, %27
%29 = load i32, i32* %13
%30 = load i32, i32* %7
%31 = icmp slt i32 %29, %30
br i1 %31, label %32, label %37
32: ; preds = %28
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
br label %34
34: ; preds = %32
%35 = load i32, i32* %13
%36 = add nsw i32 %35, 1
store i32 %36, i32* %13
br label %28
37: ; preds = %28
%38 = load i32, i32* %9
%39 = load i32, i32* %11
%40 = add nsw i32 %39, %38
store i32 %40, i32* %11
br label %41
41: ; preds = %53, %37
%42 = load i32, i32* %11
%43 = load i32, i32* %10
%44 = icmp slt i32 %42, %43
br i1 %44, label %45, label %56
45: ; preds = %41
%46 = load i8*, i8** %5
%47 = load i32, i32* %11
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds i8, i8* %46, i64 %48
%50 = load i8, i8* %49
%51 = sext i8 %50 to i32
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %51)
br label %53
53: ; preds = %45
%54 = load i32, i32* %11
%55 = add nsw i32 %54, 1
store i32 %55, i32* %11
br label %41
56: ; preds = %41
%57 = load i8*, i8** %8
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %57)
br label %134
59: ; preds = %20
br label %60
60: ; preds = %74, %59
%61 = load i8*, i8** %5
%62 = load i32, i32* %12
%63 = sext i32 %62 to i64
%64 = getelementptr inbounds i8, i8* %61, i64 %63
%65 = load i8, i8* %64
%66 = call i32 @isspace(i8 signext %65)
%67 = icmp ne i32 %66, 0
br i1 %67, label %72, label %68
68: ; preds = %60
%69 = load i32, i32* %12
%70 = load i32, i32* %11
%71 = icmp sgt i32 %69, %70
br label %72
72: ; preds = %68, %60
%73 = phi i1 [ false, %60 ], [ %71, %68 ]
br i1 %73, label %74, label %77
74: ; preds = %72
%75 = load i32, i32* %12
%76 = add nsw i32 %75, -1
store i32 %76, i32* %12
br label %60
77: ; preds = %72
%78 = load i32, i32* %12
%79 = load i32, i32* %11
%80 = icmp eq i32 %78, %79
br i1 %80, label %81, label %103
81: ; preds = %77
%82 = load i32, i32* %11
%83 = load i32, i32* %6
%84 = add nsw i32 %82, %83
store i32 %84, i32* %12
br label %85
85: ; preds = %99, %81
%86 = load i8*, i8** %5
%87 = load i32, i32* %12
%88 = sext i32 %87 to i64
%89 = getelementptr inbounds i8, i8* %86, i64 %88
%90 = load i8, i8* %89
%91 = call i32 @isspace(i8 signext %90)
%92 = icmp ne i32 %91, 0
br i1 %92, label %97, label %93
93: ; preds = %85
%94 = load i32, i32* %12
%95 = load i32, i32* %10
%96 = icmp slt i32 %94, %95
br label %97
97: ; preds = %93, %85
%98 = phi i1 [ false, %85 ], [ %96, %93 ]
br i1 %98, label %99, label %102
99: ; preds = %97
%100 = load i32, i32* %12
%101 = add nsw i32 %100, 1
store i32 %101, i32* %12
br label %85
102: ; preds = %97
br label %103
103: ; preds = %102, %77
store i32 1, i32* %13
br label %104
104: ; preds = %110, %103
%105 = load i32, i32* %13
%106 = load i32, i32* %7
%107 = icmp slt i32 %105, %106
br i1 %107, label %108, label %113
108: ; preds = %104
%109 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
br label %110
110: ; preds = %108
%111 = load i32, i32* %13
%112 = add nsw i32 %111, 1
store i32 %112, i32* %13
br label %104
113: ; preds = %104
%114 = load i32, i32* %9
%115 = load i32, i32* %11
%116 = add nsw i32 %115, %114
store i32 %116, i32* %11
br label %117
117: ; preds = %129, %113
%118 = load i32, i32* %11
%119 = load i32, i32* %12
%120 = icmp slt i32 %118, %119
br i1 %120, label %121, label %132
121: ; preds = %117
%122 = load i8*, i8** %5
%123 = load i32, i32* %11
%124 = sext i32 %123 to i64
%125 = getelementptr inbounds i8, i8* %122, i64 %124
%126 = load i8, i8* %125
%127 = sext i8 %126 to i32
%128 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %127)
br label %129
129: ; preds = %121
%130 = load i32, i32* %11
%131 = add nsw i32 %130, 1
store i32 %131, i32* %11
br label %117
132: ; preds = %117
%133 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32 1, i32* %9
br label %16
134: ; preds = %56, %16
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c" \00"
define void @print_spec_indented_and_max_length(i8* %0, i32 %1, i32 %2, i8* nocapture %3) {
%5 = tail call i32 @strlen(i8* %0)
%6 = icmp sgt i32 %5, 0
br i1 %6, label %7, label %89
7: ; preds = %4
%8 = icmp sgt i32 %2, 1
%9 = zext i32 %5 to i64
br label %10
10: ; preds = %7, %85
%11 = phi i32 [ 0, %7 ], [ %86, %85 ]
%12 = phi i32 [ 0, %7 ], [ 1, %85 ]
%13 = add i32 %11, %1
%14 = icmp slt i32 %13, %5
br i1 %14, label %15, label %18
15: ; preds = %10
%16 = sext i32 %13 to i64
%17 = sext i32 %11 to i64
br label %39
18: ; preds = %10
br i1 %8, label %19, label %24
19: ; preds = %18, %19
%20 = phi i32 [ %22, %19 ], [ 1, %18 ]
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%22 = add nuw nsw i32 %20, 1
%23 = icmp eq i32 %22, %2
br i1 %23, label %24, label %19
24: ; preds = %19, %18
%25 = add i32 %11, %12
%26 = icmp slt i32 %25, %5
br i1 %26, label %27, label %37
27: ; preds = %24
%28 = sext i32 %25 to i64
br label %29
29: ; preds = %27, %29
%30 = phi i64 [ %28, %27 ], [ %35, %29 ]
%31 = getelementptr inbounds i8, i8* %0, i64 %30
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
%34 = tail call i32 @putchar(i32 %33)
%35 = add nsw i64 %30, 1
%36 = icmp slt i64 %35, %9
br i1 %36, label %29, label %37
37: ; preds = %29, %24
%38 = tail call i32 @puts(i8* dereferenceable(1) %3)
br label %89
39: ; preds = %15, %39
%40 = phi i64 [ %16, %15 ], [ %47, %39 ]
%41 = getelementptr inbounds i8, i8* %0, i64 %40
%42 = load i8, i8* %41
%43 = tail call i32 @isspace(i8 signext %42)
%44 = icmp eq i32 %43, 0
%45 = icmp sgt i64 %40, %17
%46 = select i1 %44, i1 %45, i1 false
%47 = add nsw i64 %40, -1
br i1 %46, label %39, label %48
48: ; preds = %39
%49 = trunc i64 %40 to i32
%50 = icmp eq i32 %11, %49
br i1 %50, label %51, label %62
51: ; preds = %48, %51
%52 = phi i64 [ %59, %51 ], [ %16, %48 ]
%53 = getelementptr inbounds i8, i8* %0, i64 %52
%54 = load i8, i8* %53
%55 = tail call i32 @isspace(i8 signext %54)
%56 = icmp eq i32 %55, 0
%57 = icmp slt i64 %52, %9
%58 = select i1 %56, i1 %57, i1 false
%59 = add nsw i64 %52, 1
br i1 %58, label %51, label %60
60: ; preds = %51
%61 = trunc i64 %52 to i32
br label %62
62: ; preds = %60, %48
%63 = phi i32 [ %49, %48 ], [ %61, %60 ]
br i1 %8, label %64, label %69
64: ; preds = %62, %64
%65 = phi i32 [ %67, %64 ], [ 1, %62 ]
%66 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%67 = add nuw nsw i32 %65, 1
%68 = icmp eq i32 %67, %2
br i1 %68, label %69, label %64
69: ; preds = %64, %62
%70 = add i32 %11, %12
%71 = icmp slt i32 %70, %63
br i1 %71, label %72, label %85
72: ; preds = %69
%73 = sext i32 %70 to i64
%74 = sext i32 %63 to i64
br label %75
75: ; preds = %72, %75
%76 = phi i64 [ %73, %72 ], [ %81, %75 ]
%77 = getelementptr inbounds i8, i8* %0, i64 %76
%78 = load i8, i8* %77
%79 = sext i8 %78 to i32
%80 = tail call i32 @putchar(i32 %79)
%81 = add nsw i64 %76, 1
%82 = icmp slt i64 %81, %74
br i1 %82, label %75, label %83
83: ; preds = %75
%84 = trunc i64 %81 to i32
br label %85
85: ; preds = %83, %69
%86 = phi i32 [ %70, %69 ], [ %84, %83 ]
%87 = tail call i32 @putchar(i32 10)
%88 = icmp slt i32 %63, %5
br i1 %88, label %10, label %89
89: ; preds = %85, %4, %37
ret void
}