#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*/ Delay_Printf(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 < 6)
      sprintf(r, "%%o%d", offset);
    else
      strcpy(r, "%l7");
    ;
    if (adr_of)
      Delay_Printf("add", "%%l2,%d,%s", index * 4, r);
    else
      Delay_Printf("ld", "[%%l2+%d],%s", index * 4, r);
    if (offset >= 6)
      Delay_Printf("st", "%s,[%%sp+%d]", r, 92 + (offset - 6) * 4);
  };
  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   $0x6,-0x4(%rbp)
jge    1163 <Call_C_Arg_Foreign_L+0x33>
lea    -0x10(%rbp),%rdi
mov    -0x4(%rbp),%edx
lea    0xea7(%rip),%rsi
call   1040 <sprintf@plt>
jmp    1173 <Call_C_Arg_Foreign_L+0x43>
lea    -0x10(%rbp),%rdi
lea    0xe98(%rip),%rsi
call   1030 <strcpy@plt>
cmpl   $0x0,-0x8(%rbp)
je     11a1 <Call_C_Arg_Foreign_L+0x71>
mov    -0xc(%rbp),%edx
shl    $0x2,%edx
lea    -0x10(%rbp),%rcx
lea    0xe7c(%rip),%rdi
lea    0xe79(%rip),%rsi
mov    $0x0,%al
call   1050 <Delay_Printf@plt>
jmp    11c0 <Call_C_Arg_Foreign_L+0x90>
mov    -0xc(%rbp),%edx
shl    $0x2,%edx
lea    -0x10(%rbp),%rcx
lea    0xe67(%rip),%rdi
lea    0xe63(%rip),%rsi
mov    $0x0,%al
call   1050 <Delay_Printf@plt>
cmpl   $0x6,-0x4(%rbp)
jl     11ef <Call_C_Arg_Foreign_L+0xbf>
lea    -0x10(%rbp),%rdx
mov    -0x4(%rbp),%ecx
sub    $0x6,%ecx
shl    $0x2,%ecx
add    $0x5c,%ecx
lea    0xe48(%rip),%rdi
lea    0xe44(%rip),%rsi
mov    $0x0,%al
call   1050 <Delay_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    $0x5,%edi
jg     1159 <Call_C_Arg_Foreign_L+0x29>
lea    0xeb5(%rip),%rsi
lea    0xc(%rsp),%rdi
mov    %ebx,%edx
call   1040 <sprintf@plt>
jmp    116a <Call_C_Arg_Foreign_L+0x3a>
lea    0xea6(%rip),%rsi
lea    0xc(%rsp),%rdi
call   1030 <strcpy@plt>
shl    $0x2,%ebp
test   %r14d,%r14d
je     1182 <Call_C_Arg_Foreign_L+0x52>
lea    0xe91(%rip),%rdi
lea    0xe8e(%rip),%rsi
jmp    1190 <Call_C_Arg_Foreign_L+0x60>
lea    0xe90(%rip),%rdi
lea    0xe8c(%rip),%rsi
lea    0xc(%rsp),%rcx
mov    %ebp,%edx
xor    %eax,%eax
call   1050 <Delay_Printf@plt>
cmp    $0x6,%ebx
jl     11c4 <Call_C_Arg_Foreign_L+0x94>
lea    0x44(,%rbx,4),%ecx
lea    0xe78(%rip),%rdi
lea    0xe74(%rip),%rsi
lea    0xc(%rsp),%rdx
xor    %eax,%eax
call   1050 <Delay_Printf@plt>
mov    $0x1,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"%%o%d\00"
@.str.1 = [4 x i8] c"%l7\00"
@.str.2 = [4 x i8] c"add\00"
@.str.3 = [11 x i8] c"%%l2,%d,%s\00"
@.str.4 = [3 x i8] c"ld\00"
@.str.5 = [13 x i8] c"[%%l2+%d],%s\00"
@.str.6 = [3 x i8] c"st\00"
@.str.7 = [13 x i8] c"%s,[%%sp+%d]\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, 6
br i1 %9, label %10, label %14
10: ; preds = %3
%11 = getelementptr inbounds [4 x i8], [4 x i8]* %7, i64 0, i64 0
%12 = load i32, i32* %4
%13 = call i32 @sprintf(i8* %11, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %12)
br label %17
14: ; preds = %3
%15 = getelementptr inbounds [4 x i8], [4 x i8]* %7, i64 0, i64 0
%16 = call i32 @strcpy(i8* %15, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
br label %17
17: ; preds = %14, %10
%18 = load i32, i32* %5
%19 = icmp ne i32 %18, 0
br i1 %19, label %20, label %25
20: ; preds = %17
%21 = load i32, i32* %6
%22 = mul nsw i32 %21, 4
%23 = getelementptr inbounds [4 x i8], [4 x i8]* %7, i64 0, i64 0
%24 = call i32 (i8*, i8*, ...) @Delay_Printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i32 %22, i8* %23)
br label %30
25: ; preds = %17
%26 = load i32, i32* %6
%27 = mul nsw i32 %26, 4
%28 = getelementptr inbounds [4 x i8], [4 x i8]* %7, i64 0, i64 0
%29 = call i32 (i8*, i8*, ...) @Delay_Printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i32 %27, i8* %28)
br label %30
30: ; preds = %25, %20
%31 = load i32, i32* %4
%32 = icmp sge i32 %31, 6
br i1 %32, label %33, label %40
33: ; preds = %30
%34 = getelementptr inbounds [4 x i8], [4 x i8]* %7, i64 0, i64 0
%35 = load i32, i32* %4
%36 = sub nsw i32 %35, 6
%37 = mul nsw i32 %36, 4
%38 = add nsw i32 92, %37
%39 = call i32 (i8*, i8*, ...) @Delay_Printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0), i8* %34, i32 %38)
br label %40
40: ; preds = %33, %30
ret i32 1
}

LLVM IR (-O2):
@.str = [6 x i8] c"%%o%d\00"
@.str.1 = [4 x i8] c"%l7\00"
@.str.2 = [4 x i8] c"add\00"
@.str.3 = [11 x i8] c"%%l2,%d,%s\00"
@.str.4 = [3 x i8] c"ld\00"
@.str.5 = [13 x i8] c"[%%l2+%d],%s\00"
@.str.6 = [3 x i8] c"st\00"
@.str.7 = [13 x i8] c"%s,[%%sp+%d]\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, 6
br i1 %6, label %7, label %9
7: ; preds = %3
%8 = call i32 @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %0)
br label %11
9: ; preds = %3
%10 = call i32 @strcpy(i8* %5, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
br label %11
11: ; preds = %9, %7
%12 = icmp eq i32 %1, 0
%13 = shl nsw i32 %2, 2
br i1 %12, label %16, label %14
14: ; preds = %11
%15 = call i32 (i8*, i8*, ...) @Delay_Printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i32 %13, i8* %5)
br label %18
16: ; preds = %11
%17 = call i32 (i8*, i8*, ...) @Delay_Printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i32 %13, i8* %5)
br label %18
18: ; preds = %16, %14
%19 = icmp sgt i32 %0, 5
br i1 %19, label %20, label %24
20: ; preds = %18
%21 = shl i32 %0, 2
%22 = add i32 %21, 68
%23 = call i32 (i8*, i8*, ...) @Delay_Printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0), i8* %5, i32 %22)
br label %24
24: ; preds = %20, %18
ret i32 1
}