#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*/ fprintf(int /*<<< orphan*/, char *, size_t, size_t,
                           int const, int const);
int /*<<< orphan*/ stderr;
bool check_array(const int ns[], const size_t len) {
  size_t i;
  bool ret = true;
  for (i = 1; i < len; i++) {
    if (ns[i - 1] > ns[i]) {
      fprintf(stderr, "ns[%zu], ns[%zu] == %d, %d\n", i, i + 1, ns[i],
              ns[i + 1]);
      ret = false;
    }
  }
  return ret;
}


x86 assembly (clang, -O0):
<check_array>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x1c(%rbp)
movq   $0x1,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    11b4 <check_array+0xa4>
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
sub    $0x1,%rcx
mov    (%rax,%rcx,4),%eax
mov    -0x8(%rbp),%rcx
mov    -0x18(%rbp),%rdx
cmp    (%rcx,%rdx,4),%eax
jle    119e <check_array+0x8e>
mov    0x2e7c(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
mov    -0x18(%rbp),%rcx
add    $0x1,%rcx
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rsi
mov    (%rax,%rsi,4),%r8d
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rsi
mov    0x4(%rax,%rsi,4),%r9d
lea    0xe6e(%rip),%rsi
call   1030 <fprintf@plt>
movl   $0x0,-0x1c(%rbp)
jmp    11a3 <check_array+0x93>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    112f <check_array+0x1f>
mov    -0x1c(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_array>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    $0x1,%eax
cmp    $0x2,%rsi
jb     1186 <check_array+0x76>
mov    %rsi,%r14
mov    %rdi,%r12
mov    $0x1,%edx
mov    $0x1,%eax
mov    0x2ea5(%rip),%r13
lea    0xebe(%rip),%r15
jmp    1172 <check_array+0x62>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    0x0(%r13),%edi
lea    0x1(%rdx),%rbx
mov    0x4(%r12,%rdx,4),%r9d
mov    %r15,%rsi
mov    %rbx,%rcx
call   1030 <fprintf@plt>
xor    %eax,%eax
mov    %rbx,%rdx
cmp    %r14,%rdx
je     1186 <check_array+0x76>
mov    (%r12,%rdx,4),%r8d
cmp    %r8d,-0x4(%r12,%rdx,4)
jg     1150 <check_array+0x40>
add    $0x1,%rdx
cmp    %r14,%rdx
jne    1172 <check_array+0x62>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [28 x i8] c"ns[%zu], ns[%zu] == %d, %d\0A\00"
define i32 @check_array(i32* %0, i64 %1) {
%3 = alloca i32*
%4 = alloca i64
%5 = alloca i64
%6 = alloca i32
store i32* %0, i32** %3
store i64 %1, i64* %4
store i32 1, i32* %6
store i64 1, i64* %5
br label %7
7: ; preds = %38, %2
%8 = load i64, i64* %5
%9 = load i64, i64* %4
%10 = icmp ult i64 %8, %9
br i1 %10, label %11, label %41
11: ; preds = %7
%12 = load i32*, i32** %3
%13 = load i64, i64* %5
%14 = sub i64 %13, 1
%15 = getelementptr inbounds i32, i32* %12, i64 %14
%16 = load i32, i32* %15
%17 = load i32*, i32** %3
%18 = load i64, i64* %5
%19 = getelementptr inbounds i32, i32* %17, i64 %18
%20 = load i32, i32* %19
%21 = icmp sgt i32 %16, %20
br i1 %21, label %22, label %37
22: ; preds = %11
%23 = load i32, i32* @stderr
%24 = load i64, i64* %5
%25 = load i64, i64* %5
%26 = add i64 %25, 1
%27 = load i32*, i32** %3
%28 = load i64, i64* %5
%29 = getelementptr inbounds i32, i32* %27, i64 %28
%30 = load i32, i32* %29
%31 = load i32*, i32** %3
%32 = load i64, i64* %5
%33 = add i64 %32, 1
%34 = getelementptr inbounds i32, i32* %31, i64 %33
%35 = load i32, i32* %34
%36 = call i32 @fprintf(i32 %23, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i64 %24, i64 %26, i32 %30, i32 %35)
store i32 0, i32* %6
br label %37
37: ; preds = %22, %11
br label %38
38: ; preds = %37
%39 = load i64, i64* %5
%40 = add i64 %39, 1
store i64 %40, i64* %5
br label %7
41: ; preds = %7
%42 = load i32, i32* %6
ret i32 %42
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [28 x i8] c"ns[%zu], ns[%zu] == %d, %d\0A\00"
define i32 @check_array(i32* nocapture %0, i64 %1) {
%3 = icmp ugt i64 %1, 1
br i1 %3, label %4, label %25
4: ; preds = %2, %21
%5 = phi i32 [ %23, %21 ], [ 1, %2 ]
%6 = phi i64 [ %22, %21 ], [ 1, %2 ]
%7 = add i64 %6, -1
%8 = getelementptr inbounds i32, i32* %0, i64 %7
%9 = load i32, i32* %8
%10 = getelementptr inbounds i32, i32* %0, i64 %6
%11 = load i32, i32* %10
%12 = icmp sgt i32 %9, %11
br i1 %12, label %15, label %13
13: ; preds = %4
%14 = add nuw i64 %6, 1
br label %21
15: ; preds = %4
%16 = load i32, i32* @stderr
%17 = add nuw i64 %6, 1
%18 = getelementptr inbounds i32, i32* %0, i64 %17
%19 = load i32, i32* %18
%20 = tail call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i64 %6, i64 %17, i32 %11, i32 %19)
br label %21
21: ; preds = %13, %15
%22 = phi i64 [ %14, %13 ], [ %17, %15 ]
%23 = phi i32 [ %5, %13 ], [ 0, %15 ]
%24 = icmp eq i64 %22, %1
br i1 %24, label %25, label %4
25: ; preds = %21, %2
%26 = phi i32 [ 1, %2 ], [ %23, %21 ]
ret i32 %26
}