#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_image_request_freeze(int, int, int /*<<< orphan*/);
int FS460_image_set_begin_field(int);
int /*<<< orphan*/ OS_mdelay(int);
int black_line(int);
int FS460_set_black_image(void) {
  int err;
  int full_height;
  int y;
  FS460_get_tv_active_lines(&full_height);
  err = FS460_image_request_freeze(0x0001, 0x0001, 0);
  if (!err) {
    OS_mdelay(40);
    err = FS460_image_set_begin_field(1);
    if (!err) {
      for (y = 0; y < (full_height / 2); y++) {
        err = black_line(720);
        if (err)
          break;
      }
      if (!err) {
        err = FS460_image_set_begin_field(0);
        if (!err) {
          for (y = 0; y < (full_height / 2); y++) {
            err = black_line(720);
            if (err)
              break;
          }
        }
      }
    }
  }
  return err;
}


x86 assembly (clang, -O0):
<FS460_set_black_image>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    -0x8(%rbp),%rdi
call   1050 <FS460_get_tv_active_lines@plt>
mov    $0x1,%esi
xor    %edx,%edx
mov    %esi,%edi
call   1030 <FS460_image_request_freeze@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jne    1277 <FS460_set_black_image+0x127>
mov    $0x28,%edi
call   1060 <OS_mdelay@plt>
mov    $0x1,%edi
call   1070 <FS460_image_set_begin_field@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jne    1272 <FS460_set_black_image+0x122>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x10(%rbp),%eax
cmp    %ecx,%eax
jge    11f1 <FS460_set_black_image+0xa1>
mov    $0x2d0,%edi
call   1040 <black_line@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
je     11de <FS460_set_black_image+0x8e>
jmp    11f1 <FS460_set_black_image+0xa1>
jmp    11e3 <FS460_set_black_image+0x93>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11a4 <FS460_set_black_image+0x54>
cmpl   $0x0,-0x4(%rbp)
jne    126d <FS460_set_black_image+0x11d>
xor    %edi,%edi
call   1070 <FS460_image_set_begin_field@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jne    1268 <FS460_set_black_image+0x118>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x14(%rbp),%eax
cmp    %ecx,%eax
jge    1263 <FS460_set_black_image+0x113>
mov    $0x2d0,%edi
call   1040 <black_line@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
je     1250 <FS460_set_black_image+0x100>
jmp    1263 <FS460_set_black_image+0x113>
jmp    1255 <FS460_set_black_image+0x105>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1216 <FS460_set_black_image+0xc6>
jmp    1268 <FS460_set_black_image+0x118>
jmp    126d <FS460_set_black_image+0x11d>
jmp    1272 <FS460_set_black_image+0x122>
jmp    1277 <FS460_set_black_image+0x127>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<FS460_set_black_image>:
push   %rbx
sub    $0x10,%rsp
lea    0xc(%rsp),%rdi
call   1050 <FS460_get_tv_active_lines@plt>
mov    $0x1,%edi
mov    $0x1,%esi
xor    %edx,%edx
call   1030 <FS460_image_request_freeze@plt>
test   %eax,%eax
jne    1204 <FS460_set_black_image+0xb4>
mov    $0x28,%edi
call   1060 <OS_mdelay@plt>
mov    $0x1,%edi
call   1070 <FS460_image_set_begin_field@plt>
test   %eax,%eax
jne    1204 <FS460_set_black_image+0xb4>
cmpl   $0x2,0xc(%rsp)
jl     11c2 <FS460_set_black_image+0x72>
xor    %ebx,%ebx
nopl   0x0(%rax)
mov    $0x2d0,%edi
call   1040 <black_line@plt>
test   %eax,%eax
jne    1204 <FS460_set_black_image+0xb4>
add    $0x1,%ebx
mov    0xc(%rsp),%eax
mov    %eax,%ecx
shr    $0x1f,%ecx
add    %eax,%ecx
sar    %ecx
cmp    %ecx,%ebx
jl     11a0 <FS460_set_black_image+0x50>
xor    %edi,%edi
call   1070 <FS460_image_set_begin_field@plt>
test   %eax,%eax
jne    1204 <FS460_set_black_image+0xb4>
cmpl   $0x2,0xc(%rsp)
mov    $0x0,%eax
jl     1204 <FS460_set_black_image+0xb4>
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
mov    $0x2d0,%edi
call   1040 <black_line@plt>
test   %eax,%eax
jne    1204 <FS460_set_black_image+0xb4>
add    $0x1,%ebx
mov    0xc(%rsp),%eax
mov    %eax,%ecx
shr    $0x1f,%ecx
add    %eax,%ecx
sar    %ecx
xor    %eax,%eax
cmp    %ecx,%ebx
jl     11e0 <FS460_set_black_image+0x90>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define i32 @FS460_set_black_image() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = call i32 @FS460_get_tv_active_lines(i32* %2)
%5 = call i32 @FS460_image_request_freeze(i32 1, i32 1, i32 0)
store i32 %5, i32* %1
%6 = load i32, i32* %1
%7 = icmp ne i32 %6, 0
br i1 %7, label %54, label %8
8: ; preds = %0
%9 = call i32 @OS_mdelay(i32 40)
%10 = call i32 @FS460_image_set_begin_field(i32 1)
store i32 %10, i32* %1
%11 = load i32, i32* %1
%12 = icmp ne i32 %11, 0
br i1 %12, label %53, label %13
13: ; preds = %8
store i32 0, i32* %3
br label %14
14: ; preds = %25, %13
%15 = load i32, i32* %3
%16 = load i32, i32* %2
%17 = sdiv i32 %16, 2
%18 = icmp slt i32 %15, %17
br i1 %18, label %19, label %28
19: ; preds = %14
%20 = call i32 @black_line(i32 720)
store i32 %20, i32* %1
%21 = load i32, i32* %1
%22 = icmp ne i32 %21, 0
br i1 %22, label %23, label %24
23: ; preds = %19
br label %28
24: ; preds = %19
br label %25
25: ; preds = %24
%26 = load i32, i32* %3
%27 = add nsw i32 %26, 1
store i32 %27, i32* %3
br label %14
28: ; preds = %23, %14
%29 = load i32, i32* %1
%30 = icmp ne i32 %29, 0
br i1 %30, label %52, label %31
31: ; preds = %28
%32 = call i32 @FS460_image_set_begin_field(i32 0)
store i32 %32, i32* %1
%33 = load i32, i32* %1
%34 = icmp ne i32 %33, 0
br i1 %34, label %51, label %35
35: ; preds = %31
store i32 0, i32* %3
br label %36
36: ; preds = %47, %35
%37 = load i32, i32* %3
%38 = load i32, i32* %2
%39 = sdiv i32 %38, 2
%40 = icmp slt i32 %37, %39
br i1 %40, label %41, label %50
41: ; preds = %36
%42 = call i32 @black_line(i32 720)
store i32 %42, i32* %1
%43 = load i32, i32* %1
%44 = icmp ne i32 %43, 0
br i1 %44, label %45, label %46
45: ; preds = %41
br label %50
46: ; preds = %41
br label %47
47: ; preds = %46
%48 = load i32, i32* %3
%49 = add nsw i32 %48, 1
store i32 %49, i32* %3
br label %36
50: ; preds = %45, %36
br label %51
51: ; preds = %50, %31
br label %52
52: ; preds = %51, %28
br label %53
53: ; preds = %52, %8
br label %54
54: ; preds = %53, %0
%55 = load i32, i32* %1
ret i32 %55
}

