#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 *, ...);
int printarray(int *array) {
  int i;
  int sorted = 1;
  int prev = -1;
  for (i = 0; i < (25); ++i) {
    printf("%d, ", array[i]);
    if (array[i] < prev) {
      sorted = 0;
    }
    prev = array[i];
  }
  if (sorted) {
    printf("\nok\n");
    return 0;
  } else {
    printf("\nNOT sorted\n");
    return -1;
  }
  return -1;
}


x86 assembly (clang, -O0):
<printarray>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x1,-0x18(%rbp)
movl   $0xffffffff,-0x1c(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x19,-0x14(%rbp)
jge    118b <printarray+0x7b>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xeb3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
cmp    -0x1c(%rbp),%eax
jge    116f <printarray+0x5f>
movl   $0x0,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1131 <printarray+0x21>
cmpl   $0x0,-0x18(%rbp)
je     11af <printarray+0x9f>
lea    0xe69(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    11c4 <printarray+0xb4>
lea    0xe54(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printarray>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r12
mov    $0x1,%ebp
mov    $0xffffffff,%r13d
xor    %r15d,%r15d
lea    0xebd(%rip),%r14
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
mov    (%r12,%rbx,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%r12,%rbx,4),%eax
cmp    %r13d,%eax
cmovl  %r15d,%ebp
add    $0x1,%rbx
mov    %eax,%r13d
cmp    $0x19,%rbx
jne    1150 <printarray+0x30>
xor    %ebx,%ebx
test   %ebp,%ebp
sete   %bl
lea    0xe81(%rip),%rax
lea    0xe86(%rip),%rdi
cmove  %rax,%rdi
neg    %ebx
call   1030 <puts@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [5 x i8] c"%d, \00"
@str = [12 x i8] c"\0ANOT sorted\00"
@str.3 = [4 x i8] c"\0Aok\00"
define i32 @printarray(i32* nocapture %0) {
br label %2
2: ; preds = %1, %2
%3 = phi i64 [ 0, %1 ], [ %12, %2 ]
%4 = phi i32 [ -1, %1 ], [ %9, %2 ]
%5 = phi i32 [ 1, %1 ], [ %11, %2 ]
%6 = getelementptr inbounds i32, i32* %0, i64 %3
%7 = load i32, i32* %6
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = load i32, i32* %6
%10 = icmp slt i32 %9, %4
%11 = select i1 %10, i32 0, i32 %5
%12 = add nuw nsw i64 %3, 1
%13 = icmp eq i64 %12, 25
br i1 %13, label %14, label %2
14: ; preds = %2
%15 = icmp eq i32 %11, 0
%16 = select i1 %15, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @str.3, i64 0, i64 0)
%17 = sext i1 %15 to i32
%18 = tail call i32 @puts(i8* dereferenceable(1) %16)
ret i32 %17
}