#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", "$4");
    break;
  case 1:
    sprintf(dest, "%s", "$5");
    break;
  case 2:
    sprintf(dest, "%s", "$6");
    break;
  case 3:
    sprintf(dest, "%s", "$7");
    break;
  case 4:
    sprintf(dest, "%s", "$8");
    break;
  case 5:
    sprintf(dest, "%s", "$9");
    break;
  case 6:
    sprintf(dest, "%s", "$10");
    break;
  case 7:
    sprintf(dest, "%s", "$11");
    break;
  default:
    sprintf(dest, "%s", "$24");
    break;
  }
  Inst_Printf("la", "$2,pl_foreign_long");
  if (!adr_of) {
    Inst_Printf("lw", "%s,%d($2)", dest, index * 4);
  } else {
    Inst_Printf("la", "%s,%d($2)", dest, index * 4);
  }
  if (offset > 7) {
    Inst_Printf("sw", "%s,%d($sp)", dest, (offset - 8) * 8 + 4);
  }
  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    $0x7,%rax
ja     1236 <Call_C_Arg_Foreign_L+0x116>
mov    -0x20(%rbp),%rax
lea    0xeb3(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    -0x14(%rbp),%rdi
lea    0xebf(%rip),%rsi
lea    0xebb(%rip),%rdx
call   1040 <sprintf@plt>
jmp    124d <Call_C_Arg_Foreign_L+0x12d>
lea    -0x14(%rbp),%rdi
lea    0xea3(%rip),%rsi
lea    0xea2(%rip),%rdx
call   1040 <sprintf@plt>
jmp    124d <Call_C_Arg_Foreign_L+0x12d>
lea    -0x14(%rbp),%rdi
lea    0xe87(%rip),%rsi
lea    0xe89(%rip),%rdx
call   1040 <sprintf@plt>
jmp    124d <Call_C_Arg_Foreign_L+0x12d>
lea    -0x14(%rbp),%rdi
lea    0xe6b(%rip),%rsi
lea    0xe70(%rip),%rdx
call   1040 <sprintf@plt>
jmp    124d <Call_C_Arg_Foreign_L+0x12d>
lea    -0x14(%rbp),%rdi
lea    0xe4f(%rip),%rsi
lea    0xe57(%rip),%rdx
call   1040 <sprintf@plt>
jmp    124d <Call_C_Arg_Foreign_L+0x12d>
lea    -0x14(%rbp),%rdi
lea    0xe33(%rip),%rsi
lea    0xe3e(%rip),%rdx
call   1040 <sprintf@plt>
jmp    124d <Call_C_Arg_Foreign_L+0x12d>
lea    -0x14(%rbp),%rdi
lea    0xe17(%rip),%rsi
lea    0xe25(%rip),%rdx
call   1040 <sprintf@plt>
jmp    124d <Call_C_Arg_Foreign_L+0x12d>
lea    -0x14(%rbp),%rdi
lea    0xdfb(%rip),%rsi
lea    0xe0d(%rip),%rdx
call   1040 <sprintf@plt>
jmp    124d <Call_C_Arg_Foreign_L+0x12d>
lea    -0x14(%rbp),%rdi
lea    0xddf(%rip),%rsi
lea    0xdf5(%rip),%rdx
call   1040 <sprintf@plt>
lea    0xded(%rip),%rdi
lea    0xde9(%rip),%rsi
mov    $0x0,%al
call   1030 <Inst_Printf@plt>
cmpl   $0x0,-0x8(%rbp)
jne    1290 <Call_C_Arg_Foreign_L+0x170>
lea    -0x14(%rbp),%rdx
mov    -0xc(%rbp),%ecx
shl    $0x2,%ecx
lea    0xdda(%rip),%rdi
lea    0xdd6(%rip),%rsi
mov    $0x0,%al
call   1030 <Inst_Printf@plt>
jmp    12af <Call_C_Arg_Foreign_L+0x18f>
lea    -0x14(%rbp),%rdx
mov    -0xc(%rbp),%ecx
shl    $0x2,%ecx
lea    0xda0(%rip),%rdi
lea    0xdb2(%rip),%rsi
mov    $0x0,%al
call   1030 <Inst_Printf@plt>
cmpl   $0x7,-0x4(%rbp)
jle    12de <Call_C_Arg_Foreign_L+0x1be>
lea    -0x14(%rbp),%rdx
mov    -0x4(%rbp),%ecx
sub    $0x8,%ecx
shl    $0x3,%ecx
add    $0x4,%ecx
lea    0xd94(%rip),%rdi
lea    0xd90(%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    $0x7,%edi
ja     1142 <Call_C_Arg_Foreign_L+0x32>
mov    %ebx,%eax
lea    0xed4(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movb   $0x0,0x2(%rsp)
movw   $0x3424,(%rsp)
jmp    119c <Call_C_Arg_Foreign_L+0x8c>
movl   $0x343224,(%rsp)
jmp    119c <Call_C_Arg_Foreign_L+0x8c>
movb   $0x0,0x2(%rsp)
movw   $0x3524,(%rsp)
jmp    119c <Call_C_Arg_Foreign_L+0x8c>
movb   $0x0,0x2(%rsp)
movw   $0x3624,(%rsp)
jmp    119c <Call_C_Arg_Foreign_L+0x8c>
movb   $0x0,0x2(%rsp)
movw   $0x3724,(%rsp)
jmp    119c <Call_C_Arg_Foreign_L+0x8c>
movb   $0x0,0x2(%rsp)
movw   $0x3824,(%rsp)
jmp    119c <Call_C_Arg_Foreign_L+0x8c>
movb   $0x0,0x2(%rsp)
movw   $0x3924,(%rsp)
jmp    119c <Call_C_Arg_Foreign_L+0x8c>
movl   $0x303124,(%rsp)
jmp    119c <Call_C_Arg_Foreign_L+0x8c>
movl   $0x313124,(%rsp)
lea    0xe8f(%rip),%r15
lea    0xe8b(%rip),%rsi
mov    %r15,%rdi
xor    %eax,%eax
call   1030 <Inst_Printf@plt>
shl    $0x2,%ebp
test   %r14d,%r14d
lea    0xe87(%rip),%rdi
cmovne %r15,%rdi
lea    0xe7f(%rip),%rsi
mov    %rsp,%rdx
mov    %ebp,%ecx
xor    %eax,%eax
call   1030 <Inst_Printf@plt>
cmp    $0x8,%ebx
jl     11fc <Call_C_Arg_Foreign_L+0xec>
lea    -0x3c(,%rbx,8),%ecx
lea    0xe6a(%rip),%rdi
lea    0xe66(%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 = [3 x i8] c"$4\00"
@.str.2 = [3 x i8] c"$5\00"
@.str.3 = [3 x i8] c"$6\00"
@.str.4 = [3 x i8] c"$7\00"
@.str.5 = [3 x i8] c"$8\00"
@.str.6 = [3 x i8] c"$9\00"
@.str.7 = [4 x i8] c"$10\00"
@.str.8 = [4 x i8] c"$11\00"
@.str.9 = [4 x i8] c"$24\00"
@.str.10 = [3 x i8] c"la\00"
@.str.11 = [19 x i8] c"$2,pl_foreign_long\00"
@.str.12 = [3 x i8] c"lw\00"
@.str.13 = [10 x i8] c"%s,%d($2)\00"
@.str.14 = [3 x i8] c"sw\00"
@.str.15 = [11 x i8] c"%s,%d($sp)\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 %33 [
i32 0, label %9
i32 1, label %12
i32 2, label %15
i32 3, label %18
i32 4, label %21
i32 5, label %24
i32 6, label %27
i32 7, label %30
]
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 ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %36
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 ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %36
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 ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
br label %36
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 ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
br label %36
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 ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
br label %36
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 ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
br label %36
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 ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
br label %36
30: ; preds = %3
%31 = getelementptr inbounds [8 x i8], [8 x i8]* %7, i64 0, i64 0
%32 = call i32 @sprintf(i8* %31, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0))
br label %36
33: ; preds = %3
%34 = getelementptr inbounds [8 x i8], [8 x i8]* %7, i64 0, i64 0
%35 = call i32 @sprintf(i8* %34, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0))
br label %36
36: ; preds = %33, %30, %27, %24, %21, %18, %15, %12, %9
%37 = call i32 (i8*, i8*, ...) @Inst_Printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.11, i64 0, i64 0))
%38 = load i32, i32* %5
%39 = icmp ne i32 %38, 0
br i1 %39, label %45, label %40
40: ; preds = %36
%41 = getelementptr inbounds [8 x i8], [8 x i8]* %7, i64 0, i64 0
%42 = load i32, i32* %6
%43 = mul nsw i32 %42, 4
%44 = call i32 (i8*, i8*, ...) @Inst_Printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.13, i64 0, i64 0), i8* %41, i32 %43)
br label %50
45: ; preds = %36
%46 = getelementptr inbounds [8 x i8], [8 x i8]* %7, i64 0, i64 0
%47 = load i32, i32* %6
%48 = mul nsw i32 %47, 4
%49 = call i32 (i8*, i8*, ...) @Inst_Printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.13, i64 0, i64 0), i8* %46, i32 %48)
br label %50
50: ; preds = %45, %40
%51 = load i32, i32* %4
%52 = icmp sgt i32 %51, 7
br i1 %52, label %53, label %60
53: ; preds = %50
%54 = getelementptr inbounds [8 x i8], [8 x i8]* %7, i64 0, i64 0
%55 = load i32, i32* %4
%56 = sub nsw i32 %55, 8
%57 = mul nsw i32 %56, 8
%58 = add nsw i32 %57, 4
%59 = call i32 (i8*, i8*, ...) @Inst_Printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.14, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.15, i64 0, i64 0), i8* %54, i32 %58)
br label %60
60: ; preds = %53, %50
ret i32 1
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"$4\00"
@.str.2 = [3 x i8] c"$5\00"
@.str.3 = [3 x i8] c"$6\00"
@.str.4 = [3 x i8] c"$7\00"
@.str.5 = [3 x i8] c"$8\00"
@.str.6 = [3 x i8] c"$9\00"
@.str.10 = [3 x i8] c"la\00"
@.str.11 = [19 x i8] c"$2,pl_foreign_long\00"
@.str.12 = [3 x i8] c"lw\00"
@.str.13 = [10 x i8] c"%s,%d($2)\00"
@.str.14 = [3 x i8] c"sw\00"
@.str.15 = [11 x i8] c"%s,%d($sp)\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 %16 [
i32 0, label %6
i32 1, label %7
i32 2, label %8
i32 3, label %9
i32 4, label %10
i32 5, label %11
i32 6, label %12
i32 7, label %14
]
6: ; preds = %3
br label %18
7: ; preds = %3
br label %18
8: ; preds = %3
br label %18
9: ; preds = %3
br label %18
10: ; preds = %3
br label %18
11: ; preds = %3
br label %18
12: ; preds = %3
%13 = bitcast [8 x i8]* %4 to i32*
store i32 3158308, i32* %13
br label %18
14: ; preds = %3
%15 = bitcast [8 x i8]* %4 to i32*
store i32 3223844, i32* %15
br label %18
16: ; preds = %3
%17 = bitcast [8 x i8]* %4 to i32*
store i32 3420708, i32* %17
br label %18
18: ; preds = %16, %14, %12, %11, %10, %9, %8, %7, %6
%19 = tail call i32 (i8*, i8*, ...) @Inst_Printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.11, i64 0, i64 0))
%20 = icmp eq i32 %1, 0
%21 = shl nsw i32 %2, 2
%22 = select i1 %20, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0)
%23 = call i32 (i8*, i8*, ...) @Inst_Printf(i8* %22, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.13, i64 0, i64 0), i8* %5, i32 %21)
%24 = icmp sgt i32 %0, 7
br i1 %24, label %25, label %29
25: ; preds = %18
%26 = shl i32 %0, 3
%27 = add i32 %26, -60
%28 = call i32 (i8*, i8*, ...) @Inst_Printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.14, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.15, i64 0, i64 0), i8* %5, i32 %27)
br label %29
29: ; preds = %25, %18
ret i32 1
}