#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_set_syscall_arg(struct pt_regs *,
                                              int /*<<< orphan*/,
                                              int /*<<< orphan*/);
void syscall_set_arguments(struct task_struct *task, struct pt_regs *regs,
                           unsigned int i, unsigned int n,
                           const unsigned long *args) {
  while (n--)
    microblaze_set_syscall_arg(regs, i++, *args++);
}


x86 assembly (clang, -O0):
<syscall_set_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     116b <syscall_set_arguments+0x5b>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    %esi,%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x20(%rbp)
mov    (%rax),%rax
mov    %eax,%edx
call   1030 <microblaze_set_syscall_arg@plt>
jmp    112a <syscall_set_arguments+0x1a>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<syscall_set_arguments>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
test   %ecx,%ecx
je     1149 <syscall_set_arguments+0x39>
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    (%r14,%rbx,8),%edx
mov    %r15,%rdi
call   1030 <microblaze_set_syscall_arg@plt>
add    $0x1,%rbx
cmp    %ebx,%r12d
jne    1130 <syscall_set_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_set_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 %24
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 = load i64*, i64** %10
%20 = getelementptr inbounds i64, i64* %19, i32 1
store i64* %20, i64** %10
%21 = load i64, i64* %19
%22 = trunc i64 %21 to i32
%23 = call i32 @microblaze_set_syscall_arg(%struct.pt_regs* %16, i32 %17, i32 %22)
br label %11
24: ; preds = %11
ret void
}

LLVM IR (-O2):
%struct.task_struct = type { i32 }
%struct.pt_regs = type { i32 }
define void @syscall_set_arguments(%struct.task_struct* nocapture readnone %0, %struct.pt_regs* %1, i32 %2, i32 %3, i64* nocapture %4) {
%6 = icmp eq i32 %3, 0
br i1 %6, label %18, label %7
7: ; preds = %5, %7
%8 = phi i64* [ %13, %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 = getelementptr inbounds i64, i64* %8, i64 1
%14 = load i64, i64* %8
%15 = trunc i64 %14 to i32
%16 = tail call i32 @microblaze_set_syscall_arg(%struct.pt_regs* %1, i32 %10, i32 %15)
%17 = icmp eq i32 %11, 0
br i1 %17, label %18, label %7
18: ; preds = %7, %5
ret void
}