#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*/ determineOrder(int **, int, int);
int /*<<< orphan*/ initTableOrder(int **, int, int);
int /*<<< orphan*/ printResult(int **, int, int);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int numPage, numSheet, printOrder[2 * 101][2];
  while (1) {
    scanf("%d", &numPage);
    if (numPage == 0)
      break;
    numSheet = numPage / 4;
    if (numPage % 4)
      numSheet++;
    initTableOrder(printOrder, numSheet << 1, -1);
    determineOrder(printOrder, numSheet, numPage);
    printResult(printOrder, numSheet, numPage);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x660,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xea7(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
cmpl   $0x0,-0x8(%rbp)
jne    1171 <main+0x31>
jmp    11dc <main+0x9c>
mov    -0x8(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     119c <main+0x5c>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
lea    -0x660(%rbp),%rdi
mov    -0xc(%rbp),%esi
shl    $0x1,%esi
mov    $0xffffffff,%edx
call   1040 <initTableOrder@plt>
lea    -0x660(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x8(%rbp),%edx
call   1060 <determineOrder@plt>
lea    -0x660(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x8(%rbp),%edx
call   1030 <printResult@plt>
jmp    1152 <main+0x12>
xor    %eax,%eax
add    $0x660,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x668,%rsp
lea    0xeab(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%eax
test   %eax,%eax
je     11d3 <main+0x93>
lea    0x10(%rsp),%r12
lea    0xe8d(%rip),%r14
lea    0xc(%rsp),%r15
nopl   0x0(%rax,%rax,1)
lea    0x3(%rax),%ebx
test   %eax,%eax
cmovns %eax,%ebx
sar    $0x2,%ebx
and    $0x3,%eax
cmp    $0x1,%eax
sbb    $0xffffffff,%ebx
lea    (%rbx,%rbx,1),%esi
mov    %r12,%rdi
mov    $0xffffffff,%edx
call   1040 <initTableOrder@plt>
mov    0xc(%rsp),%edx
mov    %r12,%rdi
mov    %ebx,%esi
call   1060 <determineOrder@plt>
mov    0xc(%rsp),%edx
mov    %r12,%rdi
mov    %ebx,%esi
call   1030 <printResult@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%eax
test   %eax,%eax
jne    1180 <main+0x40>
xor    %eax,%eax
add    $0x668,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [202 x [2 x i32]]
store i32 0, i32* %1
br label %5
5: ; preds = %0, %19
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%7 = load i32, i32* %2
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %10
9: ; preds = %5
br label %35
10: ; preds = %5
%11 = load i32, i32* %2
%12 = sdiv i32 %11, 4
store i32 %12, i32* %3
%13 = load i32, i32* %2
%14 = srem i32 %13, 4
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %10
%17 = load i32, i32* %3
%18 = add nsw i32 %17, 1
store i32 %18, i32* %3
br label %19
19: ; preds = %16, %10
%20 = getelementptr inbounds [202 x [2 x i32]], [202 x [2 x i32]]* %4, i64 0, i64 0
%21 = bitcast [2 x i32]* %20 to i32**
%22 = load i32, i32* %3
%23 = shl i32 %22, 1
%24 = call i32 @initTableOrder(i32** %21, i32 %23, i32 -1)
%25 = getelementptr inbounds [202 x [2 x i32]], [202 x [2 x i32]]* %4, i64 0, i64 0
%26 = bitcast [2 x i32]* %25 to i32**
%27 = load i32, i32* %3
%28 = load i32, i32* %2
%29 = call i32 @determineOrder(i32** %26, i32 %27, i32 %28)
%30 = getelementptr inbounds [202 x [2 x i32]], [202 x [2 x i32]]* %4, i64 0, i64 0
%31 = bitcast [2 x i32]* %30 to i32**
%32 = load i32, i32* %3
%33 = load i32, i32* %2
%34 = call i32 @printResult(i32** %31, i32 %32, i32 %33)
br label %5
35: ; preds = %9
ret i32 0
}

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