#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*/ drawpixel(int, int);
int /*<<< orphan*/ edgedetect(float, float, float, float, int *, int *);
void scanfil(float x1, float y1, float x2, float y2, float x3, float y3,
             float x4, float y4) {
  int le[500], re[500];
  int i, j;
  for (i = 0; i < 500; i++) {
    le[i] = 500;
    re[i] = 0;
  }
  edgedetect(x1, y1, x2, y2, le, re);
  edgedetect(x2, y2, x3, y3, le, re);
  edgedetect(x3, y3, x4, y4, le, re);
  edgedetect(x4, y4, x1, y1, le, re);
  for (i = 0; i < 500; i++)
    if (le[i] <= re[i])
      for (j = le[i]; j < re[i]; j++)
        drawpixel(i, j);
}


x86 assembly (clang, -O0):
<scanfil>:
push   %rbp
mov    %rsp,%rbp
sub    $0xfd0,%rsp
movss  %xmm0,-0x4(%rbp)
movss  %xmm1,-0x8(%rbp)
movss  %xmm2,-0xc(%rbp)
movss  %xmm3,-0x10(%rbp)
movss  %xmm4,-0x14(%rbp)
movss  %xmm5,-0x18(%rbp)
movss  %xmm6,-0x1c(%rbp)
movss  %xmm7,-0x20(%rbp)
movl   $0x0,-0xfc4(%rbp)
cmpl   $0x1f4,-0xfc4(%rbp)
jge    11a5 <scanfil+0x85>
movslq -0xfc4(%rbp),%rax
movl   $0x1f4,-0x7f0(%rbp,%rax,4)
movslq -0xfc4(%rbp),%rax
movl   $0x0,-0xfc0(%rbp,%rax,4)
mov    -0xfc4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xfc4(%rbp)
jmp    115d <scanfil+0x3d>
movss  -0x4(%rbp),%xmm0
movss  -0x8(%rbp),%xmm1
movss  -0xc(%rbp),%xmm2
movss  -0x10(%rbp),%xmm3
lea    -0x7f0(%rbp),%rdi
lea    -0xfc0(%rbp),%rsi
call   1040 <edgedetect@plt>
movss  -0xc(%rbp),%xmm0
movss  -0x10(%rbp),%xmm1
movss  -0x14(%rbp),%xmm2
movss  -0x18(%rbp),%xmm3
lea    -0x7f0(%rbp),%rdi
lea    -0xfc0(%rbp),%rsi
call   1040 <edgedetect@plt>
movss  -0x14(%rbp),%xmm0
movss  -0x18(%rbp),%xmm1
movss  -0x1c(%rbp),%xmm2
movss  -0x20(%rbp),%xmm3
lea    -0x7f0(%rbp),%rdi
lea    -0xfc0(%rbp),%rsi
call   1040 <edgedetect@plt>
movss  -0x1c(%rbp),%xmm0
movss  -0x20(%rbp),%xmm1
movss  -0x4(%rbp),%xmm2
movss  -0x8(%rbp),%xmm3
lea    -0x7f0(%rbp),%rdi
lea    -0xfc0(%rbp),%rsi
call   1040 <edgedetect@plt>
movl   $0x0,-0xfc4(%rbp)
cmpl   $0x1f4,-0xfc4(%rbp)
jge    12ee <scanfil+0x1ce>
movslq -0xfc4(%rbp),%rax
mov    -0x7f0(%rbp,%rax,4),%eax
movslq -0xfc4(%rbp),%rcx
cmp    -0xfc0(%rbp,%rcx,4),%eax
jg     12d5 <scanfil+0x1b5>
movslq -0xfc4(%rbp),%rax
mov    -0x7f0(%rbp,%rax,4),%eax
mov    %eax,-0xfc8(%rbp)
mov    -0xfc8(%rbp),%eax
movslq -0xfc4(%rbp),%rcx
cmp    -0xfc0(%rbp,%rcx,4),%eax
jge    12d0 <scanfil+0x1b0>
mov    -0xfc4(%rbp),%edi
mov    -0xfc8(%rbp),%esi
call   1030 <drawpixel@plt>
mov    -0xfc8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xfc8(%rbp)
jmp    1291 <scanfil+0x171>
jmp    12d5 <scanfil+0x1b5>
jmp    12da <scanfil+0x1ba>
mov    -0xfc4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xfc4(%rbp)
jmp    124b <scanfil+0x12b>
add    $0xfd0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<scanfil>:
push   %rbp
push   %r14
push   %rbx
sub    $0xfc0,%rsp
movss  %xmm7,0x1c(%rsp)
movss  %xmm6,0x18(%rsp)
movss  %xmm5,0xc(%rsp)
movss  %xmm4,0x8(%rsp)
movss  %xmm3,0x4(%rsp)
movss  %xmm2,(%rsp)
movss  %xmm1,0x14(%rsp)
movss  %xmm0,0x10(%rsp)
lea    0x7f0(%rsp),%rdi
mov    $0x7d0,%edx
xor    %esi,%esi
call   1030 <memset@plt>
mov    $0xc,%eax
movaps 0xe76(%rip),%xmm0
nopw   0x0(%rax,%rax,1)
movaps %xmm0,-0x10(%rsp,%rax,4)
movaps %xmm0,(%rsp,%rax,4)
movaps %xmm0,0x10(%rsp,%rax,4)
movaps %xmm0,0x20(%rsp,%rax,4)
add    $0x10,%rax
cmp    $0x1fc,%rax
jne    1190 <scanfil+0x60>
movaps %xmm0,0x7e0(%rsp)
lea    0x20(%rsp),%rbx
lea    0x7f0(%rsp),%r14
movss  0x10(%rsp),%xmm0
movss  0x14(%rsp),%xmm1
movss  (%rsp),%xmm2
movss  0x4(%rsp),%xmm3
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <edgedetect@plt>
movss  (%rsp),%xmm0
movss  0x4(%rsp),%xmm1
movss  0x8(%rsp),%xmm2
movss  0xc(%rsp),%xmm3
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <edgedetect@plt>
movss  0x8(%rsp),%xmm0
movss  0xc(%rsp),%xmm1
movss  0x18(%rsp),%xmm2
movss  0x1c(%rsp),%xmm3
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <edgedetect@plt>
movss  0x18(%rsp),%xmm0
movss  0x1c(%rsp),%xmm1
movss  0x10(%rsp),%xmm2
movss  0x14(%rsp),%xmm3
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <edgedetect@plt>
xor    %ebx,%ebx
jmp    126d <scanfil+0x13d>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x1,%rbx
cmp    $0x1f4,%rbx
je     1297 <scanfil+0x167>
mov    0x20(%rsp,%rbx,4),%ebp
cmp    0x7f0(%rsp,%rbx,4),%ebp
jge    1260 <scanfil+0x130>
nopw   0x0(%rax,%rax,1)
mov    %ebx,%edi
mov    %ebp,%esi
call   1040 <drawpixel@plt>
add    $0x1,%ebp
cmp    0x7f0(%rsp,%rbx,4),%ebp
jl     1280 <scanfil+0x150>
jmp    1260 <scanfil+0x130>
add    $0xfc0,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define void @scanfil(float %0, float %1, float %2, float %3, float %4, float %5, float %6, float %7) {
%9 = alloca float
%10 = alloca float
%11 = alloca float
%12 = alloca float
%13 = alloca float
%14 = alloca float
%15 = alloca float
%16 = alloca float
%17 = alloca [500 x i32]
%18 = alloca [500 x i32]
%19 = alloca i32
%20 = alloca i32
store float %0, float* %9
store float %1, float* %10
store float %2, float* %11
store float %3, float* %12
store float %4, float* %13
store float %5, float* %14
store float %6, float* %15
store float %7, float* %16
store i32 0, i32* %19
br label %21
21: ; preds = %31, %8
%22 = load i32, i32* %19
%23 = icmp slt i32 %22, 500
br i1 %23, label %24, label %34
24: ; preds = %21
%25 = load i32, i32* %19
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [500 x i32], [500 x i32]* %17, i64 0, i64 %26
store i32 500, i32* %27
%28 = load i32, i32* %19
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [500 x i32], [500 x i32]* %18, i64 0, i64 %29
store i32 0, i32* %30
br label %31
31: ; preds = %24
%32 = load i32, i32* %19
%33 = add nsw i32 %32, 1
store i32 %33, i32* %19
br label %21
34: ; preds = %21
%35 = load float, float* %9
%36 = load float, float* %10
%37 = load float, float* %11
%38 = load float, float* %12
%39 = getelementptr inbounds [500 x i32], [500 x i32]* %17, i64 0, i64 0
%40 = getelementptr inbounds [500 x i32], [500 x i32]* %18, i64 0, i64 0
%41 = call i32 @edgedetect(float %35, float %36, float %37, float %38, i32* %39, i32* %40)
%42 = load float, float* %11
%43 = load float, float* %12
%44 = load float, float* %13
%45 = load float, float* %14
%46 = getelementptr inbounds [500 x i32], [500 x i32]* %17, i64 0, i64 0
%47 = getelementptr inbounds [500 x i32], [500 x i32]* %18, i64 0, i64 0
%48 = call i32 @edgedetect(float %42, float %43, float %44, float %45, i32* %46, i32* %47)
%49 = load float, float* %13
%50 = load float, float* %14
%51 = load float, float* %15
%52 = load float, float* %16
%53 = getelementptr inbounds [500 x i32], [500 x i32]* %17, i64 0, i64 0
%54 = getelementptr inbounds [500 x i32], [500 x i32]* %18, i64 0, i64 0
%55 = call i32 @edgedetect(float %49, float %50, float %51, float %52, i32* %53, i32* %54)
%56 = load float, float* %15
%57 = load float, float* %16
%58 = load float, float* %9
%59 = load float, float* %10
%60 = getelementptr inbounds [500 x i32], [500 x i32]* %17, i64 0, i64 0
%61 = getelementptr inbounds [500 x i32], [500 x i32]* %18, i64 0, i64 0
%62 = call i32 @edgedetect(float %56, float %57, float %58, float %59, i32* %60, i32* %61)
store i32 0, i32* %19
br label %63
63: ; preds = %97, %34
%64 = load i32, i32* %19
%65 = icmp slt i32 %64, 500
br i1 %65, label %66, label %100
66: ; preds = %63
%67 = load i32, i32* %19
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds [500 x i32], [500 x i32]* %17, i64 0, i64 %68
%70 = load i32, i32* %69
%71 = load i32, i32* %19
%72 = sext i32 %71 to i64
%73 = getelementptr inbounds [500 x i32], [500 x i32]* %18, i64 0, i64 %72
%74 = load i32, i32* %73
%75 = icmp sle i32 %70, %74
br i1 %75, label %76, label %96
76: ; preds = %66
%77 = load i32, i32* %19
%78 = sext i32 %77 to i64
%79 = getelementptr inbounds [500 x i32], [500 x i32]* %17, i64 0, i64 %78
%80 = load i32, i32* %79
store i32 %80, i32* %20
br label %81
81: ; preds = %92, %76
%82 = load i32, i32* %20
%83 = load i32, i32* %19
%84 = sext i32 %83 to i64
%85 = getelementptr inbounds [500 x i32], [500 x i32]* %18, i64 0, i64 %84
%86 = load i32, i32* %85
%87 = icmp slt i32 %82, %86
br i1 %87, label %88, label %95
88: ; preds = %81
%89 = load i32, i32* %19
%90 = load i32, i32* %20
%91 = call i32 @drawpixel(i32 %89, i32 %90)
br label %92
92: ; preds = %88
%93 = load i32, i32* %20
%94 = add nsw i32 %93, 1
store i32 %94, i32* %20
br label %81
95: ; preds = %81
br label %96
96: ; preds = %95, %66
br label %97
97: ; preds = %96
%98 = load i32, i32* %19
%99 = add nsw i32 %98, 1
store i32 %99, i32* %19
br label %63
100: ; preds = %63
ret void
}

