#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 */
struct task_struct {
  int dummy;
};
struct pt_regs {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ microblaze_get_syscall_arg(struct pt_regs *,
                                              int /*<<< orphan*/);
void syscall_get_arguments(struct task_struct *task, struct pt_regs *regs,
                           unsigned int i, unsigned int n,
                           unsigned long *args) {
  while (n--)
    *args++ = microblaze_get_syscall_arg(regs, i++);
}


x86 assembly (clang, -O0):
<syscall_get_arguments>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x18(%rbp)
cmp    $0x0,%eax
je     116c <syscall_get_arguments+0x5c>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    %esi,%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
call   1030 <microblaze_get_syscall_arg@plt>
movslq %eax,%rcx
mov    -0x20(%rbp),%rax
mov    %rax,%rdx
add    $0x8,%rdx
mov    %rdx,-0x20(%rbp)
mov    %rcx,(%rax)
jmp    112a <syscall_get_arguments+0x1a>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<syscall_get_arguments>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
test   %ecx,%ecx
je     114b <syscall_get_arguments+0x3b>
mov    %r8,%r14
mov    %rsi,%r15
mov    %ecx,%r12d
mov    %edx,%r13d
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
lea    (%rbx,%r13,1),%esi
mov    %r15,%rdi
call   1030 <microblaze_get_syscall_arg@plt>
cltq
mov    %rax,(%r14,%rbx,8)
add    $0x1,%rbx
cmp    %ebx,%r12d
jne    1130 <syscall_get_arguments+0x20>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.task_struct = type { i32 }
%struct.pt_regs = type { i32 }
define void @syscall_get_arguments(%struct.task_struct* %0, %struct.pt_regs* %1, i32 %2, i32 %3, i64* %4) {
%6 = alloca %struct.task_struct*
%7 = alloca %struct.pt_regs*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i64*
store %struct.task_struct* %0, %struct.task_struct** %6
store %struct.pt_regs* %1, %struct.pt_regs** %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store i64* %4, i64** %10
br label %11
11: ; preds = %15, %5
%12 = load i32, i32* %9
%13 = add i32 %12, -1
store i32 %13, i32* %9
%14 = icmp ne i32 %12, 0
br i1 %14, label %15, label %23
15: ; preds = %11
%16 = load %struct.pt_regs*, %struct.pt_regs** %7
%17 = load i32, i32* %8
%18 = add i32 %17, 1
store i32 %18, i32* %8
%19 = call i32 @microblaze_get_syscall_arg(%struct.pt_regs* %16, i32 %17)
%20 = sext i32 %19 to i64
%21 = load i64*, i64** %10
%22 = getelementptr inbounds i64, i64* %21, i32 1
store i64* %22, i64** %10
store i64 %20, i64* %21
br label %11
23: ; preds = %11
ret void
}

LLVM IR (-O2):
%struct.task_struct = type { i32 }
%struct.pt_regs = type { i32 }
define void @syscall_get_arguments(%struct.task_struct* nocapture readnone %0, %struct.pt_regs* %1, i32 %2, i32 %3, i64* nocapture writeonly %4) {
%6 = icmp eq i32 %3, 0
br i1 %6, label %17, label %7
7: ; preds = %5, %7
%8 = phi i64* [ %15, %7 ], [ %4, %5 ]
%9 = phi i32 [ %11, %7 ], [ %3, %5 ]
%10 = phi i32 [ %12, %7 ], [ %2, %5 ]
%11 = add i32 %9, -1
%12 = add i32 %10, 1
%13 = tail call i32 @microblaze_get_syscall_arg(%struct.pt_regs* %1, i32 %10)
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i64, i64* %8, i64 1
store i64 %14, i64* %8
%16 = icmp eq i32 %11, 0
br i1 %16, label %17, label %7
17: ; preds = %7, %5
ret void
}