#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 asin(int);
int cos(int);
int /*<<< orphan*/ printf(char *, int, int);
int /*<<< orphan*/ scanf(char *, int *, int *);
int sin(int);
int main(void) {
  int d, theta = 0, temp, X, Y;
  double x = 0.0, y = 0.0;
  while (1) {
    scanf("%d,%d", &d, &temp);
    if (d == 0 && temp == 0)
      break;
    x += d * sin(theta * asin(1) / 90);
    y += d * cos(theta * asin(1) / 90);
    theta += temp;
  }
  X = x;
  Y = y;
  printf("%d\n%d\n", X, Y);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
lea    0xe83(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0x10(%rbp),%rdx
call   1060 <scanf@plt>
cmpl   $0x0,-0x8(%rbp)
jne    11a3 <main+0x53>
cmpl   $0x0,-0x10(%rbp)
jne    11a3 <main+0x53>
jmp    1237 <main+0xe7>
mov    -0x8(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    $0x1,%edi
call   1050 <asin@plt>
mov    %eax,%ecx
mov    -0x38(%rbp),%eax
imul   %ecx,%eax
mov    $0x5a,%ecx
cltd
idiv   %ecx
mov    %eax,%edi
call   1040 <sin@plt>
mov    %eax,%ecx
mov    -0x34(%rbp),%eax
imul   %ecx,%eax
cvtsi2sd %eax,%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    $0x1,%edi
call   1050 <asin@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%eax
imul   %ecx,%eax
mov    $0x5a,%ecx
cltd
idiv   %ecx
mov    %eax,%edi
call   1070 <cos@plt>
mov    %eax,%ecx
mov    -0x2c(%rbp),%eax
imul   %ecx,%eax
cvtsi2sd %eax,%xmm0
addsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x10(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    1176 <main+0x26>
cvttsd2si -0x20(%rbp),%eax
mov    %eax,-0x14(%rbp)
cvttsd2si -0x28(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
lea    0xdb2(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x20,%rsp
lea    0xe9d(%rip),%rdi
lea    0xc(%rsp),%rsi
lea    0x8(%rsp),%rdx
call   1060 <scanf@plt>
mov    0xc(%rsp),%ebx
xor    %esi,%esi
mov    0x8(%rsp),%eax
or     %ebx,%eax
mov    $0x0,%edx
je     126e <main+0x11e>
xor    %ebp,%ebp
xorpd  %xmm0,%xmm0
movsd  %xmm0,0x18(%rsp)
lea    0xe64(%rip),%r14
lea    0xc(%rsp),%r15
lea    0x8(%rsp),%r12
xorpd  %xmm0,%xmm0
movsd  %xmm0,0x10(%rsp)
mov    $0x1,%edi
call   1050 <asin@plt>
imul   %ebp,%eax
movslq %eax,%rdi
imul   $0xffffffffb60b60b7,%rdi,%rax
shr    $0x20,%rax
add    %eax,%edi
mov    %edi,%eax
shr    $0x1f,%eax
sar    $0x6,%edi
add    %eax,%edi
call   1040 <sin@plt>
imul   %ebx,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  0x10(%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x10(%rsp)
mov    0xc(%rsp),%ebx
mov    $0x1,%edi
call   1050 <asin@plt>
imul   %ebp,%eax
movslq %eax,%rdi
imul   $0xffffffffb60b60b7,%rdi,%rax
shr    $0x20,%rax
add    %eax,%edi
mov    %edi,%eax
shr    $0x1f,%eax
sar    $0x6,%edi
add    %eax,%edi
call   1070 <cos@plt>
imul   %ebx,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  0x18(%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x18(%rsp)
add    0x8(%rsp),%ebp
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
call   1060 <scanf@plt>
mov    0xc(%rsp),%ebx
mov    0x8(%rsp),%eax
or     %ebx,%eax
jne    11b0 <main+0x60>
cvttsd2si 0x10(%rsp),%esi
cvttsd2si 0x18(%rsp),%edx
lea    0xd91(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"%d,%d\00"
@.str.1 = [7 x i8] c"%d\0A%d\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 double
%8 = alloca double
store i32 0, i32* %1
store i32 0, i32* %3
store double 0.000000e+00, double* %7
store double 0.000000e+00, double* %8
br label %9
9: ; preds = %0, %17
%10 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %2, i32* %4)
%11 = load i32, i32* %2
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %17
13: ; preds = %9
%14 = load i32, i32* %4
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %17
16: ; preds = %13
br label %41
17: ; preds = %13, %9
%18 = load i32, i32* %2
%19 = load i32, i32* %3
%20 = call i32 @asin(i32 1)
%21 = mul nsw i32 %19, %20
%22 = sdiv i32 %21, 90
%23 = call i32 @sin(i32 %22)
%24 = mul nsw i32 %18, %23
%25 = sitofp i32 %24 to double
%26 = load double, double* %7
%27 = fadd double %26, %25
store double %27, double* %7
%28 = load i32, i32* %2
%29 = load i32, i32* %3
%30 = call i32 @asin(i32 1)
%31 = mul nsw i32 %29, %30
%32 = sdiv i32 %31, 90
%33 = call i32 @cos(i32 %32)
%34 = mul nsw i32 %28, %33
%35 = sitofp i32 %34 to double
%36 = load double, double* %8
%37 = fadd double %36, %35
store double %37, double* %8
%38 = load i32, i32* %4
%39 = load i32, i32* %3
%40 = add nsw i32 %39, %38
store i32 %40, i32* %3
br label %9
41: ; preds = %16
%42 = load double, double* %7
%43 = fptosi double %42 to i32
store i32 %43, i32* %5
%44 = load double, double* %8
%45 = fptosi double %44 to i32
store i32 %45, i32* %6
%46 = load i32, i32* %5
%47 = load i32, i32* %6
%48 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %46, i32 %47)
ret i32 0
}

LLVM IR (-O2):
@.str = [6 x i8] c"%d,%d\00"
@.str.1 = [7 x i8] c"%d\0A%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %1, i32* %2)
%6 = load i32, i32* %1
%7 = icmp eq i32 %6, 0
%8 = load i32, i32* %2
%9 = icmp eq i32 %8, 0
%10 = select i1 %7, i1 %9, i1 false
br i1 %10, label %42, label %11
11: ; preds = %0, %11
%12 = phi i32 [ %34, %11 ], [ %6, %0 ]
%13 = phi double [ %30, %11 ], [ 0.000000e+00, %0 ]
%14 = phi double [ %22, %11 ], [ 0.000000e+00, %0 ]
%15 = phi i32 [ %32, %11 ], [ 0, %0 ]
%16 = call i32 @asin(i32 1)
%17 = mul nsw i32 %16, %15
%18 = sdiv i32 %17, 90
%19 = call i32 @sin(i32 %18)
%20 = mul nsw i32 %19, %12
%21 = sitofp i32 %20 to double
%22 = fadd double %14, %21
%23 = load i32, i32* %1
%24 = call i32 @asin(i32 1)
%25 = mul nsw i32 %24, %15
%26 = sdiv i32 %25, 90
%27 = call i32 @cos(i32 %26)
%28 = mul nsw i32 %27, %23
%29 = sitofp i32 %28 to double
%30 = fadd double %13, %29
%31 = load i32, i32* %2
%32 = add nsw i32 %31, %15
%33 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %1, i32* %2)
%34 = load i32, i32* %1
%35 = icmp eq i32 %34, 0
%36 = load i32, i32* %2
%37 = icmp eq i32 %36, 0
%38 = select i1 %35, i1 %37, i1 false
br i1 %38, label %39, label %11
39: ; preds = %11
%40 = fptosi double %22 to i32
%41 = fptosi double %30 to i32
br label %42
42: ; preds = %39, %0
%43 = phi i32 [ 0, %0 ], [ %40, %39 ]
%44 = phi i32 [ 0, %0 ], [ %41, %39 ]
%45 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %43, i32 %44)
ret i32 0
}