#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*/ strcpy(char *, char *);
void PrintString(char *str) {
  int i, last_blank_space_index = 0, current_line_length = 0;
  static char output[500 + 1];
  strcpy(output, str);
  for (i = 0; i < 500 && output[i] != '\0'; i++) {
    current_line_length++;
    if (output[i] == ' ') {
      last_blank_space_index = i;
    }
    if (output[i] == '\n') {
      last_blank_space_index = 0;
      current_line_length = 0;
    } else if (current_line_length == 80) {
      if (last_blank_space_index == 0) {
        output[i] = '\n';
        current_line_length = 0;
      } else {
        i = last_blank_space_index;
        output[i] = '\n';
        last_blank_space_index = 0;
        current_line_length = 0;
      }
    }
  }
  if (i == 500) {
    output[i] = '\0';
  }
  printf("%s\n", output);
}


x86 assembly (clang, -O0):
<PrintString>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x8(%rbp),%rsi
lea    0x2efb(%rip),%rdi
call   1030 <strcpy@plt>
movl   $0x0,-0xc(%rbp)
xor    %eax,%eax
cmpl   $0x1f4,-0xc(%rbp)
mov    %al,-0x15(%rbp)
jge    117b <PrintString+0x5b>
movslq -0xc(%rbp),%rcx
lea    0x2ed2(%rip),%rax
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x15(%rbp)
mov    -0x15(%rbp),%al
test   $0x1,%al
jne    118b <PrintString+0x6b>
jmp    124c <PrintString+0x12c>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
movslq -0xc(%rbp),%rcx
lea    0x2ea1(%rip),%rax
movsbl (%rax,%rcx,1),%eax
cmp    $0x20,%eax
jne    11b2 <PrintString+0x92>
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
movslq -0xc(%rbp),%rcx
lea    0x2e83(%rip),%rax
movsbl (%rax,%rcx,1),%eax
cmp    $0xa,%eax
jne    11dd <PrintString+0xbd>
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
jmp    1239 <PrintString+0x119>
cmpl   $0x50,-0x14(%rbp)
jne    1234 <PrintString+0x114>
cmpl   $0x0,-0x10(%rbp)
jne    120c <PrintString+0xec>
movslq -0xc(%rbp),%rcx
lea    0x2e44(%rip),%rax
movb   $0xa,(%rax,%rcx,1)
movl   $0x0,-0x14(%rbp)
jmp    122f <PrintString+0x10f>
mov    -0x10(%rbp),%eax
mov    %eax,-0xc(%rbp)
movslq -0xc(%rbp),%rcx
lea    0x2e23(%rip),%rax
movb   $0xa,(%rax,%rcx,1)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
jmp    1234 <PrintString+0x114>
jmp    1239 <PrintString+0x119>
jmp    123e <PrintString+0x11e>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1151 <PrintString+0x31>
cmpl   $0x1f4,-0xc(%rbp)
jne    1268 <PrintString+0x148>
movslq -0xc(%rbp),%rcx
lea    0x2ddc(%rip),%rax
movb   $0x0,(%rax,%rcx,1)
lea    0xd91(%rip),%rdi
lea    0x2dca(%rip),%rsi
call   1040 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<PrintString>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rsi
lea    0x2f12(%rip),%r14
mov    %r14,%rdi
call   1030 <strcpy@plt>
xor    %edx,%edx
xor    %eax,%eax
xor    %ecx,%ecx
jmp    1166 <PrintString+0x46>
lea    (%r14,%rsi,1),%rcx
movslq %edi,%rdx
lea    (%r14,%rdx,1),%rdi
test   %edx,%edx
cmove  %rcx,%rdi
cmovne %edx,%esi
movb   $0xa,(%rdi)
mov    %esi,%ecx
xor    %edx,%edx
mov    %ecx,%esi
lea    0x1(%rsi),%ecx
cmp    $0x1f3,%esi
jge    118e <PrintString+0x6e>
movslq %ecx,%rsi
movzbl (%rsi,%r14,1),%ebx
test   %bl,%bl
je     119d <PrintString+0x7d>
mov    %ecx,%edi
cmp    $0x20,%bl
je     117b <PrintString+0x5b>
mov    %eax,%edi
xor    %eax,%eax
cmp    $0xa,%bl
je     1157 <PrintString+0x37>
add    $0x1,%edx
cmp    $0x50,%edx
je     113e <PrintString+0x1e>
mov    %edi,%eax
jmp    1159 <PrintString+0x39>
cmp    $0x1f4,%ecx
jne    119d <PrintString+0x7d>
movb   $0x0,0x3097(%rip)
lea    0xe5c(%rip),%rdi
lea    0x2e95(%rip),%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <printf@plt>

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

LLVM IR (-O2):
@PrintString.output = internal global [501 x i8] zeroinitializer
@.str = [4 x i8] c"%s\0A\00"
define void @PrintString(i8* %0) {
%2 = tail call i32 @strcpy(i8* getelementptr inbounds ([501 x i8], [501 x i8]* @PrintString.output, i64 0, i64 0), i8* %0)
br label %3
3: ; preds = %1, %24
%4 = phi i32 [ 0, %1 ], [ %27, %24 ]
%5 = phi i32 [ 0, %1 ], [ %26, %24 ]
%6 = phi i32 [ 0, %1 ], [ %28, %24 ]
%7 = sext i32 %6 to i64
%8 = getelementptr inbounds [501 x i8], [501 x i8]* @PrintString.output, i64 0, i64 %7
%9 = load i8, i8* %8
%10 = icmp eq i8 %9, 0
br i1 %10, label %33, label %11
11: ; preds = %3
%12 = add nsw i32 %4, 1
%13 = icmp eq i8 %9, 32
%14 = select i1 %13, i32 %6, i32 %5
%15 = icmp eq i8 %9, 10
br i1 %15, label %24, label %16
16: ; preds = %11
%17 = icmp eq i32 %12, 80
br i1 %17, label %18, label %24
18: ; preds = %16
%19 = icmp eq i32 %14, 0
%20 = sext i32 %14 to i64
%21 = getelementptr inbounds [501 x i8], [501 x i8]* @PrintString.output, i64 0, i64 %20
%22 = select i1 %19, i8* %8, i8* %21
%23 = select i1 %19, i32 %6, i32 %14
store i8 10, i8* %22
br label %24
24: ; preds = %18, %11, %16
%25 = phi i32 [ %6, %16 ], [ %6, %11 ], [ %23, %18 ]
%26 = phi i32 [ %14, %16 ], [ 0, %11 ], [ 0, %18 ]
%27 = phi i32 [ %12, %16 ], [ 0, %11 ], [ 0, %18 ]
%28 = add nsw i32 %25, 1
%29 = icmp slt i32 %25, 499
br i1 %29, label %3, label %30
30: ; preds = %24
%31 = icmp eq i32 %28, 500
br i1 %31, label %32, label %33
32: ; preds = %30
store i8 0, i8* getelementptr inbounds ([501 x i8], [501 x i8]* @PrintString.output, i64 0, i64 500)
br label %33
33: ; preds = %3, %32, %30
%34 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([501 x i8], [501 x i8]* @PrintString.output, i64 0, i64 0))
ret void
}