Given the following C code and unoptimized assembly code, your task is to generate highly optimized x86-64 assembly code.
C Code:

```c
dx[]={0,1,0,-1},dy[]={1,0,-1,0};
w,h,x,y,d;
move(r){
	x+=dx[d]*r,y+=dy[d]*r;
	if(x<1)x=1;
	if(x>w)x=w;
	if(y<1)y=1;
	if(y>h)y=h;
}
main(){
	for(;scanf("%d%d",&w,&h)*w;){
		char op[9];
		int r;
		x=y=1,d=0;
		for(;scanf("%s",op),strcmp(op,"STOP");){
			if(strcmp(op,"FORWARD")==0){
				scanf("%d",&r);
				move(r);
			}
			if(strcmp(op,"BACKWARD")==0){
				scanf("%d",&r);
				move(-r);
			}
			if(strcmp(op,"RIGHT")==0){
				d=(d+1)%4;
			}
			if(strcmp(op,"LEFT")==0){
				d=(d+3)%4;
			}
		}
		printf("%d %d\n",x,y);
	}
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	dx
	.data
	.align 16
	.type	dx, @object
	.size	dx, 16
dx:
	.long	0
	.long	1
	.long	0
	.long	-1
	.globl	dy
	.align 16
	.type	dy, @object
	.size	dy, 16
dy:
	.long	1
	.long	0
	.long	-1
	.long	0
	.globl	w
	.bss
	.align 4
	.type	w, @object
	.size	w, 4
w:
	.zero	4
	.globl	h
	.align 4
	.type	h, @object
	.size	h, 4
h:
	.zero	4
	.globl	x
	.align 4
	.type	x, @object
	.size	x, 4
x:
	.zero	4
	.globl	y
	.align 4
	.type	y, @object
	.size	y, 4
y:
	.zero	4
	.globl	d
	.align 4
	.type	d, @object
	.size	d, 4
d:
	.zero	4
	.text
	.globl	move
	.type	move, @function
move:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	%edi, -4(%rbp)
	movl	d(%rip), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	dx(%rip), %rax
	movl	(%rdx,%rax), %eax
	imull	-4(%rbp), %eax
	movl	%eax, %edx
	movl	x(%rip), %eax
	addl	%edx, %eax
	movl	%eax, x(%rip)
	movl	d(%rip), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	dy(%rip), %rax
	movl	(%rdx,%rax), %eax
	imull	-4(%rbp), %eax
	movl	%eax, %edx
	movl	y(%rip), %eax
	addl	%edx, %eax
	movl	%eax, y(%rip)
	movl	x(%rip), %eax
	testl	%eax, %eax
	jg	.L2
	movl	$1, x(%rip)
.L2:
	movl	x(%rip), %edx
	movl	w(%rip), %eax
	cmpl	%eax, %edx
	jle	.L3
	movl	w(%rip), %eax
	movl	%eax, x(%rip)
.L3:
	movl	y(%rip), %eax
	testl	%eax, %eax
	jg	.L4
	movl	$1, y(%rip)
.L4:
	movl	y(%rip), %edx
	movl	h(%rip), %eax
	cmpl	%eax, %edx
	jle	.L5
	movl	h(%rip), %eax
	movl	%eax, y(%rip)
.L5:
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	move, .-move
	.section	.rodata
.LC0:
	.string	"FORWARD"
.LC1:
	.string	"%d"
.LC2:
	.string	"BACKWARD"
.LC3:
	.string	"RIGHT"
.LC4:
	.string	"LEFT"
.LC5:
	.string	"%s"
.LC6:
	.string	"STOP"
.LC7:
	.string	"%d %d\n"
.LC8:
	.string	"%d%d"
	.text
	.globl	main
	.type	main, @function
main:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	jmp	.L7
.L13:
	movl	$1, y(%rip)
	movl	y(%rip), %eax
	movl	%eax, x(%rip)
	movl	$0, d(%rip)
	jmp	.L8
.L12:
	leaq	-17(%rbp), %rax
	leaq	.LC0(%rip), %rdx
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L9
	leaq	-24(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	scanf@PLT
	movl	-24(%rbp), %eax
	movl	%eax, %edi
	movl	$0, %eax
	call	move
.L9:
	leaq	-17(%rbp), %rax
	leaq	.LC2(%rip), %rdx
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L10
	leaq	-24(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	scanf@PLT
	movl	-24(%rbp), %eax
	negl	%eax
	movl	%eax, %edi
	movl	$0, %eax
	call	move
.L10:
	leaq	-17(%rbp), %rax
	leaq	.LC3(%rip), %rdx
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L11
	movl	d(%rip), %eax
	addl	$1, %eax
	cltd
	shrl	$30, %edx
	addl	%edx, %eax
	andl	$3, %eax
	subl	%edx, %eax
	movl	%eax, d(%rip)
.L11:
	leaq	-17(%rbp), %rax
	leaq	.LC4(%rip), %rdx
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L8
	movl	d(%rip), %eax
	addl	$3, %eax
	cltd
	shrl	$30, %edx
	addl	%edx, %eax
	andl	$3, %eax
	subl	%edx, %eax
	movl	%eax, d(%rip)
.L8:
	leaq	-17(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC5(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	scanf@PLT
	leaq	-17(%rbp), %rax
	leaq	.LC6(%rip), %rdx
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L12
	movl	y(%rip), %edx
	movl	x(%rip), %eax
	movl	%eax, %esi
	leaq	.LC7(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L7:
	leaq	h(%rip), %rax
	movq	%rax, %rdx
	leaq	w(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC8(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	scanf@PLT
	movl	w(%rip), %edx
	imull	%edx, %eax
	testl	%eax, %eax
	jne	.L13
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L15
	call	__stack_chk_fail@PLT
.L15:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	main, .-main
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:
```

