#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 */
typedef int /*<<< orphan*/ Window;
typedef int /*<<< orphan*/ GC;
typedef int /*<<< orphan*/ Display;

/* Variables and functions */
int /*<<< orphan*/ XDrawLine(int /*<<< orphan*/ *, int /*<<< orphan*/,
                             int /*<<< orphan*/, int, int, int, int);
void XDrawPoly(Display *display, Window window, GC gc, int *xverts, int *yverts,
               int nvert) {
  int i;
  for (i = 1; i < nvert; i++)
    XDrawLine(display, window, gc, xverts[i - 1], yverts[i - 1], xverts[i],
              yverts[i]);
  XDrawLine(display, window, gc, xverts[nvert - 1], yverts[nvert - 1],
            xverts[0], yverts[0]);
  return;
}


x86 assembly (clang, -O0):
<XDrawPoly>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
mov    %r9d,-0x24(%rbp)
movl   $0x1,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    119c <XDrawPoly+0x8c>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x18(%rbp),%rax
mov    -0x28(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%ecx
mov    -0x20(%rbp),%rax
mov    -0x28(%rbp),%r8d
sub    $0x1,%r8d
movslq %r8d,%r8
mov    (%rax,%r8,4),%r8d
mov    -0x18(%rbp),%rax
movslq -0x28(%rbp),%r9
mov    (%rax,%r9,4),%r9d
mov    -0x20(%rbp),%rax
movslq -0x28(%rbp),%r10
mov    (%rax,%r10,4),%eax
mov    %eax,(%rsp)
call   1030 <XDrawLine@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1135 <XDrawPoly+0x25>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x18(%rbp),%rax
mov    -0x24(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%ecx
mov    -0x20(%rbp),%rax
mov    -0x24(%rbp),%r8d
sub    $0x1,%r8d
movslq %r8d,%r8
mov    (%rax,%r8,4),%r8d
mov    -0x18(%rbp),%rax
mov    (%rax),%r9d
mov    -0x20(%rbp),%rax
mov    (%rax),%eax
mov    %eax,(%rsp)
call   1030 <XDrawLine@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<XDrawPoly>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r8,%rbp
mov    %rcx,%rbx
mov    %edx,%r15d
mov    %esi,%r12d
mov    %rdi,%r13
mov    %r9d,0xc(%rsp)
cmp    $0x2,%r9d
jl     117f <XDrawPoly+0x6f>
mov    0xc(%rsp),%eax
mov    %rax,0x10(%rsp)
mov    $0x1,%r14d
nopw   0x0(%rax,%rax,1)
mov    -0x4(%rbx,%r14,4),%ecx
mov    (%rbx,%r14,4),%r9d
mov    -0x4(%rbp,%r14,4),%r8d
mov    0x0(%rbp,%r14,4),%eax
mov    %eax,(%rsp)
mov    %r13,%rdi
mov    %r12d,%esi
mov    %r15d,%edx
call   1030 <XDrawLine@plt>
add    $0x1,%r14
cmp    %r14,0x10(%rsp)
jne    1150 <XDrawPoly+0x40>
movslq 0xc(%rsp),%rax
mov    -0x4(%rbx,%rax,4),%ecx
mov    -0x4(%rbp,%rax,4),%r8d
mov    (%rbx),%r9d
mov    0x0(%rbp),%eax
mov    %eax,(%rsp)
mov    %r13,%rdi
mov    %r12d,%esi
mov    %r15d,%edx
call   1030 <XDrawLine@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @XDrawPoly(i32* %0, i32 %1, i32 %2, i32* %3, i32* %4, i32 %5) {
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32*
%11 = alloca i32*
%12 = alloca i32
%13 = alloca i32
store i32* %0, i32** %7
store i32 %1, i32* %8
store i32 %2, i32* %9
store i32* %3, i32** %10
store i32* %4, i32** %11
store i32 %5, i32* %12
store i32 1, i32* %13
br label %14
14: ; preds = %45, %6
%15 = load i32, i32* %13
%16 = load i32, i32* %12
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %48
18: ; preds = %14
%19 = load i32*, i32** %7
%20 = load i32, i32* %8
%21 = load i32, i32* %9
%22 = load i32*, i32** %10
%23 = load i32, i32* %13
%24 = sub nsw i32 %23, 1
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i32, i32* %22, i64 %25
%27 = load i32, i32* %26
%28 = load i32*, i32** %11
%29 = load i32, i32* %13
%30 = sub nsw i32 %29, 1
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i32, i32* %28, i64 %31
%33 = load i32, i32* %32
%34 = load i32*, i32** %10
%35 = load i32, i32* %13
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i32, i32* %34, i64 %36
%38 = load i32, i32* %37
%39 = load i32*, i32** %11
%40 = load i32, i32* %13
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i32, i32* %39, i64 %41
%43 = load i32, i32* %42
%44 = call i32 @XDrawLine(i32* %19, i32 %20, i32 %21, i32 %27, i32 %33, i32 %38, i32 %43)
br label %45
45: ; preds = %18
%46 = load i32, i32* %13
%47 = add nsw i32 %46, 1
store i32 %47, i32* %13
br label %14
48: ; preds = %14
%49 = load i32*, i32** %7
%50 = load i32, i32* %8
%51 = load i32, i32* %9
%52 = load i32*, i32** %10
%53 = load i32, i32* %12
%54 = sub nsw i32 %53, 1
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds i32, i32* %52, i64 %55
%57 = load i32, i32* %56
%58 = load i32*, i32** %11
%59 = load i32, i32* %12
%60 = sub nsw i32 %59, 1
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds i32, i32* %58, i64 %61
%63 = load i32, i32* %62
%64 = load i32*, i32** %10
%65 = getelementptr inbounds i32, i32* %64, i64 0
%66 = load i32, i32* %65
%67 = load i32*, i32** %11
%68 = getelementptr inbounds i32, i32* %67, i64 0
%69 = load i32, i32* %68
%70 = call i32 @XDrawLine(i32* %49, i32 %50, i32 %51, i32 %57, i32 %63, i32 %66, i32 %69)
ret void
}

LLVM IR (-O2):
define void @XDrawPoly(i32* %0, i32 %1, i32 %2, i32* nocapture %3, i32* nocapture %4, i32 %5) {
%7 = icmp sgt i32 %5, 1
br i1 %7, label %8, label %24
8: ; preds = %6
%9 = zext i32 %5 to i64
br label %10
10: ; preds = %8, %10
%11 = phi i64 [ 1, %8 ], [ %22, %10 ]
%12 = add nsw i64 %11, -1
%13 = getelementptr inbounds i32, i32* %3, i64 %12
%14 = load i32, i32* %13
%15 = getelementptr inbounds i32, i32* %4, i64 %12
%16 = load i32, i32* %15
%17 = getelementptr inbounds i32, i32* %3, i64 %11
%18 = load i32, i32* %17
%19 = getelementptr inbounds i32, i32* %4, i64 %11
%20 = load i32, i32* %19
%21 = tail call i32 @XDrawLine(i32* %0, i32 %1, i32 %2, i32 %14, i32 %16, i32 %18, i32 %20)
%22 = add nuw nsw i64 %11, 1
%23 = icmp eq i64 %22, %9
br i1 %23, label %24, label %10
24: ; preds = %10, %6
%25 = add nsw i32 %5, -1
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i32, i32* %3, i64 %26
%28 = load i32, i32* %27
%29 = getelementptr inbounds i32, i32* %4, i64 %26
%30 = load i32, i32* %29
%31 = load i32, i32* %3
%32 = load i32, i32* %4
%33 = tail call i32 @XDrawLine(i32* %0, i32 %1, i32 %2, i32 %28, i32 %30, i32 %31, i32 %32)
ret void
}