#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*/ free(char *);
scalar_t__ malloc(int);
int /*<<< orphan*/ memset(char *, char, int);
int /*<<< orphan*/ sprintf(char *, char *, ...);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
char *strrchr(char *, char);
void wrapLines(char *msg, int msgSize) {
  char *indentedLineSpacing = (char *)malloc(32);
  memset(indentedLineSpacing, ' ', 32);
  indentedLineSpacing[30] = '\t';
  indentedLineSpacing[31] = 0;
  int i;
  char tempBuf[msgSize];
  memset(tempBuf, 0, msgSize);
  int lineFeedSize = 80;
  strncpy(tempBuf, msg, lineFeedSize);
  for (i = lineFeedSize; i < strlen(msg); i += lineFeedSize) {
    if (strlen(msg + i) + strlen(indentedLineSpacing) > 80) {
      char *returnPos = strrchr(tempBuf, ' ');
      returnPos[0] = '\n';
      char wrapText[255];
      strcpy(wrapText, returnPos + 1);
      sprintf(returnPos + 1, "%s%s", indentedLineSpacing, wrapText);
      lineFeedSize = (strlen(msg + i) < 80 ? strlen(msg + i) : 80) -
                     strlen(indentedLineSpacing) - strlen(wrapText);
      strncpy(returnPos + strlen(returnPos), msg + i, lineFeedSize);
    } else if (strlen(strrchr(tempBuf, '\n')) + strlen(msg + i) > 80) {
      char *returnPos = strrchr(tempBuf, ' ');
      returnPos[0] = '\n';
      char wrapText[255];
      strcpy(wrapText, returnPos + 1);
      sprintf(returnPos + 1, "%s%s", indentedLineSpacing, wrapText);
      strncpy(returnPos + strlen(returnPos), msg + i, strlen(msg + i));
    } else {
      strncpy(tempBuf + strlen(tempBuf), msg + i, strlen(msg + i));
    }
  }
  strncpy(msg, tempBuf, msgSize);
  if (msg[strlen(msg) - 1] != '\n') {
    sprintf(msg + strlen(msg), "\n");
  }
  free(indentedLineSpacing);
}


