#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*/ graph_line(int, int, int, int, unsigned char, unsigned char,
                              unsigned char, unsigned char *, unsigned int,
                              unsigned int);
void graph_polygon(int *points, unsigned int no_of_points, unsigned char r,
                   unsigned char g, unsigned char b, unsigned char *img,
                   unsigned int img_width, unsigned int img_height) {
  int i;
  for (i = 1; i < no_of_points; i++) {
    graph_line(points[(i - 1) * 2], points[(i - 1) * 2 + 1], points[i * 2],
               points[i * 2 + 1], r, g, b, img, img_width, img_height);
  }
  graph_line(points[(i - 1) * 2], points[(i - 1) * 2 + 1], points[0], points[1],
             r, g, b, img, img_width, img_height);
}


x86 assembly (clang, -O0):
<graph_polygon>:
push   %rbp
mov    %rsp,%rbp
push   %rbx
sub    $0x48,%rsp
mov    %r8b,%al
mov    0x18(%rbp),%r8d
mov    0x10(%rbp),%r8d
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %dl,-0x15(%rbp)
mov    %cl,-0x16(%rbp)
mov    %al,-0x17(%rbp)
mov    %r9,-0x20(%rbp)
movl   $0x1,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x14(%rbp),%eax
jae    11dc <graph_polygon+0xcc>
mov    -0x10(%rbp),%rax
mov    -0x24(%rbp),%ecx
sub    $0x1,%ecx
shl    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%edi
mov    -0x10(%rbp),%rax
mov    -0x24(%rbp),%ecx
sub    $0x1,%ecx
shl    $0x1,%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%esi
mov    -0x10(%rbp),%rax
mov    -0x24(%rbp),%ecx
shl    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%edx
mov    -0x10(%rbp),%rax
mov    -0x24(%rbp),%ecx
shl    $0x1,%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%ecx
mov    -0x15(%rbp),%r8b
mov    -0x16(%rbp),%r9b
mov    -0x17(%rbp),%bl
mov    -0x20(%rbp),%r11
mov    0x10(%rbp),%r10d
mov    0x18(%rbp),%eax
movzbl %r8b,%r8d
movzbl %r9b,%r9d
movzbl %bl,%ebx
mov    %ebx,(%rsp)
mov    %r11,0x8(%rsp)
mov    %r10d,0x10(%rsp)
mov    %eax,0x18(%rsp)
call   1030 <graph_line@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    113f <graph_polygon+0x2f>
mov    -0x10(%rbp),%rax
mov    -0x24(%rbp),%ecx
sub    $0x1,%ecx
shl    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%edi
mov    -0x10(%rbp),%rax
mov    -0x24(%rbp),%ecx
sub    $0x1,%ecx
shl    $0x1,%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%esi
mov    -0x10(%rbp),%rax
mov    (%rax),%edx
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%ecx
mov    -0x15(%rbp),%r8b
mov    -0x16(%rbp),%r9b
mov    -0x17(%rbp),%bl
mov    -0x20(%rbp),%r11
mov    0x10(%rbp),%r10d
mov    0x18(%rbp),%eax
movzbl %r8b,%r8d
movzbl %r9b,%r9d
movzbl %bl,%ebx
mov    %ebx,(%rsp)
mov    %r11,0x8(%rsp)
mov    %r10d,0x10(%rsp)
mov    %eax,0x18(%rsp)
call   1030 <graph_line@plt>
add    $0x48,%rsp
pop    %rbx
pop    %rbp
ret