Only output the optimized assembly code. Do not include any other text. Do not write any comments in the assembly code. Wrap the assembly code in ```assembly``` tags.
user
	.file	"temp.c"
	.text
	.p2align 4
	.globl	move
	.type	move, @function
move:
.LFB0:
	.cfi_startproc
	endbr64
	movslq	d(%rip), %rdx
	leaq	dx(%rip), %rax
	leaq	dy(%rip), %rcx
	movl	(%rax,%rdx,4), %esi
	movl	x(%rip), %eax
	imull	%edi, %esi
	imull	(%rcx,%rdx,4), %edi
	addl	y(%rip), %edi
	movl	%edi, y(%rip)
	addl	%esi, %eax
	movl	%eax, x(%rip)
	testl	%eax, %eax
	jg	.L2
	movl	$1, x(%rip)
	movl	$1, %eax
.L2:
	movl	w(%rip), %edx
	cmpl	%eax, %edx
	jge	.L3
	movl	%edx, x(%rip)
.L3:
	testl	%edi, %edi
	jg	.L4
	movl	$1, y(%rip)
	movl	$1, %edi
.L4:
	movl	h(%rip), %eax
	cmpl	%edi, %eax
	jge	.L5
	movl	%eax, y(%rip)
.L5:
	ret
	.cfi_endproc
.LFE0:
	.size	move, .-move
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"FORWARD"
.LC1:
	.string	"%d"
.LC2:
	.string	"BACKWARD"
.LC3:
	.string	"RIGHT"
.LC4:
	.string	"LEFT"
.LC5:
	.string	"%s"
.LC6:
	.string	"STOP"
.LC7:
	.string	"%d %d\n"
.LC8:
	.string	"%d%d"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	leaq	.LC1(%rip), %r14
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	leaq	.LC5(%rip), %rbx
	subq	$40, %rsp
	.cfi_def_cfa_offset 96
	movq	%fs:40, %rax
	movq	%rax, 24(%rsp)
	xorl	%eax, %eax
	.p2align 4,,10
	.p2align 3
.L8:
	leaq	h(%rip), %rdx
	leaq	w(%rip), %rsi
	xorl	%eax, %eax
	leaq	.LC8(%rip), %rdi
	call	scanf@PLT
	imull	w(%rip), %eax
	testl	%eax, %eax
	je	.L44
	xorl	%eax, %eax
	leaq	15(%rsp), %r15
	movl	$1, y(%rip)
	movabsq	$19230739007688518, %rbp
	movl	$1, x(%rip)
	leaq	dx(%rip), %r13
.L9:
	movl	%eax, d(%rip)
	leaq	dy(%rip), %r12
	.p2align 4,,10
	.p2align 3
