#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*/ FS460_get_tv_active_lines(int *);
int /*<<< orphan*/ FS460_play_begin();
int /*<<< orphan*/ FS460_play_is_effect_finished(unsigned int *);
int /*<<< orphan*/ FS460_play_run(int);
int /*<<< orphan*/ FS460_play_stop();
int /*<<< orphan*/ move(int /*<<< orphan*/, int, int /*<<< orphan*/, int, int);
int /*<<< orphan*/ scale(int, int, int, int, int, int, int, int, int);
void turnfield_test(void) {
  static int mode = 0;
  int full_height;
  FS460_play_begin();
  FS460_get_tv_active_lines(&full_height);
  switch (mode++) {
  default:
    mode = 1;
  case 0:
    scale(0, 0, 0, 0, 0, 0, 720 - (720 / 60), full_height - (full_height / 60),
          60);
    scale(0, 0, 720, full_height, 720 - (720 / 60),
          full_height - (full_height / 60), 720, full_height, 60);
    scale(720, full_height, 720, full_height, 0 + (720 / 60),
          0 + (full_height / 60), 720, full_height, 60);
    scale(0, 0, 720, full_height, 0, 0, 0 + (720 / 60), 0 + (full_height / 60),
          60);
    break;
  case 1:
    scale(0, full_height, 0, full_height, 0, 2 + (full_height / 60),
          720 - (720 / 60), full_height, 60);
    scale(0, 2, 720, full_height, 720 - (720 / 60), 2, 720,
          2 + (full_height / 60), 60);
    scale(720, 2, 720, 2, 0 + (720 / 60), 2, 720,
          full_height - (full_height / 60), 60);
    scale(0, 2, 720, full_height, 0, full_height - (full_height / 60),
          0 + (720 / 60), full_height, 60);
    break;
  case 2: {
    scale(180, full_height, 540, full_height, 180, 2 + 1, 540, full_height,
          full_height);
    scale(180, 2, 540, full_height, 180, 2, 540, 2 + 1, full_height);
    scale(180, 2, 540, 2, 180, 2, 540, full_height - 1, full_height);
    scale(180, 2, 540, full_height, 180, full_height - 1, 540, full_height,
          full_height);
  } break;
  case 3: {
    scale(180, full_height, 540, full_height, 180, 2 + 2, 540, full_height,
          full_height / 2);
    scale(180, 2, 540, full_height, 180, 2, 540, 2 + 2, full_height / 2);
    scale(180, 2, 540, 2, 180, 2, 540, full_height - 2, full_height / 2);
    scale(180, 2, 540, full_height, 180, full_height - 2, 540, full_height,
          full_height / 2);
  } break;
  case 4: {
    unsigned int finished;
    FS460_play_stop();
    move(0, -full_height, 0, full_height, 120);
    move(0, full_height, 0, -full_height, 120);
    while (0 == FS460_play_is_effect_finished(&finished) && !finished)
      ;
  } break;
  }
  FS460_play_run(0x0001);
}