x86 assembly (clang, -O0):
<wrapLines>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2c0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    $0x20,%edi
mov    %edi,-0x25c(%rbp)
call   1090 <malloc@plt>
mov    -0x25c(%rbp),%edx
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    %edx,%esi
call   1080 <memset@plt>
mov    -0x18(%rbp),%rax
movb   $0x9,0x1e(%rax)
mov    -0x18(%rbp),%rax
movb   $0x0,0x1f(%rax)
mov    -0xc(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x28(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x258(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x30(%rbp)
mov    -0xc(%rbp),%edx
xor    %esi,%esi
call   1080 <memset@plt>
mov    -0x258(%rbp),%rdi
movl   $0x50,-0x34(%rbp)
mov    -0x8(%rbp),%rsi
mov    -0x34(%rbp),%edx
call   1040 <strncpy@plt>
mov    -0x34(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x260(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,%ecx
mov    -0x260(%rbp),%eax
cmp    %ecx,%eax
jge    14f5 <wrapLines+0x375>
mov    -0x8(%rbp),%rdi
movslq -0x1c(%rbp),%rax
add    %rax,%rdi
call   1060 <strlen@plt>
mov    %eax,-0x264(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,%ecx
mov    -0x264(%rbp),%eax
add    %ecx,%eax
cmp    $0x50,%eax
jle    1379 <wrapLines+0x1f9>
mov    -0x258(%rbp),%rdi
mov    $0x20,%esi
call   1070 <strrchr@plt>
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rax
movb   $0xa,(%rax)
lea    -0x140(%rbp),%rdi
mov    -0x40(%rbp),%rsi
add    $0x1,%rsi
call   1050 <strcpy@plt>
mov    -0x40(%rbp),%rdi
add    $0x1,%rdi
mov    -0x18(%rbp),%rdx
lea    -0x140(%rbp),%rcx
lea    0xd48(%rip),%rsi
mov    $0x0,%al
call   10a0 <sprintf@plt>
mov    -0x8(%rbp),%rdi
movslq -0x1c(%rbp),%rax
add    %rax,%rdi
call   1060 <strlen@plt>
cmp    $0x50,%eax
jge    12f3 <wrapLines+0x173>
mov    -0x8(%rbp),%rdi
movslq -0x1c(%rbp),%rax
add    %rax,%rdi
call   1060 <strlen@plt>
mov    %eax,-0x268(%rbp)
jmp    1303 <wrapLines+0x183>
mov    $0x50,%eax
mov    %eax,-0x268(%rbp)
jmp    1303 <wrapLines+0x183>
mov    -0x268(%rbp),%eax
mov    %eax,-0x278(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,%ecx
mov    -0x278(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x274(%rbp)
lea    -0x140(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,%ecx
mov    -0x274(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x34(%rbp)
mov    -0x40(%rbp),%rax
mov    %rax,-0x270(%rbp)
mov    -0x40(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0x270(%rbp),%rdi
cltq
add    %rax,%rdi
mov    -0x8(%rbp),%rsi
movslq -0x1c(%rbp),%rax
add    %rax,%rsi
mov    -0x34(%rbp),%edx
call   1040 <strncpy@plt>
jmp    14e2 <wrapLines+0x362>
mov    -0x258(%rbp),%rdi
mov    $0xa,%esi
call   1070 <strrchr@plt>
mov    %rax,%rdi
call   1060 <strlen@plt>
mov    %eax,-0x27c(%rbp)
mov    -0x8(%rbp),%rdi
movslq -0x1c(%rbp),%rax
add    %rax,%rdi
call   1060 <strlen@plt>
mov    %eax,%ecx
mov    -0x27c(%rbp),%eax
add    %ecx,%eax
cmp    $0x50,%eax
jle    1484 <wrapLines+0x304>
mov    -0x258(%rbp),%rdi
mov    $0x20,%esi
call   1070 <strrchr@plt>
mov    %rax,-0x148(%rbp)
mov    -0x148(%rbp),%rax
movb   $0xa,(%rax)
lea    -0x250(%rbp),%rdi
mov    -0x148(%rbp),%rsi
add    $0x1,%rsi
call   1050 <strcpy@plt>
mov    -0x148(%rbp),%rdi
add    $0x1,%rdi
mov    -0x18(%rbp),%rdx
lea    -0x250(%rbp),%rcx
lea    0xbef(%rip),%rsi
mov    $0x0,%al
call   10a0 <sprintf@plt>
mov    -0x148(%rbp),%rax
mov    %rax,-0x298(%rbp)
mov    -0x148(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,%ecx
mov    -0x298(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x290(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x288(%rbp)
mov    -0x8(%rbp),%rdi
movslq -0x1c(%rbp),%rax
add    %rax,%rdi
call   1060 <strlen@plt>
mov    -0x290(%rbp),%rdi
mov    -0x288(%rbp),%rsi
mov    %eax,%edx
call   1040 <strncpy@plt>
jmp    14dd <wrapLines+0x35d>
mov    -0x258(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,%ecx
mov    -0x258(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x2a8(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x2a0(%rbp)
mov    -0x8(%rbp),%rdi
movslq -0x1c(%rbp),%rax
add    %rax,%rdi
call   1060 <strlen@plt>
mov    -0x2a8(%rbp),%rdi
mov    -0x2a0(%rbp),%rsi
mov    %eax,%edx
call   1040 <strncpy@plt>
jmp    14e2 <wrapLines+0x362>
jmp    14e7 <wrapLines+0x367>
mov    -0x34(%rbp),%eax
add    -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
jmp    121a <wrapLines+0x9a>
mov    -0x258(%rbp),%rsi
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%edx
call   1040 <strncpy@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x2b0(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,%ecx
mov    -0x2b0(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0xa,%eax
je     1566 <wrapLines+0x3e6>
mov    -0x8(%rbp),%rax
mov    %rax,-0x2b8(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0x2b8(%rbp),%rdi
cltq
add    %rax,%rdi
lea    0xaa6(%rip),%rsi
mov    $0x0,%al
call   10a0 <sprintf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<wrapLines>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x128,%rsp
mov    %esi,%r15d
mov    %rdi,%r12
mov    $0x20,%edi
call   1090 <malloc@plt>
mov    %rax,%r14
mov    %rax,%rdi
mov    $0x20,%esi
mov    $0x20,%edx
call   1080 <memset@plt>
movw   $0x9,0x1e(%r14)
mov    %r15d,%eax
mov    %rsp,%rbx
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
mov    %rbx,%rdi
xor    %esi,%esi
mov    %r15d,-0x3c(%rbp)
mov    %r15d,%edx
call   1080 <memset@plt>
mov    $0x50,%r15d
mov    %rbx,%rdi
mov    %r12,%rsi
mov    $0x50,%edx
call   1040 <strncpy@plt>
mov    %r12,-0x38(%rbp)
mov    %r12,%rdi
mov    %r14,%r12
mov    %rbx,%r14
call   1060 <strlen@plt>
cmp    $0x51,%eax
jl     13cb <wrapLines+0x24b>
mov    $0x50,%ebx
mov    %r14,-0x48(%rbp)
mov    %r12,-0x50(%rbp)
jmp    1285 <wrapLines+0x105>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r12,%rdi
call   1060 <strlen@plt>
mov    %ebx,%r12d
mov    %eax,%ebx
lea    -0x150(%rbp),%rdi
call   1060 <strlen@plt>
add    %ebx,%eax
mov    %r12d,%ebx
sub    %eax,%ebx
mov    %r14,%rdi
call   1060 <strlen@plt>
movslq %eax,%rdi
add    %r14,%rdi
mov    %r13,%rsi
mov    %ebx,%edx
call   1040 <strncpy@plt>
mov    -0x50(%rbp),%r12
mov    -0x48(%rbp),%r14
add    %ebx,%r15d
mov    -0x38(%rbp),%rdi
call   1060 <strlen@plt>
cmp    %eax,%r15d
jge    13cb <wrapLines+0x24b>
mov    %ebx,-0x2c(%rbp)
movslq %r15d,%r13
add    -0x38(%rbp),%r13
mov    %r13,%rdi
call   1060 <strlen@plt>
mov    %eax,%ebx
mov    %r12,%rdi
call   1060 <strlen@plt>
add    %ebx,%eax
cmp    $0x51,%eax
jl     1310 <wrapLines+0x190>
mov    %r14,%rdi
mov    $0x20,%esi
call   1070 <strrchr@plt>
mov    %rax,%r14
movb   $0xa,(%rax)
lea    0x1(%rax),%rbx
lea    -0x150(%rbp),%rdi
mov    %rbx,%rsi
call   1050 <strcpy@plt>
mov    %rbx,%rdi
lea    0xd28(%rip),%rsi
mov    %r12,%rdx
lea    -0x150(%rbp),%rcx
xor    %eax,%eax
call   10a0 <sprintf@plt>
mov    %r13,%rdi
call   1060 <strlen@plt>
mov    $0x50,%ebx
cmp    $0x4f,%eax
jg     1230 <wrapLines+0xb0>
mov    %r13,%rdi
call   1060 <strlen@plt>
mov    %eax,%ebx
jmp    1230 <wrapLines+0xb0>
xchg   %ax,%ax
mov    %r14,%rdi
mov    $0xa,%esi
call   1070 <strrchr@plt>
mov    %rax,%rdi
call   1060 <strlen@plt>
mov    %eax,%ebx
mov    %r13,%rdi
call   1060 <strlen@plt>
add    %ebx,%eax
cmp    $0x51,%eax
jl     13a0 <wrapLines+0x220>
mov    %r14,%rdi
mov    $0x20,%esi
call   1070 <strrchr@plt>
mov    %r12,%rbx
mov    %rax,%r12
movb   $0xa,(%rax)
lea    0x1(%rax),%r14
lea    -0x150(%rbp),%rdi
mov    %r14,%rsi
call   1050 <strcpy@plt>
mov    %r14,%rdi
mov    %rbx,%r14
lea    0xc94(%rip),%rsi
mov    %rbx,%rdx
lea    -0x150(%rbp),%rcx
xor    %eax,%eax
call   10a0 <sprintf@plt>
mov    %r12,%rdi
call   1060 <strlen@plt>
movslq %eax,%rbx
add    %r12,%rbx
mov    %r14,%r12
mov    -0x48(%rbp),%r14
jmp    13ae <wrapLines+0x22e>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r14,%rdi
call   1060 <strlen@plt>
movslq %eax,%rbx
add    %r14,%rbx
mov    %r13,%rdi
call   1060 <strlen@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
mov    %eax,%edx
call   1040 <strncpy@plt>
mov    -0x2c(%rbp),%ebx
jmp    1270 <wrapLines+0xf0>
mov    -0x38(%rbp),%rbx
mov    %rbx,%rdi
mov    %r14,%rsi
mov    -0x3c(%rbp),%edx
call   1040 <strncpy@plt>
mov    %rbx,%rdi
call   1060 <strlen@plt>
cltq
cmpb   $0xa,-0x1(%rax,%rbx,1)
je     1402 <wrapLines+0x282>
mov    -0x38(%rbp),%rbx
mov    %rbx,%rdi
call   1060 <strlen@plt>
cltq
movw   $0xa,(%rbx,%rax,1)
mov    %r12,%rdi
call   1030 <free@plt>
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"%s%s\00"
@.str.1 = [2 x i8] c"\0A\00"
define void @wrapLines(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i32
%10 = alloca i8*
%11 = alloca [255 x i8]
%12 = alloca i8*
%13 = alloca [255 x i8]
store i8* %0, i8** %3
store i32 %1, i32* %4
%14 = call i64 @malloc(i32 32)
%15 = inttoptr i64 %14 to i8*
store i8* %15, i8** %5
%16 = load i8*, i8** %5
%17 = call i32 @memset(i8* %16, i8 signext 32, i32 32)
%18 = load i8*, i8** %5
%19 = getelementptr inbounds i8, i8* %18, i64 30
store i8 9, i8* %19
%20 = load i8*, i8** %5
%21 = getelementptr inbounds i8, i8* %20, i64 31
store i8 0, i8* %21
%22 = load i32, i32* %4
%23 = zext i32 %22 to i64
%24 = call i8* @llvm.stacksave()
store i8* %24, i8** %7
%25 = alloca i8, i64 %23
store i64 %23, i64* %8
%26 = load i32, i32* %4
%27 = call i32 @memset(i8* %25, i8 signext 0, i32 %26)
store i32 80, i32* %9
%28 = load i8*, i8** %3
%29 = load i32, i32* %9
%30 = call i32 @strncpy(i8* %25, i8* %28, i32 %29)
%31 = load i32, i32* %9
store i32 %31, i32* %6
br label %32
32: ; preds = %146, %2
%33 = load i32, i32* %6
%34 = load i8*, i8** %3
%35 = call i32 @strlen(i8* %34)
%36 = icmp slt i32 %33, %35
br i1 %36, label %37, label %150
37: ; preds = %32
%38 = load i8*, i8** %3
%39 = load i32, i32* %6
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i8, i8* %38, i64 %40
%42 = call i32 @strlen(i8* %41)
%43 = load i8*, i8** %5
%44 = call i32 @strlen(i8* %43)
%45 = add nsw i32 %42, %44
%46 = icmp sgt i32 %45, 80
br i1 %46, label %47, label %92
47: ; preds = %37
%48 = call i8* @strrchr(i8* %25, i8 signext 32)
store i8* %48, i8** %10
%49 = load i8*, i8** %10
%50 = getelementptr inbounds i8, i8* %49, i64 0
store i8 10, i8* %50
%51 = getelementptr inbounds [255 x i8], [255 x i8]* %11, i64 0, i64 0
%52 = load i8*, i8** %10
%53 = getelementptr inbounds i8, i8* %52, i64 1
%54 = call i32 @strcpy(i8* %51, i8* %53)
%55 = load i8*, i8** %10
%56 = getelementptr inbounds i8, i8* %55, i64 1
%57 = load i8*, i8** %5
%58 = getelementptr inbounds [255 x i8], [255 x i8]* %11, i64 0, i64 0
%59 = call i32 (i8*, i8*, ...) @sprintf(i8* %56, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %57, i8* %58)
%60 = load i8*, i8** %3
%61 = load i32, i32* %6
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds i8, i8* %60, i64 %62
%64 = call i32 @strlen(i8* %63)
%65 = icmp slt i32 %64, 80
br i1 %65, label %66, label %72
66: ; preds = %47
%67 = load i8*, i8** %3
%68 = load i32, i32* %6
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds i8, i8* %67, i64 %69
%71 = call i32 @strlen(i8* %70)
br label %73
72: ; preds = %47
br label %73
73: ; preds = %72, %66
%74 = phi i32 [ %71, %66 ], [ 80, %72 ]
%75 = load i8*, i8** %5
%76 = call i32 @strlen(i8* %75)
%77 = sub nsw i32 %74, %76
%78 = getelementptr inbounds [255 x i8], [255 x i8]* %11, i64 0, i64 0
%79 = call i32 @strlen(i8* %78)
%80 = sub nsw i32 %77, %79
store i32 %80, i32* %9
%81 = load i8*, i8** %10
%82 = load i8*, i8** %10
%83 = call i32 @strlen(i8* %82)
%84 = sext i32 %83 to i64
%85 = getelementptr inbounds i8, i8* %81, i64 %84
%86 = load i8*, i8** %3
%87 = load i32, i32* %6
%88 = sext i32 %87 to i64
%89 = getelementptr inbounds i8, i8* %86, i64 %88
%90 = load i32, i32* %9
%91 = call i32 @strncpy(i8* %85, i8* %89, i32 %90)
br label %145
92: ; preds = %37
%93 = call i8* @strrchr(i8* %25, i8 signext 10)
%94 = call i32 @strlen(i8* %93)
%95 = load i8*, i8** %3
%96 = load i32, i32* %6
%97 = sext i32 %96 to i64
%98 = getelementptr inbounds i8, i8* %95, i64 %97
%99 = call i32 @strlen(i8* %98)
%100 = add nsw i32 %94, %99
%101 = icmp sgt i32 %100, 80
br i1 %101, label %102, label %130
102: ; preds = %92
%103 = call i8* @strrchr(i8* %25, i8 signext 32)
store i8* %103, i8** %12
%104 = load i8*, i8** %12
%105 = getelementptr inbounds i8, i8* %104, i64 0
store i8 10, i8* %105
%106 = getelementptr inbounds [255 x i8], [255 x i8]* %13, i64 0, i64 0
%107 = load i8*, i8** %12
%108 = getelementptr inbounds i8, i8* %107, i64 1
%109 = call i32 @strcpy(i8* %106, i8* %108)
%110 = load i8*, i8** %12
%111 = getelementptr inbounds i8, i8* %110, i64 1
%112 = load i8*, i8** %5
%113 = getelementptr inbounds [255 x i8], [255 x i8]* %13, i64 0, i64 0
%114 = call i32 (i8*, i8*, ...) @sprintf(i8* %111, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %112, i8* %113)
%115 = load i8*, i8** %12
%116 = load i8*, i8** %12
%117 = call i32 @strlen(i8* %116)
%118 = sext i32 %117 to i64
%119 = getelementptr inbounds i8, i8* %115, i64 %118
%120 = load i8*, i8** %3
%121 = load i32, i32* %6
%122 = sext i32 %121 to i64
%123 = getelementptr inbounds i8, i8* %120, i64 %122
%124 = load i8*, i8** %3
%125 = load i32, i32* %6
%126 = sext i32 %125 to i64
%127 = getelementptr inbounds i8, i8* %124, i64 %126
%128 = call i32 @strlen(i8* %127)
%129 = call i32 @strncpy(i8* %119, i8* %123, i32 %128)
br label %144
130: ; preds = %92
%131 = call i32 @strlen(i8* %25)
%132 = sext i32 %131 to i64
%133 = getelementptr inbounds i8, i8* %25, i64 %132
%134 = load i8*, i8** %3
%135 = load i32, i32* %6
%136 = sext i32 %135 to i64
%137 = getelementptr inbounds i8, i8* %134, i64 %136
%138 = load i8*, i8** %3
%139 = load i32, i32* %6
%140 = sext i32 %139 to i64
%141 = getelementptr inbounds i8, i8* %138, i64 %140
%142 = call i32 @strlen(i8* %141)
%143 = call i32 @strncpy(i8* %133, i8* %137, i32 %142)
br label %144
144: ; preds = %130, %102
br label %145
145: ; preds = %144, %73
br label %146
146: ; preds = %145
%147 = load i32, i32* %9
%148 = load i32, i32* %6
%149 = add nsw i32 %148, %147
store i32 %149, i32* %6
br label %32
150: ; preds = %32
%151 = load i8*, i8** %3
%152 = load i32, i32* %4
%153 = call i32 @strncpy(i8* %151, i8* %25, i32 %152)
%154 = load i8*, i8** %3
%155 = load i8*, i8** %3
%156 = call i32 @strlen(i8* %155)
%157 = sub nsw i32 %156, 1
%158 = sext i32 %157 to i64
%159 = getelementptr inbounds i8, i8* %154, i64 %158
%160 = load i8, i8* %159
%161 = sext i8 %160 to i32
%162 = icmp ne i32 %161, 10
br i1 %162, label %163, label %170
163: ; preds = %150
%164 = load i8*, i8** %3
%165 = load i8*, i8** %3
%166 = call i32 @strlen(i8* %165)
%167 = sext i32 %166 to i64
%168 = getelementptr inbounds i8, i8* %164, i64 %167
%169 = call i32 (i8*, i8*, ...) @sprintf(i8* %168, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %170
170: ; preds = %163, %150
%171 = load i8*, i8** %5
%172 = call i32 @free(i8* %171)
%173 = load i8*, i8** %7
ret void
}

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