#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 */
scalar_t__ EOF;
int /*<<< orphan*/ printf(char *, int, int);
scalar_t__ scanf(char *, ...);
int main(void) {
  int a, b, x = 0, y = 0;
  scanf("%*d");
  while (scanf("%d %d", &a, &b) != EOF) {
    switch (a) {
    case 0:
      y += b;
      break;
    case 1:
      x += b;
      break;
    case 2:
      y -= b;
      break;
    case 3:
      x -= b;
      break;
    }
  }
  printf("%d %d", x, y);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
lea    0xecc(%rip),%rdi
mov    $0x0,%al
call   1040 <scanf@plt>
lea    0xec2(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
mov    $0x0,%al
call   1040 <scanf@plt>
mov    0x2e80(%rip),%rcx
cmp    (%rcx),%rax
je     11d2 <main+0xb2>
mov    -0x8(%rbp),%eax
mov    %rax,-0x20(%rbp)
sub    $0x3,%rax
ja     11cd <main+0xad>
mov    -0x20(%rbp),%rax
lea    0xe73(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0xc(%rbp),%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    11cd <main+0xad>
mov    -0xc(%rbp),%eax
add    -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
jmp    11cd <main+0xad>
mov    -0xc(%rbp),%ecx
mov    -0x14(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x14(%rbp)
jmp    11cd <main+0xad>
mov    -0xc(%rbp),%ecx
mov    -0x10(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x10(%rbp)
jmp    114b <main+0x2b>
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
lea    0xe35(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xede(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <scanf@plt>
lea    0xed2(%rip),%rdi
lea    0x4(%rsp),%rsi
mov    %rsp,%rdx
xor    %eax,%eax
call   1040 <scanf@plt>
mov    0x2e90(%rip),%rcx
mov    $0x0,%ebp
cmp    (%rcx),%rax
jne    1183 <main+0x63>
lea    0xeab(%rip),%rdi
mov    %ebx,%esi
mov    %ebp,%edx
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe8a(%rip),%r14
lea    0x4(%rsp),%r15
mov    %rsp,%r12
lea    0xe67(%rip),%r13
xor    %ebp,%ebp
xor    %ebx,%ebx
jmp    11cc <main+0xac>
nop
sub    (%rsp),%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
xor    %eax,%eax
call   1040 <scanf@plt>
mov    0x2e21(%rip),%rcx
cmp    (%rcx),%rax
je     1162 <main+0x42>
mov    0x4(%rsp),%eax
cmp    $0x3,%rax
ja     11b0 <main+0x90>
movslq 0x0(%r13,%rax,4),%rax
add    %r13,%rax
jmp    *%rax
add    (%rsp),%ebp
jmp    11b0 <main+0x90>
cs nopw 0x0(%rax,%rax,1)
nop
add    (%rsp),%ebx
jmp    11b0 <main+0x90>
cs nopw 0x0(%rax,%rax,1)
nop
sub    (%rsp),%ebp
jmp    11b0 <main+0x90>

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

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