#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 /*<<< orphan*/ buf;

/* Variables and functions */
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, int);
int process(int, char **, int, int, int, int);
int /*<<< orphan*/ sscanf(char *, char *, int *, ...);
int /*<<< orphan*/ stdin;
int main() {
  char pt[500][2];
  char buf[256];
  int i, pt_num, max_width, max_height, pt_x, pt_y, width, height;
  while (1) {
    {
      if (fgets(buf, sizeof(buf), stdin) == NULL)
        break;
    };
    sscanf(buf, "%d", &pt_num);
    if (pt_num == 0)
      break;
    {
      if (fgets(buf, sizeof(buf), stdin) == NULL)
        break;
    };
    sscanf(buf, "%d %d", &max_width, &max_height);
    for (i = 0; i < pt_num; i++) {
      {
        if (fgets(buf, sizeof(buf), stdin) == NULL)
          break;
      };
      sscanf(buf, "%d %d", &pt_x, &pt_y);
      pt[i][0] = pt_x;
      pt[i][1] = pt_y;
    }
    {
      if (fgets(buf, sizeof(buf), stdin) == NULL)
        break;
    };
    sscanf(buf, "%d %d", &width, &height);
    printf("%d\n", process(pt_num, pt, max_width, max_height, width, height));
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x510,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x4f0(%rbp),%rdi
mov    0x2e88(%rip),%rax
mov    (%rax),%edx
mov    $0x100,%esi
call   1050 <fgets@plt>
cmp    $0x0,%rax
jne    117b <main+0x3b>
jmp    1328 <main+0x1e8>
lea    -0x4f0(%rbp),%rdi
lea    0xe7a(%rip),%rsi
lea    -0x4f8(%rbp),%rdx
mov    $0x0,%al
call   1060 <sscanf@plt>
cmpl   $0x0,-0x4f8(%rbp)
jne    11a9 <main+0x69>
jmp    1328 <main+0x1e8>
lea    -0x4f0(%rbp),%rdi
mov    0x2e31(%rip),%rax
mov    (%rax),%edx
mov    $0x100,%esi
call   1050 <fgets@plt>
cmp    $0x0,%rax
jne    11d2 <main+0x92>
jmp    1328 <main+0x1e8>
lea    -0x4f0(%rbp),%rdi
lea    0xe20(%rip),%rsi
lea    -0x4fc(%rbp),%rdx
lea    -0x500(%rbp),%rcx
mov    $0x0,%al
call   1060 <sscanf@plt>
movl   $0x0,-0x4f4(%rbp)
mov    -0x4f4(%rbp),%eax
cmp    -0x4f8(%rbp),%eax
jge    129d <main+0x15d>
lea    -0x4f0(%rbp),%rdi
mov    0x2dc9(%rip),%rax
mov    (%rax),%edx
mov    $0x100,%esi
call   1050 <fgets@plt>
cmp    $0x0,%rax
jne    123a <main+0xfa>
jmp    129d <main+0x15d>
lea    -0x4f0(%rbp),%rdi
lea    0xdb8(%rip),%rsi
lea    -0x504(%rbp),%rdx
lea    -0x508(%rbp),%rcx
mov    $0x0,%al
call   1060 <sscanf@plt>
mov    -0x504(%rbp),%eax
mov    %al,%cl
movslq -0x4f4(%rbp),%rax
mov    %cl,-0x3f0(%rbp,%rax,2)
mov    -0x508(%rbp),%eax
mov    %al,%cl
movslq -0x4f4(%rbp),%rax
mov    %cl,-0x3ef(%rbp,%rax,2)
mov    -0x4f4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4f4(%rbp)
jmp    11ff <main+0xbf>
lea    -0x4f0(%rbp),%rdi
mov    0x2d3d(%rip),%rax
mov    (%rax),%edx
mov    $0x100,%esi
call   1050 <fgets@plt>
cmp    $0x0,%rax
jne    12c6 <main+0x186>
jmp    1328 <main+0x1e8>
lea    -0x4f0(%rbp),%rdi
lea    0xd2c(%rip),%rsi
lea    -0x50c(%rbp),%rdx
lea    -0x510(%rbp),%rcx
mov    $0x0,%al
call   1060 <sscanf@plt>
mov    -0x4f8(%rbp),%edi
lea    -0x3f0(%rbp),%rsi
mov    -0x4fc(%rbp),%edx
mov    -0x500(%rbp),%ecx
mov    -0x50c(%rbp),%r8d
mov    -0x510(%rbp),%r9d
call   1040 <process@plt>
mov    %eax,%esi
lea    0xce8(%rip),%rdi
call   1030 <printf@plt>
jmp    1152 <main+0x12>
xor    %eax,%eax
add    $0x510,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x508,%rsp
mov    0x2e90(%rip),%r14
mov    (%r14),%edx
lea    0x20(%rsp),%rdi
mov    $0x100,%esi
call   1050 <fgets@plt>
test   %rax,%rax
je     12b6 <main+0x176>
lea    0x20(%rsp),%rbx
lea    0xe81(%rip),%r12
lea    0x14(%rsp),%r13
lea    0x10(%rsp),%rbp
nopl   0x0(%rax)
mov    %rbx,%rdi
lea    0xe69(%rip),%rsi
lea    0x4(%rsp),%rdx
xor    %eax,%eax
call   1060 <sscanf@plt>
cmpl   $0x0,0x4(%rsp)
je     12b6 <main+0x176>
mov    (%r14),%edx
mov    %rbx,%rdi
mov    $0x100,%esi
call   1050 <fgets@plt>
test   %rax,%rax
je     12b6 <main+0x176>
mov    %rbx,%rdi
mov    %r12,%rsi
lea    0x1c(%rsp),%rdx
lea    0x18(%rsp),%rcx
xor    %eax,%eax
call   1060 <sscanf@plt>
cmpl   $0x0,0x4(%rsp)
jle    1240 <main+0x100>
xor    %r15d,%r15d
nopl   0x0(%rax,%rax,1)
mov    (%r14),%edx
mov    %rbx,%rdi
mov    $0x100,%esi
call   1050 <fgets@plt>
test   %rax,%rax
je     1240 <main+0x100>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %r13,%rdx
mov    %rbp,%rcx
xor    %eax,%eax
call   1060 <sscanf@plt>
movzbl 0x14(%rsp),%eax
mov    %al,0x120(%rsp,%r15,2)
movzbl 0x10(%rsp),%eax
mov    %al,0x121(%rsp,%r15,2)
add    $0x1,%r15
movslq 0x4(%rsp),%rax
cmp    %rax,%r15
jl     11f0 <main+0xb0>
mov    (%r14),%edx
mov    %rbx,%rdi
mov    $0x100,%esi
call   1050 <fgets@plt>
test   %rax,%rax
je     12b6 <main+0x176>
mov    %rbx,%rdi
mov    %r12,%rsi
lea    0xc(%rsp),%rdx
lea    0x8(%rsp),%rcx
xor    %eax,%eax
call   1060 <sscanf@plt>
mov    0x4(%rsp),%edi
mov    0x1c(%rsp),%edx
mov    0x18(%rsp),%ecx
mov    0xc(%rsp),%r8d
mov    0x8(%rsp),%r9d
lea    0x120(%rsp),%rsi
call   1040 <process@plt>
lea    0xd70(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    (%r14),%edx
mov    %rbx,%rdi
mov    $0x100,%esi
call   1050 <fgets@plt>
test   %rax,%rax
jne    1190 <main+0x50>
xor    %eax,%eax
add    $0x508,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stdin = global i32 0
@.str = [3 x i8] c"%d\00"
@.str.1 = [6 x i8] c"%d %d\00"
@.str.2 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [500 x [2 x i8]]
%3 = alloca [256 x i8]
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32 0, i32* %1
br label %12
12: ; preds = %0, %67
%13 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%14 = load i32, i32* @stdin
%15 = call i32* @fgets(i8* %13, i32 256, i32 %14)
%16 = icmp eq i32* %15, null
br i1 %16, label %17, label %18
17: ; preds = %12
br label %79
18: ; preds = %12
%19 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%20 = call i32 (i8*, i8*, i32*, ...) @sscanf(i8* %19, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %5)
%21 = load i32, i32* %5
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %24
23: ; preds = %18
br label %79
24: ; preds = %18
%25 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%26 = load i32, i32* @stdin
%27 = call i32* @fgets(i8* %25, i32 256, i32 %26)
%28 = icmp eq i32* %27, null
br i1 %28, label %29, label %30
29: ; preds = %24
br label %79
30: ; preds = %24
%31 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%32 = call i32 (i8*, i8*, i32*, ...) @sscanf(i8* %31, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %6, i32* %7)
store i32 0, i32* %4
br label %33
33: ; preds = %58, %30
%34 = load i32, i32* %4
%35 = load i32, i32* %5
%36 = icmp slt i32 %34, %35
br i1 %36, label %37, label %61
37: ; preds = %33
%38 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%39 = load i32, i32* @stdin
%40 = call i32* @fgets(i8* %38, i32 256, i32 %39)
%41 = icmp eq i32* %40, null
br i1 %41, label %42, label %43
42: ; preds = %37
br label %61
43: ; preds = %37
%44 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%45 = call i32 (i8*, i8*, i32*, ...) @sscanf(i8* %44, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %8, i32* %9)
%46 = load i32, i32* %8
%47 = trunc i32 %46 to i8
%48 = load i32, i32* %4
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds [500 x [2 x i8]], [500 x [2 x i8]]* %2, i64 0, i64 %49
%51 = getelementptr inbounds [2 x i8], [2 x i8]* %50, i64 0, i64 0
store i8 %47, i8* %51
%52 = load i32, i32* %9
%53 = trunc i32 %52 to i8
%54 = load i32, i32* %4
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds [500 x [2 x i8]], [500 x [2 x i8]]* %2, i64 0, i64 %55
%57 = getelementptr inbounds [2 x i8], [2 x i8]* %56, i64 0, i64 1
store i8 %53, i8* %57
br label %58
58: ; preds = %43
%59 = load i32, i32* %4
%60 = add nsw i32 %59, 1
store i32 %60, i32* %4
br label %33
61: ; preds = %42, %33
%62 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%63 = load i32, i32* @stdin
%64 = call i32* @fgets(i8* %62, i32 256, i32 %63)
%65 = icmp eq i32* %64, null
br i1 %65, label %66, label %67
66: ; preds = %61
br label %79
67: ; preds = %61
%68 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%69 = call i32 (i8*, i8*, i32*, ...) @sscanf(i8* %68, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %10, i32* %11)
%70 = load i32, i32* %5
%71 = getelementptr inbounds [500 x [2 x i8]], [500 x [2 x i8]]* %2, i64 0, i64 0
%72 = bitcast [2 x i8]* %71 to i8**
%73 = load i32, i32* %6
%74 = load i32, i32* %7
%75 = load i32, i32* %10
%76 = load i32, i32* %11
%77 = call i32 @process(i32 %70, i8** %72, i32 %73, i32 %74, i32 %75, i32 %76)
%78 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %77)
br label %12
79: ; preds = %66, %29, %23, %17
ret i32 0
}

LLVM IR (-O2):
@stdin = global i32 0
@.str = [3 x i8] c"%d\00"
@.str.1 = [6 x i8] c"%d %d\00"
@.str.2 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca [500 x [2 x i8]]
%2 = alloca [256 x i8]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = getelementptr inbounds [500 x [2 x i8]], [500 x [2 x i8]]* %1, i64 0, i64 0, i64 0
%11 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%12 = bitcast i32* %3 to i8*
%13 = bitcast i32* %4 to i8*
%14 = bitcast i32* %5 to i8*
%15 = bitcast i32* %6 to i8*
%16 = bitcast i32* %7 to i8*
%17 = bitcast i32* %8 to i8*
%18 = bitcast i32* %9 to i8*
%19 = load i32, i32* @stdin
%20 = call i32* @fgets(i8* %11, i32 256, i32 %19)
%21 = icmp eq i32* %20, null
br i1 %21, label %69, label %22
22: ; preds = %0
%23 = bitcast [500 x [2 x i8]]* %1 to i8**
br label %24
24: ; preds = %22, %57
%25 = call i32 (i8*, i8*, i32*, ...) @sscanf(i8* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%26 = load i32, i32* %3
%27 = icmp eq i32 %26, 0
br i1 %27, label %69, label %28
28: ; preds = %24
%29 = load i32, i32* @stdin
%30 = call i32* @fgets(i8* %11, i32 256, i32 %29)
%31 = icmp eq i32* %30, null
br i1 %31, label %69, label %32
32: ; preds = %28
%33 = call i32 (i8*, i8*, i32*, ...) @sscanf(i8* %11, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %4, i32* %5)
%34 = load i32, i32* %3
%35 = icmp sgt i32 %34, 0
br i1 %35, label %36, label %53
36: ; preds = %32, %41
%37 = phi i64 [ %49, %41 ], [ 0, %32 ]
%38 = load i32, i32* @stdin
%39 = call i32* @fgets(i8* %11, i32 256, i32 %38)
%40 = icmp eq i32* %39, null
br i1 %40, label %53, label %41
41: ; preds = %36
%42 = call i32 (i8*, i8*, i32*, ...) @sscanf(i8* %11, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %6, i32* %7)
%43 = load i32, i32* %6
%44 = trunc i32 %43 to i8
%45 = getelementptr inbounds [500 x [2 x i8]], [500 x [2 x i8]]* %1, i64 0, i64 %37, i64 0
store i8 %44, i8* %45
%46 = load i32, i32* %7
%47 = trunc i32 %46 to i8
%48 = getelementptr inbounds [500 x [2 x i8]], [500 x [2 x i8]]* %1, i64 0, i64 %37, i64 1
store i8 %47, i8* %48
%49 = add nuw nsw i64 %37, 1
%50 = load i32, i32* %3
%51 = sext i32 %50 to i64
%52 = icmp slt i64 %49, %51
br i1 %52, label %36, label %53
53: ; preds = %41, %36, %32
%54 = load i32, i32* @stdin
%55 = call i32* @fgets(i8* %11, i32 256, i32 %54)
%56 = icmp eq i32* %55, null
br i1 %56, label %69, label %57
57: ; preds = %53
%58 = call i32 (i8*, i8*, i32*, ...) @sscanf(i8* %11, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %8, i32* %9)
%59 = load i32, i32* %3
%60 = load i32, i32* %4
%61 = load i32, i32* %5
%62 = load i32, i32* %8
%63 = load i32, i32* %9
%64 = call i32 @process(i32 %59, i8** %23, i32 %60, i32 %61, i32 %62, i32 %63)
%65 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %64)
%66 = load i32, i32* @stdin
%67 = call i32* @fgets(i8* %11, i32 256, i32 %66)
%68 = icmp eq i32* %67, null
br i1 %68, label %69, label %24
69: ; preds = %57, %24, %28, %53, %0
ret i32 0
}