#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*/ scanf(char *, int *);
int processInput(int *arr) {
  int present, prev = -1, i = 0;
  while (1) {
    scanf("%d", &present);
    if (present == -1)
      break;
    if (prev < present) {
      arr[i] = present;
      i++;
      prev = present;
    } else if (prev > present)
      return -1;
  }
  return i;
}


x86 assembly (clang, -O0):
<processInput>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0xffffffff,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
lea    0xecf(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1030 <scanf@plt>
cmpl   $0xffffffff,-0x14(%rbp)
jne    1149 <processInput+0x39>
jmp    1199 <processInput+0x89>
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1177 <processInput+0x67>
mov    -0x14(%rbp),%edx
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
jmp    1194 <processInput+0x84>
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jle    118f <processInput+0x7f>
movl   $0xffffffff,-0x4(%rbp)
jmp    119f <processInput+0x8f>
jmp    1194 <processInput+0x84>
jmp    112a <processInput+0x1a>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<processInput>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%r14
lea    0xeda(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1030 <scanf@plt>
mov    0xc(%rsp),%eax
cmp    $0xffffffff,%eax
je     117d <processInput+0x6d>
mov    $0xffffffff,%ebp
xor    %ebx,%ebx
lea    0xeb9(%rip),%r15
lea    0xc(%rsp),%r12
jmp    1170 <processInput+0x60>
xchg   %ax,%ax
movslq %ebx,%rbx
mov    %eax,(%r14,%rbx,4)
add    $0x1,%ebx
mov    %eax,%ebp
mov    %r15,%rdi
mov    %r12,%rsi
call   1030 <scanf@plt>
mov    0xc(%rsp),%eax
cmp    $0xffffffff,%eax
je     117f <processInput+0x6f>
cmp    %eax,%ebp
jl     1150 <processInput+0x40>
jle    115c <processInput+0x4c>
mov    $0xffffffff,%ebx
jmp    117f <processInput+0x6f>
xor    %ebx,%ebx
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
define i32 @processInput(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 0, i32* %6
br label %7
7: ; preds = %1, %31
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %4)
%9 = load i32, i32* %4
%10 = icmp eq i32 %9, -1
br i1 %10, label %11, label %12
11: ; preds = %7
br label %32
12: ; preds = %7
%13 = load i32, i32* %5
%14 = load i32, i32* %4
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %25
16: ; preds = %12
%17 = load i32, i32* %4
%18 = load i32*, i32** %3
%19 = load i32, i32* %6
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i32, i32* %18, i64 %20
store i32 %17, i32* %21
%22 = load i32, i32* %6
%23 = add nsw i32 %22, 1
store i32 %23, i32* %6
%24 = load i32, i32* %4
store i32 %24, i32* %5
br label %31
25: ; preds = %12
%26 = load i32, i32* %5
%27 = load i32, i32* %4
%28 = icmp sgt i32 %26, %27
br i1 %28, label %29, label %30
29: ; preds = %25
store i32 -1, i32* %2
br label %34
30: ; preds = %25
br label %31
31: ; preds = %30, %16
br label %7
32: ; preds = %11
%33 = load i32, i32* %6
store i32 %33, i32* %2
br label %34
34: ; preds = %32, %29
%35 = load i32, i32* %2
ret i32 %35
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
define i32 @processInput(i32* nocapture writeonly %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%5 = load i32, i32* %2
%6 = icmp eq i32 %5, -1
br i1 %6, label %24, label %7
7: ; preds = %1, %18
%8 = phi i32 [ %22, %18 ], [ %5, %1 ]
%9 = phi i32 [ %20, %18 ], [ 0, %1 ]
%10 = phi i32 [ %19, %18 ], [ -1, %1 ]
%11 = icmp slt i32 %10, %8
br i1 %11, label %12, label %16
12: ; preds = %7
%13 = sext i32 %9 to i64
%14 = getelementptr inbounds i32, i32* %0, i64 %13
store i32 %8, i32* %14
%15 = add nsw i32 %9, 1
br label %18
16: ; preds = %7
%17 = icmp sgt i32 %10, %8
br i1 %17, label %24, label %18
18: ; preds = %16, %12
%19 = phi i32 [ %8, %12 ], [ %10, %16 ]
%20 = phi i32 [ %15, %12 ], [ %9, %16 ]
%21 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%22 = load i32, i32* %2
%23 = icmp eq i32 %22, -1
br i1 %23, label %24, label %7
24: ; preds = %16, %18, %1
%25 = phi i32 [ 0, %1 ], [ %20, %18 ], [ -1, %16 ]
ret i32 %25
}