#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 rand();
int /*<<< orphan*/ swap(int *, int, int);
void skew_array(int *l, int n) {
  int i, j;
  i = 0;
  j = n - 1;
  while (i < j) {
    swap(l, i, j);
    i += 50 + rand() % 50;
    j -= 50 + rand() % 50;
  }
}


x86 assembly (clang, -O0):
<skew_array>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1193 <skew_array+0x73>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
call   1030 <swap@plt>
mov    $0x0,%al
call   1040 <rand@plt>
mov    $0x32,%ecx
cltd
idiv   %ecx
mov    %edx,%eax
add    $0x32,%eax
add    -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    $0x0,%al
call   1040 <rand@plt>
mov    $0x32,%ecx
cltd
idiv   %ecx
add    $0x32,%edx
mov    -0x14(%rbp),%eax
sub    %edx,%eax
mov    %eax,-0x14(%rbp)
jmp    113f <skew_array+0x1f>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<skew_array>:
push   %r15
push   %r14
push   %rbx
cmp    $0x2,%esi
jl     11a2 <skew_array+0x82>
mov    %esi,%r15d
mov    %rdi,%r14
add    $0xffffffff,%r15d
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %ebx,%esi
mov    %r15d,%edx
call   1030 <swap@plt>
xor    %eax,%eax
call   1040 <rand@plt>
cltq
imul   $0x51eb851f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x24,%rcx
add    %edx,%ecx
imul   $0x32,%ecx,%ecx
sub    %ecx,%eax
add    %eax,%ebx
add    $0x32,%ebx
xor    %eax,%eax
call   1040 <rand@plt>
cltq
imul   $0x51eb851f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x24,%rcx
add    %edx,%ecx
imul   $0x32,%ecx,%ecx
sub    %eax,%ecx
add    %ecx,%r15d
add    $0xffffffce,%r15d
cmp    %r15d,%ebx
jl     1140 <skew_array+0x20>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @skew_array(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
store i32 0, i32* %5
%7 = load i32, i32* %4
%8 = sub nsw i32 %7, 1
store i32 %8, i32* %6
br label %9
9: ; preds = %13, %2
%10 = load i32, i32* %5
%11 = load i32, i32* %6
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %28
13: ; preds = %9
%14 = load i32*, i32** %3
%15 = load i32, i32* %5
%16 = load i32, i32* %6
%17 = call i32 @swap(i32* %14, i32 %15, i32 %16)
%18 = call i32 (...) @rand()
%19 = srem i32 %18, 50
%20 = add nsw i32 50, %19
%21 = load i32, i32* %5
%22 = add nsw i32 %21, %20
store i32 %22, i32* %5
%23 = call i32 (...) @rand()
%24 = srem i32 %23, 50
%25 = add nsw i32 50, %24
%26 = load i32, i32* %6
%27 = sub nsw i32 %26, %25
store i32 %27, i32* %6
br label %9
28: ; preds = %9
ret void
}

LLVM IR (-O2):
define void @skew_array(i32* %0, i32 %1) {
%3 = icmp sgt i32 %1, 1
br i1 %3, label %4, label %19
4: ; preds = %2
%5 = add nsw i32 %1, -1
br label %6
6: ; preds = %4, %6
%7 = phi i32 [ %17, %6 ], [ %5, %4 ]
%8 = phi i32 [ %13, %6 ], [ 0, %4 ]
%9 = tail call i32 @swap(i32* %0, i32 %8, i32 %7)
%10 = tail call i32 (...) @rand()
%11 = srem i32 %10, 50
%12 = add i32 %8, 50
%13 = add i32 %12, %11
%14 = tail call i32 (...) @rand()
%15 = srem i32 %14, 50
%16 = add i32 %7, -50
%17 = sub i32 %16, %15
%18 = icmp slt i32 %13, %17
br i1 %18, label %6, label %19
19: ; preds = %6, %2
ret void
}