#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 *, char *, ...);
int /*<<< orphan*/ sprintf(char *, char *, int);
int /*<<< orphan*/ strcpy(char *, char *);
int Call_C_Arg_Foreign_L(int offset, int adr_of, int index) {
  {
    char r[4];
    if (offset < 8)
      sprintf(r,
              "r"
              "%d",
              offset + 3);
    else
      strcpy(r, "r"
                "11");
    ;
    Inst_Printf("addis",
                "%s,0,"
                "ha16("
                "_"
                "pl_foreign_long+%d"
                ")",
                r, index * 4);
    if (adr_of)
      Inst_Printf("addi",
                  "%s,%s,"
                  "lo16("
                  "_"
                  "pl_foreign_long+%d"
                  ")",
                  r, r, index * 4);
    else
      Inst_Printf("lwz",
                  "%s,"
                  "lo16("
                  "_"
                  "pl_foreign_long+%d"
                  ")"
                  "(%s)",
                  r, index * 4, r);
    if (offset >= 8)
      Inst_Printf("stw",
                  "%s,%d("
                  "r"
                  "1"
                  ")",
                  r, offset * 4 + 24);
  };
  return 1;
}


x86 assembly (clang, -O0):
<Call_C_Arg_Foreign_L>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
cmpl   $0x8,-0x4(%rbp)
jge    1166 <Call_C_Arg_Foreign_L+0x36>
lea    -0x10(%rbp),%rdi
mov    -0x4(%rbp),%edx
add    $0x3,%edx
lea    0xea4(%rip),%rsi
call   1050 <sprintf@plt>
jmp    1176 <Call_C_Arg_Foreign_L+0x46>
lea    -0x10(%rbp),%rdi
lea    0xe93(%rip),%rsi
call   1040 <strcpy@plt>
lea    -0x10(%rbp),%rdx
mov    -0xc(%rbp),%ecx
shl    $0x2,%ecx
lea    0xe81(%rip),%rdi
lea    0xe80(%rip),%rsi
mov    $0x0,%al
call   1030 <Inst_Printf@plt>
cmpl   $0x0,-0x8(%rbp)
je     11c9 <Call_C_Arg_Foreign_L+0x99>
lea    -0x10(%rbp),%rdx
lea    -0x10(%rbp),%rcx
mov    -0xc(%rbp),%r8d
shl    $0x2,%r8d
lea    0xe77(%rip),%rdi
lea    0xe75(%rip),%rsi
mov    $0x0,%al
call   1030 <Inst_Printf@plt>
jmp    11ec <Call_C_Arg_Foreign_L+0xbc>
lea    -0x10(%rbp),%rdx
mov    -0xc(%rbp),%ecx
shl    $0x2,%ecx
lea    -0x10(%rbp),%r8
lea    0xe74(%rip),%rdi
lea    0xe71(%rip),%rsi
mov    $0x0,%al
call   1030 <Inst_Printf@plt>
cmpl   $0x8,-0x4(%rbp)
jl     1218 <Call_C_Arg_Foreign_L+0xe8>
lea    -0x10(%rbp),%rdx
mov    -0x4(%rbp),%ecx
shl    $0x2,%ecx
add    $0x18,%ecx
lea    0xe6d(%rip),%rdi
lea    0xe6a(%rip),%rsi
mov    $0x0,%al
call   1030 <Inst_Printf@plt>
mov    $0x1,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Call_C_Arg_Foreign_L>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %edx,%ebp
mov    %esi,%r14d
mov    %edi,%ebx
cmp    $0x7,%edi
jg     115a <Call_C_Arg_Foreign_L+0x2a>
lea    0x3(%rbx),%edx
lea    0xeb2(%rip),%rsi
lea    0xc(%rsp),%rdi
call   1050 <sprintf@plt>
jmp    116b <Call_C_Arg_Foreign_L+0x3b>
lea    0xea3(%rip),%rsi
lea    0xc(%rsp),%rdi
call   1040 <strcpy@plt>
shl    $0x2,%ebp
lea    0xe93(%rip),%rdi
lea    0xe92(%rip),%rsi
lea    0xc(%rsp),%rdx
mov    %ebp,%ecx
xor    %eax,%eax
call   1030 <Inst_Printf@plt>
test   %r14d,%r14d
je     11e3 <Call_C_Arg_Foreign_L+0xb3>
lea    0xe97(%rip),%rdi
lea    0xe95(%rip),%rsi
lea    0xc(%rsp),%rcx
mov    %rcx,%rdx
mov    %ebp,%r8d
xor    %eax,%eax
call   1030 <Inst_Printf@plt>
cmp    $0x8,%ebx
jl     11d5 <Call_C_Arg_Foreign_L+0xa5>
lea    0x18(,%rbx,4),%ecx
lea    0xeb5(%rip),%rdi
lea    0xeb2(%rip),%rsi
lea    0xc(%rsp),%rdx
xor    %eax,%eax
call   1030 <Inst_Printf@plt>
mov    $0x1,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
lea    0xe68(%rip),%rdi
lea    0xe65(%rip),%rsi
lea    0xc(%rsp),%rdx
mov    %ebp,%ecx
mov    %rdx,%r8
xor    %eax,%eax
call   1030 <Inst_Printf@plt>
cmp    $0x8,%ebx
jge    11b4 <Call_C_Arg_Foreign_L+0x84>
jmp    11d5 <Call_C_Arg_Foreign_L+0xa5>

