#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 */
size_t __tractorbeam_strlen1(char const *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ strcmp(char *, char *);
scalar_t__ strlen(char *);
char *strtok(char *, char *);
char *tbh_strdup(char const *);
void __printf_indent(const char *a, const char *b, size_t maxlen) {
  char *tmp = tbh_strdup(b);
  char *delim = " ";
  char *token = NULL;
  size_t prefix = __tractorbeam_strlen1(a);
  size_t at = 0;
  printf("\n%s", a);
  token = strtok(tmp, delim);
  do {
    at += strlen(token);
    if ((at + prefix > maxlen) || (strcmp("\n", token) == 0)) {
      at = prefix;
      printf("\n");
      while (at-- > 0) {
        printf(delim);
      }
      at = 0;
    }
    if (strcmp("\n", token) != 0) {
      printf("%s ", token);
    }
  } while ((token = strtok(NULL, delim)) != NULL);
  printf("\n");
  free(tmp);
}


x86 assembly (clang, -O0):
<__printf_indent>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1080 <tbh_strdup@plt>
mov    %rax,-0x20(%rbp)
lea    0xe70(%rip),%rax
mov    %rax,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
mov    -0x8(%rbp),%rdi
call   1070 <__tractorbeam_strlen1@plt>
mov    %rax,-0x38(%rbp)
movq   $0x0,-0x40(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xe3c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1090 <strtok@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
call   1040 <strlen@plt>
add    -0x40(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rax
add    -0x38(%rbp),%rax
cmp    -0x18(%rbp),%rax
ja     1219 <__printf_indent+0xa9>
mov    -0x30(%rbp),%rsi
lea    0xdfa(%rip),%rdi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    1260 <__printf_indent+0xf0>
mov    -0x38(%rbp),%rax
mov    %rax,-0x40(%rbp)
lea    0xddc(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x40(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x40(%rbp)
cmp    $0x0,%rax
jbe    1258 <__printf_indent+0xe8>
mov    -0x28(%rbp),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    122f <__printf_indent+0xbf>
movq   $0x0,-0x40(%rbp)
mov    -0x30(%rbp),%rsi
lea    0xd99(%rip),%rdi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
je     128c <__printf_indent+0x11c>
mov    -0x30(%rbp),%rsi
lea    0xd81(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1291 <__printf_indent+0x121>
mov    -0x28(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edi
call   1090 <strtok@plt>
mov    %rax,-0x30(%rbp)
cmp    $0x0,%rax
jne    11dc <__printf_indent+0x6c>
lea    0xd51(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__printf_indent>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r15
mov    %rdi,%rbp
mov    %rsi,%rdi
call   1090 <tbh_strdup@plt>
mov    %rax,%r14
mov    %rbp,%rdi
call   1080 <__tractorbeam_strlen1@plt>
mov    %rax,%rbx
lea    0xe52(%rip),%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe49(%rip),%rsi
mov    %r14,(%rsp)
mov    %r14,%rdi
call   10a0 <strtok@plt>
mov    %rax,%r14
lea    0xe2f(%rip),%r13
xor    %ebp,%ebp
jmp    11fa <__printf_indent+0x7a>
nopl   0x0(%rax)
xor    %edi,%edi
lea    0xe1f(%rip),%rsi
call   10a0 <strtok@plt>
mov    %rax,%r14
test   %rax,%rax
je     127c <__printf_indent+0xfc>
mov    %rbp,%r12
mov    %r14,%rdi
call   1050 <strlen@plt>
mov    %rax,%rbp
add    %r12,%rbp
lea    (%rbx,%rbp,1),%rax
cmp    %r15,%rax
ja     1224 <__printf_indent+0xa4>
mov    %r13,%rdi
mov    %r14,%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
jne    1252 <__printf_indent+0xd2>
mov    $0xa,%edi
call   1040 <putchar@plt>
test   %rbx,%rbx
je     1250 <__printf_indent+0xd0>
mov    %rbx,%rbp
cs nopw 0x0(%rax,%rax,1)
mov    $0x20,%edi
call   1040 <putchar@plt>
add    $0xffffffffffffffff,%rbp
jne    1240 <__printf_indent+0xc0>
xor    %ebp,%ebp
mov    %r13,%rdi
mov    %r14,%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
je     11e0 <__printf_indent+0x60>
lea    0xd99(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    11e0 <__printf_indent+0x60>
mov    $0xa,%edi
call   1040 <putchar@plt>
mov    (%rsp),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>

LLVM IR (-O0):
@.str = [2 x i8] c" \00"
@.str.1 = [4 x i8] c"\0A%s\00"
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [4 x i8] c"%s \00"
define void @__printf_indent(i8* %0, i8* %1, i64 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i64
%11 = alloca i64
store i8* %0, i8** %4
store i8* %1, i8** %5
store i64 %2, i64* %6
%12 = load i8*, i8** %5
%13 = call i8* @tbh_strdup(i8* %12)
store i8* %13, i8** %7
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8** %8
store i8* null, i8** %9
%14 = load i8*, i8** %4
%15 = call i64 @__tractorbeam_strlen1(i8* %14)
store i64 %15, i64* %10
store i64 0, i64* %11
%16 = load i8*, i8** %4
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %16)
%18 = load i8*, i8** %7
%19 = load i8*, i8** %8
%20 = call i8* @strtok(i8* %18, i8* %19)
store i8* %20, i8** %9
br label %21
21: ; preds = %54, %3
%22 = load i8*, i8** %9
%23 = call i64 @strlen(i8* %22)
%24 = load i64, i64* %11
%25 = add i64 %24, %23
store i64 %25, i64* %11
%26 = load i64, i64* %11
%27 = load i64, i64* %10
%28 = add i64 %26, %27
%29 = load i64, i64* %6
%30 = icmp ugt i64 %28, %29
br i1 %30, label %35, label %31
31: ; preds = %21
%32 = load i8*, i8** %9
%33 = call i64 @strcmp(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i8* %32)
%34 = icmp eq i64 %33, 0
br i1 %34, label %35, label %46
35: ; preds = %31, %21
%36 = load i64, i64* %10
store i64 %36, i64* %11
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %38
38: ; preds = %42, %35
%39 = load i64, i64* %11
%40 = add i64 %39, -1
store i64 %40, i64* %11
%41 = icmp ugt i64 %39, 0
br i1 %41, label %42, label %45
42: ; preds = %38
%43 = load i8*, i8** %8
%44 = call i32 (i8*, ...) @printf(i8* %43)
br label %38
45: ; preds = %38
store i64 0, i64* %11
br label %46
46: ; preds = %45, %31
%47 = load i8*, i8** %9
%48 = call i64 @strcmp(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i8* %47)
%49 = icmp ne i64 %48, 0
br i1 %49, label %50, label %53
50: ; preds = %46
%51 = load i8*, i8** %9
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %51)
br label %53
53: ; preds = %50, %46
br label %54
54: ; preds = %53
%55 = load i8*, i8** %8
%56 = call i8* @strtok(i8* null, i8* %55)
store i8* %56, i8** %9
%57 = icmp ne i8* %56, null
br i1 %57, label %21, label %58
58: ; preds = %54
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%60 = load i8*, i8** %7
%61 = call i32 @free(i8* %60)
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c" \00"
@.str.1 = [4 x i8] c"\0A%s\00"
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [4 x i8] c"%s \00"
define void @__printf_indent(i8* %0, i8* %1, i64 %2) {
%4 = tail call i8* @tbh_strdup(i8* %1)
%5 = tail call i64 @__tractorbeam_strlen1(i8* %0)
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%7 = tail call i8* @strtok(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i64 %5, 0
br label %9
9: ; preds = %32, %3
%10 = phi i8* [ %7, %3 ], [ %33, %32 ]
%11 = phi i64 [ 0, %3 ], [ %27, %32 ]
%12 = tail call i64 @strlen(i8* dereferenceable(1) %10)
%13 = add i64 %12, %11
%14 = add i64 %13, %5
%15 = icmp ugt i64 %14, %2
br i1 %15, label %19, label %16
16: ; preds = %9
%17 = tail call i64 @strcmp(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i8* %10)
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %26
19: ; preds = %16, %9
%20 = tail call i32 @putchar(i32 10)
br i1 %8, label %26, label %21
21: ; preds = %19, %21
%22 = phi i64 [ %23, %21 ], [ %5, %19 ]
%23 = add i64 %22, -1
%24 = tail call i32 @putchar(i32 32)
%25 = icmp eq i64 %23, 0
br i1 %25, label %26, label %21
26: ; preds = %21, %19, %16
%27 = phi i64 [ %13, %16 ], [ 0, %19 ], [ 0, %21 ]
%28 = tail call i64 @strcmp(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i8* %10)
%29 = icmp eq i64 %28, 0
br i1 %29, label %32, label %30
30: ; preds = %26
%31 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %10)
br label %32
32: ; preds = %26, %30
%33 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%34 = icmp eq i8* %33, null
br i1 %34, label %35, label %9
35: ; preds = %32
%36 = tail call i32 @putchar(i32 10)
%37 = tail call i32 @free(i8* %4)
ret void
}