#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 FS460_play_begin();
int FS460_play_is_effect_finished(unsigned int *);
int FS460_play_run(int);
int /*<<< orphan*/ set(int /*<<< orphan*/, int /*<<< orphan*/, int, int,
                       int /*<<< orphan*/, int);
int /*<<< orphan*/ vertical_flash(int, int);
void vertical_flash_test(void) {
  static int mode = 0;
  int full_height;
  unsigned int completed;
  int err;
  FS460_get_tv_active_lines(&full_height);
  err = FS460_play_begin();
  if (!err) {
    set(0, 0, 720, full_height, 0, 0x0001);
    set(0, 0, 720, full_height, 0, 0x0001);
    set(0, 0, 720, full_height, 0, 0x0001);
    set(0, 0, 720, full_height, 0, 0x0001);
    err = FS460_play_run(0);
    if (!err) {
      completed = 0;
      while (!err && !completed)
        err = FS460_play_is_effect_finished(&completed);
    }
  }
  FS460_play_begin();
  switch (mode++) {
  default:
    mode = 1;
  case 0:
    vertical_flash(1, 0);
    break;
  case 1:
    vertical_flash(2, 0);
    break;
  case 2:
    vertical_flash(4, 0);
    break;
  case 3:
    vertical_flash(6, 0);
    break;
  case 4:
    vertical_flash(8, 0);
    break;
  case 5:
    vertical_flash(10, 0);
    break;
  case 6:
    vertical_flash(6, 1);
    break;
  }
  FS460_play_run(0x0001);
}


