#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 *, char *, char *);
int /*<<< orphan*/ scanf(char *, int *, ...);
int main() {
  int lightX;
  int lightY;
  int initialTX;
  int initialTY;
  int thorX;
  int thorY;
  scanf("%d%d%d%d", &lightX, &lightY, &initialTX, &initialTY);
  thorX = initialTX;
  thorY = initialTY;
  while (1) {
    int remainingTurns;
    scanf("%d", &remainingTurns);
    char *moveX = "";
    char *directionY = "";
    if (thorY > lightY) {
      directionY = "N";
      thorY--;
    } else if (thorY < lightY) {
      directionY = "S";
      thorY++;
    }
    if (thorX > lightX) {
      moveX = "W";
      thorX--;
    } else if (thorX < lightX) {
      moveX = "E";
      thorX++;
    }
    printf("%s%s\n", directionY, moveX);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
lea    -0x10(%rbp),%rcx
lea    -0x14(%rbp),%r8
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x10(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x1c(%rbp)
lea    0xea6(%rip),%rdi
lea    -0x20(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
lea    0xea4(%rip),%rax
mov    %rax,-0x28(%rbp)
lea    0xe99(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jle    11a6 <main+0x86>
lea    0xe75(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    -0x1c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x1c(%rbp)
jmp    11cb <main+0xab>
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11c6 <main+0xa6>
lea    0xe52(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11cb <main+0xab>
mov    -0x18(%rbp),%eax
cmp    -0x8(%rbp),%eax
jle    11f0 <main+0xd0>
lea    0xe2f(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x18(%rbp)
jmp    1215 <main+0xf5>
mov    -0x18(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1210 <main+0xf0>
lea    0xe0c(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1215 <main+0xf5>
mov    -0x30(%rbp),%rsi
mov    -0x28(%rbp),%rdx
lea    0xded(%rip),%rdi
call   1030 <printf@plt>
jmp    1159 <main+0x39>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xecb(%rip),%rdi
lea    0x10(%rsp),%rsi
lea    0xc(%rsp),%rdx
lea    0x8(%rsp),%rcx
lea    0x4(%rsp),%r8
xor    %eax,%eax
call   1040 <scanf@plt>
mov    0x8(%rsp),%ebp
mov    0x4(%rsp),%ebx
lea    0xea7(%rip),%r14
lea    0x14(%rsp),%r15
lea    0xea6(%rip),%r12
lea    0xea4(%rip),%r13
jmp    1192 <main+0x72>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0xffffffff,%ebp
lea    0xe83(%rip),%rdx
mov    %r12,%rdi
call   1030 <printf@plt>
mov    %r14,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
cmp    0xc(%rsp),%ebx
jle    11c0 <main+0xa0>
add    $0xffffffff,%ebx
lea    0xe5a(%rip),%rsi
cmp    0x10(%rsp),%ebp
jg     1180 <main+0x60>
jmp    11e9 <main+0xc9>
nopw   0x0(%rax,%rax,1)
jge    11e0 <main+0xc0>
add    $0x1,%ebx
lea    0xe3f(%rip),%rsi
cmp    0x10(%rsp),%ebp
jg     1180 <main+0x60>
jmp    11e9 <main+0xc9>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r13,%rsi
cmp    0x10(%rsp),%ebp
jg     1180 <main+0x60>
jge    1200 <main+0xe0>
add    $0x1,%ebp
lea    0xe1a(%rip),%rdx
jmp    118a <main+0x6a>
nopw   0x0(%rax,%rax,1)
mov    %r13,%rdx
jmp    118a <main+0x6a>

LLVM IR (-O0):
@.str = [9 x i8] c"%d%d%d%d\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [1 x i8] zeroinitializer
@.str.3 = [2 x i8] c"N\00"
@.str.4 = [2 x i8] c"S\00"
@.str.5 = [2 x i8] c"W\00"
@.str.6 = [2 x i8] c"E\00"
@.str.7 = [6 x i8] c"%s%s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i8*
store i32 0, i32* %1
%11 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32* %2, i32* %3, i32* %4, i32* %5)
%12 = load i32, i32* %4
store i32 %12, i32* %6
%13 = load i32, i32* %5
store i32 %13, i32* %7
br label %14
14: ; preds = %0, %45
%15 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %8)
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), i8** %9
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), i8** %10
%16 = load i32, i32* %7
%17 = load i32, i32* %3
%18 = icmp sgt i32 %16, %17
br i1 %18, label %19, label %22
19: ; preds = %14
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i8** %10
%20 = load i32, i32* %7
%21 = add nsw i32 %20, -1
store i32 %21, i32* %7
br label %30
22: ; preds = %14
%23 = load i32, i32* %7
%24 = load i32, i32* %3
%25 = icmp slt i32 %23, %24
br i1 %25, label %26, label %29
26: ; preds = %22
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i8** %10
%27 = load i32, i32* %7
%28 = add nsw i32 %27, 1
store i32 %28, i32* %7
br label %29
29: ; preds = %26, %22
br label %30
30: ; preds = %29, %19
%31 = load i32, i32* %6
%32 = load i32, i32* %2
%33 = icmp sgt i32 %31, %32
br i1 %33, label %34, label %37
34: ; preds = %30
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0), i8** %9
%35 = load i32, i32* %6
%36 = add nsw i32 %35, -1
store i32 %36, i32* %6
br label %45
37: ; preds = %30
%38 = load i32, i32* %6
%39 = load i32, i32* %2
%40 = icmp slt i32 %38, %39
br i1 %40, label %41, label %44
41: ; preds = %37
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0), i8** %9
%42 = load i32, i32* %6
%43 = add nsw i32 %42, 1
store i32 %43, i32* %6
br label %44
44: ; preds = %41, %37
br label %45
45: ; preds = %44, %34
%46 = load i8*, i8** %10
%47 = load i8*, i8** %9
%48 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), i8* %46, i8* %47)
br label %14
}

LLVM IR (-O2):
@.str = [9 x i8] c"%d%d%d%d\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [1 x i8] zeroinitializer
@.str.3 = [2 x i8] c"N\00"
@.str.4 = [2 x i8] c"S\00"
@.str.5 = [2 x i8] c"W\00"
@.str.6 = [2 x i8] c"E\00"
@.str.7 = [6 x i8] c"%s%s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = bitcast i32* %1 to i8*
%7 = bitcast i32* %2 to i8*
%8 = bitcast i32* %3 to i8*
%9 = bitcast i32* %4 to i8*
%10 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32* %1, i32* %2, i32* %3, i32* %4)
%11 = load i32, i32* %3
%12 = load i32, i32* %4
%13 = bitcast i32* %5 to i8*
br label %14
14: ; preds = %37, %0
%15 = phi i32 [ %11, %0 ], [ %38, %37 ]
%16 = phi i32 [ %12, %0 ], [ %27, %37 ]
%17 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %5)
%18 = load i32, i32* %2
%19 = icmp sgt i32 %16, %18
br i1 %19, label %20, label %22
20: ; preds = %14
%21 = add nsw i32 %16, -1
br label %26
22: ; preds = %14
%23 = icmp slt i32 %16, %18
br i1 %23, label %24, label %26
24: ; preds = %22
%25 = add nsw i32 %16, 1
br label %26
26: ; preds = %22, %24, %20
%27 = phi i32 [ %21, %20 ], [ %25, %24 ], [ %16, %22 ]
%28 = phi i8* [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), %20 ], [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), %24 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), %22 ]
%29 = load i32, i32* %1
%30 = icmp sgt i32 %15, %29
br i1 %30, label %31, label %33
31: ; preds = %26
%32 = add nsw i32 %15, -1
br label %37
33: ; preds = %26
%34 = icmp slt i32 %15, %29
br i1 %34, label %35, label %37
35: ; preds = %33
%36 = add nsw i32 %15, 1
br label %37
37: ; preds = %33, %35, %31
%38 = phi i32 [ %32, %31 ], [ %36, %35 ], [ %15, %33 ]
%39 = phi i8* [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0), %31 ], [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0), %35 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), %33 ]
%40 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), i8* %28, i8* %39)
br label %14
}