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

/* Variables and functions */
int /*<<< orphan*/ CalculateTriangleCoordinates(int /*<<< orphan*/ *, short,
                                                short, unsigned short,
                                                unsigned short, short);
int /*<<< orphan*/ Convex;
int /*<<< orphan*/ CoordModeOrigin;
int XFillPolygon(int /*<<< orphan*/ *, int /*<<< orphan*/, int /*<<< orphan*/,
                 int /*<<< orphan*/ *, int, int /*<<< orphan*/,
                 int /*<<< orphan*/);
int FillTriangle(Display *display, Drawable d, GC gc, short x, short y,
                 unsigned short width, unsigned short height, short angle) {
  XPoint points[4];
  CalculateTriangleCoordinates(points, x, y, width, height, angle);
  return XFillPolygon(display, d, gc, points, 4, Convex, CoordModeOrigin);
}


x86 assembly (clang, -O0):
<FillTriangle>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %r8d,-0x40(%rbp)
mov    %ecx,%eax
mov    -0x40(%rbp),%ecx
mov    %eax,-0x3c(%rbp)
mov    %edx,%eax
mov    -0x3c(%rbp),%edx
mov    %eax,-0x38(%rbp)
mov    %esi,%eax
mov    -0x38(%rbp),%esi
mov    %eax,-0x34(%rbp)
mov    %rdi,%r8
mov    -0x34(%rbp),%edi
mov    %r9w,%ax
mov    0x18(%rbp),%r9w
mov    0x10(%rbp),%r9w
mov    %r8,-0x8(%rbp)
mov    %edi,-0xc(%rbp)
mov    %esi,-0x10(%rbp)
mov    %dx,-0x12(%rbp)
mov    %cx,-0x14(%rbp)
mov    %ax,-0x16(%rbp)
lea    -0x30(%rbp),%rdi
mov    -0x12(%rbp),%si
mov    -0x14(%rbp),%dx
mov    -0x16(%rbp),%cx
mov    0x10(%rbp),%ax
movswl %si,%esi
movswl %dx,%edx
movzwl %cx,%ecx
movzwl %ax,%r8d
movswl 0x18(%rbp),%r9d
call   1040 <CalculateTriangleCoordinates@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
lea    -0x30(%rbp),%rcx
mov    0x2e2a(%rip),%rax
mov    (%rax),%r9d
mov    0x2e30(%rip),%rax
mov    (%rax),%eax
mov    $0x4,%r8d
mov    %eax,(%rsp)
call   1030 <XFillPolygon@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<FillTriangle>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x20,%rsp
mov    %r9d,%ebp
mov    %r8d,%eax
mov    %edx,%r14d
mov    %esi,%r15d
mov    %rdi,%rbx
movzwl 0x50(%rsp),%r8d
movswl 0x58(%rsp),%r9d
lea    0x10(%rsp),%r12
mov    %r12,%rdi
mov    %ecx,%esi
mov    %eax,%edx
mov    %ebp,%ecx
call   1040 <CalculateTriangleCoordinates@plt>
mov    0x2e77(%rip),%rax
mov    (%rax),%r9d
mov    0x2e7d(%rip),%rax
mov    (%rax),%eax
mov    %eax,(%rsp)
mov    %rbx,%rdi
mov    %r15d,%esi
mov    %r14d,%edx
mov    %r12,%rcx
mov    $0x4,%r8d
call   1030 <XFillPolygon@plt>
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@Convex = global i32 0
@CoordModeOrigin = global i32 0
define i32 @FillTriangle(i32* %0, i32 %1, i32 %2, i16 signext %3, i16 signext %4, i16 zeroext %5, i16 zeroext %6, i16 signext %7) {
%9 = alloca i32*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i16
%13 = alloca i16
%14 = alloca i16
%15 = alloca i16
%16 = alloca i16
%17 = alloca [4 x i32]
store i32* %0, i32** %9
store i32 %1, i32* %10
store i32 %2, i32* %11
store i16 %3, i16* %12
store i16 %4, i16* %13
store i16 %5, i16* %14
store i16 %6, i16* %15
store i16 %7, i16* %16
%18 = getelementptr inbounds [4 x i32], [4 x i32]* %17, i64 0, i64 0
%19 = load i16, i16* %12
%20 = load i16, i16* %13
%21 = load i16, i16* %14
%22 = load i16, i16* %15
%23 = load i16, i16* %16
%24 = call i32 @CalculateTriangleCoordinates(i32* %18, i16 signext %19, i16 signext %20, i16 zeroext %21, i16 zeroext %22, i16 signext %23)
%25 = load i32*, i32** %9
%26 = load i32, i32* %10
%27 = load i32, i32* %11
%28 = getelementptr inbounds [4 x i32], [4 x i32]* %17, i64 0, i64 0
%29 = load i32, i32* @Convex
%30 = load i32, i32* @CoordModeOrigin
%31 = call i32 @XFillPolygon(i32* %25, i32 %26, i32 %27, i32* %28, i32 4, i32 %29, i32 %30)
ret i32 %31
}

LLVM IR (-O2):
@Convex = global i32 0
@CoordModeOrigin = global i32 0
define i32 @FillTriangle(i32* %0, i32 %1, i32 %2, i16 signext %3, i16 signext %4, i16 zeroext %5, i16 zeroext %6, i16 signext %7) {
%9 = alloca [4 x i32]
%10 = bitcast [4 x i32]* %9 to i8*
%11 = getelementptr inbounds [4 x i32], [4 x i32]* %9, i64 0, i64 0
%12 = call i32 @CalculateTriangleCoordinates(i32* %11, i16 signext %3, i16 signext %4, i16 zeroext %5, i16 zeroext %6, i16 signext %7)
%13 = load i32, i32* @Convex
%14 = load i32, i32* @CoordModeOrigin
%15 = call i32 @XFillPolygon(i32* %0, i32 %1, i32 %2, i32* %11, i32 4, i32 %13, i32 %14)
ret i32 %15
}