LLVM IR (-O2):
define i32 @FS460_set_black_image() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = call i32 @FS460_get_tv_active_lines(i32* %1)
%4 = call i32 @FS460_image_request_freeze(i32 1, i32 1, i32 0)
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %37
6: ; preds = %0
%7 = call i32 @OS_mdelay(i32 40)
%8 = call i32 @FS460_image_set_begin_field(i32 1)
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %37
10: ; preds = %6
%11 = load i32, i32* %1
%12 = icmp sgt i32 %11, 1
br i1 %12, label %17, label %22
13: ; preds = %17
%14 = load i32, i32* %1
%15 = sdiv i32 %14, 2
%16 = icmp slt i32 %21, %15
br i1 %16, label %17, label %22
17: ; preds = %10, %13
%18 = phi i32 [ %21, %13 ], [ 0, %10 ]
%19 = call i32 @black_line(i32 720)
%20 = icmp eq i32 %19, 0
%21 = add nuw nsw i32 %18, 1
br i1 %20, label %13, label %37
22: ; preds = %13, %10
%23 = call i32 @FS460_image_set_begin_field(i32 0)
%24 = icmp eq i32 %23, 0
br i1 %24, label %25, label %37
25: ; preds = %22
%26 = load i32, i32* %1
%27 = icmp sgt i32 %26, 1
br i1 %27, label %32, label %37
28: ; preds = %32
%29 = load i32, i32* %1
%30 = sdiv i32 %29, 2
%31 = icmp slt i32 %36, %30
br i1 %31, label %32, label %37
32: ; preds = %25, %28
%33 = phi i32 [ %36, %28 ], [ 0, %25 ]
%34 = call i32 @black_line(i32 720)
%35 = icmp eq i32 %34, 0
%36 = add nuw nsw i32 %33, 1
br i1 %35, label %28, label %37
37: ; preds = %17, %28, %32, %25, %6, %22, %0
%38 = phi i32 [ %4, %0 ], [ %8, %6 ], [ %23, %22 ], [ 0, %25 ], [ 0, %28 ], [ %34, %32 ], [ %19, %17 ]
ret i32 %38
}