#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 back_up(char *, int);
scalar_t__ isspace(char);
int /*<<< orphan*/ printf(char *, char const *);
int /*<<< orphan*/ putchar(char);
int strlen(char const *);
int /*<<< orphan*/ strncat(char *, char const *, int);
void print_right_cell(const char *s, int start, int width) {
  int n = strlen(s);
  int i, first = 1;
  char chunk[78];
  const char *p = s;
  if (n <= width) {
    printf("%s\n", s);
  } else {
    while (n > 0) {
      int done;
      char *q;
      *chunk = 0;
      strncat(chunk, p, width + 1);
      done = back_up(chunk, width);
      p += done;
      n -= done;
      if (first) {
        first = 0;
      } else {
        for (i = 0; i < start; i++) {
          putchar(' ');
        }
      }
      q = chunk;
      while (isspace(*q))
        q++;
      printf("%s\n", q);
    }
  }
}


x86 assembly (clang, -O0):
<print_right_cell>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x14(%rbp)
movl   $0x1,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x78(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x10(%rbp),%eax
jg     11b1 <print_right_cell+0x51>
mov    -0x8(%rbp),%rsi
lea    0xe59(%rip),%rdi
call   1050 <printf@plt>
jmp    12a0 <print_right_cell+0x140>
jmp    11b6 <print_right_cell+0x56>
cmpl   $0x0,-0x14(%rbp)
jle    129b <print_right_cell+0x13b>
movb   $0x0,-0x70(%rbp)
lea    -0x70(%rbp),%rdi
mov    -0x78(%rbp),%rsi
mov    -0x10(%rbp),%edx
add    $0x1,%edx
call   1060 <strncat@plt>
lea    -0x70(%rbp),%rdi
mov    -0x10(%rbp),%esi
call   1080 <back_up@plt>
mov    %eax,-0x7c(%rbp)
mov    -0x7c(%rbp),%ecx
mov    -0x78(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x78(%rbp)
mov    -0x7c(%rbp),%ecx
mov    -0x14(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     1218 <print_right_cell+0xb8>
movl   $0x0,-0x1c(%rbp)
jmp    1248 <print_right_cell+0xe8>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1243 <print_right_cell+0xe3>
mov    $0x20,%edi
call   1030 <putchar@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    121f <print_right_cell+0xbf>
jmp    1248 <print_right_cell+0xe8>
lea    -0x70(%rbp),%rax
mov    %rax,-0x88(%rbp)
mov    -0x88(%rbp),%rax
movsbl (%rax),%edi
call   1070 <isspace@plt>
cmp    $0x0,%rax
je     1283 <print_right_cell+0x123>
mov    -0x88(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x88(%rbp)
jmp    1253 <print_right_cell+0xf3>
mov    -0x88(%rbp),%rsi
lea    0xd6f(%rip),%rdi
call   1050 <printf@plt>
jmp    11b6 <print_right_cell+0x56>
jmp    12a0 <print_right_cell+0x140>
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_right_cell>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
mov    %edx,%ebx
mov    %esi,%ebp
mov    %rdi,%r13
call   1040 <strlen@plt>
cmp    %ebx,%eax
jle    123f <print_right_cell+0xdf>
mov    %eax,%r14d
mov    %ebp,0xc(%rsp)
test   %eax,%eax
jle    1230 <print_right_cell+0xd0>
lea    0x1(%rbx),%eax
mov    %eax,0x8(%rsp)
mov    $0x1,%r15b
nopl   0x0(%rax,%rax,1)
movb   $0x0,0x10(%rsp)
lea    0x10(%rsp),%rbp
mov    %rbp,%rdi
mov    %r13,%rsi
mov    0x8(%rsp),%edx
call   1060 <strncat@plt>
mov    %rbp,%rdi
mov    %rbx,%rbp
mov    %ebx,%esi
call   1080 <back_up@plt>
mov    %eax,%r12d
test   $0x1,%r15b
mov    0xc(%rsp),%ebx
jne    11ef <print_right_cell+0x8f>
test   %ebx,%ebx
jle    11ef <print_right_cell+0x8f>
nopw   0x0(%rax,%rax,1)
mov    $0x20,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebx
jne    11e0 <print_right_cell+0x80>
movslq %r12d,%rax
add    %rax,%r13
sub    %eax,%r14d
lea    0xf(%rsp),%rbx
nopl   (%rax)
movsbl 0x1(%rbx),%edi
add    $0x1,%rbx
call   1070 <isspace@plt>
test   %rax,%rax
jne    1200 <print_right_cell+0xa0>
lea    0xde7(%rip),%rdi
mov    %rbx,%rsi
call   1050 <printf@plt>
xor    %r15d,%r15d
test   %r14d,%r14d
mov    %rbp,%rbx
jg     11a0 <print_right_cell+0x40>
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xdba(%rip),%rdi
mov    %r13,%rsi
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <printf@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"%s\0A\00"
define void @print_right_cell(i8* %0, i32 %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca [78 x i8]
%11 = alloca i8*
%12 = alloca i32
%13 = alloca i8*
store i8* %0, i8** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%14 = load i8*, i8** %4
%15 = call i32 @strlen(i8* %14)
store i32 %15, i32* %7
store i32 1, i32* %9
%16 = load i8*, i8** %4
store i8* %16, i8** %11
%17 = load i32, i32* %7
%18 = load i32, i32* %6
%19 = icmp sle i32 %17, %18
br i1 %19, label %20, label %23
20: ; preds = %3
%21 = load i8*, i8** %4
%22 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %21)
br label %72
23: ; preds = %3
br label %24
24: ; preds = %68, %23
%25 = load i32, i32* %7
%26 = icmp sgt i32 %25, 0
br i1 %26, label %27, label %71
27: ; preds = %24
%28 = getelementptr inbounds [78 x i8], [78 x i8]* %10, i64 0, i64 0
store i8 0, i8* %28
%29 = getelementptr inbounds [78 x i8], [78 x i8]* %10, i64 0, i64 0
%30 = load i8*, i8** %11
%31 = load i32, i32* %6
%32 = add nsw i32 %31, 1
%33 = call i32 @strncat(i8* %29, i8* %30, i32 %32)
%34 = getelementptr inbounds [78 x i8], [78 x i8]* %10, i64 0, i64 0
%35 = load i32, i32* %6
%36 = call i32 @back_up(i8* %34, i32 %35)
store i32 %36, i32* %12
%37 = load i32, i32* %12
%38 = load i8*, i8** %11
%39 = sext i32 %37 to i64
%40 = getelementptr inbounds i8, i8* %38, i64 %39
store i8* %40, i8** %11
%41 = load i32, i32* %12
%42 = load i32, i32* %7
%43 = sub nsw i32 %42, %41
store i32 %43, i32* %7
%44 = load i32, i32* %9
%45 = icmp ne i32 %44, 0
br i1 %45, label %46, label %47
46: ; preds = %27
store i32 0, i32* %9
br label %58
47: ; preds = %27
store i32 0, i32* %8
br label %48
48: ; preds = %54, %47
%49 = load i32, i32* %8
%50 = load i32, i32* %5
%51 = icmp slt i32 %49, %50
br i1 %51, label %52, label %57
52: ; preds = %48
%53 = call i32 @putchar(i8 signext 32)
br label %54
54: ; preds = %52
%55 = load i32, i32* %8
%56 = add nsw i32 %55, 1
store i32 %56, i32* %8
br label %48
57: ; preds = %48
br label %58
58: ; preds = %57, %46
%59 = getelementptr inbounds [78 x i8], [78 x i8]* %10, i64 0, i64 0
store i8* %59, i8** %13
br label %60
60: ; preds = %65, %58
%61 = load i8*, i8** %13
%62 = load i8, i8* %61
%63 = call i64 @isspace(i8 signext %62)
%64 = icmp ne i64 %63, 0
br i1 %64, label %65, label %68
65: ; preds = %60
%66 = load i8*, i8** %13
%67 = getelementptr inbounds i8, i8* %66, i32 1
store i8* %67, i8** %13
br label %60
68: ; preds = %60
%69 = load i8*, i8** %13
%70 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %69)
br label %24
71: ; preds = %24
br label %72
72: ; preds = %71, %20
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"%s\0A\00"
define void @print_right_cell(i8* %0, i32 %1, i32 %2) {
%4 = alloca [78 x i8]
%5 = tail call i32 @strlen(i8* %0)
%6 = getelementptr inbounds [78 x i8], [78 x i8]* %4, i64 0, i64 0
%7 = icmp sgt i32 %5, %2
br i1 %7, label %8, label %13
8: ; preds = %3
%9 = icmp sgt i32 %5, 0
br i1 %9, label %10, label %40
10: ; preds = %8
%11 = add nsw i32 %2, 1
%12 = icmp slt i32 %1, 1
br label %15
13: ; preds = %3
%14 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %40
15: ; preds = %10, %37
%16 = phi i32 [ %5, %10 ], [ %23, %37 ]
%17 = phi i8* [ %0, %10 ], [ %22, %37 ]
%18 = phi i1 [ true, %10 ], [ false, %37 ]
store i8 0, i8* %6
%19 = call i32 @strncat(i8* %6, i8* %17, i32 %11)
%20 = call i32 @back_up(i8* %6, i32 %2)
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8, i8* %17, i64 %21
%23 = sub nsw i32 %16, %20
%24 = or i1 %18, %12
br i1 %24, label %30, label %25
25: ; preds = %15, %25
%26 = phi i32 [ %28, %25 ], [ 0, %15 ]
%27 = call i32 @putchar(i8 signext 32)
%28 = add nuw nsw i32 %26, 1
%29 = icmp eq i32 %28, %1
br i1 %29, label %30, label %25
30: ; preds = %25, %15
br label %31
31: ; preds = %30, %31
%32 = phi i8* [ %36, %31 ], [ %6, %30 ]
%33 = load i8, i8* %32
%34 = call i64 @isspace(i8 signext %33)
%35 = icmp eq i64 %34, 0
%36 = getelementptr inbounds i8, i8* %32, i64 1
br i1 %35, label %37, label %31
37: ; preds = %31
%38 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %32)
%39 = icmp sgt i32 %23, 0
br i1 %39, label %15, label %40
40: ; preds = %37, %8, %13
ret void
}