#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*/ clean_line(char *, int);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
void shift_queue(char *lineptr[], char *cache, int ntail) {
  int len = strlen(lineptr[0]) + 1;
  int element = 0;
  char *p = cache;
  clean_line(lineptr[0], len);
  while (element != ntail - 1) {
    element++;
    int _len = strlen(lineptr[element]) + 1;
    char tmp[_len];
    strcpy(tmp, lineptr[element]);
    clean_line(lineptr[element], _len);
    strcpy(p, tmp);
    lineptr[element - 1] = p;
    p = p + _len;
  }
  return;
}


x86 assembly (clang, -O0):
<shift_queue>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
call   1040 <strlen@plt>
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
mov    -0x18(%rbp),%esi
call   1050 <clean_line@plt>
mov    -0x1c(%rbp),%eax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
je     122c <shift_queue+0xfc>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1040 <strlen@plt>
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x38(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x48(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x40(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
call   1030 <strcpy@plt>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x2c(%rbp),%esi
call   1050 <clean_line@plt>
mov    -0x48(%rbp),%rsi
mov    -0x28(%rbp),%rdi
call   1030 <strcpy@plt>
mov    -0x28(%rbp),%rdx
mov    -0x8(%rbp),%rax
mov    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x28(%rbp),%rax
movslq -0x2c(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x28(%rbp)
mov    -0x38(%rbp),%rax
mov    %rax,%rsp
jmp    1173 <shift_queue+0x43>
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<shift_queue>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %edx,%r15d
mov    %rsi,%r13
mov    %rdi,%rbx
mov    (%rdi),%rdi
call   1040 <strlen@plt>
lea    0x1(%rax),%esi
mov    (%rbx),%rdi
call   1050 <clean_line@plt>
add    $0xffffffff,%r15d
je     11fb <shift_queue+0xcb>
mov    %r15d,%eax
mov    %rax,-0x30(%rbp)
xor    %r14d,%r14d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
lea    0x1(%r14),%rax
mov    %rax,-0x48(%rbp)
mov    0x8(%rbx,%r14,8),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x38(%rbp)
mov    %rsp,-0x40(%rbp)
lea    0x1(%rax),%r12d
lea    0xf(%r12),%rax
and    $0xfffffffffffffff0,%rax
mov    %rbx,%r15
mov    %rsp,%rbx
sub    %rax,%rbx
mov    %rbx,%rsp
mov    0x8(%r15,%r14,8),%rsi
mov    %rbx,%rdi
call   1030 <strcpy@plt>
mov    0x8(%r15,%r14,8),%rdi
mov    %r12d,%esi
call   1050 <clean_line@plt>
mov    %r13,%rdi
mov    %rbx,%rsi
mov    %r15,%rbx
call   1030 <strcpy@plt>
mov    %r13,(%r15,%r14,8)
movslq -0x38(%rbp),%rax
add    %rax,%r13
add    $0x1,%r13
mov    -0x40(%rbp),%rsp
mov    -0x48(%rbp),%rax
mov    %rax,%r14
cmp    %rax,-0x30(%rbp)
jne    1180 <shift_queue+0x50>
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @shift_queue(i8** %0, i8* %1, i32 %2) {
%4 = alloca i8**
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i64
store i8** %0, i8*** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%13 = load i8**, i8*** %4
%14 = getelementptr inbounds i8*, i8** %13, i64 0
%15 = load i8*, i8** %14
%16 = call i32 @strlen(i8* %15)
%17 = add nsw i32 %16, 1
store i32 %17, i32* %7
store i32 0, i32* %8
%18 = load i8*, i8** %5
store i8* %18, i8** %9
%19 = load i8**, i8*** %4
%20 = getelementptr inbounds i8*, i8** %19, i64 0
%21 = load i8*, i8** %20
%22 = load i32, i32* %7
%23 = call i32 @clean_line(i8* %21, i32 %22)
br label %24
24: ; preds = %29, %3
%25 = load i32, i32* %8
%26 = load i32, i32* %6
%27 = sub nsw i32 %26, 1
%28 = icmp ne i32 %25, %27
br i1 %28, label %29, label %69
29: ; preds = %24
%30 = load i32, i32* %8
%31 = add nsw i32 %30, 1
store i32 %31, i32* %8
%32 = load i8**, i8*** %4
%33 = load i32, i32* %8
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i8*, i8** %32, i64 %34
%36 = load i8*, i8** %35
%37 = call i32 @strlen(i8* %36)
%38 = add nsw i32 %37, 1
store i32 %38, i32* %10
%39 = load i32, i32* %10
%40 = zext i32 %39 to i64
%41 = call i8* @llvm.stacksave()
store i8* %41, i8** %11
%42 = alloca i8, i64 %40
store i64 %40, i64* %12
%43 = load i8**, i8*** %4
%44 = load i32, i32* %8
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds i8*, i8** %43, i64 %45
%47 = load i8*, i8** %46
%48 = call i32 @strcpy(i8* %42, i8* %47)
%49 = load i8**, i8*** %4
%50 = load i32, i32* %8
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds i8*, i8** %49, i64 %51
%53 = load i8*, i8** %52
%54 = load i32, i32* %10
%55 = call i32 @clean_line(i8* %53, i32 %54)
%56 = load i8*, i8** %9
%57 = call i32 @strcpy(i8* %56, i8* %42)
%58 = load i8*, i8** %9
%59 = load i8**, i8*** %4
%60 = load i32, i32* %8
%61 = sub nsw i32 %60, 1
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds i8*, i8** %59, i64 %62
store i8* %58, i8** %63
%64 = load i8*, i8** %9
%65 = load i32, i32* %10
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds i8, i8* %64, i64 %66
store i8* %67, i8** %9
%68 = load i8*, i8** %11
br label %24
69: ; preds = %24
ret void
}

LLVM IR (-O2):
define void @shift_queue(i8** nocapture %0, i8* %1, i32 %2) {
%4 = load i8*, i8** %0
%5 = tail call i32 @strlen(i8* %4)
%6 = add nsw i32 %5, 1
%7 = load i8*, i8** %0
%8 = tail call i32 @clean_line(i8* %7, i32 %6)
%9 = add nsw i32 %2, -1
%10 = icmp eq i32 %9, 0
br i1 %10, label %33, label %11
11: ; preds = %3
%12 = zext i32 %9 to i64
br label %13
13: ; preds = %11, %13
%14 = phi i64 [ 0, %11 ], [ %16, %13 ]
%15 = phi i8* [ %1, %11 ], [ %31, %13 ]
%16 = add nuw nsw i64 %14, 1
%17 = getelementptr inbounds i8*, i8** %0, i64 %16
%18 = load i8*, i8** %17
%19 = call i32 @strlen(i8* %18)
%20 = add nsw i32 %19, 1
%21 = zext i32 %20 to i64
%22 = call i8* @llvm.stacksave()
%23 = alloca i8, i64 %21
%24 = load i8*, i8** %17
%25 = call i32 @strcpy(i8* %23, i8* %24)
%26 = load i8*, i8** %17
%27 = call i32 @clean_line(i8* %26, i32 %20)
%28 = call i32 @strcpy(i8* %15, i8* %23)
%29 = getelementptr inbounds i8*, i8** %0, i64 %14
store i8* %15, i8** %29
%30 = sext i32 %20 to i64
%31 = getelementptr inbounds i8, i8* %15, i64 %30
%32 = icmp eq i64 %16, %12
br i1 %32, label %33, label %13
33: ; preds = %13, %3
ret void
}