#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*/ inPlaceReverse(unsigned char *, int);
int /*<<< orphan*/ puts(char *);
void process(char *strand, int len) {
  char *s, c;
  inPlaceReverse((unsigned char *)strand, len);
  s = strand;
  while (len > 60) {
    c = s[60];
    s[60] = '\0';
    puts(s);
    s[60] = c;
    s += 60;
    len -= 60;
  }
  s[len] = '\0';
  puts(s);
}


x86 assembly (clang, -O0):
<process>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1040 <inPlaceReverse@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
cmpl   $0x3c,-0xc(%rbp)
jle    118c <process+0x6c>
mov    -0x18(%rbp),%rax
mov    0x3c(%rax),%al
mov    %al,-0x19(%rbp)
mov    -0x18(%rbp),%rax
movb   $0x0,0x3c(%rax)
mov    -0x18(%rbp),%rdi
call   1030 <puts@plt>
mov    -0x19(%rbp),%cl
mov    -0x18(%rbp),%rax
mov    %cl,0x3c(%rax)
mov    -0x18(%rbp),%rax
add    $0x3c,%rax
mov    %rax,-0x18(%rbp)
mov    -0xc(%rbp),%eax
sub    $0x3c,%eax
mov    %eax,-0xc(%rbp)
jmp    1143 <process+0x23>
mov    -0x18(%rbp),%rax
movslq -0xc(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x18(%rbp),%rdi
call   1030 <puts@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<process>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%r14d
mov    %rdi,%rbx
call   1040 <inPlaceReverse@plt>
cmp    $0x3d,%r14d
jl     116a <process+0x4a>
nopl   0x0(%rax,%rax,1)
lea    0x3c(%rbx),%r15
movzbl 0x3c(%rbx),%ebp
movb   $0x0,0x3c(%rbx)
mov    %rbx,%rdi
call   1030 <puts@plt>
mov    %bpl,0x3c(%rbx)
lea    -0x3c(%r14),%eax
mov    %r15,%rbx
cmp    $0x78,%r14d
mov    %eax,%r14d
ja     1140 <process+0x20>
jmp    1170 <process+0x50>
mov    %rbx,%r15
mov    %r14d,%eax
cltq
movb   $0x0,(%r15,%rax,1)
mov    %r15,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <puts@plt>

LLVM IR (-O0):
define void @process(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8
store i8* %0, i8** %3
store i32 %1, i32* %4
%7 = load i8*, i8** %3
%8 = load i32, i32* %4
%9 = call i32 @inPlaceReverse(i8* %7, i32 %8)
%10 = load i8*, i8** %3
store i8* %10, i8** %5
br label %11
11: ; preds = %14, %2
%12 = load i32, i32* %4
%13 = icmp sgt i32 %12, 60
br i1 %13, label %14, label %29
14: ; preds = %11
%15 = load i8*, i8** %5
%16 = getelementptr inbounds i8, i8* %15, i64 60
%17 = load i8, i8* %16
store i8 %17, i8* %6
%18 = load i8*, i8** %5
%19 = getelementptr inbounds i8, i8* %18, i64 60
store i8 0, i8* %19
%20 = load i8*, i8** %5
%21 = call i32 @puts(i8* %20)
%22 = load i8, i8* %6
%23 = load i8*, i8** %5
%24 = getelementptr inbounds i8, i8* %23, i64 60
store i8 %22, i8* %24
%25 = load i8*, i8** %5
%26 = getelementptr inbounds i8, i8* %25, i64 60
store i8* %26, i8** %5
%27 = load i32, i32* %4
%28 = sub nsw i32 %27, 60
store i32 %28, i32* %4
br label %11
29: ; preds = %11
%30 = load i8*, i8** %5
%31 = load i32, i32* %4
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i8, i8* %30, i64 %32
store i8 0, i8* %33
%34 = load i8*, i8** %5
%35 = call i32 @puts(i8* %34)
ret void
}

LLVM IR (-O2):
define void @process(i8* %0, i32 %1) {
%3 = tail call i32 @inPlaceReverse(i8* %0, i32 %1)
%4 = icmp sgt i32 %1, 60
br i1 %4, label %5, label %13
5: ; preds = %2, %5
%6 = phi i32 [ %11, %5 ], [ %1, %2 ]
%7 = phi i8* [ %8, %5 ], [ %0, %2 ]
%8 = getelementptr inbounds i8, i8* %7, i64 60
%9 = load i8, i8* %8
store i8 0, i8* %8
%10 = tail call i32 @puts(i8* dereferenceable(1) %7)
store i8 %9, i8* %8
%11 = add nsw i32 %6, -60
%12 = icmp ugt i32 %6, 120
br i1 %12, label %5, label %13
13: ; preds = %5, %2
%14 = phi i8* [ %0, %2 ], [ %8, %5 ]
%15 = phi i32 [ %1, %2 ], [ %11, %5 ]
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8, i8* %14, i64 %16
store i8 0, i8* %17
%18 = tail call i32 @puts(i8* dereferenceable(1) %14)
ret void
}