x86 assembly (clang, -O0):
<turnfield_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
xor    %eax,%eax
call   1070 <FS460_play_begin@plt>
lea    -0x4(%rbp),%rdi
call   1030 <FS460_get_tv_active_lines@plt>
mov    0x2ece(%rip),%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
mov    %ecx,%eax
add    $0x1,%eax
sub    $0x4,%rcx
mov    %eax,0x2eb9(%rip)
ja     11bd <turnfield_test+0x4d>
mov    -0x10(%rbp),%rax
lea    0xe4c(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x1,0x2e95(%rip)
mov    -0x4(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x3c,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x14(%rbp),%eax
sub    %ecx,%eax
xor    %r9d,%r9d
mov    %r9d,%edi
mov    %r9d,%esi
mov    %r9d,%edx
mov    %r9d,%ecx
mov    %r9d,%r8d
movl   $0x2c4,(%rsp)
mov    %eax,0x8(%rsp)
movl   $0x3c,0x10(%rsp)
call   1050 <scale@plt>
mov    -0x4(%rbp),%ecx
mov    -0x4(%rbp),%r9d
mov    -0x4(%rbp),%eax
mov    $0x3c,%esi
cltd
idiv   %esi
sub    %eax,%r9d
mov    -0x4(%rbp),%eax
xor    %esi,%esi
mov    $0x2d0,%edx
mov    $0x2c4,%r8d
mov    %esi,%edi
movl   $0x2d0,(%rsp)
mov    %eax,0x8(%rsp)
movl   $0x3c,0x10(%rsp)
call   1050 <scale@plt>
mov    -0x4(%rbp),%esi
mov    -0x4(%rbp),%ecx
mov    -0x4(%rbp),%eax
mov    $0x3c,%edi
cltd
idiv   %edi
mov    %eax,%r9d
add    $0x0,%r9d
mov    -0x4(%rbp),%eax
mov    $0x2d0,%edx
mov    $0xc,%r8d
mov    %edx,%edi
movl   $0x2d0,(%rsp)
mov    %eax,0x8(%rsp)
movl   $0x3c,0x10(%rsp)
call   1050 <scale@plt>
mov    -0x4(%rbp),%ecx
mov    -0x4(%rbp),%eax
mov    $0x3c,%esi
cltd
idiv   %esi
add    $0x0,%eax
xor    %r9d,%r9d
mov    $0x2d0,%edx
mov    %r9d,%edi
mov    %r9d,%esi
mov    %r9d,%r8d
movl   $0xc,(%rsp)
mov    %eax,0x8(%rsp)
movl   $0x3c,0x10(%rsp)
call   1050 <scale@plt>
jmp    162d <turnfield_test+0x4bd>
mov    -0x4(%rbp),%esi
mov    -0x4(%rbp),%ecx
mov    -0x4(%rbp),%eax
mov    $0x3c,%edi
cltd
idiv   %edi
mov    %eax,%r9d
add    $0x2,%r9d
mov    -0x4(%rbp),%eax
xor    %r8d,%r8d
mov    %r8d,%edi
mov    %r8d,%edx
movl   $0x2c4,(%rsp)
mov    %eax,0x8(%rsp)
movl   $0x3c,0x10(%rsp)
call   1050 <scale@plt>
mov    -0x4(%rbp),%ecx
mov    -0x4(%rbp),%eax
mov    $0x3c,%esi
cltd
idiv   %esi
add    $0x2,%eax
xor    %edi,%edi
mov    $0x2,%r9d
mov    $0x2d0,%edx
mov    $0x2c4,%r8d
mov    %r9d,%esi
movl   $0x2d0,(%rsp)
mov    %eax,0x8(%rsp)
movl   $0x3c,0x10(%rsp)
call   1050 <scale@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x3c,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
sub    %ecx,%eax
mov    $0x2d0,%edx
mov    $0x2,%r9d
mov    $0xc,%r8d
mov    %edx,%edi
mov    %r9d,%esi
mov    %r9d,%ecx
movl   $0x2d0,(%rsp)
mov    %eax,0x8(%rsp)
movl   $0x3c,0x10(%rsp)
call   1050 <scale@plt>
mov    -0x4(%rbp),%ecx
mov    -0x4(%rbp),%r9d
mov    -0x4(%rbp),%eax
mov    $0x3c,%esi
cltd
idiv   %esi
sub    %eax,%r9d
mov    -0x4(%rbp),%eax
xor    %r8d,%r8d
mov    $0x2,%esi
mov    $0x2d0,%edx
mov    %r8d,%edi
movl   $0xc,(%rsp)
mov    %eax,0x8(%rsp)
movl   $0x3c,0x10(%rsp)
call   1050 <scale@plt>
jmp    162d <turnfield_test+0x4bd>
mov    -0x4(%rbp),%esi
mov    -0x4(%rbp),%ecx
mov    -0x4(%rbp),%r10d
mov    -0x4(%rbp),%eax
mov    $0xb4,%r8d
mov    $0x21c,%edx
mov    $0x3,%r9d
mov    %r8d,%edi
movl   $0x21c,(%rsp)
mov    %r10d,0x8(%rsp)
mov    %eax,0x10(%rsp)
call   1050 <scale@plt>
mov    -0x4(%rbp),%ecx
mov    -0x4(%rbp),%eax
mov    $0xb4,%r8d
mov    $0x2,%r9d
mov    $0x21c,%edx
mov    %r8d,%edi
mov    %r9d,%esi
movl   $0x21c,(%rsp)
movl   $0x3,0x8(%rsp)
mov    %eax,0x10(%rsp)
call   1050 <scale@plt>
mov    -0x4(%rbp),%r10d
sub    $0x1,%r10d
mov    -0x4(%rbp),%eax
mov    $0xb4,%r8d
mov    $0x2,%r9d
mov    $0x21c,%edx
mov    %r8d,%edi
mov    %r9d,%esi
mov    %r9d,%ecx
movl   $0x21c,(%rsp)
mov    %r10d,0x8(%rsp)
mov    %eax,0x10(%rsp)
call   1050 <scale@plt>
mov    -0x4(%rbp),%ecx
mov    -0x4(%rbp),%r9d
sub    $0x1,%r9d
mov    -0x4(%rbp),%r10d
mov    -0x4(%rbp),%eax
mov    $0xb4,%r8d
mov    $0x2,%esi
mov    $0x21c,%edx
mov    %r8d,%edi
movl   $0x21c,(%rsp)
mov    %r10d,0x8(%rsp)
mov    %eax,0x10(%rsp)
call   1050 <scale@plt>
jmp    162d <turnfield_test+0x4bd>
mov    -0x4(%rbp),%esi
mov    -0x4(%rbp),%ecx
mov    -0x4(%rbp),%r10d
mov    -0x4(%rbp),%eax
mov    $0x2,%edi
cltd
idiv   %edi
mov    $0xb4,%r8d
mov    $0x21c,%edx
mov    $0x4,%r9d
mov    %r8d,%edi
movl   $0x21c,(%rsp)
mov    %r10d,0x8(%rsp)
mov    %eax,0x10(%rsp)
call   1050 <scale@plt>
mov    -0x4(%rbp),%ecx
mov    -0x4(%rbp),%eax
mov    $0x2,%esi
cltd
idiv   %esi
mov    $0xb4,%r8d
mov    $0x2,%r9d
mov    $0x21c,%edx
mov    %r8d,%edi
mov    %r9d,%esi
movl   $0x21c,(%rsp)
movl   $0x4,0x8(%rsp)
mov    %eax,0x10(%rsp)
call   1050 <scale@plt>
mov    -0x4(%rbp),%r10d
sub    $0x2,%r10d
mov    -0x4(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    $0xb4,%r8d
mov    $0x2,%r9d
mov    $0x21c,%edx
mov    %r8d,%edi
mov    %r9d,%esi
mov    %r9d,%ecx
movl   $0x21c,(%rsp)
mov    %r10d,0x8(%rsp)
mov    %eax,0x10(%rsp)
call   1050 <scale@plt>
mov    -0x4(%rbp),%ecx
mov    -0x4(%rbp),%r9d
sub    $0x2,%r9d
mov    -0x4(%rbp),%r10d
mov    -0x4(%rbp),%eax
mov    $0x2,%esi
cltd
idiv   %esi
mov    $0xb4,%r8d
mov    $0x2,%esi
mov    $0x21c,%edx
mov    %r8d,%edi
movl   $0x21c,(%rsp)
mov    %r10d,0x8(%rsp)
mov    %eax,0x10(%rsp)
call   1050 <scale@plt>
jmp    162d <turnfield_test+0x4bd>
mov    $0x0,%al
call   1040 <FS460_play_stop@plt>
xor    %esi,%esi
sub    -0x4(%rbp),%esi
mov    -0x4(%rbp),%ecx
xor    %edx,%edx
mov    $0x78,%r8d
mov    %edx,%edi
call   1090 <move@plt>
mov    -0x4(%rbp),%esi
xor    %ecx,%ecx
sub    -0x4(%rbp),%ecx
xor    %edx,%edx
mov    $0x78,%r8d
mov    %edx,%edi
call   1090 <move@plt>
lea    -0x8(%rbp),%rdi
call   1080 <FS460_play_is_effect_finished@plt>
mov    %eax,%edx
xor    %eax,%eax
xor    %ecx,%ecx
cmp    %edx,%ecx
mov    %al,-0x19(%rbp)
jne    1613 <turnfield_test+0x4a3>
cmpl   $0x0,-0x8(%rbp)
setne  %al
xor    $0xff,%al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    1623 <turnfield_test+0x4b3>
jmp    1628 <turnfield_test+0x4b8>
jmp    15ed <turnfield_test+0x47d>
jmp    162d <turnfield_test+0x4bd>
mov    $0x1,%edi
call   1060 <FS460_play_run@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<turnfield_test>:
push   %rbx
sub    $0x10,%rsp
xor    %eax,%eax
call   1070 <FS460_play_begin@plt>
lea    0x8(%rsp),%rdi
call   1030 <FS460_get_tv_active_lines@plt>
mov    0x2ed0(%rip),%eax
lea    0x1(%rax),%ecx
mov    %ecx,0x2ec7(%rip)
cmp    $0x4,%rax
ja     12cc <turnfield_test+0x15c>
lea    0xe5a(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movslq 0x8(%rsp),%rcx
imul   $0xffffffff88888889,%rcx,%rax
shr    $0x20,%rax
add    %ecx,%eax
mov    %eax,%edx
sar    $0x5,%edx
shr    $0x1f,%eax
lea    (%rdx,%rax,1),%r9d
add    $0x2,%r9d
sub    $0x8,%rsp
xor    %edi,%edi
mov    %ecx,%esi
xor    %edx,%edx
xor    %r8d,%r8d
push   $0x3c
push   %rcx
push   $0x2c4
call   1050 <scale@plt>
add    $0x20,%rsp
movslq 0x8(%rsp),%rcx
imul   $0xffffffff88888889,%rcx,%rax
shr    $0x20,%rax
add    %ecx,%eax
mov    %eax,%edx
sar    $0x5,%edx
shr    $0x1f,%eax
add    %edx,%eax
add    $0x2,%eax
sub    $0x8,%rsp
xor    %edi,%edi
mov    $0x2,%esi
mov    $0x2d0,%edx
mov    $0x2c4,%r8d
mov    $0x2,%r9d
push   $0x3c
push   %rax
push   $0x2d0
call   1050 <scale@plt>
add    $0x20,%rsp
movslq 0x8(%rsp),%rax
imul   $0x77777777,%rax,%rbx
shr    $0x20,%rbx
sub    %eax,%ebx
mov    %ebx,%ecx
shr    $0x1f,%ecx
sar    $0x5,%ebx
add    %ecx,%ebx
add    %eax,%ebx
sub    $0x8,%rsp
mov    $0x2d0,%edi
mov    $0x2,%esi
mov    $0x2d0,%edx
mov    $0x2,%ecx
mov    $0xc,%r8d
mov    $0x2,%r9d
push   $0x3c
push   %rbx
push   $0x2d0
call   1050 <scale@plt>
add    $0x20,%rsp
movslq 0x8(%rsp),%rcx
imul   $0x77777777,%rcx,%r9
shr    $0x20,%r9
sub    %ecx,%r9d
mov    %r9d,%eax
shr    $0x1f,%eax
sar    $0x5,%r9d
add    %eax,%r9d
add    %ecx,%r9d
sub    $0x8,%rsp
xor    %edi,%edi
mov    $0x2,%esi
mov    $0x2d0,%edx
xor    %r8d,%r8d
push   $0x3c
push   %rcx
jmp    13d7 <turnfield_test+0x267>
movl   $0x1,0x2d86(%rip)
movslq 0x8(%rsp),%rax
imul   $0x77777777,%rax,%rbx
shr    $0x20,%rbx
sub    %eax,%ebx
mov    %ebx,%ecx
shr    $0x1f,%ecx
sar    $0x5,%ebx
add    %ecx,%ebx
add    %eax,%ebx
sub    $0x8,%rsp
xor    %edi,%edi
xor    %esi,%esi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
xor    %r9d,%r9d
push   $0x3c
push   %rbx
push   $0x2c4
call   1050 <scale@plt>
add    $0x20,%rsp
movslq 0x8(%rsp),%rcx
imul   $0x77777777,%rcx,%r9
shr    $0x20,%r9
sub    %ecx,%r9d
mov    %r9d,%eax
shr    $0x1f,%eax
sar    $0x5,%r9d
add    %eax,%r9d
add    %ecx,%r9d
sub    $0x8,%rsp
xor    %edi,%edi
xor    %esi,%esi
mov    $0x2d0,%edx
mov    $0x2c4,%r8d
push   $0x3c
push   %rcx
push   $0x2d0
call   1050 <scale@plt>
add    $0x20,%rsp
movslq 0x8(%rsp),%rcx
imul   $0xffffffff88888889,%rcx,%r9
shr    $0x20,%r9
add    %ecx,%r9d
mov    %r9d,%eax
shr    $0x1f,%eax
sar    $0x5,%r9d
add    %eax,%r9d
sub    $0x8,%rsp
mov    $0x2d0,%edi
mov    %ecx,%esi
mov    $0x2d0,%edx
mov    $0xc,%r8d
push   $0x3c
push   %rcx
push   $0x2d0
call   1050 <scale@plt>
add    $0x20,%rsp
movslq 0x8(%rsp),%rcx
imul   $0xffffffff88888889,%rcx,%rax
shr    $0x20,%rax
add    %ecx,%eax
mov    %eax,%edx
shr    $0x1f,%edx
sar    $0x5,%eax
add    %edx,%eax
sub    $0x8,%rsp
xor    %edi,%edi
xor    %esi,%esi
mov    $0x2d0,%edx
xor    %r8d,%r8d
xor    %r9d,%r9d
push   $0x3c
push   %rax
push   $0xc
jmp    1591 <turnfield_test+0x421>
mov    0x8(%rsp),%ecx
sub    $0x8,%rsp
mov    $0xb4,%edi
mov    %ecx,%esi
mov    $0x21c,%edx
mov    $0xb4,%r8d
mov    $0x3,%r9d
push   %rcx
push   %rcx
push   $0x21c
call   1050 <scale@plt>
add    $0x20,%rsp
mov    0x8(%rsp),%ecx
sub    $0x8,%rsp
mov    $0xb4,%edi
mov    $0x2,%esi
mov    $0x21c,%edx
mov    $0xb4,%r8d
mov    $0x2,%r9d
push   %rcx
push   $0x3
push   $0x21c
call   1050 <scale@plt>
add    $0x20,%rsp
mov    0x8(%rsp),%ebx
sub    $0x8,%rsp
mov    %ebx,%eax
add    $0xffffffff,%eax
mov    $0xb4,%edi
mov    $0x2,%esi
mov    $0x21c,%edx
mov    $0x2,%ecx
mov    $0xb4,%r8d
mov    $0x2,%r9d
push   %rbx
push   %rax
push   $0x21c
call   1050 <scale@plt>
add    $0x20,%rsp
mov    0x8(%rsp),%ecx
lea    -0x1(%rcx),%r9d
sub    $0x8,%rsp
mov    $0xb4,%edi
mov    $0x2,%esi
mov    $0x21c,%edx
mov    $0xb4,%r8d
push   %rcx
jmp    158b <turnfield_test+0x41b>
mov    0x8(%rsp),%ecx
mov    %ecx,%eax
shr    $0x1f,%eax
add    %ecx,%eax
sar    %eax
sub    $0x8,%rsp
mov    $0xb4,%edi
mov    %ecx,%esi
mov    $0x21c,%edx
mov    $0xb4,%r8d
mov    $0x4,%r9d
push   %rax
push   %rcx
push   $0x21c
call   1050 <scale@plt>
add    $0x20,%rsp
mov    0x8(%rsp),%ecx
mov    %ecx,%eax
shr    $0x1f,%eax
add    %ecx,%eax
sar    %eax
sub    $0x8,%rsp
mov    $0xb4,%edi
mov    $0x2,%esi
mov    $0x21c,%edx
mov    $0xb4,%r8d
mov    $0x2,%r9d
push   %rax
push   $0x4
push   $0x21c
call   1050 <scale@plt>
add    $0x20,%rsp
mov    0x8(%rsp),%ecx
lea    -0x2(%rcx),%ebx
mov    %ecx,%eax
shr    $0x1f,%eax
add    %ecx,%eax
sar    %eax
sub    $0x8,%rsp
mov    $0xb4,%edi
mov    $0x2,%esi
mov    $0x21c,%edx
mov    $0x2,%ecx
mov    $0xb4,%r8d
mov    $0x2,%r9d
push   %rax
push   %rbx
push   $0x21c
call   1050 <scale@plt>
add    $0x20,%rsp
mov    0x8(%rsp),%ecx
lea    -0x2(%rcx),%r9d
mov    %ecx,%eax
shr    $0x1f,%eax
add    %ecx,%eax
sar    %eax
sub    $0x8,%rsp
mov    $0xb4,%edi
mov    $0x2,%esi
mov    $0x21c,%edx
mov    $0xb4,%r8d
push   %rax
push   %rcx
push   $0x21c
call   1050 <scale@plt>
add    $0x20,%rsp
mov    $0x1,%edi
call   1060 <FS460_play_run@plt>
add    $0x10,%rsp
pop    %rbx
ret
xor    %eax,%eax
call   1040 <FS460_play_stop@plt>
mov    0x8(%rsp),%ecx
mov    %ecx,%esi
neg    %esi
xor    %edi,%edi
xor    %edx,%edx
mov    $0x78,%r8d
call   1090 <move@plt>
mov    0x8(%rsp),%esi
mov    %esi,%ecx
neg    %ecx
xor    %edi,%edi
xor    %edx,%edx
mov    $0x78,%r8d
call   1090 <move@plt>
lea    0xc(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %rbx,%rdi
call   1080 <FS460_play_is_effect_finished@plt>
or     0xc(%rsp),%eax
je     15f0 <turnfield_test+0x480>
jmp    159a <turnfield_test+0x42a>

LLVM IR (-O0):
@turnfield_test.mode = internal global i32 0
define void @turnfield_test() {
%1 = alloca i32
%2 = alloca i32
%3 = call i32 (...) @FS460_play_begin()
%4 = call i32 @FS460_get_tv_active_lines(i32* %1)
%5 = load i32, i32* @turnfield_test.mode
%6 = add nsw i32 %5, 1
store i32 %6, i32* @turnfield_test.mode
switch i32 %5, label %7 [
i32 0, label %8
i32 1, label %33
i32 2, label %58
i32 3, label %77
i32 4, label %100
]
7: ; preds = %0
store i32 1, i32* @turnfield_test.mode
br label %8
8: ; preds = %0, %7
%9 = load i32, i32* %1
%10 = load i32, i32* %1
%11 = sdiv i32 %10, 60
%12 = sub nsw i32 %9, %11
%13 = call i32 @scale(i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 708, i32 %12, i32 60)
%14 = load i32, i32* %1
%15 = load i32, i32* %1
%16 = load i32, i32* %1
%17 = sdiv i32 %16, 60
%18 = sub nsw i32 %15, %17
%19 = load i32, i32* %1
%20 = call i32 @scale(i32 0, i32 0, i32 720, i32 %14, i32 708, i32 %18, i32 720, i32 %19, i32 60)
%21 = load i32, i32* %1
%22 = load i32, i32* %1
%23 = load i32, i32* %1
%24 = sdiv i32 %23, 60
%25 = add nsw i32 0, %24
%26 = load i32, i32* %1
%27 = call i32 @scale(i32 720, i32 %21, i32 720, i32 %22, i32 12, i32 %25, i32 720, i32 %26, i32 60)
%28 = load i32, i32* %1
%29 = load i32, i32* %1
%30 = sdiv i32 %29, 60
%31 = add nsw i32 0, %30
%32 = call i32 @scale(i32 0, i32 0, i32 720, i32 %28, i32 0, i32 0, i32 12, i32 %31, i32 60)
br label %121
33: ; preds = %0
%34 = load i32, i32* %1
%35 = load i32, i32* %1
%36 = load i32, i32* %1
%37 = sdiv i32 %36, 60
%38 = add nsw i32 2, %37
%39 = load i32, i32* %1
%40 = call i32 @scale(i32 0, i32 %34, i32 0, i32 %35, i32 0, i32 %38, i32 708, i32 %39, i32 60)
%41 = load i32, i32* %1
%42 = load i32, i32* %1
%43 = sdiv i32 %42, 60
%44 = add nsw i32 2, %43
%45 = call i32 @scale(i32 0, i32 2, i32 720, i32 %41, i32 708, i32 2, i32 720, i32 %44, i32 60)
%46 = load i32, i32* %1
%47 = load i32, i32* %1
%48 = sdiv i32 %47, 60
%49 = sub nsw i32 %46, %48
%50 = call i32 @scale(i32 720, i32 2, i32 720, i32 2, i32 12, i32 2, i32 720, i32 %49, i32 60)
%51 = load i32, i32* %1
%52 = load i32, i32* %1
%53 = load i32, i32* %1
%54 = sdiv i32 %53, 60
%55 = sub nsw i32 %52, %54
%56 = load i32, i32* %1
%57 = call i32 @scale(i32 0, i32 2, i32 720, i32 %51, i32 0, i32 %55, i32 12, i32 %56, i32 60)
br label %121
58: ; preds = %0
%59 = load i32, i32* %1
%60 = load i32, i32* %1
%61 = load i32, i32* %1
%62 = load i32, i32* %1
%63 = call i32 @scale(i32 180, i32 %59, i32 540, i32 %60, i32 180, i32 3, i32 540, i32 %61, i32 %62)
%64 = load i32, i32* %1
%65 = load i32, i32* %1
%66 = call i32 @scale(i32 180, i32 2, i32 540, i32 %64, i32 180, i32 2, i32 540, i32 3, i32 %65)
%67 = load i32, i32* %1
%68 = sub nsw i32 %67, 1
%69 = load i32, i32* %1
%70 = call i32 @scale(i32 180, i32 2, i32 540, i32 2, i32 180, i32 2, i32 540, i32 %68, i32 %69)
%71 = load i32, i32* %1
%72 = load i32, i32* %1
%73 = sub nsw i32 %72, 1
%74 = load i32, i32* %1
%75 = load i32, i32* %1
%76 = call i32 @scale(i32 180, i32 2, i32 540, i32 %71, i32 180, i32 %73, i32 540, i32 %74, i32 %75)
br label %121
77: ; preds = %0
%78 = load i32, i32* %1
%79 = load i32, i32* %1
%80 = load i32, i32* %1
%81 = load i32, i32* %1
%82 = sdiv i32 %81, 2
%83 = call i32 @scale(i32 180, i32 %78, i32 540, i32 %79, i32 180, i32 4, i32 540, i32 %80, i32 %82)
%84 = load i32, i32* %1
%85 = load i32, i32* %1
%86 = sdiv i32 %85, 2
%87 = call i32 @scale(i32 180, i32 2, i32 540, i32 %84, i32 180, i32 2, i32 540, i32 4, i32 %86)
%88 = load i32, i32* %1
%89 = sub nsw i32 %88, 2
%90 = load i32, i32* %1
%91 = sdiv i32 %90, 2
%92 = call i32 @scale(i32 180, i32 2, i32 540, i32 2, i32 180, i32 2, i32 540, i32 %89, i32 %91)
%93 = load i32, i32* %1
%94 = load i32, i32* %1
%95 = sub nsw i32 %94, 2
%96 = load i32, i32* %1
%97 = load i32, i32* %1
%98 = sdiv i32 %97, 2
%99 = call i32 @scale(i32 180, i32 2, i32 540, i32 %93, i32 180, i32 %95, i32 540, i32 %96, i32 %98)
br label %121
100: ; preds = %0
%101 = call i32 (...) @FS460_play_stop()
%102 = load i32, i32* %1
%103 = sub nsw i32 0, %102
%104 = load i32, i32* %1
%105 = call i32 @move(i32 0, i32 %103, i32 0, i32 %104, i32 120)
%106 = load i32, i32* %1
%107 = load i32, i32* %1
%108 = sub nsw i32 0, %107
%109 = call i32 @move(i32 0, i32 %106, i32 0, i32 %108, i32 120)
br label %110
110: ; preds = %119, %100
%111 = call i32 @FS460_play_is_effect_finished(i32* %2)
%112 = icmp eq i32 0, %111
br i1 %112, label %113, label %117
113: ; preds = %110
%114 = load i32, i32* %2
%115 = icmp ne i32 %114, 0
%116 = xor i1 %115, true
br label %117
117: ; preds = %113, %110
%118 = phi i1 [ false, %110 ], [ %116, %113 ]
br i1 %118, label %119, label %120
119: ; preds = %117
br label %110
120: ; preds = %117
br label %121
121: ; preds = %120, %77, %58, %33, %8
%122 = call i32 @FS460_play_run(i32 1)
ret void
}

LLVM IR (-O2):
@turnfield_test.mode = internal unnamed_addr global i32 0
define void @turnfield_test() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = tail call i32 (...) @FS460_play_begin()
%5 = call i32 @FS460_get_tv_active_lines(i32* %1)
%6 = load i32, i32* @turnfield_test.mode
%7 = add nsw i32 %6, 1
store i32 %7, i32* @turnfield_test.mode
switch i32 %6, label %8 [
i32 0, label %9
i32 1, label %24
i32 2, label %41
i32 3, label %52
i32 4, label %67
]
8: ; preds = %0
store i32 1, i32* @turnfield_test.mode
br label %9
9: ; preds = %0, %8
%10 = load i32, i32* %1
%11 = sdiv i32 %10, -60
%12 = add i32 %11, %10
%13 = call i32 @scale(i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 708, i32 %12, i32 60)
%14 = load i32, i32* %1
%15 = sdiv i32 %14, -60
%16 = add i32 %15, %14
%17 = call i32 @scale(i32 0, i32 0, i32 720, i32 %14, i32 708, i32 %16, i32 720, i32 %14, i32 60)
%18 = load i32, i32* %1
%19 = sdiv i32 %18, 60
%20 = call i32 @scale(i32 720, i32 %18, i32 720, i32 %18, i32 12, i32 %19, i32 720, i32 %18, i32 60)
%21 = load i32, i32* %1
%22 = sdiv i32 %21, 60
%23 = call i32 @scale(i32 0, i32 0, i32 720, i32 %21, i32 0, i32 0, i32 12, i32 %22, i32 60)
br label %83
24: ; preds = %0
%25 = load i32, i32* %1
%26 = sdiv i32 %25, 60
%27 = add nsw i32 %26, 2
%28 = call i32 @scale(i32 0, i32 %25, i32 0, i32 %25, i32 0, i32 %27, i32 708, i32 %25, i32 60)
%29 = load i32, i32* %1
%30 = sdiv i32 %29, 60
%31 = add nsw i32 %30, 2
%32 = call i32 @scale(i32 0, i32 2, i32 720, i32 %29, i32 708, i32 2, i32 720, i32 %31, i32 60)
%33 = load i32, i32* %1
%34 = sdiv i32 %33, -60
%35 = add i32 %34, %33
%36 = call i32 @scale(i32 720, i32 2, i32 720, i32 2, i32 12, i32 2, i32 720, i32 %35, i32 60)
%37 = load i32, i32* %1
%38 = sdiv i32 %37, -60
%39 = add i32 %38, %37
%40 = call i32 @scale(i32 0, i32 2, i32 720, i32 %37, i32 0, i32 %39, i32 12, i32 %37, i32 60)
br label %83
41: ; preds = %0
%42 = load i32, i32* %1
%43 = call i32 @scale(i32 180, i32 %42, i32 540, i32 %42, i32 180, i32 3, i32 540, i32 %42, i32 %42)
%44 = load i32, i32* %1
%45 = call i32 @scale(i32 180, i32 2, i32 540, i32 %44, i32 180, i32 2, i32 540, i32 3, i32 %44)
%46 = load i32, i32* %1
%47 = add nsw i32 %46, -1
%48 = call i32 @scale(i32 180, i32 2, i32 540, i32 2, i32 180, i32 2, i32 540, i32 %47, i32 %46)
%49 = load i32, i32* %1
%50 = add nsw i32 %49, -1
%51 = call i32 @scale(i32 180, i32 2, i32 540, i32 %49, i32 180, i32 %50, i32 540, i32 %49, i32 %49)
br label %83
52: ; preds = %0
%53 = load i32, i32* %1
%54 = sdiv i32 %53, 2
%55 = call i32 @scale(i32 180, i32 %53, i32 540, i32 %53, i32 180, i32 4, i32 540, i32 %53, i32 %54)
%56 = load i32, i32* %1
%57 = sdiv i32 %56, 2
%58 = call i32 @scale(i32 180, i32 2, i32 540, i32 %56, i32 180, i32 2, i32 540, i32 4, i32 %57)
%59 = load i32, i32* %1
%60 = add nsw i32 %59, -2
%61 = sdiv i32 %59, 2
%62 = call i32 @scale(i32 180, i32 2, i32 540, i32 2, i32 180, i32 2, i32 540, i32 %60, i32 %61)
%63 = load i32, i32* %1
%64 = add nsw i32 %63, -2
%65 = sdiv i32 %63, 2
%66 = call i32 @scale(i32 180, i32 2, i32 540, i32 %63, i32 180, i32 %64, i32 540, i32 %63, i32 %65)
br label %83
67: ; preds = %0
%68 = bitcast i32* %2 to i8*
%69 = call i32 (...) @FS460_play_stop()
%70 = load i32, i32* %1
%71 = sub nsw i32 0, %70
%72 = call i32 @move(i32 0, i32 %71, i32 0, i32 %70, i32 120)
%73 = load i32, i32* %1
%74 = sub nsw i32 0, %73
%75 = call i32 @move(i32 0, i32 %73, i32 0, i32 %74, i32 120)
br label %76
76: ; preds = %76, %67
%77 = call i32 @FS460_play_is_effect_finished(i32* %2)
%78 = icmp eq i32 %77, 0
%79 = load i32, i32* %2
%80 = icmp eq i32 %79, 0
%81 = select i1 %78, i1 %80, i1 false
br i1 %81, label %76, label %82
82: ; preds = %76
br label %83
83: ; preds = %82, %52, %41, %24, %9
%84 = call i32 @FS460_play_run(i32 1)
ret void
}