#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 FS460_image_is_transfer_completed(int *);
int FS460_image_set_start_write(unsigned char *, int);
int black_line(int scaler_width) {
  int err;
  int completed;
  unsigned char line_yuv[720 * 2];
  int i;
  for (i = 0; i < scaler_width * 2; i += 2) {
    line_yuv[i] = 0x80;
    line_yuv[i + 1] = 0x10;
  }
  err = FS460_image_set_start_write(line_yuv, scaler_width * 2);
  if (!err) {
    completed = 0;
    while (!completed && !err)
      err = FS460_image_is_transfer_completed(&completed);
  }
  return err;
}


x86 assembly (clang, -O0):
<black_line>:
push   %rbp
mov    %rsp,%rbp
sub    $0x5c0,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x5b4(%rbp)
mov    -0x5b4(%rbp),%eax
mov    -0x4(%rbp),%ecx
shl    $0x1,%ecx
cmp    %ecx,%eax
jge    1182 <black_line+0x62>
movslq -0x5b4(%rbp),%rax
movb   $0x80,-0x5b0(%rbp,%rax,1)
80
mov    -0x5b4(%rbp),%eax
add    $0x1,%eax
cltq
movb   $0x10,-0x5b0(%rbp,%rax,1)
10
mov    -0x5b4(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x5b4(%rbp)
jmp    1138 <black_line+0x18>
lea    -0x5b0(%rbp),%rdi
mov    -0x4(%rbp),%esi
shl    $0x1,%esi
call   1030 <FS460_image_set_start_write@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    11f2 <black_line+0xd2>
movl   $0x0,-0xc(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0xc(%rbp)
mov    %al,-0x5b5(%rbp)
jne    11c9 <black_line+0xa9>
cmpl   $0x0,-0x8(%rbp)
setne  %al
xor    $0xff,%al
mov    %al,-0x5b5(%rbp)
mov    -0x5b5(%rbp),%al
test   $0x1,%al
jne    11dc <black_line+0xbc>
jmp    11ed <black_line+0xcd>
lea    -0xc(%rbp),%rdi
call   1040 <FS460_image_is_transfer_completed@plt>
mov    %eax,-0x8(%rbp)
jmp    11a8 <black_line+0x88>
jmp    11f2 <black_line+0xd2>
mov    -0x8(%rbp),%eax
add    $0x5c0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<black_line>:
push   %rbx
sub    $0x5b0,%rsp
lea    (%rdi,%rdi,1),%esi
test   %edi,%edi
jle    1230 <black_line+0x110>
movslq %esi,%rax
cmp    $0x3,%rax
mov    $0x2,%r8d
cmovge %rax,%r8
add    $0xffffffffffffffff,%r8
cmp    $0x1e,%r8
jae    1155 <black_line+0x35>
xor    %ecx,%ecx
jmp    1220 <black_line+0x100>
shr    %r8
add    $0x1,%r8
movabs $0x7ffffffffffffff0,%rcx
ff ff 7f
and    %r8,%rcx
lea    -0x10(%rcx),%rbx
mov    %rbx,%rdi
shr    $0x4,%rdi
add    $0x1,%rdi
mov    %edi,%edx
and    $0x3,%edx
cmp    $0x30,%rbx
jae    1187 <black_line+0x67>
xor    %ebx,%ebx
jmp    11d5 <black_line+0xb5>
and    $0xfffffffffffffffc,%rdi
xor    %ebx,%ebx
movaps 0xe6c(%rip),%xmm0
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movaps %xmm0,0x10(%rsp,%rbx,2)
movaps %xmm0,0x20(%rsp,%rbx,2)
movaps %xmm0,0x30(%rsp,%rbx,2)
movaps %xmm0,0x40(%rsp,%rbx,2)
movaps %xmm0,0x50(%rsp,%rbx,2)
movaps %xmm0,0x60(%rsp,%rbx,2)
movaps %xmm0,0x70(%rsp,%rbx,2)
movaps %xmm0,0x80(%rsp,%rbx,2)
add    $0x40,%rbx
add    $0xfffffffffffffffc,%rdi
jne    11a0 <black_line+0x80>
test   %rdx,%rdx
je     120b <black_line+0xeb>
add    %rbx,%rbx
movaps 0xe1c(%rip),%xmm0
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %rbx,%rdi
or     $0x11,%rdi
movaps %xmm0,0x10(%rsp,%rbx,1)
movaps %xmm0,0xf(%rsp,%rdi,1)
add    $0x20,%rbx
add    $0xffffffffffffffff,%rdx
jne    11f0 <black_line+0xd0>
cmp    %rcx,%r8
je     1230 <black_line+0x110>
add    %rcx,%rcx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movw   $0x1080,0x10(%rsp,%rcx,1)
add    $0x2,%rcx
cmp    %rax,%rcx
jl     1220 <black_line+0x100>
lea    0x10(%rsp),%rdi
call   1030 <FS460_image_set_start_write@plt>
test   %eax,%eax
jne    1260 <black_line+0x140>
movl   $0x0,0xc(%rsp)
lea    0xc(%rsp),%rbx
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1040 <FS460_image_is_transfer_completed@plt>
mov    0xc(%rsp),%ecx
or     %eax,%ecx
je     1250 <black_line+0x130>
add    $0x5b0,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define i32 @black_line(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca [1440 x i8]
%6 = alloca i32
store i32 %0, i32* %2
store i32 0, i32* %6
br label %7
7: ; preds = %20, %1
%8 = load i32, i32* %6
%9 = load i32, i32* %2
%10 = mul nsw i32 %9, 2
%11 = icmp slt i32 %8, %10
br i1 %11, label %12, label %23
12: ; preds = %7
%13 = load i32, i32* %6
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds [1440 x i8], [1440 x i8]* %5, i64 0, i64 %14
store i8 -128, i8* %15
%16 = load i32, i32* %6
%17 = add nsw i32 %16, 1
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [1440 x i8], [1440 x i8]* %5, i64 0, i64 %18
store i8 16, i8* %19
br label %20
20: ; preds = %12
%21 = load i32, i32* %6
%22 = add nsw i32 %21, 2
store i32 %22, i32* %6
br label %7
23: ; preds = %7
%24 = getelementptr inbounds [1440 x i8], [1440 x i8]* %5, i64 0, i64 0
%25 = load i32, i32* %2
%26 = mul nsw i32 %25, 2
%27 = call i32 @FS460_image_set_start_write(i8* %24, i32 %26)
store i32 %27, i32* %3
%28 = load i32, i32* %3
%29 = icmp ne i32 %28, 0
br i1 %29, label %43, label %30
30: ; preds = %23
store i32 0, i32* %4
br label %31
31: ; preds = %40, %30
%32 = load i32, i32* %4
%33 = icmp ne i32 %32, 0
br i1 %33, label %38, label %34
34: ; preds = %31
%35 = load i32, i32* %3
%36 = icmp ne i32 %35, 0
%37 = xor i1 %36, true
br label %38
38: ; preds = %34, %31
%39 = phi i1 [ false, %31 ], [ %37, %34 ]
br i1 %39, label %40, label %42
40: ; preds = %38
%41 = call i32 @FS460_image_is_transfer_completed(i32* %4)
store i32 %41, i32* %3
br label %31
42: ; preds = %38
br label %43
43: ; preds = %42, %23
%44 = load i32, i32* %3
ret i32 %44
}

LLVM IR (-O2):
define i32 @black_line(i32 %0) {
%2 = alloca i32
%3 = alloca [1440 x i8]
%4 = bitcast i32* %2 to i8*
%5 = getelementptr inbounds [1440 x i8], [1440 x i8]* %3, i64 0, i64 0
%6 = shl nsw i32 %0, 1
%7 = icmp sgt i32 %0, 0
br i1 %7, label %8, label %96
8: ; preds = %1
%9 = sext i32 %6 to i64
%10 = call i64 @llvm.smax.i64(i64 %9, i64 2)
%11 = add nsw i64 %10, -1
%12 = lshr i64 %11, 1
%13 = add nuw nsw i64 %12, 1
%14 = icmp ult i64 %11, 30
br i1 %14, label %87, label %15
15: ; preds = %8
%16 = and i64 %13, 9223372036854775792
%17 = shl nuw i64 %16, 1
%18 = add nsw i64 %16, -16
%19 = lshr exact i64 %18, 4
%20 = add nuw nsw i64 %19, 1
%21 = and i64 %20, 3
%22 = icmp ult i64 %18, 48
br i1 %22, label %67, label %23
23: ; preds = %15
%24 = and i64 %20, 2305843009213693948
br label %25
25: ; preds = %25, %23
%26 = phi i64 [ 0, %23 ], [ %64, %25 ]
%27 = phi i64 [ 0, %23 ], [ %65, %25 ]
%28 = shl i64 %26, 1
%29 = or i64 %28, 1
%30 = or i64 %28, 17
%31 = getelementptr inbounds [1440 x i8], [1440 x i8]* %3, i64 0, i64 %29
%32 = getelementptr inbounds [1440 x i8], [1440 x i8]* %3, i64 0, i64 %30
%33 = getelementptr inbounds i8, i8* %31, i64 -1
%34 = bitcast i8* %33 to <16 x i8>*
%35 = getelementptr inbounds i8, i8* %32, i64 -1
%36 = bitcast i8* %35 to <16 x i8>*
store <16 x i8> <i8 -128, i8 16, i8 -128, i8 16, i8 -128, i8 16, i8 -128, i8 16, i8 -128, i8 16, i8 -128, i8 16, i8 -128, i8 16, i8 -128, i8 16>, <16 x i8>* %34
store <16 x i8> <i8 -128, i8 16, i8 -128, i8 16, i8 -128, i8 16, i8 -128, i8 16, i8 -128, i8 16, i8 -128, i8 16, i8 -128, i8 16, i8 -128, i8 16>, <16 x i8>* %36
%37 = shl i64 %26, 1
%38 = or i64 %37, 33
%39 = or i64 %37, 49
%40 = getelementptr inbounds [1440 x i8], [1440 x i8]* %3, i64 0, i64 %38
%41 = getelementptr inbounds [1440 x i8], [1440 x i8]* %3, i64 0, i64 %39
%42 = getelementptr inbounds i8, i8* %40, i64 -1
%43 = bitcast i8* %42 to <16 x i8>*
%44 = getelementptr inbounds i8, i8* %41, i64 -1
%45 = bitcast i8* %44 to <16 x i8>*
store <16 x i8> <i8 -128, i8 16, i8 -128, i8 16, i8 -128, i8 16, i8 -128, i8 16, i8 -128, i8 16, i8 -128, i8 16, i8 -128, i8 16, i8 -128, i8 16>, <16 x i8>* %43
store <16 x i8> <i8 -128, i8 16, i8 -128, i8 16, i8 -128, i8 16, i8 -128, i8 16, i8 -128, i8 16, i8 -128, i8 16, i8 -128, i8 16, i8 -128, i8 16>, <16 x i8>* %45
%46 = shl i64 %26, 1
%47 = or i64 %46, 65
%48 = or i64 %46, 81
%49 = getelementptr inbounds [1440 x i8], [1440 x i8]* %3, i64 0, i64 %47
%50 = getelementptr inbounds [1440 x i8], [1440 x i8]* %3, i64 0, i64 %48
%51 = getelementptr inbounds i8, i8* %49, i64 -1
%52 = bitcast i8* %51 to <16 x i8>*
%53 = getelementptr inbounds i8, i8* %50, i64 -1
%54 = bitcast i8* %53 to <16 x i8>*
store <16 x i8> <i8 -128, i8 16, i8 -128, i8 16, i8 -128, i8 16, i8 -128, i8 16, i8 -128, i8 16, i8 -128, i8 16, i8 -128, i8 16, i8 -128, i8 16>, <16 x i8>* %52
store <16 x i8> <i8 -128, i8 16, i8 -128, i8 16, i8 -128, i8 16, i8 -128, i8 16, i8 -128, i8 16, i8 -128, i8 16, i8 -128, i8 16, i8 -128, i8 16>, <16 x i8>* %54
%55 = shl i64 %26, 1
%56 = or i64 %55, 97
%57 = or i64 %55, 113
%58 = getelementptr inbounds [1440 x i8], [1440 x i8]* %3, i64 0, i64 %56
%59 = getelementptr inbounds [1440 x i8], [1440 x i8]* %3, i64 0, i64 %57
%60 = getelementptr inbounds i8, i8* %58, i64 -1
%61 = bitcast i8* %60 to <16 x i8>*
%62 = getelementptr inbounds i8, i8* %59, i64 -1
%63 = bitcast i8* %62 to <16 x i8>*
store <16 x i8> <i8 -128, i8 16, i8 -128, i8 16, i8 -128, i8 16, i8 -128, i8 16, i8 -128, i8 16, i8 -128, i8 16, i8 -128, i8 16, i8 -128, i8 16>, <16 x i8>* %61
store <16 x i8> <i8 -128, i8 16, i8 -128, i8 16, i8 -128, i8 16, i8 -128, i8 16, i8 -128, i8 16, i8 -128, i8 16, i8 -128, i8 16, i8 -128, i8 16>, <16 x i8>* %63
%64 = add nuw i64 %26, 64
%65 = add i64 %27, 4
%66 = icmp eq i64 %65, %24
br i1 %66, label %67, label %25
67: ; preds = %25, %15
%68 = phi i64 [ 0, %15 ], [ %64, %25 ]
%69 = icmp eq i64 %21, 0
br i1 %69, label %85, label %70
70: ; preds = %67, %70
%71 = phi i64 [ %82, %70 ], [ %68, %67 ]
%72 = phi i64 [ %83, %70 ], [ 0, %67 ]
%73 = shl i64 %71, 1
%74 = or i64 %73, 1
%75 = or i64 %73, 17
%76 = getelementptr inbounds [1440 x i8], [1440 x i8]* %3, i64 0, i64 %74
%77 = getelementptr inbounds [1440 x i8], [1440 x i8]* %3, i64 0, i64 %75
%78 = getelementptr inbounds i8, i8* %76, i64 -1
%79 = bitcast i8* %78 to <16 x i8>*
%80 = getelementptr inbounds i8, i8* %77, i64 -1
%81 = bitcast i8* %80 to <16 x i8>*
store <16 x i8> <i8 -128, i8 16, i8 -128, i8 16, i8 -128, i8 16, i8 -128, i8 16, i8 -128, i8 16, i8 -128, i8 16, i8 -128, i8 16, i8 -128, i8 16>, <16 x i8>* %79
store <16 x i8> <i8 -128, i8 16, i8 -128, i8 16, i8 -128, i8 16, i8 -128, i8 16, i8 -128, i8 16, i8 -128, i8 16, i8 -128, i8 16, i8 -128, i8 16>, <16 x i8>* %81
%82 = add nuw i64 %71, 16
%83 = add i64 %72, 1
%84 = icmp eq i64 %83, %21
br i1 %84, label %85, label %70
85: ; preds = %70, %67
%86 = icmp eq i64 %13, %16
br i1 %86, label %96, label %87
87: ; preds = %8, %85
%88 = phi i64 [ 0, %8 ], [ %17, %85 ]
br label %89
89: ; preds = %87, %89
%90 = phi i64 [ %94, %89 ], [ %88, %87 ]
%91 = getelementptr inbounds [1440 x i8], [1440 x i8]* %3, i64 0, i64 %90
store i8 -128, i8* %91
%92 = or i64 %90, 1
%93 = getelementptr inbounds [1440 x i8], [1440 x i8]* %3, i64 0, i64 %92
store i8 16, i8* %93
%94 = add nuw nsw i64 %90, 2
%95 = icmp slt i64 %94, %9
br i1 %95, label %89, label %96
96: ; preds = %89, %85, %1
%97 = call i32 @FS460_image_set_start_write(i8* %5, i32 %6)
%98 = icmp eq i32 %97, 0
br i1 %98, label %99, label %106
99: ; preds = %96
store i32 0, i32* %2
br label %100
100: ; preds = %99, %100
%101 = call i32 @FS460_image_is_transfer_completed(i32* %2)
%102 = load i32, i32* %2
%103 = icmp eq i32 %102, 0
%104 = icmp eq i32 %101, 0
%105 = select i1 %103, i1 %104, i1 false
br i1 %105, label %100, label %106
106: ; preds = %100, %96
%107 = phi i32 [ %97, %96 ], [ %101, %100 ]
ret i32 %107
}