#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 *, ...);
void put_string(char *str) {
  int i = 0, charactersPrinted = 0;
  for (i = 0; str[i] != '\0'; i++) {
    printf("%c", str[i]);
    charactersPrinted++;
    if (charactersPrinted >= 50 && str[i] == ' ') {
      printf("\n\t\t");
      charactersPrinted = 0;
    }
    if (charactersPrinted == 60) {
      printf("\n\t\t");
      charactersPrinted = 0;
    }
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<put_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     11cf <put_string+0xbf>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%esi
lea    0xea7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
cmpl   $0x32,-0x10(%rbp)
jl     119d <put_string+0x8d>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x20,%eax
jne    119d <put_string+0x8d>
lea    0xe74(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x10(%rbp)
cmpl   $0x3c,-0x10(%rbp)
jne    11bc <put_string+0xac>
lea    0xe55(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x10(%rbp)
jmp    11c1 <put_string+0xb1>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1131 <put_string+0x21>
lea    0xe31(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<put_string>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    (%rdi),%al
test   %al,%al
je     117a <put_string+0x5a>
mov    %rdi,%rbx
add    $0x1,%rbx
xor    %r15d,%r15d
lea    0xec2(%rip),%r14
jmp    1158 <put_string+0x38>
xor    %r15d,%r15d
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
je     117a <put_string+0x5a>
mov    %r15d,%ebp
movsbl %al,%edi
call   1030 <putchar@plt>
lea    0x1(%rbp),%r15d
cmp    $0x31,%ebp
jl     114d <put_string+0x2d>
cmpb   $0x20,-0x1(%rbx)
je     1140 <put_string+0x20>
cmp    $0x3c,%r15d
jne    114d <put_string+0x2d>
jmp    1140 <put_string+0x20>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"%c\00"
@.str.1 = [4 x i8] c"\0A\09\09\00"
@.str.2 = [2 x i8] c"\0A\00"
define void @put_string(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %3
store i32 0, i32* %4
store i32 0, i32* %3
br label %5
5: ; preds = %41, %1
%6 = load i8*, i8** %2
%7 = load i32, i32* %3
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds i8, i8* %6, i64 %8
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %44
13: ; preds = %5
%14 = load i8*, i8** %2
%15 = load i32, i32* %3
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8, i8* %14, i64 %16
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %19)
%21 = load i32, i32* %4
%22 = add nsw i32 %21, 1
store i32 %22, i32* %4
%23 = load i32, i32* %4
%24 = icmp sge i32 %23, 50
br i1 %24, label %25, label %35
25: ; preds = %13
%26 = load i8*, i8** %2
%27 = load i32, i32* %3
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8, i8* %26, 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 %35
33: ; preds = %25
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %4
br label %35
35: ; preds = %33, %25, %13
%36 = load i32, i32* %4
%37 = icmp eq i32 %36, 60
br i1 %37, label %38, label %40
38: ; preds = %35
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %4
br label %40
40: ; preds = %38, %35
br label %41
41: ; preds = %40
%42 = load i32, i32* %3
%43 = add nsw i32 %42, 1
store i32 %43, i32* %3
br label %5
44: ; preds = %5
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str.1 = [4 x i8] c"\0A\09\09\00"
define void @put_string(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 0
br i1 %3, label %26, label %4
4: ; preds = %1, %20
%5 = phi i64 [ %22, %20 ], [ 0, %1 ]
%6 = phi i8 [ %24, %20 ], [ %2, %1 ]
%7 = phi i8* [ %23, %20 ], [ %0, %1 ]
%8 = phi i32 [ %21, %20 ], [ 0, %1 ]
%9 = sext i8 %6 to i32
%10 = tail call i32 @putchar(i32 %9)
%11 = add nsw i32 %8, 1
%12 = icmp sgt i32 %8, 48
br i1 %12, label %13, label %20
13: ; preds = %4
%14 = load i8, i8* %7
%15 = icmp eq i8 %14, 32
%16 = icmp eq i32 %11, 60
%17 = select i1 %15, i1 true, i1 %16
br i1 %17, label %18, label %20
18: ; preds = %13
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
br label %20
20: ; preds = %13, %18, %4
%21 = phi i32 [ %11, %4 ], [ 0, %18 ], [ %11, %13 ]
%22 = add nuw i64 %5, 1
%23 = getelementptr inbounds i8, i8* %0, i64 %22
%24 = load i8, i8* %23
%25 = icmp eq i8 %24, 0
br i1 %25, label %26, label %4
26: ; preds = %20, %1
%27 = tail call i32 @putchar(i32 10)
ret void
}