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


x86 assembly (clang, -O0):
<Call_C_Arg_String>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
cmpl   $0x8,-0x4(%rbp)
jge    1163 <Call_C_Arg_String+0x33>
lea    -0xc(%rbp),%rdi
mov    -0x4(%rbp),%edx
add    $0x3,%edx
lea    0xea7(%rip),%rsi
call   1050 <sprintf@plt>
jmp    1173 <Call_C_Arg_String+0x43>
lea    -0xc(%rbp),%rdi
lea    0xe96(%rip),%rsi
call   1040 <strcpy@plt>
lea    -0xc(%rbp),%rdx
mov    -0x8(%rbp),%r8d
lea    0xe86(%rip),%rdi
lea    0xe85(%rip),%rsi
lea    0xe8e(%rip),%rcx
mov    $0x0,%al
call   1030 <Inst_Printf@plt>
lea    -0xc(%rbp),%rdx
lea    -0xc(%rbp),%rcx
mov    -0x8(%rbp),%r9d
lea    0xe78(%rip),%rdi
lea    0xe76(%rip),%rsi
lea    0xe66(%rip),%r8
mov    $0x0,%al
call   1030 <Inst_Printf@plt>
cmpl   $0x8,-0x4(%rbp)
jl     11eb <Call_C_Arg_String+0xbb>
lea    -0xc(%rbp),%rdx
mov    -0x4(%rbp),%ecx
shl    $0x2,%ecx
add    $0x18,%ecx
lea    0xe5b(%rip),%rdi
lea    0xe58(%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_String>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%r15d
mov    %edi,%ebx
cmp    $0x7,%edi
jg     1157 <Call_C_Arg_String+0x27>
lea    0x3(%rbx),%edx
lea    0xeb5(%rip),%rsi
lea    0x4(%rsp),%rdi
call   1050 <sprintf@plt>
jmp    1168 <Call_C_Arg_String+0x38>
lea    0xea6(%rip),%rsi
lea    0x4(%rsp),%rdi
call   1040 <strcpy@plt>
lea    0xe99(%rip),%rdi
lea    0xe98(%rip),%rsi
lea    0xea1(%rip),%r14
lea    0x4(%rsp),%rbp
mov    %rbp,%rdx
mov    %r14,%rcx
mov    %r15d,%r8d
xor    %eax,%eax
call   1030 <Inst_Printf@plt>
lea    0xe89(%rip),%rdi
lea    0xe87(%rip),%rsi
mov    %rbp,%rdx
mov    %rbp,%rcx
mov    %r14,%r8
mov    %r15d,%r9d
xor    %eax,%eax
call   1030 <Inst_Printf@plt>
cmp    $0x8,%ebx
jl     11d9 <Call_C_Arg_String+0xa9>
lea    0x18(,%rbx,4),%ecx
lea    0xe72(%rip),%rdi
lea    0xe6f(%rip),%rsi
lea    0x4(%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 = [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 = [16 x i8] c"%s,0,ha16(%s%d)\00"
@.str.4 = [4 x i8] c".LC\00"
@.str.5 = [5 x i8] c"addi\00"
@.str.6 = [17 x i8] c"%s,%s,lo16(%s%d)\00"
@.str.7 = [4 x i8] c"stw\00"
@.str.8 = [10 x i8] c"%s,%d(r1)\00"
define i32 @Call_C_Arg_String(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca [4 x i8]
store i32 %0, i32* %3
store i32 %1, i32* %4
%6 = load i32, i32* %3
%7 = icmp slt i32 %6, 8
br i1 %7, label %8, label %13
8: ; preds = %2
%9 = getelementptr inbounds [4 x i8], [4 x i8]* %5, i64 0, i64 0
%10 = load i32, i32* %3
%11 = add nsw i32 %10, 3
%12 = call i32 @sprintf(i8* %9, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %11)
br label %16
13: ; preds = %2
%14 = getelementptr inbounds [4 x i8], [4 x i8]* %5, i64 0, i64 0
%15 = call i32 @strcpy(i8* %14, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
br label %16
16: ; preds = %13, %8
%17 = getelementptr inbounds [4 x i8], [4 x i8]* %5, i64 0, i64 0
%18 = load i32, i32* %4
%19 = 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 ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i8* %17, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %18)
%20 = getelementptr inbounds [4 x i8], [4 x i8]* %5, i64 0, i64 0
%21 = getelementptr inbounds [4 x i8], [4 x i8]* %5, i64 0, i64 0
%22 = load i32, i32* %4
%23 = call i32 (i8*, i8*, i8*, ...) @Inst_Printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0), i8* %20, i8* %21, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %22)
%24 = load i32, i32* %3
%25 = icmp sge i32 %24, 8
br i1 %25, label %26, label %32
26: ; preds = %16
%27 = getelementptr inbounds [4 x i8], [4 x i8]* %5, i64 0, i64 0
%28 = load i32, i32* %3
%29 = mul nsw i32 %28, 4
%30 = add nsw i32 %29, 24
%31 = call i32 (i8*, i8*, i8*, ...) @Inst_Printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.8, i64 0, i64 0), i8* %27, i32 %30)
br label %32
32: ; preds = %26, %16
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 = [16 x i8] c"%s,0,ha16(%s%d)\00"
@.str.4 = [4 x i8] c".LC\00"
@.str.5 = [5 x i8] c"addi\00"
@.str.6 = [17 x i8] c"%s,%s,lo16(%s%d)\00"
@.str.7 = [4 x i8] c"stw\00"
@.str.8 = [10 x i8] c"%s,%d(r1)\00"
define i32 @Call_C_Arg_String(i32 %0, i32 %1) {
%3 = alloca [4 x i8]
%4 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 0
%5 = icmp slt i32 %0, 8
br i1 %5, label %6, label %9
6: ; preds = %2
%7 = add nsw i32 %0, 3
%8 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %7)
br label %11
9: ; preds = %2
%10 = call i32 @strcpy(i8* %4, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
br label %11
11: ; preds = %9, %6
%12 = 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 ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i8* %4, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %1)
%13 = call i32 (i8*, i8*, i8*, ...) @Inst_Printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0), i8* %4, i8* %4, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %1)
%14 = icmp sgt i32 %0, 7
br i1 %14, label %15, label %19
15: ; preds = %11
%16 = shl nsw i32 %0, 2
%17 = add nsw i32 %16, 24
%18 = call i32 (i8*, i8*, i8*, ...) @Inst_Printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.8, i64 0, i64 0), i8* %4, i32 %17)
br label %19
19: ; preds = %15, %11
ret i32 1
}