#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*/ print_array(int *, int);
int /*<<< orphan*/ swap_arr(int *, int *, int, int);
void swap_arr_test() {
  int arr1[5] = {1, 2, 3, 4, 5};
  int arr2[5] = {6, 7, 8, 9, 10};
  swap_arr(arr1, arr2, 5, sizeof(int));
  print_array(arr1, 5);
  print_array(arr2, 5);
}


x86 assembly (clang, -O0):
<swap_arr_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    0xed1(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xece(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xecc(%rip),%eax
mov    %eax,-0x10(%rbp)
mov    0xed2(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0xecf(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    0xecd(%rip),%eax
mov    %eax,-0x30(%rbp)
lea    -0x20(%rbp),%rdi
lea    -0x40(%rbp),%rsi
mov    $0x5,%edx
mov    $0x4,%ecx
call   1040 <swap_arr@plt>
lea    -0x20(%rbp),%rdi
mov    $0x5,%esi
call   1030 <print_array@plt>
lea    -0x40(%rbp),%rdi
mov    $0x5,%esi
call   1030 <print_array@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<swap_arr_test>:
push   %r14
push   %rbx
sub    $0x38,%rsp
mov    0xee3(%rip),%eax
mov    %eax,0x30(%rsp)
movaps 0xec8(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
mov    0xeed(%rip),%eax
mov    %eax,0x10(%rsp)
movaps 0xed2(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    0x20(%rsp),%rbx
mov    %rsp,%r14
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x5,%edx
mov    $0x4,%ecx
call   1040 <swap_arr@plt>
mov    %rbx,%rdi
mov    $0x5,%esi
call   1030 <print_array@plt>
mov    %r14,%rdi
mov    $0x5,%esi
call   1030 <print_array@plt>
add    $0x38,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.swap_arr_test.arr1 = [5 x i32] [i32 1, i32 2, i32 3, i32 4, i32 5]
@__const.swap_arr_test.arr2 = [5 x i32] [i32 6, i32 7, i32 8, i32 9, i32 10]
define void @swap_arr_test() {
%1 = alloca [5 x i32]
%2 = alloca [5 x i32]
%3 = bitcast [5 x i32]* %1 to i8*
%4 = bitcast [5 x i32]* %2 to i8*
%5 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 0
%6 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 0
%7 = call i32 @swap_arr(i32* %5, i32* %6, i32 5, i32 4)
%8 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 0
%9 = call i32 @print_array(i32* %8, i32 5)
%10 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 0
%11 = call i32 @print_array(i32* %10, i32 5)
ret void
}

LLVM IR (-O2):
@__const.swap_arr_test.arr1 = [5 x i32] [i32 1, i32 2, i32 3, i32 4, i32 5]
@__const.swap_arr_test.arr2 = [5 x i32] [i32 6, i32 7, i32 8, i32 9, i32 10]
define void @swap_arr_test() {
%1 = alloca [5 x i32]
%2 = alloca [5 x i32]
%3 = bitcast [5 x i32]* %1 to i8*
%4 = bitcast [5 x i32]* %2 to i8*
%5 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 0
%6 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 0
%7 = call i32 @swap_arr(i32* %5, i32* %6, i32 5, i32 4)
%8 = call i32 @print_array(i32* %5, i32 5)
%9 = call i32 @print_array(i32* %6, i32 5)
ret void
}