#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 calculate_output(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ stderr;
int main() {
  int output = -1;
  while (1) {
    int input;
    scanf("%d", &input);
    output = calculate_output(input);
    if (output == -2)
      fprintf(stderr, "Invalid input: %d\n", input);
    else if (output != -1)
      printf("%d\n", output);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0xffffffff,-0x8(%rbp)
lea    0xea3(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1060 <scanf@plt>
mov    -0xc(%rbp),%edi
call   1030 <calculate_output@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0xfffffffe,-0x8(%rbp)
jne    1198 <main+0x58>
mov    0x2e5e(%rip),%rax
mov    (%rax),%edi
mov    -0xc(%rbp),%edx
lea    0xe75(%rip),%rsi
call   1050 <fprintf@plt>
jmp    11b6 <main+0x76>
cmpl   $0xffffffff,-0x8(%rbp)
je     11b1 <main+0x71>
mov    -0x8(%rbp),%esi
lea    0xe66(%rip),%rdi
call   1040 <printf@plt>
jmp    11b6 <main+0x76>
jmp    1156 <main+0x16>

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xeac(%rip),%r14
lea    0xc(%rsp),%rbx
mov    0x2e80(%rip),%r13
lea    0xe9c(%rip),%r15
lea    0xea4(%rip),%r12
jmp    1180 <main+0x40>
mov    0x0(%r13),%edi
mov    0xc(%rsp),%edx
mov    %r15,%rsi
call   1050 <fprintf@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1060 <scanf@plt>
mov    0xc(%rsp),%edi
call   1030 <calculate_output@plt>
cmp    $0xffffffff,%eax
je     1180 <main+0x40>
cmp    $0xfffffffe,%eax
je     1170 <main+0x30>
mov    %r12,%rdi
mov    %eax,%esi
call   1040 <printf@plt>
jmp    1180 <main+0x40>

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@stderr = global i32 0
@.str.1 = [19 x i8] c"Invalid input: %d\0A\00"
@.str.2 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
store i32 -1, i32* %2
br label %4
4: ; preds = %0, %21
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%6 = load i32, i32* %3
%7 = call i32 @calculate_output(i32 %6)
store i32 %7, i32* %2
%8 = load i32, i32* %2
%9 = icmp eq i32 %8, -2
br i1 %9, label %10, label %14
10: ; preds = %4
%11 = load i32, i32* @stderr
%12 = load i32, i32* %3
%13 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 %12)
br label %21
14: ; preds = %4
%15 = load i32, i32* %2
%16 = icmp ne i32 %15, -1
br i1 %16, label %17, label %20
17: ; preds = %14
%18 = load i32, i32* %2
%19 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %18)
br label %20
20: ; preds = %17, %14
br label %21
21: ; preds = %20, %10
br label %4
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@stderr = global i32 0
@.str.1 = [19 x i8] c"Invalid input: %d\0A\00"
@.str.2 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
br label %3
3: ; preds = %13, %0
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%5 = load i32, i32* %1
%6 = call i32 @calculate_output(i32 %5)
switch i32 %6, label %11 [
i32 -2, label %7
i32 -1, label %13
]
7: ; preds = %3
%8 = load i32, i32* @stderr
%9 = load i32, i32* %1
%10 = call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 %9)
br label %13
11: ; preds = %3
%12 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %6)
br label %13
13: ; preds = %3, %11, %7
br label %3
}