#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*/ perror(char *);
int /*<<< orphan*/ printf(char *);
void checkAscending(int *nums, int size) {
  for (int i = 0; i < size - 1; i++)
    if (nums[i] > nums[i + 1]) {
      perror("Sorting failed!\n");
      printf("Sorting failed!\n");
      return;
    }
  perror("Sorted successfully!\n");
  printf("Sorted successfully!\n");
}


x86 assembly (clang, -O0):
<checkAscending>:
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    1198 <checkAscending+0x78>
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    1185 <checkAscending+0x65>
lea    0xe91(%rip),%rdi
call   1040 <perror@plt>
lea    0xe85(%rip),%rdi
call   1030 <printf@plt>
jmp    11b0 <checkAscending+0x90>
jmp    118a <checkAscending+0x6a>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1136 <checkAscending+0x16>
lea    0xe72(%rip),%rdi
call   1040 <perror@plt>
lea    0xe66(%rip),%rdi
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<checkAscending>:
push   %r14
push   %rbx
push   %rax
add    $0xffffffff,%esi
xor    %ecx,%ecx
test   %esi,%esi
cmovle %ecx,%esi
lea    0xef2(%rip),%r14
lea    0xed5(%rip),%rax
lea    0xef9(%rip),%r8
lea    0xeb6(%rip),%r9
nopw   0x0(%rax,%rax,1)
cmp    %rcx,%rsi
je     116b <checkAscending+0x4b>
mov    (%rdi,%rcx,4),%edx
lea    0x1(%rcx),%rbx
cmp    0x4(%rdi,%rcx,4),%edx
mov    %rbx,%rcx
jle    1150 <checkAscending+0x30>
mov    %r9,%rax
mov    %r8,%r14
mov    %rax,%rdi
call   1040 <perror@plt>
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <puts@plt>

LLVM IR (-O0):
@.str = [17 x i8] c"Sorting failed!\0A\00"
@.str.1 = [22 x i8] c"Sorted successfully!\0A\00"
define void @checkAscending(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 = %28, %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 %31
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 %27
24: ; preds = %11
%25 = call i32 @perror(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%26 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
br label %34
27: ; preds = %11
br label %28
28: ; preds = %27
%29 = load i32, i32* %5
%30 = add nsw i32 %29, 1
store i32 %30, i32* %5
br label %6
31: ; preds = %6
%32 = call i32 @perror(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
%33 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
br label %34
34: ; preds = %31, %24
ret void
}

LLVM IR (-O2):
@.str = [17 x i8] c"Sorting failed!\0A\00"
@.str.1 = [22 x i8] c"Sorted successfully!\0A\00"
@str = [21 x i8] c"Sorted successfully!\00"
@str.2 = [16 x i8] c"Sorting failed!\00"
define void @checkAscending(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 %16, 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 = %6, %9
%17 = phi i8* [ getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), %9 ], [ getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), %6 ]
%18 = phi i8* [ getelementptr inbounds ([16 x i8], [16 x i8]* @str.2, i64 0, i64 0), %9 ], [ getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0), %6 ]
%19 = tail call i32 @perror(i8* %17)
%20 = tail call i32 @puts(i8* dereferenceable(1) %18)
ret void
}