#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 *);
char *indent(char const *);
int linecount(char const *);
char *savefmt(char *, char const *, char const *, char const *);
int strlen(char const *);
char *wrapit(const char *pfx, const char *s, const char *sfx) {
  char *out;
  if (linecount(s) > 1 || strlen(pfx) + strlen(s) + strlen(sfx) > 60) {
    char *ind = indent(s);
    out = savefmt("%s\n%s\n%s", pfx, ind, sfx);
    free(ind);
  } else {
    out = savefmt("%s %s %s", pfx, s, sfx);
  }
  return out;
}


x86 assembly (clang, -O0):
<wrapit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <linecount@plt>
cmp    $0x1,%eax
jg     11ae <wrapit+0x5e>
mov    -0x8(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x2c(%rbp),%eax
add    %ecx,%eax
cmp    $0x3c,%eax
jle    11e5 <wrapit+0x95>
mov    -0x10(%rbp),%rdi
call   1060 <indent@plt>
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rsi
mov    -0x28(%rbp),%rdx
mov    -0x18(%rbp),%rcx
lea    0xe32(%rip),%rdi
call   1070 <savefmt@plt>
mov    %rax,-0x20(%rbp)
mov    -0x28(%rbp),%rdi
call   1040 <free@plt>
jmp    1201 <wrapit+0xb1>
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rcx
lea    0xe11(%rip),%rdi
call   1070 <savefmt@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<wrapit>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %rdi,%r15
mov    %rsi,%rdi
call   1030 <linecount@plt>
cmp    $0x1,%eax
jg     1195 <wrapit+0x45>
mov    %r15,%rdi
call   1050 <strlen@plt>
mov    %eax,%r12d
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %eax,%ebp
add    %r12d,%ebp
mov    %r14,%rdi
call   1050 <strlen@plt>
add    %ebp,%eax
cmp    $0x3d,%eax
jl     11cc <wrapit+0x7c>
mov    %rbx,%rdi
call   1060 <indent@plt>
mov    %rax,%rbx
lea    0xe59(%rip),%rdi
mov    %r15,%rsi
mov    %rax,%rdx
mov    %r14,%rcx
call   1070 <savefmt@plt>
mov    %rax,%rbp
mov    %rbx,%rdi
call   1040 <free@plt>
mov    %rbp,%rax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe36(%rip),%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
mov    %r14,%rcx
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1070 <savefmt@plt>

LLVM IR (-O0):
@.str = [9 x i8] c"%s\0A%s\0A%s\00"
@.str.1 = [9 x i8] c"%s %s %s\00"
define i8* @wrapit(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%9 = load i8*, i8** %5
%10 = call i32 @linecount(i8* %9)
%11 = icmp sgt i32 %10, 1
br i1 %11, label %22, label %12
12: ; preds = %3
%13 = load i8*, i8** %4
%14 = call i32 @strlen(i8* %13)
%15 = load i8*, i8** %5
%16 = call i32 @strlen(i8* %15)
%17 = add nsw i32 %14, %16
%18 = load i8*, i8** %6
%19 = call i32 @strlen(i8* %18)
%20 = add nsw i32 %17, %19
%21 = icmp sgt i32 %20, 60
br i1 %21, label %22, label %31
22: ; preds = %12, %3
%23 = load i8*, i8** %5
%24 = call i8* @indent(i8* %23)
store i8* %24, i8** %8
%25 = load i8*, i8** %4
%26 = load i8*, i8** %8
%27 = load i8*, i8** %6
%28 = call i8* @savefmt(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %25, i8* %26, i8* %27)
store i8* %28, i8** %7
%29 = load i8*, i8** %8
%30 = call i32 @free(i8* %29)
br label %36
31: ; preds = %12
%32 = load i8*, i8** %4
%33 = load i8*, i8** %5
%34 = load i8*, i8** %6
%35 = call i8* @savefmt(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* %32, i8* %33, i8* %34)
store i8* %35, i8** %7
br label %36
36: ; preds = %31, %22
%37 = load i8*, i8** %7
ret i8* %37
}

LLVM IR (-O2):
@.str = [9 x i8] c"%s\0A%s\0A%s\00"
@.str.1 = [9 x i8] c"%s %s %s\00"
define i8* @wrapit(i8* %0, i8* %1, i8* %2) {
%4 = tail call i32 @linecount(i8* %1)
%5 = icmp sgt i32 %4, 1
br i1 %5, label %13, label %6
6: ; preds = %3
%7 = tail call i32 @strlen(i8* %0)
%8 = tail call i32 @strlen(i8* %1)
%9 = add nsw i32 %8, %7
%10 = tail call i32 @strlen(i8* %2)
%11 = add nsw i32 %9, %10
%12 = icmp sgt i32 %11, 60
br i1 %12, label %13, label %17
13: ; preds = %6, %3
%14 = tail call i8* @indent(i8* %1)
%15 = tail call i8* @savefmt(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %14, i8* %2)
%16 = tail call i32 @free(i8* %14)
br label %19
17: ; preds = %6
%18 = tail call i8* @savefmt(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* %0, i8* %1, i8* %2)
br label %19
19: ; preds = %17, %13
%20 = phi i8* [ %15, %13 ], [ %18, %17 ]
ret i8* %20
}