#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_D(int offset, int adr_of, int index) {
  if (adr_of) {
    {
      char r[4];
      if (offset < 6)
        sprintf(r, "%%o%d", offset);
      else
        strcpy(r, "%l7");
      ;
      Delay_Printf("add", "%%l3,%d,%s", index * 8, r);
      if (offset >= 6)
        Delay_Printf("st", "%s,[%%sp+%d]", r, 92 + (offset - 6) * 4);
    };
    return 1;
  }
  {
    char r[4];
    if (offset < 6)
      sprintf(r, "%%o%d", offset);
    else
      strcpy(r, "%l7");
    ;
    Delay_Printf("ld", "[%%l3+%d],%s", index * 8, r);
    if (offset >= 6)
      Delay_Printf("st", "%s,[%%sp+%d]", r, 92 + (offset - 6) * 4);
  };
  offset++;
  {
    char r[4];
    if (offset < 6)
      sprintf(r, "%%o%d", offset);
    else
      strcpy(r, "%l7");
    ;
    Delay_Printf("ld", "[%%l3+%d],%s", index * 8 + 4, r);
    if (offset >= 6)
      Delay_Printf("st", "%s,[%%sp+%d]", r, 92 + (offset - 6) * 4);
  };
  return 2;
}


x86 assembly (clang, -O0):
<Call_C_Arg_Foreign_D>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     11d7 <Call_C_Arg_Foreign_D+0xa7>
cmpl   $0x6,-0x8(%rbp)
jge    116d <Call_C_Arg_Foreign_D+0x3d>
lea    -0x14(%rbp),%rdi
mov    -0x8(%rbp),%edx
lea    0xe9d(%rip),%rsi
call   1040 <sprintf@plt>
jmp    117d <Call_C_Arg_Foreign_D+0x4d>
lea    -0x14(%rbp),%rdi
lea    0xe8e(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x10(%rbp),%edx
shl    $0x3,%edx
lea    -0x14(%rbp),%rcx
lea    0xe7c(%rip),%rdi
lea    0xe79(%rip),%rsi
mov    $0x0,%al
call   1050 <Delay_Printf@plt>
cmpl   $0x6,-0x8(%rbp)
jl     11cb <Call_C_Arg_Foreign_D+0x9b>
lea    -0x14(%rbp),%rdx
mov    -0x8(%rbp),%ecx
sub    $0x6,%ecx
shl    $0x2,%ecx
add    $0x5c,%ecx
lea    0xe5c(%rip),%rdi
lea    0xe58(%rip),%rsi
mov    $0x0,%al
call   1050 <Delay_Printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    12ea <Call_C_Arg_Foreign_D+0x1ba>
cmpl   $0x6,-0x8(%rbp)
jge    11f9 <Call_C_Arg_Foreign_D+0xc9>
lea    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%edx
lea    0xe11(%rip),%rsi
call   1040 <sprintf@plt>
jmp    1209 <Call_C_Arg_Foreign_D+0xd9>
lea    -0x18(%rbp),%rdi
lea    0xe02(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x10(%rbp),%edx
shl    $0x3,%edx
lea    -0x18(%rbp),%rcx
lea    0xe0f(%rip),%rdi
lea    0xe0b(%rip),%rsi
mov    $0x0,%al
call   1050 <Delay_Printf@plt>
cmpl   $0x6,-0x8(%rbp)
jl     1257 <Call_C_Arg_Foreign_D+0x127>
lea    -0x18(%rbp),%rdx
mov    -0x8(%rbp),%ecx
sub    $0x6,%ecx
shl    $0x2,%ecx
add    $0x5c,%ecx
lea    0xdd0(%rip),%rdi
lea    0xdcc(%rip),%rsi
mov    $0x0,%al
call   1050 <Delay_Printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
cmpl   $0x6,-0x8(%rbp)
jge    1282 <Call_C_Arg_Foreign_D+0x152>
lea    -0x1c(%rbp),%rdi
mov    -0x8(%rbp),%edx
lea    0xd88(%rip),%rsi
call   1040 <sprintf@plt>
jmp    1292 <Call_C_Arg_Foreign_D+0x162>
lea    -0x1c(%rbp),%rdi
lea    0xd79(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x10(%rbp),%edx
shl    $0x3,%edx
add    $0x4,%edx
lea    -0x1c(%rbp),%rcx
lea    0xd83(%rip),%rdi
lea    0xd7f(%rip),%rsi
mov    $0x0,%al
call   1050 <Delay_Printf@plt>
cmpl   $0x6,-0x8(%rbp)
jl     12e3 <Call_C_Arg_Foreign_D+0x1b3>
lea    -0x1c(%rbp),%rdx
mov    -0x8(%rbp),%ecx
sub    $0x6,%ecx
shl    $0x2,%ecx
add    $0x5c,%ecx
lea    0xd44(%rip),%rdi
lea    0xd40(%rip),%rsi
mov    $0x0,%al
call   1050 <Delay_Printf@plt>
movl   $0x2,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Call_C_Arg_Foreign_D>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %edx,%ebx
mov    %edi,%r14d
test   %esi,%esi
je     118b <Call_C_Arg_Foreign_D+0x5b>
cmp    $0x5,%r14d
jg     1216 <Call_C_Arg_Foreign_D+0xe6>
lea    0xeac(%rip),%rsi
lea    0x14(%rsp),%rbp
mov    %rbp,%rdi
mov    %r14d,%edx
call   1040 <sprintf@plt>
shl    $0x3,%ebx
lea    0xe9c(%rip),%rdi
lea    0xe99(%rip),%rsi
mov    %ebx,%edx
mov    %rbp,%rcx
xor    %eax,%eax
call   1050 <Delay_Printf@plt>
mov    $0x1,%eax
jmp    131b <Call_C_Arg_Foreign_D+0x1eb>
cmp    $0x6,%r14d
jge    1271 <Call_C_Arg_Foreign_D+0x141>
lea    0xe64(%rip),%rsi
lea    0x10(%rsp),%rbp
mov    %rbp,%rdi
mov    %r14d,%edx
call   1040 <sprintf@plt>
shl    $0x3,%ebx
lea    0xe73(%rip),%rdi
lea    0xe6f(%rip),%rsi
mov    %ebx,%edx
mov    %rbp,%rcx
xor    %eax,%eax
call   1050 <Delay_Printf@plt>
mov    $0x5c,%r15d
cmp    $0x5,%r14d
je     12ca <Call_C_Arg_Foreign_D+0x19a>
add    $0x1,%r14d
lea    0xe1c(%rip),%rsi
lea    0xc(%rsp),%rbp
mov    %rbp,%rdi
mov    %r14d,%edx
call   1040 <sprintf@plt>
or     $0x4,%ebx
lea    0xe2b(%rip),%rdi
lea    0xe27(%rip),%rsi
mov    %ebx,%edx
mov    %rbp,%rcx
xor    %eax,%eax
call   1050 <Delay_Printf@plt>
jmp    1316 <Call_C_Arg_Foreign_D+0x1e6>
lea    0xde9(%rip),%rsi
lea    0x14(%rsp),%rbp
mov    %rbp,%rdi
call   1030 <strcpy@plt>
shl    $0x3,%ebx
lea    0xdd6(%rip),%rdi
lea    0xdd3(%rip),%rsi
mov    %ebx,%edx
mov    %rbp,%rcx
xor    %eax,%eax
call   1050 <Delay_Printf@plt>
lea    0x44(,%r14,4),%ecx
lea    0xdc3(%rip),%rdi
lea    0xdbf(%rip),%rsi
mov    %rbp,%rdx
xor    %eax,%eax
call   1050 <Delay_Printf@plt>
mov    $0x1,%eax
jmp    131b <Call_C_Arg_Foreign_D+0x1eb>
lea    0xd8e(%rip),%rsi
lea    0x10(%rsp),%rbp
mov    %rbp,%rdi
call   1030 <strcpy@plt>
shl    $0x3,%ebx
lea    0xd9a(%rip),%rdi
lea    0xd96(%rip),%rsi
mov    %ebx,%edx
mov    %rbp,%rcx
xor    %eax,%eax
call   1050 <Delay_Printf@plt>
lea    0x44(,%r14,4),%ecx
lea    0xd68(%rip),%rdi
lea    0xd64(%rip),%rsi
mov    %rbp,%rdx
xor    %eax,%eax
call   1050 <Delay_Printf@plt>
lea    0x48(,%r14,4),%r15d
lea    0xd35(%rip),%rsi
lea    0xc(%rsp),%rbp
mov    %rbp,%rdi
call   1030 <strcpy@plt>
or     $0x4,%ebx
lea    0xd41(%rip),%rdi
lea    0xd3d(%rip),%rsi
mov    %ebx,%edx
mov    %rbp,%rcx
xor    %eax,%eax
call   1050 <Delay_Printf@plt>
lea    0xd17(%rip),%rdi
lea    0xd13(%rip),%rsi
mov    %rbp,%rdx
mov    %r15d,%ecx
xor    %eax,%eax
call   1050 <Delay_Printf@plt>
mov    $0x2,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
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"%%l3,%d,%s\00"
@.str.4 = [3 x i8] c"st\00"
@.str.5 = [13 x i8] c"%s,[%%sp+%d]\00"
@.str.6 = [3 x i8] c"ld\00"
@.str.7 = [13 x i8] c"[%%l3+%d],%s\00"
define i32 @Call_C_Arg_Foreign_D(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca [4 x i8]
%9 = alloca [4 x i8]
%10 = alloca [4 x i8]
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
%11 = load i32, i32* %6
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %38
13: ; preds = %3
%14 = load i32, i32* %5
%15 = icmp slt i32 %14, 6
br i1 %15, label %16, label %20
16: ; preds = %13
%17 = getelementptr inbounds [4 x i8], [4 x i8]* %8, i64 0, i64 0
%18 = load i32, i32* %5
%19 = call i32 @sprintf(i8* %17, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %18)
br label %23
20: ; preds = %13
%21 = getelementptr inbounds [4 x i8], [4 x i8]* %8, i64 0, i64 0
%22 = call i32 @strcpy(i8* %21, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
br label %23
23: ; preds = %20, %16
%24 = load i32, i32* %7
%25 = mul nsw i32 %24, 8
%26 = getelementptr inbounds [4 x i8], [4 x i8]* %8, i64 0, i64 0
%27 = 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 %25, i8* %26)
%28 = load i32, i32* %5
%29 = icmp sge i32 %28, 6
br i1 %29, label %30, label %37
30: ; preds = %23
%31 = getelementptr inbounds [4 x i8], [4 x i8]* %8, i64 0, i64 0
%32 = load i32, i32* %5
%33 = sub nsw i32 %32, 6
%34 = mul nsw i32 %33, 4
%35 = add nsw i32 92, %34
%36 = 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), i8* %31, i32 %35)
br label %37
37: ; preds = %30, %23
store i32 1, i32* %4
br label %90
38: ; preds = %3
%39 = load i32, i32* %5
%40 = icmp slt i32 %39, 6
br i1 %40, label %41, label %45
41: ; preds = %38
%42 = getelementptr inbounds [4 x i8], [4 x i8]* %9, i64 0, i64 0
%43 = load i32, i32* %5
%44 = call i32 @sprintf(i8* %42, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %43)
br label %48
45: ; preds = %38
%46 = getelementptr inbounds [4 x i8], [4 x i8]* %9, i64 0, i64 0
%47 = call i32 @strcpy(i8* %46, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
br label %48
48: ; preds = %45, %41
%49 = load i32, i32* %7
%50 = mul nsw i32 %49, 8
%51 = getelementptr inbounds [4 x i8], [4 x i8]* %9, i64 0, i64 0
%52 = 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), i32 %50, i8* %51)
%53 = load i32, i32* %5
%54 = icmp sge i32 %53, 6
br i1 %54, label %55, label %62
55: ; preds = %48
%56 = getelementptr inbounds [4 x i8], [4 x i8]* %9, i64 0, i64 0
%57 = load i32, i32* %5
%58 = sub nsw i32 %57, 6
%59 = mul nsw i32 %58, 4
%60 = add nsw i32 92, %59
%61 = 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), i8* %56, i32 %60)
br label %62
62: ; preds = %55, %48
%63 = load i32, i32* %5
%64 = add nsw i32 %63, 1
store i32 %64, i32* %5
%65 = load i32, i32* %5
%66 = icmp slt i32 %65, 6
br i1 %66, label %67, label %71
67: ; preds = %62
%68 = getelementptr inbounds [4 x i8], [4 x i8]* %10, i64 0, i64 0
%69 = load i32, i32* %5
%70 = call i32 @sprintf(i8* %68, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %69)
br label %74
71: ; preds = %62
%72 = getelementptr inbounds [4 x i8], [4 x i8]* %10, i64 0, i64 0
%73 = call i32 @strcpy(i8* %72, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
br label %74
74: ; preds = %71, %67
%75 = load i32, i32* %7
%76 = mul nsw i32 %75, 8
%77 = add nsw i32 %76, 4
%78 = getelementptr inbounds [4 x i8], [4 x i8]* %10, i64 0, i64 0
%79 = 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), i32 %77, i8* %78)
%80 = load i32, i32* %5
%81 = icmp sge i32 %80, 6
br i1 %81, label %82, label %89
82: ; preds = %74
%83 = getelementptr inbounds [4 x i8], [4 x i8]* %10, i64 0, i64 0
%84 = load i32, i32* %5
%85 = sub nsw i32 %84, 6
%86 = mul nsw i32 %85, 4
%87 = add nsw i32 92, %86
%88 = 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), i8* %83, i32 %87)
br label %89
89: ; preds = %82, %74
store i32 2, i32* %4
br label %90
90: ; preds = %89, %37
%91 = load i32, i32* %4
ret i32 %91
}

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"%%l3,%d,%s\00"
@.str.4 = [3 x i8] c"st\00"
@.str.5 = [13 x i8] c"%s,[%%sp+%d]\00"
@.str.6 = [3 x i8] c"ld\00"
@.str.7 = [13 x i8] c"[%%l3+%d],%s\00"
define i32 @Call_C_Arg_Foreign_D(i32 %0, i32 %1, i32 %2) {
%4 = alloca [4 x i8]
%5 = alloca [4 x i8]
%6 = alloca [4 x i8]
%7 = icmp eq i32 %1, 0
br i1 %7, label %23, label %8
8: ; preds = %3
%9 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 0
%10 = icmp slt i32 %0, 6
br i1 %10, label %11, label %15
11: ; preds = %8
%12 = call i32 @sprintf(i8* %9, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %0)
%13 = shl nsw i32 %2, 3
%14 = 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* %9)
br label %22
15: ; preds = %8
%16 = call i32 @strcpy(i8* %9, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%17 = shl nsw i32 %2, 3
%18 = 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 %17, i8* %9)
%19 = shl i32 %0, 2
%20 = add i32 %19, 68
%21 = 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), i8* %9, i32 %20)
br label %22
22: ; preds = %11, %15
br label %56
23: ; preds = %3
%24 = getelementptr inbounds [4 x i8], [4 x i8]* %5, i64 0, i64 0
%25 = icmp slt i32 %0, 6
br i1 %25, label %35, label %26
26: ; preds = %23
%27 = call i32 @strcpy(i8* %24, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%28 = shl nsw i32 %2, 3
%29 = 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), i32 %28, i8* %24)
%30 = shl i32 %0, 2
%31 = add i32 %30, 68
%32 = 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), i8* %24, i32 %31)
%33 = getelementptr inbounds [4 x i8], [4 x i8]* %6, i64 0, i64 0
%34 = add i32 %30, 72
br label %46
35: ; preds = %23
%36 = call i32 @sprintf(i8* %24, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %0)
%37 = shl nsw i32 %2, 3
%38 = 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), i32 %37, i8* %24)
%39 = getelementptr inbounds [4 x i8], [4 x i8]* %6, i64 0, i64 0
%40 = icmp eq i32 %0, 5
br i1 %40, label %46, label %41
41: ; preds = %35
%42 = add nsw i32 %0, 1
%43 = call i32 @sprintf(i8* %39, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %42)
%44 = or i32 %37, 4
%45 = 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), i32 %44, i8* %39)
br label %54
46: ; preds = %35, %26
%47 = phi i32 [ %34, %26 ], [ 92, %35 ]
%48 = phi i32 [ %28, %26 ], [ %37, %35 ]
%49 = getelementptr inbounds [4 x i8], [4 x i8]* %6, i64 0, i64 0
%50 = call i32 @strcpy(i8* %49, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%51 = or i32 %48, 4
%52 = 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), i32 %51, i8* %49)
%53 = 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), i8* %49, i32 %47)
br label %54
54: ; preds = %41, %46
%55 = getelementptr inbounds [4 x i8], [4 x i8]* %6, i64 0, i64 0
br label %56
56: ; preds = %54, %22
%57 = phi i32 [ 1, %22 ], [ 2, %54 ]
ret i32 %57
}