#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 */
typedef size_t int32_t;

/* Variables and functions */
int random();
void increasing_array(int32_t *a, int32_t n) {
  int32_t i, v;
  v = ((int32_t)(random() % 100)) - 50;
  for (i = 0; i < n; i++) {
    a[i] = v;
    v += (int32_t)(random() % 4);
  }
}


x86 assembly (clang, -O0):
<increasing_array>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1030 <random@plt>
mov    $0x64,%ecx
cltd
idiv   %ecx
movslq %edx,%rax
sub    $0x32,%rax
mov    %rax,-0x20(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    118b <increasing_array+0x7b>
mov    -0x20(%rbp),%rdx
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    $0x0,%al
call   1030 <random@plt>
mov    $0x4,%ecx
cltd
idiv   %ecx
movslq %edx,%rax
add    -0x20(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1142 <increasing_array+0x32>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<increasing_array>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r15
mov    %rdi,%r14
xor    %eax,%eax
call   1030 <random@plt>
test   %r15,%r15
je     1176 <increasing_array+0x66>
cltq
imul   $0x51eb851f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x25,%rcx
add    %edx,%ecx
imul   $0x64,%ecx,%ecx
neg    %ecx
add    %ecx,%eax
add    $0xffffffce,%eax
movslq %eax,%r12
xor    %ebx,%ebx
nop
mov    %r12,(%r14,%rbx,8)
xor    %eax,%eax
call   1030 <random@plt>
lea    0x3(%rax),%ecx
test   %eax,%eax
cmovns %eax,%ecx
and    $0xfffffffc,%ecx
sub    %ecx,%eax
cltq
add    %rax,%r12
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1150 <increasing_array+0x40>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define void @increasing_array(i64* nocapture writeonly %0, i64 %1) {
%3 = tail call i32 (...) @random()
%4 = icmp eq i64 %1, 0
br i1 %4, label %19, label %5
5: ; preds = %2
%6 = srem i32 %3, 100
%7 = add nsw i32 %6, -50
%8 = sext i32 %7 to i64
br label %9
9: ; preds = %5, %9
%10 = phi i64 [ %16, %9 ], [ %8, %5 ]
%11 = phi i64 [ %17, %9 ], [ 0, %5 ]
%12 = getelementptr inbounds i64, i64* %0, i64 %11
store i64 %10, i64* %12
%13 = tail call i32 (...) @random()
%14 = srem i32 %13, 4
%15 = sext i32 %14 to i64
%16 = add i64 %10, %15
%17 = add nuw i64 %11, 1
%18 = icmp eq i64 %17, %1
br i1 %18, label %19, label %9
19: ; preds = %9, %2
ret void
}