#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*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ tri(int);
void main() {
  int input;
  scanf("%d", &input);
  while (input != -1) {
    if (input % 2 == 1 || input == 0)
      printf("1\n");
    else
      printf("%ld\n", tri(input / 2));
    scanf("%d", &input);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xec1(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0xffffffff,-0x4(%rbp)
je     11ba <main+0x8a>
mov    -0x4(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x1,%edx
je     1170 <main+0x40>
cmpl   $0x0,-0x4(%rbp)
jne    1183 <main+0x53>
lea    0xe8c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11a5 <main+0x75>
mov    -0x4(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%edi
call   1050 <tri@plt>
mov    %eax,%esi
lea    0xe68(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe54(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1040 <scanf@plt>
jmp    1148 <main+0x18>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
lea    0xeb1(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%eax
cmp    $0xffffffff,%eax
je     11c8 <main+0x88>
lea    0xe9f(%rip),%r14
lea    0xe90(%rip),%r15
lea    0x4(%rsp),%rbx
lea    0xe87(%rip),%r12
jmp    119c <main+0x5c>
xchg   %ax,%ax
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%eax
cmp    $0xffffffff,%eax
je     11c8 <main+0x88>
test   %eax,%eax
je     1180 <main+0x40>
mov    %eax,%edi
shr    $0x1f,%edi
add    %eax,%edi
mov    %edi,%ecx
and    $0xfffffffe,%ecx
sub    %ecx,%eax
cmp    $0x1,%eax
je     1180 <main+0x40>
sar    %edi
call   1060 <tri@plt>
mov    %r12,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1188 <main+0x48>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.2 = [5 x i8] c"%ld\0A\00"
@str = [2 x i8] c"1\00"
define void @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%4 = load i32, i32* %1
%5 = icmp eq i32 %4, -1
br i1 %5, label %22, label %6
6: ; preds = %0, %18
%7 = phi i32 [ %20, %18 ], [ %4, %0 ]
%8 = srem i32 %7, 2
%9 = sdiv i32 %7, 2
%10 = icmp eq i32 %8, 1
%11 = icmp eq i32 %7, 0
%12 = or i1 %11, %10
br i1 %12, label %13, label %15
13: ; preds = %6
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
br label %18
15: ; preds = %6
%16 = call i32 @tri(i32 %9)
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %16)
br label %18
18: ; preds = %15, %13
%19 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%20 = load i32, i32* %1
%21 = icmp eq i32 %20, -1
br i1 %21, label %22, label %6
22: ; preds = %18, %0
ret void
}