.L33:
	xorl	%eax, %eax
	movq	%r15, %rsi
	movq	%rbx, %rdi
	call	scanf@PLT
	cmpl	$1347376211, (%r15)
	je	.L45
.L34:
	cmpq	%rbp, (%r15)
	je	.L46
.L13:
	leaq	.LC2(%rip), %rsi
	movq	%r15, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	je	.L47
.L19:
	cmpl	$1212631378, (%r15)
	je	.L48
.L24:
	cmpl	$1413891404, (%r15)
	jne	.L33
	cmpb	$0, 4(%r15)
	jne	.L33
	movl	d(%rip), %eax
	addl	$3, %eax
	movl	%eax, %ecx
	sarl	$31, %ecx
	shrl	$30, %ecx
	addl	%ecx, %eax
	andl	$3, %eax
	subl	%ecx, %eax
	jmp	.L9
	.p2align 4,,10
	.p2align 3
.L45:
	cmpb	$0, 4(%r15)
	jne	.L34
	movl	y(%rip), %edx
	movl	x(%rip), %esi
	leaq	.LC7(%rip), %rdi
	xorl	%eax, %eax
	call	printf@PLT
	jmp	.L8
	.p2align 4,,10
	.p2align 3
.L48:
	cmpw	$84, 4(%r15)
	jne	.L24
	movl	d(%rip), %eax
	addl	$1, %eax
	movl	%eax, %ecx
	sarl	$31, %ecx
	shrl	$30, %ecx
	addl	%ecx, %eax
	andl	$3, %eax
	subl	%ecx, %eax
	movl	%eax, d(%rip)
	jmp	.L33
	.p2align 4,,10
	.p2align 3
.L46:
	leaq	8(%rsp), %rsi
	movq	%r14, %rdi
	xorl	%eax, %eax
	call	scanf@PLT
	movslq	d(%rip), %rsi
	movl	8(%rsp), %eax
	movl	0(%r13,%rsi,4), %ecx
	imull	%eax, %ecx
	addl	x(%rip), %ecx
	imull	(%r12,%rsi,4), %eax
	addl	y(%rip), %eax
	movl	%ecx, x(%rip)
	movl	%eax, y(%rip)
	testl	%ecx, %ecx
	jg	.L14
	movl	$1, x(%rip)
	movl	$1, %ecx
.L14:
	movl	w(%rip), %esi
	cmpl	%ecx, %esi
	jge	.L15
	movl	%esi, x(%rip)
.L15:
	testl	%eax, %eax
	jg	.L16
	movl	$1, y(%rip)
	movl	$1, %eax
.L16:
	movl	h(%rip), %ecx
	cmpl	%eax, %ecx
	jge	.L13
	movl	%ecx, y(%rip)
	jmp	.L13
	.p2align 4,,10
	.p2align 3
.L47:
	leaq	8(%rsp), %rsi
	movq	%r14, %rdi
	call	scanf@PLT
	movslq	d(%rip), %rsi
	movl	8(%rsp), %eax
	movl	0(%r13,%rsi,4), %ecx
	negl	%eax
	imull	%eax, %ecx
	addl	x(%rip), %ecx
	imull	(%r12,%rsi,4), %eax
	addl	y(%rip), %eax
	movl	%ecx, x(%rip)
	movl	%eax, y(%rip)
	testl	%ecx, %ecx
	jg	.L20
	movl	$1, x(%rip)
	movl	$1, %ecx
.L20:
	movl	w(%rip), %esi
	cmpl	%ecx, %esi
	jge	.L21
	movl	%esi, x(%rip)
.L21:
	testl	%eax, %eax
	jg	.L22
	movl	$1, y(%rip)
	movl	$1, %eax
.L22:
	movl	h(%rip), %ecx
	cmpl	%eax, %ecx
	jge	.L19
	movl	%ecx, y(%rip)
	jmp	.L19
