#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*/ Inst_Printf(char *, char *, ...);
void Move_Ret_To_Mem_L(char *name, int index) {
  Inst_Printf("lda", "$1,%s", name);
  if (index * 8 > 1 << 15) {
    Inst_Printf("lda", "$2,%d", index * 8);
    Inst_Printf("addq", "$1,$2,$1");
    index = 0;
  }
  Inst_Printf("stq", "$0,%d($1)", index * 8);
}


x86 assembly (clang, -O0):
<Move_Ret_To_Mem_L>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rdx
lea    0xed6(%rip),%rdi
lea    0xed3(%rip),%rsi
mov    $0x0,%al
call   1030 <Inst_Printf@plt>
mov    -0xc(%rbp),%eax
shl    $0x3,%eax
cmp    $0x8000,%eax
jle    1180 <Move_Ret_To_Mem_L+0x70>
mov    -0xc(%rbp),%edx
shl    $0x3,%edx
lea    0xeaa(%rip),%rdi
lea    0xead(%rip),%rsi
mov    $0x0,%al
call   1030 <Inst_Printf@plt>
lea    0xea5(%rip),%rdi
lea    0xea3(%rip),%rsi
mov    $0x0,%al
call   1030 <Inst_Printf@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%edx
shl    $0x3,%edx
lea    0xe91(%rip),%rdi
lea    0xe8e(%rip),%rsi
mov    $0x0,%al
call   1030 <Inst_Printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Move_Ret_To_Mem_L>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%rdx
lea    0xee1(%rip),%rdi
lea    0xede(%rip),%rsi
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <Inst_Printf@plt>
cmp    $0x1001,%ebp
jl     1168 <Move_Ret_To_Mem_L+0x58>
shl    $0x3,%ebp
lea    0xebf(%rip),%rdi
lea    0xec2(%rip),%rsi
mov    %ebp,%edx
xor    %eax,%eax
call   1030 <Inst_Printf@plt>
lea    0xeb8(%rip),%rdi
lea    0xeb6(%rip),%rsi
xor    %eax,%eax
call   1030 <Inst_Printf@plt>
jmp    116a <Move_Ret_To_Mem_L+0x5a>
mov    %ebp,%ebx
shl    $0x3,%ebx
lea    0xeaa(%rip),%rdi
lea    0xea7(%rip),%rsi
mov    %ebx,%edx
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <Inst_Printf@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"lda\00"
@.str.1 = [6 x i8] c"$1,%s\00"
@.str.2 = [6 x i8] c"$2,%d\00"
@.str.3 = [5 x i8] c"addq\00"
@.str.4 = [9 x i8] c"$1,$2,$1\00"
@.str.5 = [4 x i8] c"stq\00"
@.str.6 = [10 x i8] c"$0,%d($1)\00"
define void @Move_Ret_To_Mem_L(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
%5 = load i8*, i8** %3
%6 = call i32 (i8*, i8*, ...) @Inst_Printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %5)
%7 = load i32, i32* %4
%8 = mul nsw i32 %7, 8
%9 = icmp sgt i32 %8, 32768
br i1 %9, label %10, label %15
10: ; preds = %2
%11 = load i32, i32* %4
%12 = mul nsw i32 %11, 8
%13 = call i32 (i8*, i8*, ...) @Inst_Printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %12)
%14 = call i32 (i8*, i8*, ...) @Inst_Printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %4
br label %15
15: ; preds = %10, %2
%16 = load i32, i32* %4
%17 = mul nsw i32 %16, 8
%18 = call i32 (i8*, i8*, ...) @Inst_Printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i32 %17)
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"lda\00"
@.str.1 = [6 x i8] c"$1,%s\00"
@.str.2 = [6 x i8] c"$2,%d\00"
@.str.3 = [5 x i8] c"addq\00"
@.str.4 = [9 x i8] c"$1,$2,$1\00"
@.str.5 = [4 x i8] c"stq\00"
@.str.6 = [10 x i8] c"$0,%d($1)\00"
define void @Move_Ret_To_Mem_L(i8* %0, i32 %1) {
%3 = tail call i32 (i8*, i8*, ...) @Inst_Printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%4 = icmp sgt i32 %1, 4096
br i1 %4, label %5, label %9
5: ; preds = %2
%6 = shl nsw i32 %1, 3
%7 = tail call i32 (i8*, i8*, ...) @Inst_Printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %6)
%8 = tail call i32 (i8*, i8*, ...) @Inst_Printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
br label %9
9: ; preds = %5, %2
%10 = phi i32 [ 0, %5 ], [ %1, %2 ]
%11 = shl nsw i32 %10, 3
%12 = tail call i32 (i8*, i8*, ...) @Inst_Printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i32 %11)
ret void
}