#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 *, ...);
int /*<<< orphan*/ sprintf(char *, char *, char *);
int Call_C_Arg_Foreign_L(int offset, int adr_of, int index) {
  char dest[8];
  switch (offset) {
  case 0:
    sprintf(dest, "%s", "$16");
    break;
  case 1:
    sprintf(dest, "%s", "$17");
    break;
  case 2:
    sprintf(dest, "%s", "$18");
    break;
  case 3:
    sprintf(dest, "%s", "$19");
    break;
  case 4:
    sprintf(dest, "%s", "$20");
    break;
  case 5:
    sprintf(dest, "%s", "$21");
    break;
  default:
    sprintf(dest, "%s", "$1");
    break;
  }
  Inst_Printf("lda", "$2,pl_foreign_long");
  if (!adr_of) {
    Inst_Printf("ldq", "%s,%d($2)", dest, index * 8);
  } else {
    Inst_Printf("lda", "%s,%d($2)", dest, index * 8);
  }
  if (offset > 5) {
    Inst_Printf("stq", "%s,%d($30)", dest, (offset - 6) * 8);
  }
  return 1;
}


x86 assembly (clang, -O0):
<Call_C_Arg_Foreign_L>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    -0x4(%rbp),%eax
mov    %rax,-0x20(%rbp)
sub    $0x5,%rax
ja     11fe <Call_C_Arg_Foreign_L+0xde>
mov    -0x20(%rbp),%rax
lea    0xeb3(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    -0x14(%rbp),%rdi
lea    0xeb7(%rip),%rsi
lea    0xeb3(%rip),%rdx
call   1040 <sprintf@plt>
jmp    1215 <Call_C_Arg_Foreign_L+0xf5>
lea    -0x14(%rbp),%rdi
lea    0xe9b(%rip),%rsi
lea    0xe9b(%rip),%rdx
call   1040 <sprintf@plt>
jmp    1215 <Call_C_Arg_Foreign_L+0xf5>
lea    -0x14(%rbp),%rdi
lea    0xe7f(%rip),%rsi
lea    0xe83(%rip),%rdx
call   1040 <sprintf@plt>
jmp    1215 <Call_C_Arg_Foreign_L+0xf5>
lea    -0x14(%rbp),%rdi
lea    0xe63(%rip),%rsi
lea    0xe6b(%rip),%rdx
call   1040 <sprintf@plt>
jmp    1215 <Call_C_Arg_Foreign_L+0xf5>
lea    -0x14(%rbp),%rdi
lea    0xe47(%rip),%rsi
lea    0xe53(%rip),%rdx
call   1040 <sprintf@plt>
jmp    1215 <Call_C_Arg_Foreign_L+0xf5>
lea    -0x14(%rbp),%rdi
lea    0xe2b(%rip),%rsi
lea    0xe3b(%rip),%rdx
call   1040 <sprintf@plt>
jmp    1215 <Call_C_Arg_Foreign_L+0xf5>
lea    -0x14(%rbp),%rdi
lea    0xe0f(%rip),%rsi
lea    0xe23(%rip),%rdx
call   1040 <sprintf@plt>
lea    0xe1a(%rip),%rdi
lea    0xe17(%rip),%rsi
mov    $0x0,%al
call   1030 <Inst_Printf@plt>
cmpl   $0x0,-0x8(%rbp)
jne    1258 <Call_C_Arg_Foreign_L+0x138>
lea    -0x14(%rbp),%rdx
mov    -0xc(%rbp),%ecx
shl    $0x3,%ecx
lea    0xe08(%rip),%rdi
lea    0xe05(%rip),%rsi
mov    $0x0,%al
call   1030 <Inst_Printf@plt>
jmp    1277 <Call_C_Arg_Foreign_L+0x157>
lea    -0x14(%rbp),%rdx
mov    -0xc(%rbp),%ecx
shl    $0x3,%ecx
lea    0xdcd(%rip),%rdi
lea    0xde1(%rip),%rsi
mov    $0x0,%al
call   1030 <Inst_Printf@plt>
cmpl   $0x5,-0x4(%rbp)
jle    12a3 <Call_C_Arg_Foreign_L+0x183>
lea    -0x14(%rbp),%rdx
mov    -0x4(%rbp),%ecx
sub    $0x6,%ecx
shl    $0x3,%ecx
lea    0xdc6(%rip),%rdi
lea    0xdc3(%rip),%rsi
mov    $0x0,%al
call   1030 <Inst_Printf@plt>
mov    $0x1,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Call_C_Arg_Foreign_L>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%ebp
mov    %esi,%r14d
mov    %edi,%ebx
cmp    $0x5,%edi
ja     113e <Call_C_Arg_Foreign_L+0x2e>
mov    %ebx,%eax
lea    0xed4(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x363124,(%rsp)
jmp    1176 <Call_C_Arg_Foreign_L+0x66>
movb   $0x0,0x2(%rsp)
movw   $0x3124,(%rsp)
jmp    1176 <Call_C_Arg_Foreign_L+0x66>
movl   $0x373124,(%rsp)
jmp    1176 <Call_C_Arg_Foreign_L+0x66>
movl   $0x383124,(%rsp)
jmp    1176 <Call_C_Arg_Foreign_L+0x66>
movl   $0x393124,(%rsp)
jmp    1176 <Call_C_Arg_Foreign_L+0x66>
movl   $0x303224,(%rsp)
jmp    1176 <Call_C_Arg_Foreign_L+0x66>
movl   $0x313224,(%rsp)
lea    0xe9e(%rip),%r15
lea    0xe9b(%rip),%rsi
mov    %r15,%rdi
xor    %eax,%eax
call   1030 <Inst_Printf@plt>
shl    $0x3,%ebp
test   %r14d,%r14d
lea    0xe97(%rip),%rdi
cmovne %r15,%rdi
lea    0xe90(%rip),%rsi
mov    %rsp,%rdx
mov    %ebp,%ecx
xor    %eax,%eax
call   1030 <Inst_Printf@plt>
cmp    $0x6,%ebx
jl     11d6 <Call_C_Arg_Foreign_L+0xc6>
lea    -0x30(,%rbx,8),%ecx
lea    0xe7b(%rip),%rdi
lea    0xe78(%rip),%rsi
mov    %rsp,%rdx
xor    %eax,%eax
call   1030 <Inst_Printf@plt>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@.str.1 = [4 x i8] c"$16\00"
@.str.2 = [4 x i8] c"$17\00"
@.str.3 = [4 x i8] c"$18\00"
@.str.4 = [4 x i8] c"$19\00"
@.str.5 = [4 x i8] c"$20\00"
@.str.6 = [4 x i8] c"$21\00"
@.str.7 = [3 x i8] c"$1\00"
@.str.8 = [4 x i8] c"lda\00"
@.str.9 = [19 x i8] c"$2,pl_foreign_long\00"
@.str.10 = [4 x i8] c"ldq\00"
@.str.11 = [10 x i8] c"%s,%d($2)\00"
@.str.12 = [4 x i8] c"stq\00"
@.str.13 = [11 x i8] c"%s,%d($30)\00"
define i32 @Call_C_Arg_Foreign_L(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca [8 x i8]
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%8 = load i32, i32* %4
switch i32 %8, label %27 [
i32 0, label %9
i32 1, label %12
i32 2, label %15
i32 3, label %18
i32 4, label %21
i32 5, label %24
]
9: ; preds = %3
%10 = getelementptr inbounds [8 x i8], [8 x i8]* %7, i64 0, i64 0
%11 = call i32 @sprintf(i8* %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
br label %30
12: ; preds = %3
%13 = getelementptr inbounds [8 x i8], [8 x i8]* %7, i64 0, i64 0
%14 = call i32 @sprintf(i8* %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
br label %30
15: ; preds = %3
%16 = getelementptr inbounds [8 x i8], [8 x i8]* %7, i64 0, i64 0
%17 = call i32 @sprintf(i8* %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
br label %30
18: ; preds = %3
%19 = getelementptr inbounds [8 x i8], [8 x i8]* %7, i64 0, i64 0
%20 = call i32 @sprintf(i8* %19, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
br label %30
21: ; preds = %3
%22 = getelementptr inbounds [8 x i8], [8 x i8]* %7, i64 0, i64 0
%23 = call i32 @sprintf(i8* %22, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
br label %30
24: ; preds = %3
%25 = getelementptr inbounds [8 x i8], [8 x i8]* %7, i64 0, i64 0
%26 = call i32 @sprintf(i8* %25, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
br label %30
27: ; preds = %3
%28 = getelementptr inbounds [8 x i8], [8 x i8]* %7, i64 0, i64 0
%29 = call i32 @sprintf(i8* %28, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0))
br label %30
30: ; preds = %27, %24, %21, %18, %15, %12, %9
%31 = call i32 (i8*, i8*, ...) @Inst_Printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.9, i64 0, i64 0))
%32 = load i32, i32* %5
%33 = icmp ne i32 %32, 0
br i1 %33, label %39, label %34
34: ; preds = %30
%35 = getelementptr inbounds [8 x i8], [8 x i8]* %7, i64 0, i64 0
%36 = load i32, i32* %6
%37 = mul nsw i32 %36, 8
%38 = call i32 (i8*, i8*, ...) @Inst_Printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.11, i64 0, i64 0), i8* %35, i32 %37)
br label %44
39: ; preds = %30
%40 = getelementptr inbounds [8 x i8], [8 x i8]* %7, i64 0, i64 0
%41 = load i32, i32* %6
%42 = mul nsw i32 %41, 8
%43 = call i32 (i8*, i8*, ...) @Inst_Printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.11, i64 0, i64 0), i8* %40, i32 %42)
br label %44
44: ; preds = %39, %34
%45 = load i32, i32* %4
%46 = icmp sgt i32 %45, 5
br i1 %46, label %47, label %53
47: ; preds = %44
%48 = getelementptr inbounds [8 x i8], [8 x i8]* %7, i64 0, i64 0
%49 = load i32, i32* %4
%50 = sub nsw i32 %49, 6
%51 = mul nsw i32 %50, 8
%52 = call i32 (i8*, i8*, ...) @Inst_Printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.13, i64 0, i64 0), i8* %48, i32 %51)
br label %53
53: ; preds = %47, %44
ret i32 1
}

