#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*/ strcpy(char *, char *);
int strlen(char *);
void fix_description(char *description) {
  char original_description[1024] = {0};
  int i, j = 0, w = 0, last_space = 0, last_jspace = 0;
  strcpy(original_description, description);
  for (i = 0; i < strlen(original_description); i++) {
    description[j] = original_description[i];
    if (original_description[i] == ' ') {
      last_space = i;
      last_jspace = j;
      j++;
    } else if (original_description[i] == '\n') {
      last_space = i;
      last_jspace = j;
      j++;
      description[j] = ' ';
      j++;
      w = 1;
    } else {
      j++;
    }
    w++;
    if (w > 80) {
      i = last_space;
      j = last_jspace;
      description[j] = '\n';
      j++;
      description[j] = ' ';
      j++;
      w = 1;
    }
  }
}


x86 assembly (clang, -O0):
<fix_description>:
push   %rbp
mov    %rsp,%rbp
sub    $0x430,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x410(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1050 <memset@plt>
movl   $0x0,-0x418(%rbp)
movl   $0x0,-0x41c(%rbp)
movl   $0x0,-0x420(%rbp)
movl   $0x0,-0x424(%rbp)
lea    -0x410(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <strcpy@plt>
movl   $0x0,-0x414(%rbp)
mov    -0x414(%rbp),%eax
mov    %eax,-0x428(%rbp)
lea    -0x410(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x428(%rbp),%eax
cmp    %ecx,%eax
jge    132f <fix_description+0x1ff>
movslq -0x414(%rbp),%rax
mov    -0x410(%rbp,%rax,1),%dl
mov    -0x8(%rbp),%rax
movslq -0x418(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
movslq -0x414(%rbp),%rax
movsbl -0x410(%rbp,%rax,1),%eax
ff
cmp    $0x20,%eax
jne    121c <fix_description+0xec>
mov    -0x414(%rbp),%eax
mov    %eax,-0x420(%rbp)
mov    -0x418(%rbp),%eax
mov    %eax,-0x424(%rbp)
mov    -0x418(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x418(%rbp)
jmp    129c <fix_description+0x16c>
movslq -0x414(%rbp),%rax
movsbl -0x410(%rbp,%rax,1),%eax
ff
cmp    $0xa,%eax
jne    1288 <fix_description+0x158>
mov    -0x414(%rbp),%eax
mov    %eax,-0x420(%rbp)
mov    -0x418(%rbp),%eax
mov    %eax,-0x424(%rbp)
mov    -0x418(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x418(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x418(%rbp),%rcx
movb   $0x20,(%rax,%rcx,1)
mov    -0x418(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x418(%rbp)
movl   $0x1,-0x41c(%rbp)
jmp    1297 <fix_description+0x167>
mov    -0x418(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x418(%rbp)
jmp    129c <fix_description+0x16c>
mov    -0x41c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x41c(%rbp)
cmpl   $0x50,-0x41c(%rbp)
jle    1316 <fix_description+0x1e6>
mov    -0x420(%rbp),%eax
mov    %eax,-0x414(%rbp)
mov    -0x424(%rbp),%eax
mov    %eax,-0x418(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x418(%rbp),%rcx
movb   $0xa,(%rax,%rcx,1)
mov    -0x418(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x418(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x418(%rbp),%rcx
movb   $0x20,(%rax,%rcx,1)
mov    -0x418(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x418(%rbp)
movl   $0x1,-0x41c(%rbp)
jmp    131b <fix_description+0x1eb>
mov    -0x414(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x414(%rbp)
jmp    1194 <fix_description+0x64>
add    $0x430,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fix_description>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x418,%rsp
mov    %rdi,%rbp
lea    0x10(%rsp),%rbx
xor    %r14d,%r14d
mov    $0x400,%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1050 <memset@plt>
mov    %rbx,%rdi
mov    %rbp,0x8(%rsp)
mov    %rbp,%rsi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
test   %eax,%eax
jle    1215 <fix_description+0xe5>
xor    %ecx,%ecx
xor    %r12d,%r12d
xor    %ebx,%ebx
xor    %ebp,%ebp
jmp    11c2 <fix_description+0x92>
cs nopw 0x0(%rax,%rax,1)
mov    $0x2,%r12d
mov    %ebx,%r15d
mov    %ebp,%r13d
movslq %ebx,%rbx
movb   $0x20,0x1(%rsi,%rbx,1)
add    $0x1,%rbx
add    $0x1,%ebx
add    $0x1,%ebp
lea    0x10(%rsp),%rdi
call   1040 <strlen@plt>
mov    %r15d,%r14d
mov    %r13d,%ecx
cmp    %eax,%ebp
jge    1215 <fix_description+0xe5>
movslq %ebp,%rax
movzbl 0x10(%rsp,%rax,1),%eax
movslq %ebx,%rdx
mov    0x8(%rsp),%rsi
mov    %al,(%rsi,%rdx,1)
cmp    $0xa,%al
je     1190 <fix_description+0x60>
mov    %ebp,%r13d
mov    %ebx,%r15d
cmp    $0x20,%al
je     11e9 <fix_description+0xb9>
mov    %ecx,%r13d
mov    %r14d,%r15d
cmp    $0x50,%r12d
jge    1200 <fix_description+0xd0>
add    $0x1,%r12d
jmp    11a8 <fix_description+0x78>
cs nopw 0x0(%rax,%rax,1)
nop
movslq %r15d,%rax
movb   $0xa,(%rsi,%rax,1)
mov    $0x1,%r12d
mov    %r15d,%ebx
mov    %r13d,%ebp
jmp    119c <fix_description+0x6c>
add    $0x418,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @fix_description(i8* %0) {
%2 = alloca [1024 x i8]
%3 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%4 = call i32 @strcpy(i8* %3, i8* %0)
%5 = call i32 @strlen(i8* %3)
%6 = icmp sgt i32 %5, 0
br i1 %6, label %7, label %44
7: ; preds = %1, %34
%8 = phi i32 [ %35, %34 ], [ 0, %1 ]
%9 = phi i32 [ %36, %34 ], [ 0, %1 ]
%10 = phi i32 [ %39, %34 ], [ 0, %1 ]
%11 = phi i32 [ %40, %34 ], [ 0, %1 ]
%12 = phi i32 [ %41, %34 ], [ 0, %1 ]
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 %13
%15 = load i8, i8* %14
%16 = sext i32 %11 to i64
%17 = getelementptr inbounds i8, i8* %0, i64 %16
store i8 %15, i8* %17
switch i8 %15, label %18 [
i8 32, label %19
i8 10, label %27
]
18: ; preds = %7
br label %19
19: ; preds = %7, %18
%20 = phi i32 [ %9, %18 ], [ %12, %7 ]
%21 = phi i32 [ %8, %18 ], [ %11, %7 ]
%22 = add nsw i32 %10, 1
%23 = icmp sgt i32 %10, 79
br i1 %23, label %24, label %34
24: ; preds = %19
%25 = sext i32 %21 to i64
%26 = getelementptr inbounds i8, i8* %0, i64 %25
store i8 10, i8* %26
br label %27
27: ; preds = %7, %24
%28 = phi i32 [ %21, %24 ], [ %11, %7 ]
%29 = phi i32 [ %20, %24 ], [ %12, %7 ]
%30 = phi i32 [ 1, %24 ], [ 2, %7 ]
%31 = add nsw i32 %28, 1
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i8, i8* %0, i64 %32
store i8 32, i8* %33
br label %34
34: ; preds = %27, %19
%35 = phi i32 [ %21, %19 ], [ %28, %27 ]
%36 = phi i32 [ %20, %19 ], [ %29, %27 ]
%37 = phi i32 [ %12, %19 ], [ %29, %27 ]
%38 = phi i32 [ %11, %19 ], [ %31, %27 ]
%39 = phi i32 [ %22, %19 ], [ %30, %27 ]
%40 = add nsw i32 %38, 1
%41 = add nsw i32 %37, 1
%42 = call i32 @strlen(i8* %3)
%43 = icmp slt i32 %41, %42
br i1 %43, label %7, label %44
44: ; preds = %34, %1
ret void
}