.L44:
	movq	24(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L49
	addq	$40, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
.L49:
	.cfi_restore_state
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE1:
	.size	main, .-main
	.globl	d
	.bss
	.align 4
	.type	d, @object
	.size	d, 4
d:
	.zero	4
	.globl	y
	.align 4
	.type	y, @object
	.size	y, 4
y:
	.zero	4
	.globl	x
	.align 4
	.type	x, @object
	.size	x, 4
x:
	.zero	4
	.globl	h
	.align 4
	.type	h, @object
	.size	h, 4
h:
	.zero	4
	.globl	w
	.align 4
	.type	w, @object
	.size	w, 4
w:
	.zero	4
	.globl	dy
	.data
	.align 16
	.type	dy, @object
	.size	dy, 16
dy:
	.long	1
	.long	0
	.long	-1
	.long	0
	.globl	dx
	.align 16
	.type	dx, @object
	.size	dx, 16
dx:
	.long	0
	.long	1
	.long	0
	.long	-1
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:

rule
	.file	"temp.c"
	.text
	.p2align 4
	.globl	move
	.type	move, @function
move:
.LFB0:
	.cfi_startproc
	endbr64
	movslq	d(%rip), %rdx
	leaq	dx(%rip), %rax
	leaq	dy(%rip), %rcx
	movl	(%rax,%rdx,4), %esi
	movl	x(%rip), %eax
	imull	%edi, %esi
	imull	(%rcx,%rdx,4), %edi
	addl	y(%rip), %edi
	movl	%edi, y(%rip)
	addl	%esi, %eax
	movl	%eax, x(%rip)
	testl	%eax, %eax
	jg	.L2
	movl	$1, x(%rip)
	movl	$1, %eax
.L2:
	movl	w(%rip), %edx
	cmpl	%eax, %edx
	jge	.L3
	movl	%edx, x(%rip)
.L3:
	testl	%edi, %edi
	jg	.L4
	movl	$1, y(%rip)
	movl	$1, %edi
.L4:
	movl	h(%rip), %eax
	cmpl	%edi, %eax
	jge	.L5
	movl	%eax, y(%rip)
.L5:
	ret
	.cfi_endproc
.LFE0:
	.size	move, .-move
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"FORWARD"
.LC1:
	.string	"%d"
.LC2:
	.string	"BACKWARD"
.LC3:
	.string	"RIGHT"
.LC4:
	.string	"LEFT"
.LC5:
	.string	"%s"
.LC6:
	.string	"STOP"
.LC7:
	.string	"%d %d\n"
.LC8:
	.string	"%d%d"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	leaq	.LC1(%rip), %r14
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	leaq	.LC5(%rip), %rbx
	subq	$40, %rsp
	.cfi_def_cfa_offset 96
	movq	%fs:40, %rax
	movq	%rax, 24(%rsp)
	xorl	%eax, %eax
	.p2align 4,,10
	.p2align 3
.L8:
	leaq	h(%rip), %rdx
	leaq	w(%rip), %rsi
	xorl	%eax, %eax
	leaq	.LC8(%rip), %rdi
	call	scanf@PLT
	imull	w(%rip), %eax
	testl	%eax, %eax
	je	.L44
	xorl	%eax, %eax
	leaq	15(%rsp), %r15
	movl	$1, y(%rip)
	movabsq	$19230739007688518, %rbp
	movl	$1, x(%rip)
	leaq	dx(%rip), %r13
.L9:
	movl	%eax, d(%rip)
	leaq	dy(%rip), %r12
	.p2align 4,,10
	.p2align 3
.L33:
	xorl	%eax, %eax
	movq	%r15, %rsi
	movq	%rbx, %rdi
	call	scanf@PLT
	cmpl	$1347376211, (%r15)
	je	.L45
.L34:
	cmpq	%rbp, (%r15)
	je	.L46
.L13:
	leaq	.LC2(%rip), %rsi
	movq	%r15, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	je	.L47
.L19:
	cmpl	$1212631378, (%r15)
	je	.L48
.L24:
	cmpl	$1413891404, (%r15)
	jne	.L33
	cmpb	$0, 4(%r15)
	jne	.L33
	movl	d(%rip), %eax
	addl	$3, %eax
	movl	%eax, %ecx
	sarl	$31, %ecx
	shrl	$30, %ecx
	addl	%ecx, %eax
	andl	$3, %eax
	subl	%ecx, %eax
	jmp	.L9
	.p2align 4,,10
	.p2align 3
.L45:
	cmpb	$0, 4(%r15)
	jne	.L34
	movl	y(%rip), %edx
	movl	x(%rip), %esi
	leaq	.LC7(%rip), %rdi
	xorl	%eax, %eax
	call	printf@PLT
	jmp	.L8
	.p2align 4,,10
	.p2align 3
.L48:
	cmpw	$84, 4(%r15)
	jne	.L24
	movl	d(%rip), %eax
	addl	$1, %eax
	movl	%eax, %ecx
	sarl	$31, %ecx
	shrl	$30, %ecx
	addl	%ecx, %eax
	andl	$3, %eax
	subl	%ecx, %eax
	movl	%eax, d(%rip)
	jmp	.L33
	.p2align 4,,10
	.p2align 3
.L46:
	leaq	8(%rsp), %rsi
	movq	%r14, %rdi
	xorl	%eax, %eax
	call	scanf@PLT
	movslq	d(%rip), %rsi
	movl	8(%rsp), %eax
	movl	0(%r13,%rsi,4), %ecx
	imull	%eax, %ecx
	addl	x(%rip), %ecx
	imull	(%r12,%rsi,4), %eax
	addl	y(%rip), %eax
	movl	%ecx, x(%rip)
	movl	%eax, y(%rip)
	testl	%ecx, %ecx
	jg	.L14
	movl	$1, x(%rip)
	movl	$1, %ecx
.L14:
	movl	w(%rip), %esi
	cmpl	%ecx, %esi
	jge	.L15
	movl	%esi, x(%rip)
.L15:
	testl	%eax, %eax
	jg	.L16
	movl	$1, y(%rip)
	movl	$1, %eax
.L16:
	movl	h(%rip), %ecx
	cmpl	%eax, %ecx
	jge	.L13
	movl	%ecx, y(%rip)
	jmp	.L13
	.p2align 4,,10
	.p2align 3
.L47:
	leaq	8(%rsp), %rsi
	movq	%r14, %rdi
	call	scanf@PLT
	movslq	d(%rip), %rsi
	movl	8(%rsp), %eax
	movl	0(%r13,%rsi,4), %ecx
	negl	%eax
	imull	%eax, %ecx
	addl	x(%rip), %ecx
	imull	(%r12,%rsi,4), %eax
	addl	y(%rip), %eax
	movl	%ecx, x(%rip)
	movl	%eax, y(%rip)
	testl	%ecx, %ecx
	jg	.L20
	movl	$1, x(%rip)
	movl	$1, %ecx
.L20:
	movl	w(%rip), %esi
	cmpl	%ecx, %esi
	jge	.L21
	movl	%esi, x(%rip)
.L21:
	testl	%eax, %eax
	jg	.L22
	movl	$1, y(%rip)
	movl	$1, %eax
.L22:
	movl	h(%rip), %ecx
	cmpl	%eax, %ecx
	jge	.L19
	movl	%ecx, y(%rip)
	jmp	.L19
.L44:
	movq	24(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L49
	addq	$40, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
.L49:
	.cfi_restore_state
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE1:
	.size	main, .-main
	.globl	d
	.bss
	.align 4
	.type	d, @object
	.size	d, 4
d:
	.zero	4
	.globl	y
	.align 4
	.type	y, @object
	.size	y, 4
y:
	.zero	4
	.globl	x
	.align 4
	.type	x, @object
	.size	x, 4
x:
	.zero	4
	.globl	h
	.align 4
	.type	h, @object
	.size	h, 4
h:
	.zero	4
	.globl	w
	.align 4
	.type	w, @object
	.size	w, 4
w:
	.zero	4
	.globl	dy
	.data
	.align 16
	.type	dy, @object
	.size	dy, 16
dy:
	.long	1
	.long	0
	.long	-1
	.long	0
	.globl	dx
	.align 16
	.type	dx, @object
	.size	dx, 16
dx:
	.long	0
	.long	1
	.long	0
	.long	-1
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:

dx[]={0,1,0,-1},dy[]={1,0,-1,0};
w,h,x,y,d;
move(r){
	x+=dx[d]*r,y+=dy[d]*r;
	if(x<1)x=1;
	if(x>w)x=w;
	if(y<1)y=1;
	if(y>h)y=h;
}
main(){
	for(;scanf("%d%d",&w,&h)*w;){
		char op[9];
		int r;
		x=y=1,d=0;
		for(;scanf("%s",op),strcmp(op,"STOP");){
			if(strcmp(op,"FORWARD")==0){
				scanf("%d",&r);
				move(r);
			}
			if(strcmp(op,"BACKWARD")==0){
				scanf("%d",&r);
				move(-r);
			}
			if(strcmp(op,"RIGHT")==0){
				d=(d+1)%4;
			}
			if(strcmp(op,"LEFT")==0){
				d=(d+3)%4;
			}
		}
		printf("%d %d\n",x,y);
	}
}
6 5
FORWARD 3
RIGHT
FORWARD 5
LEFT
BACKWARD 2
STOP
5 1
FORWARD 2
STOP
0 0
 6 5
FORWARD 3
RIGHT
FORWARD 5
LEFT
BACKWARD 3
STOP
3 1
FORWARD 2
STOP
0 0
 6 6
FORDARW 1
RIGHT
FORWARD 5
LEFT
BACKWARD 3
STOP
3 2
FORWARD 2
STOP
0 0
 1 2
FORDARW 3
RIGHT
FORWARD 5
LEFT
BACKWARD 3
STOP
4 1
DRAWROF 2
STOP
0 0
 6 5
FORWARD 3
RIGHT
FORWARD 7
LEFT
BACKWARD 0
STOP
3 1
FORWARD 2
STOP
0 0
 2 2
FORDARW 3
RIGHT
FORWARD 5
LEFT
BACKWARD 3
STOP
4 1
DRAWROF 2
STOP
0 0
 2 5
FORWARD 3
RIGHT
FORWARD 5
LEFT
BACKWARD 2
STOP
3 1
FORWARD 2
STOP
0 0
 6 5
FORWARD 3
RIGHT
FORWARD 3
LEFT
BACKWARD 2
STOP
5 1
FOSW@RD 2
STOP
0 0
 6 5
FORWARD 4
RIGHT
FORWARD 3
LEFT
BACKWARD 2
STOP
5 1
FOSW@RD 2
STOP
0 0
 6 5
FORWARD 4
RIGHT
FORWARD 1
LEFT
BACKWARD 2
STOP
5 1
FOSW@RD 2
STOP
0 0

6 2
1 1
 6 1
1 1
 6 1
1 2
 1 1
1 1
 6 4
1 1
 2 1
1 1
 2 2
1 1
 4 2
1 1
 4 3
1 1
 2 3
1 1

Given the following C code and unoptimized assembly code, your task is to generate highly optimized x86-64 assembly code.
C Code:

```c
dx[]={0,1,0,-1},dy[]={1,0,-1,0};
w,h,x,y,d;
move(r){
	x+=dx[d]*r,y+=dy[d]*r;
	if(x<1)x=1;
	if(x>w)x=w;
	if(y<1)y=1;
	if(y>h)y=h;
}
main(){
	for(;scanf("%d%d",&w,&h)*w;){
		char op[9];
		int r;
		x=y=1,d=0;
		for(;scanf("%s",op),strcmp(op,"STOP");){
			if(strcmp(op,"FORWARD")==0){
				scanf("%d",&r);
				move(r);
			}
			if(strcmp(op,"BACKWARD")==0){
				scanf("%d",&r);
				move(-r);
			}
			if(strcmp(op,"RIGHT")==0){
				d=(d+1)%4;
			}
			if(strcmp(op,"LEFT")==0){
				d=(d+3)%4;
			}
		}
		printf("%d %d\n",x,y);
	}
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	dx
	.data
	.align 16
	.type	dx, @object
	.size	dx, 16
dx:
	.long	0
	.long	1
	.long	0
	.long	-1
	.globl	dy
	.align 16
	.type	dy, @object
	.size	dy, 16
dy:
	.long	1
	.long	0
	.long	-1
	.long	0
	.globl	w
	.bss
	.align 4
	.type	w, @object
	.size	w, 4
w:
	.zero	4
	.globl	h
	.align 4
	.type	h, @object
	.size	h, 4
h:
	.zero	4
	.globl	x
	.align 4
	.type	x, @object
	.size	x, 4
x:
	.zero	4
	.globl	y
	.align 4
	.type	y, @object
	.size	y, 4
y:
	.zero	4
	.globl	d
	.align 4
	.type	d, @object
	.size	d, 4
d:
	.zero	4
	.text
	.globl	move
	.type	move, @function
move:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	%edi, -4(%rbp)
	movl	d(%rip), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	dx(%rip), %rax
	movl	(%rdx,%rax), %eax
	imull	-4(%rbp), %eax
	movl	%eax, %edx
	movl	x(%rip), %eax
	addl	%edx, %eax
	movl	%eax, x(%rip)
	movl	d(%rip), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	dy(%rip), %rax
	movl	(%rdx,%rax), %eax
	imull	-4(%rbp), %eax
	movl	%eax, %edx
	movl	y(%rip), %eax
	addl	%edx, %eax
	movl	%eax, y(%rip)
	movl	x(%rip), %eax
	testl	%eax, %eax
	jg	.L2
	movl	$1, x(%rip)
.L2:
	movl	x(%rip), %edx
	movl	w(%rip), %eax
	cmpl	%eax, %edx
	jle	.L3
	movl	w(%rip), %eax
	movl	%eax, x(%rip)
.L3:
	movl	y(%rip), %eax
	testl	%eax, %eax
	jg	.L4
	movl	$1, y(%rip)
.L4:
	movl	y(%rip), %edx
	movl	h(%rip), %eax
	cmpl	%eax, %edx
	jle	.L5
	movl	h(%rip), %eax
	movl	%eax, y(%rip)
.L5:
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	move, .-move
	.section	.rodata
.LC0:
	.string	"FORWARD"
.LC1:
	.string	"%d"
.LC2:
	.string	"BACKWARD"
.LC3:
	.string	"RIGHT"
.LC4:
	.string	"LEFT"
.LC5:
	.string	"%s"
.LC6:
	.string	"STOP"
.LC7:
	.string	"%d %d\n"
.LC8:
	.string	"%d%d"
	.text
	.globl	main
	.type	main, @function
main:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	jmp	.L7
.L13:
	movl	$1, y(%rip)
	movl	y(%rip), %eax
	movl	%eax, x(%rip)
	movl	$0, d(%rip)
	jmp	.L8
.L12:
	leaq	-17(%rbp), %rax
	leaq	.LC0(%rip), %rdx
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L9
	leaq	-24(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	scanf@PLT
	movl	-24(%rbp), %eax
	movl	%eax, %edi
	movl	$0, %eax
	call	move
.L9:
	leaq	-17(%rbp), %rax
	leaq	.LC2(%rip), %rdx
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L10
	leaq	-24(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	scanf@PLT
	movl	-24(%rbp), %eax
	negl	%eax
	movl	%eax, %edi
	movl	$0, %eax
	call	move
.L10:
	leaq	-17(%rbp), %rax
	leaq	.LC3(%rip), %rdx
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L11
	movl	d(%rip), %eax
	addl	$1, %eax
	cltd
	shrl	$30, %edx
	addl	%edx, %eax
	andl	$3, %eax
	subl	%edx, %eax
	movl	%eax, d(%rip)
.L11:
	leaq	-17(%rbp), %rax
	leaq	.LC4(%rip), %rdx
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L8
	movl	d(%rip), %eax
	addl	$3, %eax
	cltd
	shrl	$30, %edx
	addl	%edx, %eax
	andl	$3, %eax
	subl	%edx, %eax
	movl	%eax, d(%rip)
.L8:
	leaq	-17(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC5(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	scanf@PLT
	leaq	-17(%rbp), %rax
	leaq	.LC6(%rip), %rdx
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L12
	movl	y(%rip), %edx
	movl	x(%rip), %eax
	movl	%eax, %esi
	leaq	.LC7(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L7:
	leaq	h(%rip), %rax
	movq	%rax, %rdx
	leaq	w(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC8(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	scanf@PLT
	movl	w(%rip), %edx
	imull	%edx, %eax
	testl	%eax, %eax
	jne	.L13
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L15
	call	__stack_chk_fail@PLT
.L15:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	main, .-main
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:
```

Only output the optimized assembly code. Do not include any other text. Do not write any comments in the assembly code. Wrap the assembly code in ```assembly``` tags.
train
	.file	"temp.c"
	.text
	.globl	dx
	.data
	.align 16
	.type	dx, @object
	.size	dx, 16
dx:
	.long	0
	.long	1
	.long	0
	.long	-1
	.globl	dy
	.align 16
	.type	dy, @object
	.size	dy, 16
dy:
	.long	1
	.long	0
	.long	-1
	.long	0
	.globl	w
	.bss
	.align 4
	.type	w, @object
	.size	w, 4
w:
	.zero	4
	.globl	h
	.align 4
	.type	h, @object
	.size	h, 4
h:
	.zero	4
	.globl	x
	.align 4
	.type	x, @object
	.size	x, 4
x:
	.zero	4
	.globl	y
	.align 4
	.type	y, @object
	.size	y, 4
y:
	.zero	4
	.globl	d
	.align 4
	.type	d, @object
	.size	d, 4
d:
	.zero	4
	.text
	.globl	move
	.type	move, @function
move:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	%edi, -4(%rbp)
	movl	d(%rip), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	dx(%rip), %rax
	movl	(%rdx,%rax), %eax
	imull	-4(%rbp), %eax
	movl	%eax, %edx
	movl	x(%rip), %eax
	addl	%edx, %eax
	movl	%eax, x(%rip)
	movl	d(%rip), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	dy(%rip), %rax
	movl	(%rdx,%rax), %eax
	imull	-4(%rbp), %eax
	movl	%eax, %edx
	movl	y(%rip), %eax
	addl	%edx, %eax
	movl	%eax, y(%rip)
	movl	x(%rip), %eax
	testl	%eax, %eax
	jg	.L2
	movl	$1, x(%rip)
.L2:
	movl	x(%rip), %edx
	movl	w(%rip), %eax
	cmpl	%eax, %edx
	jle	.L3
	movl	w(%rip), %eax
	movl	%eax, x(%rip)
.L3:
	movl	y(%rip), %eax
	testl	%eax, %eax
	jg	.L4
	movl	$1, y(%rip)
.L4:
	movl	y(%rip), %edx
	movl	h(%rip), %eax
	cmpl	%eax, %edx
	jle	.L5
	movl	h(%rip), %eax
	movl	%eax, y(%rip)
.L5:
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	move, .-move
	.section	.rodata
.LC0:
	.string	"FORWARD"
.LC1:
	.string	"%d"
.LC2:
	.string	"BACKWARD"
.LC3:
	.string	"RIGHT"
.LC4:
	.string	"LEFT"
.LC5:
	.string	"%s"
.LC6:
	.string	"STOP"
.LC7:
	.string	"%d %d\n"
.LC8:
	.string	"%d%d"
	.text
	.globl	main
	.type	main, @function
main:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	jmp	.L7
.L13:
	movl	$1, y(%rip)
	movl	y(%rip), %eax
	movl	%eax, x(%rip)
	movl	$0, d(%rip)
	jmp	.L8
.L12:
	leaq	-17(%rbp), %rax
	leaq	.LC0(%rip), %rdx
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L9
	leaq	-24(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	scanf@PLT
	movl	-24(%rbp), %eax
	movl	%eax, %edi
	movl	$0, %eax
	call	move
.L9:
	leaq	-17(%rbp), %rax
	leaq	.LC2(%rip), %rdx
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L10
	leaq	-24(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	scanf@PLT
	movl	-24(%rbp), %eax
	negl	%eax
	movl	%eax, %edi
	movl	$0, %eax
	call	move
.L10:
	leaq	-17(%rbp), %rax
	leaq	.LC3(%rip), %rdx
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L11
	movl	d(%rip), %eax
	addl	$1, %eax
	cltd
	shrl	$30, %edx
	addl	%edx, %eax
	andl	$3, %eax
	subl	%edx, %eax
	movl	%eax, d(%rip)
.L11:
	leaq	-17(%rbp), %rax
	leaq	.LC4(%rip), %rdx
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L8
	movl	d(%rip), %eax
	addl	$3, %eax
	cltd
	shrl	$30, %edx
	addl	%edx, %eax
	andl	$3, %eax
	subl	%edx, %eax
	movl	%eax, d(%rip)
.L8:
	leaq	-17(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC5(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	scanf@PLT
	leaq	-17(%rbp), %rax
	leaq	.LC6(%rip), %rdx
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L12
	movl	y(%rip), %edx
	movl	x(%rip), %eax
	movl	%eax, %esi
	leaq	.LC7(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L7:
	leaq	h(%rip), %rax
	movq	%rax, %rdx
	leaq	w(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC8(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	scanf@PLT
	movl	w(%rip), %edx
	imull	%edx, %eax
	testl	%eax, %eax
	jne	.L13
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L15
	call	__stack_chk_fail@PLT
.L15:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	main, .-main
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:
