#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 ssize_t;

/* Variables and functions */
int /*<<< orphan*/ EXIT_SUCCESS;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ free(char *);
int getline(char **, size_t *, int /*<<< orphan*/);
scalar_t__ parse(char *, int *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdin;
int main(int argc, char **argv) {
  char *line = NULL;
  size_t len = 0;
  ssize_t read;
  int result = 0;
  while ((read = getline(&line, &len, stdin)) != -1) {
    if (parse(line, &result) < 0) {
      printf("ERROR!\n");
    } else {
      printf("%d\n", result);
    }
  }
  free(line);
  exit(EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movl   $0x0,-0x28(%rbp)
mov    0x2e64(%rip),%rax
mov    (%rax),%edx
lea    -0x18(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1050 <getline@plt>
mov    %eax,-0x24(%rbp)
cmp    $0xffffffff,%eax
je     11df <main+0x8f>
mov    -0x18(%rbp),%rdi
lea    -0x28(%rbp),%rsi
call   1060 <parse@plt>
cmp    $0x0,%rax
jge    11c9 <main+0x79>
lea    0xe43(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11da <main+0x8a>
mov    -0x28(%rbp),%esi
lea    0xe35(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    117d <main+0x2d>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    0x2de9(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
movq   $0x0,0x8(%rsp)
movq   $0x0,0x10(%rsp)
movl   $0x0,0x4(%rsp)
mov    0x2e59(%rip),%rbp
mov    0x0(%rbp),%edx
lea    0x8(%rsp),%rdi
lea    0x10(%rsp),%rsi
call   1060 <getline@plt>
cmp    $0xffffffff,%eax
jne    11be <main+0x5e>
mov    0x8(%rsp),%rdi
call   1030 <free@plt>
mov    0x2e21(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
lea    0x4(%rsp),%r15
lea    0xe3a(%rip),%r14
lea    0x8(%rsp),%r12
lea    0x10(%rsp),%rbx
lea    0xe25(%rip),%r13
jmp    1201 <main+0xa1>
nopl   (%rax)
mov    0x4(%rsp),%esi
mov    %r13,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x0(%rbp),%edx
mov    %r12,%rdi
mov    %rbx,%rsi
call   1060 <getline@plt>
cmp    $0xffffffff,%eax
je     11a6 <main+0x46>
mov    0x8(%rsp),%rdi
mov    %r15,%rsi
call   1070 <parse@plt>
test   %rax,%rax
jns    11e0 <main+0x80>
mov    %r14,%rdi
call   1040 <puts@plt>
jmp    11ee <main+0x8e>

LLVM IR (-O0):
@stdin = global i32 0
@.str = [8 x i8] c"ERROR!\0A\00"
@.str.1 = [4 x i8] c"%d\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* null, i8** %6
store i64 0, i64* %7
store i32 0, i32* %9
br label %10
10: ; preds = %23, %2
%11 = load i32, i32* @stdin
%12 = call i32 @getline(i8** %6, i64* %7, i32 %11)
store i32 %12, i32* %8
%13 = icmp ne i32 %12, -1
br i1 %13, label %14, label %24
14: ; preds = %10
%15 = load i8*, i8** %6
%16 = call i64 @parse(i8* %15, i32* %9)
%17 = icmp slt i64 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %14
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
br label %23
20: ; preds = %14
%21 = load i32, i32* %9
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %21)
br label %23
23: ; preds = %20, %18
br label %10
24: ; preds = %10
%25 = load i8*, i8** %6
%26 = call i32 @free(i8* %25)
%27 = load i32, i32* @EXIT_SUCCESS
%28 = call i32 @exit(i32 %27)
unreachable
}

LLVM IR (-O2):
@stdin = global i32 0
@.str.1 = [4 x i8] c"%d\0A\00"
@EXIT_SUCCESS = global i32 0
@str = [7 x i8] c"ERROR!\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i32
%6 = bitcast i8** %3 to i8*
store i8* null, i8** %3
%7 = bitcast i64* %4 to i8*
store i64 0, i64* %4
%8 = bitcast i32* %5 to i8*
store i32 0, i32* %5
%9 = load i32, i32* @stdin
%10 = call i32 @getline(i8** %3, i64* %4, i32 %9)
%11 = icmp eq i32 %10, -1
br i1 %11, label %25, label %12
12: ; preds = %2, %21
%13 = load i8*, i8** %3
%14 = call i64 @parse(i8* %13, i32* %5)
%15 = icmp slt i64 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %12
%17 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str, i64 0, i64 0))
br label %21
18: ; preds = %12
%19 = load i32, i32* %5
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %19)
br label %21
21: ; preds = %18, %16
%22 = load i32, i32* @stdin
%23 = call i32 @getline(i8** %3, i64* %4, i32 %22)
%24 = icmp eq i32 %23, -1
br i1 %24, label %25, label %12
25: ; preds = %21, %2
%26 = load i8*, i8** %3
%27 = call i32 @free(i8* %26)
%28 = load i32, i32* @EXIT_SUCCESS
%29 = call i32 @exit(i32 %28)
unreachable
}