LLVM IR (-O0):
@.str = [4 x i8] c"r%d\00"
@.str.1 = [4 x i8] c"r11\00"
@.str.2 = [6 x i8] c"addis\00"
@.str.3 = [31 x i8] c"%s,0,ha16(_pl_foreign_long+%d)\00"
@.str.4 = [5 x i8] c"addi\00"
@.str.5 = [32 x i8] c"%s,%s,lo16(_pl_foreign_long+%d)\00"
@.str.6 = [4 x i8] c"lwz\00"
@.str.7 = [33 x i8] c"%s,lo16(_pl_foreign_long+%d)(%s)\00"
@.str.8 = [4 x i8] c"stw\00"
@.str.9 = [10 x i8] c"%s,%d(r1)\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 [4 x i8]
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%8 = load i32, i32* %4
%9 = icmp slt i32 %8, 8
br i1 %9, label %10, label %15
10: ; preds = %3
%11 = getelementptr inbounds [4 x i8], [4 x i8]* %7, i64 0, i64 0
%12 = load i32, i32* %4
%13 = add nsw i32 %12, 3
%14 = call i32 @sprintf(i8* %11, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %13)
br label %18
15: ; preds = %3
%16 = getelementptr inbounds [4 x i8], [4 x i8]* %7, i64 0, i64 0
%17 = call i32 @strcpy(i8* %16, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
br label %18
18: ; preds = %15, %10
%19 = getelementptr inbounds [4 x i8], [4 x i8]* %7, i64 0, i64 0
%20 = load i32, i32* %6
%21 = mul nsw i32 %20, 4
%22 = call i32 (i8*, i8*, i8*, ...) @Inst_Printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), i8* %19, i32 %21)
%23 = load i32, i32* %5
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %31
25: ; preds = %18
%26 = getelementptr inbounds [4 x i8], [4 x i8]* %7, i64 0, i64 0
%27 = getelementptr inbounds [4 x i8], [4 x i8]* %7, i64 0, i64 0
%28 = load i32, i32* %6
%29 = mul nsw i32 %28, 4
%30 = call i32 (i8*, i8*, i8*, ...) @Inst_Printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.5, i64 0, i64 0), i8* %26, i8* %27, i32 %29)
br label %37
31: ; preds = %18
%32 = getelementptr inbounds [4 x i8], [4 x i8]* %7, i64 0, i64 0
%33 = load i32, i32* %6
%34 = mul nsw i32 %33, 4
%35 = getelementptr inbounds [4 x i8], [4 x i8]* %7, i64 0, i64 0
%36 = call i32 (i8*, i8*, i8*, ...) @Inst_Printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.7, i64 0, i64 0), i8* %32, i32 %34, i8* %35)
br label %37
37: ; preds = %31, %25
%38 = load i32, i32* %4
%39 = icmp sge i32 %38, 8
br i1 %39, label %40, label %46
40: ; preds = %37
%41 = getelementptr inbounds [4 x i8], [4 x i8]* %7, i64 0, i64 0
%42 = load i32, i32* %4
%43 = mul nsw i32 %42, 4
%44 = add nsw i32 %43, 24
%45 = call i32 (i8*, 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.9, i64 0, i64 0), i8* %41, i32 %44)
br label %46
46: ; preds = %40, %37
ret i32 1
}

LLVM IR (-O2):
@.str = [4 x i8] c"r%d\00"
@.str.1 = [4 x i8] c"r11\00"
@.str.2 = [6 x i8] c"addis\00"
@.str.3 = [31 x i8] c"%s,0,ha16(_pl_foreign_long+%d)\00"
@.str.4 = [5 x i8] c"addi\00"
@.str.5 = [32 x i8] c"%s,%s,lo16(_pl_foreign_long+%d)\00"
@.str.6 = [4 x i8] c"lwz\00"
@.str.7 = [33 x i8] c"%s,lo16(_pl_foreign_long+%d)(%s)\00"
@.str.8 = [4 x i8] c"stw\00"
@.str.9 = [10 x i8] c"%s,%d(r1)\00"
define i32 @Call_C_Arg_Foreign_L(i32 %0, i32 %1, i32 %2) {
%4 = alloca [4 x i8]
%5 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 0
%6 = icmp slt i32 %0, 8
br i1 %6, label %7, label %10
7: ; preds = %3
%8 = add nsw i32 %0, 3
%9 = call i32 @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %8)
br label %12
10: ; preds = %3
%11 = call i32 @strcpy(i8* %5, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
br label %12
12: ; preds = %10, %7
%13 = shl nsw i32 %2, 2
%14 = call i32 (i8*, i8*, i8*, ...) @Inst_Printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), i8* %5, i32 %13)
%15 = icmp eq i32 %1, 0
br i1 %15, label %18, label %16
16: ; preds = %12
%17 = call i32 (i8*, i8*, i8*, ...) @Inst_Printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.5, i64 0, i64 0), i8* %5, i8* %5, i32 %13)
br label %20
18: ; preds = %12
%19 = call i32 (i8*, i8*, i8*, ...) @Inst_Printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.7, i64 0, i64 0), i8* %5, i32 %13, i8* %5)
br label %20
20: ; preds = %18, %16
%21 = icmp sgt i32 %0, 7
br i1 %21, label %22, label %26
22: ; preds = %20
%23 = shl nsw i32 %0, 2
%24 = add nsw i32 %23, 24
%25 = call i32 (i8*, 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.9, i64 0, i64 0), i8* %5, i32 %24)
br label %26
26: ; preds = %22, %20
ret i32 1
}