LLVM IR (-O2):
@.str.7 = [3 x i8] c"$1\00"
@.str.8 = [4 x i8] c"lda\00"
@.str.9 = [19 x i8] c"$2,pl_foreign_long\00"
@.str.10 = [4 x i8] c"ldq\00"
@.str.11 = [10 x i8] c"%s,%d($2)\00"
@.str.12 = [4 x i8] c"stq\00"
@.str.13 = [11 x i8] c"%s,%d($30)\00"
define i32 @Call_C_Arg_Foreign_L(i32 %0, i32 %1, i32 %2) {
%4 = alloca [8 x i8]
%5 = getelementptr inbounds [8 x i8], [8 x i8]* %4, i64 0, i64 0
switch i32 %0, label %18 [
i32 0, label %6
i32 1, label %8
i32 2, label %10
i32 3, label %12
i32 4, label %14
i32 5, label %16
]
6: ; preds = %3
%7 = bitcast [8 x i8]* %4 to i32*
store i32 3551524, i32* %7
br label %19
8: ; preds = %3
%9 = bitcast [8 x i8]* %4 to i32*
store i32 3617060, i32* %9
br label %19
10: ; preds = %3
%11 = bitcast [8 x i8]* %4 to i32*
store i32 3682596, i32* %11
br label %19
12: ; preds = %3
%13 = bitcast [8 x i8]* %4 to i32*
store i32 3748132, i32* %13
br label %19
14: ; preds = %3
%15 = bitcast [8 x i8]* %4 to i32*
store i32 3158564, i32* %15
br label %19
16: ; preds = %3
%17 = bitcast [8 x i8]* %4 to i32*
store i32 3224100, i32* %17
br label %19
18: ; preds = %3
br label %19
19: ; preds = %18, %16, %14, %12, %10, %8, %6
%20 = tail call i32 (i8*, i8*, ...) @Inst_Printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.9, i64 0, i64 0))
%21 = icmp eq i32 %1, 0
%22 = shl nsw i32 %2, 3
%23 = select i1 %21, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0)
%24 = call i32 (i8*, i8*, ...) @Inst_Printf(i8* %23, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.11, i64 0, i64 0), i8* %5, i32 %22)
%25 = icmp sgt i32 %0, 5
br i1 %25, label %26, label %30
26: ; preds = %19
%27 = shl i32 %0, 3
%28 = add i32 %27, -48
%29 = call i32 (i8*, i8*, ...) @Inst_Printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.13, i64 0, i64 0), i8* %5, i32 %28)
br label %30
30: ; preds = %26, %19
ret i32 1
}