x86 assembly (clang, -O0):
<vertical_flash_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    -0x4(%rbp),%rdi
call   1030 <FS460_get_tv_active_lines@plt>
mov    $0x0,%al
call   1050 <FS460_play_begin@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jne    1256 <vertical_flash_test+0xf6>
mov    -0x4(%rbp),%ecx
xor    %r8d,%r8d
mov    $0x2d0,%edx
mov    $0x1,%r9d
mov    %r8d,%edi
mov    %r8d,%esi
call   1080 <set@plt>
mov    -0x4(%rbp),%ecx
xor    %r8d,%r8d
mov    $0x2d0,%edx
mov    $0x1,%r9d
mov    %r8d,%edi
mov    %r8d,%esi
call   1080 <set@plt>
mov    -0x4(%rbp),%ecx
xor    %r8d,%r8d
mov    $0x2d0,%edx
mov    $0x1,%r9d
mov    %r8d,%edi
mov    %r8d,%esi
call   1080 <set@plt>
mov    -0x4(%rbp),%ecx
xor    %r8d,%r8d
mov    $0x2d0,%edx
mov    $0x1,%r9d
mov    %r8d,%edi
mov    %r8d,%esi
call   1080 <set@plt>
xor    %edi,%edi
call   1040 <FS460_play_run@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jne    1251 <vertical_flash_test+0xf1>
movl   $0x0,-0x8(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0xc(%rbp)
mov    %al,-0xd(%rbp)
jne    122b <vertical_flash_test+0xcb>
cmpl   $0x0,-0x8(%rbp)
setne  %al
xor    $0xff,%al
mov    %al,-0xd(%rbp)
mov    -0xd(%rbp),%al
test   $0x1,%al
jne    123b <vertical_flash_test+0xdb>
jmp    124c <vertical_flash_test+0xec>
lea    -0x8(%rbp),%rdi
call   1070 <FS460_play_is_effect_finished@plt>
mov    %eax,-0xc(%rbp)
jmp    1210 <vertical_flash_test+0xb0>
jmp    1251 <vertical_flash_test+0xf1>
jmp    1256 <vertical_flash_test+0xf6>
xor    %eax,%eax
call   1050 <FS460_play_begin@plt>
mov    0x2df1(%rip),%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
mov    %ecx,%eax
add    $0x1,%eax
sub    $0x6,%rcx
mov    %eax,0x2ddc(%rip)
ja     1292 <vertical_flash_test+0x132>
mov    -0x18(%rbp),%rax
lea    0xd77(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x1,0x2db8(%rip)
mov    $0x1,%edi
xor    %esi,%esi
call   1060 <vertical_flash@plt>
jmp    1311 <vertical_flash_test+0x1b1>
mov    $0x2,%edi
xor    %esi,%esi
call   1060 <vertical_flash@plt>
jmp    1311 <vertical_flash_test+0x1b1>
mov    $0x4,%edi
xor    %esi,%esi
call   1060 <vertical_flash@plt>
jmp    1311 <vertical_flash_test+0x1b1>
mov    $0x6,%edi
xor    %esi,%esi
call   1060 <vertical_flash@plt>
jmp    1311 <vertical_flash_test+0x1b1>
mov    $0x8,%edi
xor    %esi,%esi
call   1060 <vertical_flash@plt>
jmp    1311 <vertical_flash_test+0x1b1>
mov    $0xa,%edi
xor    %esi,%esi
call   1060 <vertical_flash@plt>
jmp    1311 <vertical_flash_test+0x1b1>
mov    $0x6,%edi
mov    $0x1,%esi
call   1060 <vertical_flash@plt>
mov    $0x1,%edi
call   1040 <FS460_play_run@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<vertical_flash_test>:
push   %rbx
sub    $0x10,%rsp
lea    0x8(%rsp),%rdi
call   1030 <FS460_get_tv_active_lines@plt>
xor    %eax,%eax
call   1050 <FS460_play_begin@plt>
test   %eax,%eax
jne    121e <vertical_flash_test+0xbe>
mov    0x8(%rsp),%ecx
xor    %edi,%edi
xor    %esi,%esi
mov    $0x2d0,%edx
xor    %r8d,%r8d
mov    $0x1,%r9d
call   1080 <set@plt>
mov    0x8(%rsp),%ecx
xor    %edi,%edi
xor    %esi,%esi
mov    $0x2d0,%edx
xor    %r8d,%r8d
mov    $0x1,%r9d
call   1080 <set@plt>
mov    0x8(%rsp),%ecx
xor    %edi,%edi
xor    %esi,%esi
mov    $0x2d0,%edx
xor    %r8d,%r8d
mov    $0x1,%r9d
call   1080 <set@plt>
mov    0x8(%rsp),%ecx
xor    %edi,%edi
xor    %esi,%esi
mov    $0x2d0,%edx
xor    %r8d,%r8d
mov    $0x1,%r9d
call   1080 <set@plt>
xor    %edi,%edi
call   1040 <FS460_play_run@plt>
test   %eax,%eax
jne    121e <vertical_flash_test+0xbe>
movl   $0x0,0xc(%rsp)
lea    0xc(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %rbx,%rdi
call   1070 <FS460_play_is_effect_finished@plt>
or     0xc(%rsp),%eax
je     1210 <vertical_flash_test+0xb0>
xor    %eax,%eax
call   1050 <FS460_play_begin@plt>
mov    0x2e29(%rip),%eax
lea    0x1(%rax),%ecx
mov    %ecx,0x2e20(%rip)
cmp    $0x6,%rax
ja     1253 <vertical_flash_test+0xf3>
lea    0xdbf(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x2,%edi
xor    %esi,%esi
jmp    1294 <vertical_flash_test+0x134>
movl   $0x1,0x2df7(%rip)
mov    $0x1,%edi
xor    %esi,%esi
jmp    1294 <vertical_flash_test+0x134>
mov    $0x4,%edi
xor    %esi,%esi
jmp    1294 <vertical_flash_test+0x134>
mov    $0x6,%edi
xor    %esi,%esi
jmp    1294 <vertical_flash_test+0x134>
mov    $0x8,%edi
xor    %esi,%esi
jmp    1294 <vertical_flash_test+0x134>
mov    $0xa,%edi
xor    %esi,%esi
jmp    1294 <vertical_flash_test+0x134>
mov    $0x6,%edi
mov    $0x1,%esi
call   1060 <vertical_flash@plt>
mov    $0x1,%edi
call   1040 <FS460_play_run@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@vertical_flash_test.mode = internal global i32 0
define void @vertical_flash_test() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = call i32 @FS460_get_tv_active_lines(i32* %1)
%5 = call i32 (...) @FS460_play_begin()
store i32 %5, i32* %3
%6 = load i32, i32* %3
%7 = icmp ne i32 %6, 0
br i1 %7, label %34, label %8
8: ; preds = %0
%9 = load i32, i32* %1
%10 = call i32 @set(i32 0, i32 0, i32 720, i32 %9, i32 0, i32 1)
%11 = load i32, i32* %1
%12 = call i32 @set(i32 0, i32 0, i32 720, i32 %11, i32 0, i32 1)
%13 = load i32, i32* %1
%14 = call i32 @set(i32 0, i32 0, i32 720, i32 %13, i32 0, i32 1)
%15 = load i32, i32* %1
%16 = call i32 @set(i32 0, i32 0, i32 720, i32 %15, i32 0, i32 1)
%17 = call i32 @FS460_play_run(i32 0)
store i32 %17, i32* %3
%18 = load i32, i32* %3
%19 = icmp ne i32 %18, 0
br i1 %19, label %33, label %20
20: ; preds = %8
store i32 0, i32* %2
br label %21
21: ; preds = %30, %20
%22 = load i32, i32* %3
%23 = icmp ne i32 %22, 0
br i1 %23, label %28, label %24
24: ; preds = %21
%25 = load i32, i32* %2
%26 = icmp ne i32 %25, 0
%27 = xor i1 %26, true
br label %28
28: ; preds = %24, %21
%29 = phi i1 [ false, %21 ], [ %27, %24 ]
br i1 %29, label %30, label %32
30: ; preds = %28
%31 = call i32 @FS460_play_is_effect_finished(i32* %2)
store i32 %31, i32* %3
br label %21
32: ; preds = %28
br label %33
33: ; preds = %32, %8
br label %34
34: ; preds = %33, %0
%35 = call i32 (...) @FS460_play_begin()
%36 = load i32, i32* @vertical_flash_test.mode
%37 = add nsw i32 %36, 1
store i32 %37, i32* @vertical_flash_test.mode
switch i32 %36, label %38 [
i32 0, label %39
i32 1, label %41
i32 2, label %43
i32 3, label %45
i32 4, label %47
i32 5, label %49
i32 6, label %51
]
38: ; preds = %34
store i32 1, i32* @vertical_flash_test.mode
br label %39
39: ; preds = %34, %38
%40 = call i32 @vertical_flash(i32 1, i32 0)
br label %53
41: ; preds = %34
%42 = call i32 @vertical_flash(i32 2, i32 0)
br label %53
43: ; preds = %34
%44 = call i32 @vertical_flash(i32 4, i32 0)
br label %53
45: ; preds = %34
%46 = call i32 @vertical_flash(i32 6, i32 0)
br label %53
47: ; preds = %34
%48 = call i32 @vertical_flash(i32 8, i32 0)
br label %53
49: ; preds = %34
%50 = call i32 @vertical_flash(i32 10, i32 0)
br label %53
51: ; preds = %34
%52 = call i32 @vertical_flash(i32 6, i32 1)
br label %53
53: ; preds = %51, %49, %47, %45, %43, %41, %39
%54 = call i32 @FS460_play_run(i32 1)
ret void
}

LLVM IR (-O2):
@vertical_flash_test.mode = internal unnamed_addr global i32 0
define void @vertical_flash_test() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = call i32 @FS460_get_tv_active_lines(i32* %1)
%6 = call i32 (...) @FS460_play_begin()
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %26
8: ; preds = %0
%9 = load i32, i32* %1
%10 = call i32 @set(i32 0, i32 0, i32 720, i32 %9, i32 0, i32 1)
%11 = load i32, i32* %1
%12 = call i32 @set(i32 0, i32 0, i32 720, i32 %11, i32 0, i32 1)
%13 = load i32, i32* %1
%14 = call i32 @set(i32 0, i32 0, i32 720, i32 %13, i32 0, i32 1)
%15 = load i32, i32* %1
%16 = call i32 @set(i32 0, i32 0, i32 720, i32 %15, i32 0, i32 1)
%17 = call i32 @FS460_play_run(i32 0)
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %26
19: ; preds = %8
store i32 0, i32* %2
br label %20
20: ; preds = %19, %20
%21 = call i32 @FS460_play_is_effect_finished(i32* %2)
%22 = icmp eq i32 %21, 0
%23 = load i32, i32* %2
%24 = icmp eq i32 %23, 0
%25 = select i1 %22, i1 %24, i1 false
br i1 %25, label %20, label %26
26: ; preds = %20, %8, %0
%27 = call i32 (...) @FS460_play_begin()
%28 = load i32, i32* @vertical_flash_test.mode
%29 = add nsw i32 %28, 1
store i32 %29, i32* @vertical_flash_test.mode
switch i32 %28, label %30 [
i32 0, label %31
i32 1, label %33
i32 2, label %35
i32 3, label %37
i32 4, label %39
i32 5, label %41
i32 6, label %43
]
30: ; preds = %26
store i32 1, i32* @vertical_flash_test.mode
br label %31
31: ; preds = %26, %30
%32 = call i32 @vertical_flash(i32 1, i32 0)
br label %45
33: ; preds = %26
%34 = call i32 @vertical_flash(i32 2, i32 0)
br label %45
35: ; preds = %26
%36 = call i32 @vertical_flash(i32 4, i32 0)
br label %45
37: ; preds = %26
%38 = call i32 @vertical_flash(i32 6, i32 0)
br label %45
39: ; preds = %26
%40 = call i32 @vertical_flash(i32 8, i32 0)
br label %45
41: ; preds = %26
%42 = call i32 @vertical_flash(i32 10, i32 0)
br label %45
43: ; preds = %26
%44 = call i32 @vertical_flash(i32 6, i32 1)
br label %45
45: ; preds = %43, %41, %39, %37, %35, %33, %31
%46 = call i32 @FS460_play_run(i32 1)
ret void
}