x86 assembly (clang, -O2):
<graph_polygon>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %r9,%r15
mov    0x68(%rsp),%r11d
mov    0x60(%rsp),%r12d
mov    $0x2,%eax
movzbl %r8b,%ebx
movzbl %dl,%r8d
movzbl %cl,%r9d
cmp    $0x2,%esi
jb     11e8 <graph_polygon+0xd8>
mov    %esi,0x10(%rsp)
mov    %esi,%eax
add    $0xffffffffffffffff,%rax
mov    %rax,0x18(%rsp)
xor    %r14d,%r14d
xor    %r13d,%r13d
mov    %rdi,0x20(%rsp)
mov    %r8d,0xc(%rsp)
mov    %r9d,0x14(%rsp)
nopl   0x0(%rax)
mov    %r13,%rax
sar    $0x1e,%rax
mov    (%rdi,%rax,1),%ebp
movabs $0x100000000,%rax
add    %r13,%rax
sar    $0x1e,%rax
mov    (%rdi,%rax,1),%esi
mov    0x8(%rdi,%r14,8),%edx
mov    0xc(%rdi,%r14,8),%ecx
mov    %ebp,%edi
mov    0xc(%rsp),%r8d
push   %r11
push   %r12
push   %r15
push   %rbx
mov    %r15,%rbp
mov    %r11,%r15
call   1030 <graph_line@plt>
mov    0x2c(%rsp),%r8d
mov    0x40(%rsp),%rdi
mov    %r15,%r11
mov    0x34(%rsp),%r9d
mov    %rbp,%r15
add    $0x20,%rsp
movabs $0x200000000,%rax
add    %rax,%r13
add    $0x1,%r14
cmp    %r14,0x18(%rsp)
jne    1170 <graph_polygon+0x60>
mov    0x10(%rsp),%eax
add    %eax,%eax
lea    -0x2(%rax),%ecx
movslq %ecx,%rcx
mov    (%rdi,%rcx,4),%ebp
add    $0xffffffff,%eax
cltq
mov    (%rdi,%rax,4),%esi
mov    (%rdi),%edx
mov    0x4(%rdi),%ecx
mov    %ebp,%edi
push   %r11
push   %r12
push   %r15
push   %rbx
call   1030 <graph_line@plt>
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @graph_polygon(i32* nocapture %0, i32 %1, i8 zeroext %2, i8 zeroext %3, i8 zeroext %4, i8* %5, i32 %6, i32 %7) {
%9 = icmp ugt i32 %1, 1
br i1 %9, label %10, label %35
10: ; preds = %8
%11 = zext i32 %1 to i64
br label %12
12: ; preds = %10, %12
%13 = phi i64 [ 1, %10 ], [ %31, %12 ]
%14 = shl nuw i64 %13, 1
%15 = shl i64 %13, 33
%16 = add i64 %15, -8589934592
%17 = ashr exact i64 %16, 32
%18 = getelementptr inbounds i32, i32* %0, i64 %17
%19 = load i32, i32* %18
%20 = shl i64 %13, 33
%21 = add i64 %20, -4294967296
%22 = ashr exact i64 %21, 32
%23 = getelementptr inbounds i32, i32* %0, i64 %22
%24 = load i32, i32* %23
%25 = getelementptr inbounds i32, i32* %0, i64 %14
%26 = load i32, i32* %25
%27 = or i64 %14, 1
%28 = getelementptr inbounds i32, i32* %0, i64 %27
%29 = load i32, i32* %28
%30 = tail call i32 @graph_line(i32 %19, i32 %24, i32 %26, i32 %29, i8 zeroext %2, i8 zeroext %3, i8 zeroext %4, i8* %5, i32 %6, i32 %7)
%31 = add nuw nsw i64 %13, 1
%32 = icmp eq i64 %31, %11
br i1 %32, label %33, label %12
33: ; preds = %12
%34 = shl i32 %1, 1
br label %35
35: ; preds = %33, %8
%36 = phi i32 [ 2, %8 ], [ %34, %33 ]
%37 = add i32 %36, -2
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i32, i32* %0, i64 %38
%40 = load i32, i32* %39
%41 = add i32 %36, -1
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i32, i32* %0, i64 %42
%44 = load i32, i32* %43
%45 = load i32, i32* %0
%46 = getelementptr inbounds i32, i32* %0, i64 1
%47 = load i32, i32* %46
%48 = tail call i32 @graph_line(i32 %40, i32 %44, i32 %45, i32 %47, i8 zeroext %2, i8 zeroext %3, i8 zeroext %4, i8* %5, i32 %6, i32 %7)
ret void
}