#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*/ printf(char *, ...);
void verify_array(int *array, int N) {
  for (int i = 0; i < N - 1; i++)
    if (array[i] > array[i + 1]) {
      printf("FAILED: array[%d]=%d, array[%d]=%d\n", i, array[i], i + 1,
             array[i + 1]);
      return;
    }
  printf("Result verified!\n");
}


x86 assembly (clang, -O0):
<verify_array>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    11a3 <verify_array+0x93>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    -0x8(%rbp),%rcx
mov    -0x10(%rbp),%edx
add    $0x1,%edx
movslq %edx,%rdx
cmp    (%rcx,%rdx,4),%eax
jle    1190 <verify_array+0x80>
mov    -0x10(%rbp),%esi
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
mov    -0x10(%rbp),%ecx
add    $0x1,%ecx
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%edi
add    $0x1,%edi
movslq %edi,%rdi
mov    (%rax,%rdi,4),%r8d
lea    0xe7c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11b1 <verify_array+0xa1>
jmp    1195 <verify_array+0x85>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1126 <verify_array+0x16>
lea    0xe7a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<verify_array>:
add    $0xffffffff,%esi
xor    %ecx,%ecx
test   %esi,%esi
cmovle %ecx,%esi
nopw   0x0(%rax,%rax,1)
cmp    %rcx,%rsi
je     1157 <verify_array+0x37>
mov    (%rdi,%rcx,4),%edx
mov    0x4(%rdi,%rcx,4),%r8d
add    $0x1,%rcx
cmp    %r8d,%edx
jle    1130 <verify_array+0x10>
lea    -0x1(%rcx),%esi
lea    0xeb0(%rip),%rdi
xor    %eax,%eax
jmp    1040 <printf@plt>
lea    0xec6(%rip),%rdi
jmp    1030 <puts@plt>

LLVM IR (-O0):
@.str = [36 x i8] c"FAILED: array[%d]=%d, array[%d]=%d\0A\00"
@.str.1 = [18 x i8] c"Result verified!\0A\00"
define void @verify_array(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
store i32 0, i32* %5
br label %6
6: ; preds = %41, %2
%7 = load i32, i32* %5
%8 = load i32, i32* %4
%9 = sub nsw i32 %8, 1
%10 = icmp slt i32 %7, %9
br i1 %10, label %11, label %44
11: ; preds = %6
%12 = load i32*, i32** %3
%13 = load i32, i32* %5
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i32, i32* %12, i64 %14
%16 = load i32, i32* %15
%17 = load i32*, i32** %3
%18 = load i32, i32* %5
%19 = add nsw i32 %18, 1
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i32, i32* %17, i64 %20
%22 = load i32, i32* %21
%23 = icmp sgt i32 %16, %22
br i1 %23, label %24, label %40
24: ; preds = %11
%25 = load i32, i32* %5
%26 = load i32*, i32** %3
%27 = load i32, i32* %5
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i32, i32* %26, i64 %28
%30 = load i32, i32* %29
%31 = load i32, i32* %5
%32 = add nsw i32 %31, 1
%33 = load i32*, i32** %3
%34 = load i32, i32* %5
%35 = add nsw i32 %34, 1
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i32, i32* %33, i64 %36
%38 = load i32, i32* %37
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i32 %25, i32 %30, i32 %32, i32 %38)
br label %46
40: ; preds = %11
br label %41
41: ; preds = %40
%42 = load i32, i32* %5
%43 = add nsw i32 %42, 1
store i32 %43, i32* %5
br label %6
44: ; preds = %6
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
br label %46
46: ; preds = %44, %24
ret void
}

LLVM IR (-O2):
@.str = [36 x i8] c"FAILED: array[%d]=%d, array[%d]=%d\0A\00"
@str = [17 x i8] c"Result verified!\00"
define void @verify_array(i32* nocapture %0, i32 %1) {
%3 = add i32 %1, -1
%4 = call i32 @llvm.smax.i32(i32 %3, i32 0)
%5 = zext i32 %4 to i64
br label %6
6: ; preds = %9, %2
%7 = phi i64 [ %12, %9 ], [ 0, %2 ]
%8 = icmp eq i64 %7, %5
br i1 %8, label %20, label %9
9: ; preds = %6
%10 = getelementptr inbounds i32, i32* %0, i64 %7
%11 = load i32, i32* %10
%12 = add nuw nsw i64 %7, 1
%13 = getelementptr inbounds i32, i32* %0, i64 %12
%14 = load i32, i32* %13
%15 = icmp sgt i32 %11, %14
br i1 %15, label %16, label %6
16: ; preds = %9
%17 = trunc i64 %7 to i32
%18 = trunc i64 %12 to i32
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i32 %17, i32 %11, i32 %18, i32 %14)
br label %22
20: ; preds = %6
%21 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str, i64 0, i64 0))
br label %22
22: ; preds = %16, %20
ret void
}