LLVM IR (-O2):
define void @scanfil(float %0, float %1, float %2, float %3, float %4, float %5, float %6, float %7) {
%9 = alloca [500 x i32]
%10 = alloca [500 x i32]
%11 = bitcast [500 x i32]* %10 to i8*
%12 = bitcast [500 x i32]* %9 to i8*
br label %13
13: ; preds = %13, %8
%14 = phi i64 [ 0, %8 ], [ %24, %13 ]
%15 = getelementptr inbounds [500 x i32], [500 x i32]* %9, i64 0, i64 %14
%16 = bitcast i32* %15 to <4 x i32>*
store <4 x i32> <i32 500, i32 500, i32 500, i32 500>, <4 x i32>* %16
%17 = getelementptr inbounds i32, i32* %15, i64 4
%18 = bitcast i32* %17 to <4 x i32>*
store <4 x i32> <i32 500, i32 500, i32 500, i32 500>, <4 x i32>* %18
%19 = or i64 %14, 8
%20 = getelementptr inbounds [500 x i32], [500 x i32]* %9, i64 0, i64 %19
%21 = bitcast i32* %20 to <4 x i32>*
store <4 x i32> <i32 500, i32 500, i32 500, i32 500>, <4 x i32>* %21
%22 = getelementptr inbounds i32, i32* %20, i64 4
%23 = bitcast i32* %22 to <4 x i32>*
store <4 x i32> <i32 500, i32 500, i32 500, i32 500>, <4 x i32>* %23
%24 = add nuw nsw i64 %14, 16
%25 = icmp eq i64 %24, 496
br i1 %25, label %26, label %13
26: ; preds = %13
%27 = getelementptr inbounds [500 x i32], [500 x i32]* %9, i64 0, i64 496
store i32 500, i32* %27
%28 = getelementptr inbounds [500 x i32], [500 x i32]* %9, i64 0, i64 497
store i32 500, i32* %28
%29 = getelementptr inbounds [500 x i32], [500 x i32]* %9, i64 0, i64 498
store i32 500, i32* %29
%30 = getelementptr inbounds [500 x i32], [500 x i32]* %9, i64 0, i64 499
store i32 500, i32* %30
%31 = getelementptr inbounds [500 x i32], [500 x i32]* %9, i64 0, i64 0
%32 = getelementptr inbounds [500 x i32], [500 x i32]* %10, i64 0, i64 0
%33 = call i32 @edgedetect(float %0, float %1, float %2, float %3, i32* %31, i32* %32)
%34 = call i32 @edgedetect(float %2, float %3, float %4, float %5, i32* %31, i32* %32)
%35 = call i32 @edgedetect(float %4, float %5, float %6, float %7, i32* %31, i32* %32)
%36 = call i32 @edgedetect(float %6, float %7, float %0, float %1, i32* %31, i32* %32)
br label %37
37: ; preds = %26, %52
%38 = phi i64 [ 0, %26 ], [ %53, %52 ]
%39 = getelementptr inbounds [500 x i32], [500 x i32]* %9, i64 0, i64 %38
%40 = load i32, i32* %39
%41 = getelementptr inbounds [500 x i32], [500 x i32]* %10, i64 0, i64 %38
%42 = load i32, i32* %41
%43 = icmp slt i32 %40, %42
br i1 %43, label %44, label %52
44: ; preds = %37
%45 = trunc i64 %38 to i32
br label %46
46: ; preds = %44, %46
%47 = phi i32 [ %49, %46 ], [ %40, %44 ]
%48 = call i32 @drawpixel(i32 %45, i32 %47)
%49 = add nsw i32 %47, 1
%50 = load i32, i32* %41
%51 = icmp slt i32 %49, %50
br i1 %51, label %46, label %52
52: ; preds = %46, %37
%53 = add nuw nsw i64 %38, 1
%54 = icmp eq i64 %53, 500
br i1 %54, label %55, label %37
55: ; preds = %52
ret void
}