#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 int /*<<< orphan*/ b;
typedef int /*<<< orphan*/ a;

/* Variables and functions */
scalar_t__ chk(int *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *);
int main() {
  int a[5] = {1, 2, 3, 4, 5};
  int b[5] = {1, 2, 5, 3, 4};
  int size = sizeof(a) / sizeof(int);
  if (chk(a, 0, size - 1))
    printf("Arr is sorted.\n");
  else
    printf("Arr is not sorted.\n");
  size = sizeof(b);
  if (chk(b, 0, size - 1))
    printf("Arr is sorted.\n");
  else
    printf("Arr is not sorted.\n");
  return 1;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeca(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xec7(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xec5(%rip),%eax
mov    %eax,-0x10(%rbp)
mov    0xecb(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0xec8(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    0xec6(%rip),%eax
mov    %eax,-0x30(%rbp)
movl   $0x5,-0x44(%rbp)
lea    -0x20(%rbp),%rdi
mov    -0x44(%rbp),%edx
sub    $0x1,%edx
xor    %esi,%esi
call   1030 <chk@plt>
cmp    $0x0,%rax
je     11a0 <main+0x80>
lea    0xe9e(%rip),%rdi
call   1040 <printf@plt>
jmp    11ac <main+0x8c>
lea    0xe9d(%rip),%rdi
call   1040 <printf@plt>
movl   $0x14,-0x44(%rbp)
lea    -0x40(%rbp),%rdi
mov    -0x44(%rbp),%edx
sub    $0x1,%edx
xor    %esi,%esi
call   1030 <chk@plt>
cmp    $0x0,%rax
je     11df <main+0xbf>
lea    0xe5f(%rip),%rdi
call   1040 <printf@plt>
jmp    11eb <main+0xcb>
lea    0xe5e(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x38,%rsp
mov    0xee3(%rip),%eax
mov    %eax,0x30(%rsp)
movaps 0xec8(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
mov    0xeed(%rip),%eax
mov    %eax,0x10(%rsp)
movaps 0xed2(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    0x20(%rsp),%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1040 <chk@plt>
test   %rax,%rax
lea    0xec7(%rip),%r14
lea    0xed3(%rip),%rbx
mov    %rbx,%rdi
cmove  %r14,%rdi
call   1030 <puts@plt>
mov    %rsp,%rdi
xor    %esi,%esi
mov    $0x13,%edx
call   1040 <chk@plt>
test   %rax,%rax
cmove  %r14,%rbx
mov    %rbx,%rdi
call   1030 <puts@plt>
mov    $0x1,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.main.a = [5 x i32] [i32 1, i32 2, i32 3, i32 4, i32 5]
@__const.main.b = [5 x i32] [i32 1, i32 2, i32 5, i32 3, i32 4]
@.str = [16 x i8] c"Arr is sorted.\0A\00"
@.str.1 = [20 x i8] c"Arr is not sorted.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [5 x i32]
%3 = alloca [5 x i32]
%4 = alloca i32
store i32 0, i32* %1
%5 = bitcast [5 x i32]* %2 to i8*
%6 = bitcast [5 x i32]* %3 to i8*
store i32 5, i32* %4
%7 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 0
%8 = load i32, i32* %4
%9 = sub nsw i32 %8, 1
%10 = call i64 @chk(i32* %7, i32 0, i32 %9)
%11 = icmp ne i64 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %0
%13 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
br label %16
14: ; preds = %0
%15 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
br label %16
16: ; preds = %14, %12
store i32 20, i32* %4
%17 = getelementptr inbounds [5 x i32], [5 x i32]* %3, i64 0, i64 0
%18 = load i32, i32* %4
%19 = sub nsw i32 %18, 1
%20 = call i64 @chk(i32* %17, i32 0, i32 %19)
%21 = icmp ne i64 %20, 0
br i1 %21, label %22, label %24
22: ; preds = %16
%23 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
br label %26
24: ; preds = %16
%25 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
br label %26
26: ; preds = %24, %22
ret i32 1
}

LLVM IR (-O2):
@__const.main.a = [5 x i32] [i32 1, i32 2, i32 3, i32 4, i32 5]
@__const.main.b = [5 x i32] [i32 1, i32 2, i32 5, i32 3, i32 4]
@str.2 = [19 x i8] c"Arr is not sorted.\00"
@str.4 = [15 x i8] c"Arr is sorted.\00"
define i32 @main() {
%1 = alloca [5 x i32]
%2 = alloca [5 x i32]
%3 = bitcast [5 x i32]* %1 to i8*
%4 = bitcast [5 x i32]* %2 to i8*
%5 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 0
%6 = call i64 @chk(i32* %5, i32 0, i32 4)
%7 = icmp eq i64 %6, 0
%8 = select i1 %7, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @str.2, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @str.4, i64 0, i64 0)
%9 = call i32 @puts(i8* dereferenceable(1) %8)
%10 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 0
%11 = call i64 @chk(i32* %10, i32 0, i32 19)
%12 = icmp eq i64 %11, 0
%13 = select i1 %12, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @str.2, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @str.4, i64 0, i64 0)
%14 = call i32 @puts(i8* dereferenceable(1) %13)
ret i32 1
}