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


x86 assembly (clang, -O0):
<readInput>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
lea    0xecf(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1030 <scanf@plt>
cmpl   $0xffffffff,-0xc(%rbp)
jne    1149 <readInput+0x39>
jmp    116c <readInput+0x5c>
mov    -0xc(%rbp),%edx
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
movl   $0x0,-0xc(%rbp)
jmp    112a <readInput+0x1a>
mov    -0x10(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readInput>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r14
movl   $0x0,0x4(%rsp)
lea    0xed6(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1030 <scanf@plt>
mov    0x4(%rsp),%eax
xor    %ebx,%ebx
cmp    $0xffffffff,%eax
je     1174 <readInput+0x64>
lea    0xeba(%rip),%r15
lea    0x4(%rsp),%r12
nopl   0x0(%rax,%rax,1)
mov    %eax,(%r14,%rbx,4)
add    $0x1,%rbx
movl   $0x0,0x4(%rsp)
mov    %r15,%rdi
mov    %r12,%rsi
call   1030 <scanf@plt>
mov    0x4(%rsp),%eax
cmp    $0xffffffff,%eax
jne    1150 <readInput+0x40>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
define i32 @readInput(i32* nocapture writeonly %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
store i32 0, i32* %2
%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 %17, label %7
7: ; preds = %1, %7
%8 = phi i64 [ %11, %7 ], [ 0, %1 ]
%9 = phi i32 [ %13, %7 ], [ %5, %1 ]
%10 = getelementptr inbounds i32, i32* %0, i64 %8
store i32 %9, i32* %10
%11 = add nuw i64 %8, 1
store i32 0, i32* %2
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%13 = load i32, i32* %2
%14 = icmp eq i32 %13, -1
br i1 %14, label %15, label %7
15: ; preds = %7
%16 = trunc i64 %11 to i32
br label %17
17: ; preds = %15, %1
%18 = phi i32 [ 0, %1 ], [ %16, %15 ]
ret i32 %18
}