#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 */
char *malloc(size_t);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, size_t);
int /*<<< orphan*/ strcpy(char *, char *);
void shift_alpha(char *output[], char *strings[], int c, int refactor) {
  size_t len = 1024;
  int cnt, sft, sftc, vary = 0;
  cnt = sft = sftc = vary = 0;
  while (cnt < c) {
    output[sft] = malloc(len);
    memset(output[sft], 0, len);
    strcpy(output[sft], strings[cnt]);
    sft = (sft + refactor);
    ++sftc;
    if (sftc == (c / refactor) + 1) {
      ++vary;
      sft = vary;
      sftc = 0;
    }
    ++cnt;
  }
}


x86 assembly (clang, -O0):
<shift_alpha>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
movq   $0x400,-0x20(%rbp)
movl   $0x0,-0x30(%rbp)
movl   $0x0,-0x30(%rbp)
movl   $0x0,-0x2c(%rbp)
movl   $0x0,-0x28(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    121c <shift_alpha+0xec>
mov    -0x20(%rbp),%rdi
call   1050 <malloc@plt>
mov    %rax,%rdx
mov    -0x8(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x8(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x20(%rbp),%rdx
xor    %esi,%esi
call   1040 <memset@plt>
mov    -0x8(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
call   1030 <strcpy@plt>
mov    -0x28(%rbp),%eax
add    -0x18(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x14(%rbp),%eax
cltd
idivl  -0x18(%rbp)
mov    %eax,%ecx
mov    -0x34(%rbp),%eax
add    $0x1,%ecx
cmp    %ecx,%eax
jne    120e <shift_alpha+0xde>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
mov    -0x30(%rbp),%eax
mov    %eax,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1171 <shift_alpha+0x41>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<shift_alpha>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,0x10(%rsp)
mov    %edx,0x4(%rsp)
test   %edx,%edx
jle    11d7 <shift_alpha+0xa7>
mov    %ecx,%ebx
mov    %rdi,%rbp
mov    0x4(%rsp),%eax
mov    %rax,0x8(%rsp)
xor    %r13d,%r13d
xor    %r14d,%r14d
xor    %r15d,%r15d
xor    %r12d,%r12d
nopl   0x0(%rax)
mov    $0x400,%edi
call   1050 <malloc@plt>
movslq %r12d,%r12
mov    %rax,0x0(%rbp,%r12,8)
mov    $0x400,%edx
mov    %rax,%rdi
xor    %esi,%esi
call   1040 <memset@plt>
mov    0x0(%rbp,%r12,8),%rdi
mov    0x10(%rsp),%rax
mov    (%rax,%r13,8),%rsi
call   1030 <strcpy@plt>
add    %ebx,%r12d
mov    0x4(%rsp),%eax
cltd
idiv   %ebx
cmp    %eax,%r15d
lea    0x1(%r15),%eax
lea    0x1(%r14),%ecx
cmove  %ecx,%r12d
mov    $0x0,%edx
cmove  %edx,%eax
cmove  %ecx,%r14d
add    $0x1,%r13
mov    %eax,%r15d
cmp    %r13,0x8(%rsp)
jne    1170 <shift_alpha+0x40>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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