#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 */
typedef struct TYPE_3__ TYPE_1__;

/* Type definitions */
struct TYPE_3__ {
  int x;
  int y;
};
typedef TYPE_1__ XPoint;
typedef int /*<<< orphan*/ XGCValues;
typedef int /*<<< orphan*/ Window;
typedef int /*<<< orphan*/ Pixmap;
typedef int /*<<< orphan*/ GC;
typedef int /*<<< orphan*/ Display;

/* Variables and functions */
int /*<<< orphan*/ Convex;
int /*<<< orphan*/ CoordModeOrigin;
int /*<<< orphan*/ ShapeBounding;
int /*<<< orphan*/ ShapeSet;
int /*<<< orphan*/ XCreateGC(int /*<<< orphan*/ *, int /*<<< orphan*/,
                             int /*<<< orphan*/, int /*<<< orphan*/ *);
int /*<<< orphan*/ XCreatePixmap(int /*<<< orphan*/ *, int /*<<< orphan*/, int,
                                 int, int);
int /*<<< orphan*/ XFillPolygon(int /*<<< orphan*/ *, int /*<<< orphan*/,
                                int /*<<< orphan*/, TYPE_1__ *, int,
                                int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ XFillRectangle(int /*<<< orphan*/ *, int /*<<< orphan*/,
                                  int /*<<< orphan*/, int /*<<< orphan*/,
                                  int /*<<< orphan*/, int, int);
int /*<<< orphan*/ XFreeGC(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ XFreePixmap(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ XSetForeground(int /*<<< orphan*/ *, int /*<<< orphan*/,
                                  int);
int /*<<< orphan*/ XShapeCombineMask(int /*<<< orphan*/ *, int /*<<< orphan*/,
                                     int /*<<< orphan*/, int /*<<< orphan*/,
                                     int /*<<< orphan*/, int /*<<< orphan*/,
                                     int /*<<< orphan*/);
float cos(float);
float sin(float);
void make_shape_mask(Display *dpy, Window win, int width, int height,
                     int sides) {
  Pixmap shapeMask;
  XGCValues xgcv;
  GC gc;
  shapeMask = XCreatePixmap(dpy, win, width, height, 1);
  gc = XCreateGC(dpy, shapeMask, 0, &xgcv);
  XSetForeground(dpy, gc, 0);
  XFillRectangle(dpy, shapeMask, gc, 0, 0, width, height);
  XSetForeground(dpy, gc, 1);
  {
    int cx = width / 2;
    int cy = height / 2;
    float angle = 0.0;
    float step = 2.0 * 3.1415926 / sides;
    float radius = width / 2;
    int i;
    XPoint points[100];
    for (i = 0; i < sides; i++) {
      int x = cx + radius * sin(angle);
      int y = cy - radius * cos(angle);
      points[i].x = x;
      points[i].y = y;
      angle += step;
    }
    XFillPolygon(dpy, shapeMask, gc, points, sides, Convex, CoordModeOrigin);
  }
  XShapeCombineMask(dpy, win, ShapeBounding, 0, 0, shapeMask, ShapeSet);
  XFreeGC(dpy, gc);
  XFreePixmap(dpy, shapeMask);
}


x86 assembly (clang, -O0):
<make_shape_mask>:
push   %rbp
mov    %rsp,%rbp
sub    $0x380,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    %r8d,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x14(%rbp),%ecx
mov    $0x1,%r8d
call   10c0 <XCreatePixmap@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x1c(%rbp),%esi
xor    %edx,%edx
lea    -0x20(%rbp),%rcx
call   1080 <XCreateGC@plt>
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x24(%rbp),%esi
xor    %edx,%edx
call   10a0 <XSetForeground@plt>
mov    -0x8(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    -0x24(%rbp),%edx
mov    -0x10(%rbp),%r9d
mov    -0x14(%rbp),%eax
xor    %r8d,%r8d
mov    %r8d,%ecx
mov    %eax,(%rsp)
call   1050 <XFillRectangle@plt>
mov    -0x8(%rbp),%rdi
mov    -0x24(%rbp),%esi
mov    $0x1,%edx
call   10a0 <XSetForeground@plt>
mov    -0x10(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x28(%rbp)
mov    -0x14(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x2c(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x30(%rbp)
cvtsi2sdl -0x18(%rbp),%xmm1
movsd  0xda5(%rip),%xmm0
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x34(%rbp)
mov    -0x10(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cvtsi2ss %eax,%xmm0
movss  %xmm0,-0x38(%rbp)
movl   $0x0,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    136d <make_shape_mask+0x1cd>
cvtsi2ssl -0x28(%rbp),%xmm0
movss  %xmm0,-0x378(%rbp)
ff
movss  -0x38(%rbp),%xmm0
movss  %xmm0,-0x374(%rbp)
ff
movss  -0x30(%rbp),%xmm0
call   1070 <sin@plt>
movss  -0x378(%rbp),%xmm1
ff
movaps %xmm0,%xmm2
movss  -0x374(%rbp),%xmm0
ff
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
cvttss2si %xmm0,%eax
mov    %eax,-0x364(%rbp)
cvtsi2ssl -0x2c(%rbp),%xmm0
movss  %xmm0,-0x370(%rbp)
ff
movss  -0x38(%rbp),%xmm0
movss  %xmm0,-0x36c(%rbp)
ff
movss  -0x30(%rbp),%xmm0
call   1090 <cos@plt>
movss  -0x370(%rbp),%xmm1
ff
movaps %xmm0,%xmm2
movss  -0x36c(%rbp),%xmm0
ff
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
cvttss2si %xmm0,%eax
mov    %eax,-0x368(%rbp)
mov    -0x364(%rbp),%ecx
movslq -0x3c(%rbp),%rax
mov    %ecx,-0x360(%rbp,%rax,8)
mov    -0x368(%rbp),%ecx
movslq -0x3c(%rbp),%rax
mov    %ecx,-0x35c(%rbp,%rax,8)
movss  -0x34(%rbp),%xmm0
addss  -0x30(%rbp),%xmm0
movss  %xmm0,-0x30(%rbp)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    1283 <make_shape_mask+0xe3>
mov    -0x8(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    -0x24(%rbp),%edx
lea    -0x360(%rbp),%rcx
mov    -0x18(%rbp),%r8d
mov    0x2c3f(%rip),%rax
mov    (%rax),%r9d
mov    0x2c45(%rip),%rax
mov    (%rax),%eax
mov    %eax,(%rsp)
call   1040 <XFillPolygon@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    0x2c35(%rip),%rax
mov    (%rax),%edx
mov    -0x1c(%rbp),%r9d
mov    0x2c30(%rip),%rax
mov    (%rax),%eax
xor    %r8d,%r8d
mov    %r8d,%ecx
mov    %eax,(%rsp)
call   1030 <XShapeCombineMask@plt>
mov    -0x8(%rbp),%rdi
mov    -0x24(%rbp),%esi
call   10b0 <XFreeGC@plt>
mov    -0x8(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1060 <XFreePixmap@plt>
add    $0x380,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<make_shape_mask>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x368,%rsp
mov    %r8d,%ebx
mov    %ecx,%ebp
mov    %edx,%r14d
mov    %rdi,%r15
mov    %esi,0x10(%rsp)
mov    $0x1,%r8d
call   10c0 <XCreatePixmap@plt>
mov    %eax,%r12d
lea    0x1c(%rsp),%rcx
mov    %r15,%rdi
mov    %eax,%esi
xor    %edx,%edx
call   1080 <XCreateGC@plt>
mov    %eax,%r13d
mov    %r15,%rdi
mov    %eax,%esi
xor    %edx,%edx
call   10a0 <XSetForeground@plt>
mov    %ebp,(%rsp)
mov    %r15,%rdi
mov    %r12d,%esi
mov    %r13d,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
mov    %r14d,%r9d
call   1050 <XFillRectangle@plt>
mov    %r15,%rdi
mov    %r13d,%esi
mov    $0x1,%edx
call   10a0 <XSetForeground@plt>
mov    %ebx,0xc(%rsp)
test   %ebx,%ebx
jle    12ea <make_shape_mask+0x14a>
mov    %r14d,%eax
shr    $0x1f,%eax
add    %r14d,%eax
mov    0xc(%rsp),%ecx
cvtsi2sd %ecx,%xmm0
movsd  0xdc4(%rip),%xmm1
divsd  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtsd2ss %xmm1,%xmm0
movss  %xmm0,0x18(%rsp)
sar    %eax
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
mov    %ebp,%eax
shr    $0x1f,%eax
add    %ebp,%eax
sar    %eax
xorps  %xmm1,%xmm1
cvtsi2ss %eax,%xmm1
movss  %xmm1,0x14(%rsp)
movaps 0xd9d(%rip),%xmm1
movaps %xmm0,0x30(%rsp)
xorps  %xmm0,%xmm1
movaps %xmm1,0x20(%rsp)
mov    %ecx,%r14d
xorps  %xmm0,%xmm0
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
movss  %xmm0,0x8(%rsp)
movss  0x8(%rsp),%xmm0
call   1070 <sin@plt>
movaps 0x30(%rsp),%xmm1
mulss  %xmm1,%xmm0
addss  %xmm1,%xmm0
cvttss2si %xmm0,%ebp
movss  0x8(%rsp),%xmm0
call   1090 <cos@plt>
mulss  0x20(%rsp),%xmm0
addss  0x14(%rsp),%xmm0
cvttss2si %xmm0,%eax
movss  0x8(%rsp),%xmm0
mov    %ebp,0x40(%rsp,%rbx,8)
mov    %eax,0x44(%rsp,%rbx,8)
addss  0x18(%rsp),%xmm0
add    $0x1,%rbx
cmp    %rbx,%r14
jne    1290 <make_shape_mask+0xf0>
mov    0x2cd7(%rip),%rax
mov    (%rax),%r9d
mov    0x2cdd(%rip),%rax
mov    (%rax),%eax
mov    %eax,(%rsp)
lea    0x40(%rsp),%rcx
mov    %r15,%rdi
mov    %r12d,%esi
mov    %r13d,%edx
mov    0xc(%rsp),%r8d
call   1040 <XFillPolygon@plt>
mov    0x2cc1(%rip),%rax
mov    (%rax),%edx
mov    0x2cc0(%rip),%rax
mov    (%rax),%eax
mov    %eax,(%rsp)
mov    %r15,%rdi
mov    0x10(%rsp),%esi
xor    %ecx,%ecx
xor    %r8d,%r8d
mov    %r12d,%r9d
call   1030 <XShapeCombineMask@plt>
mov    %r15,%rdi
mov    %r13d,%esi
call   10b0 <XFreeGC@plt>
mov    %r15,%rdi
mov    %r12d,%esi
call   1060 <XFreePixmap@plt>
add    $0x368,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.TYPE_3__ = type { i32, i32 }
@Convex = global i32 0
@CoordModeOrigin = global i32 0
@ShapeBounding = global i32 0
@ShapeSet = global i32 0
define void @make_shape_mask(i32* %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca float
%17 = alloca float
%18 = alloca float
%19 = alloca i32
%20 = alloca [100 x %struct.TYPE_3__]
%21 = alloca i32
%22 = alloca i32
store i32* %0, i32** %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store i32 %4, i32* %10
%23 = load i32*, i32** %6
%24 = load i32, i32* %7
%25 = load i32, i32* %8
%26 = load i32, i32* %9
%27 = call i32 @XCreatePixmap(i32* %23, i32 %24, i32 %25, i32 %26, i32 1)
store i32 %27, i32* %11
%28 = load i32*, i32** %6
%29 = load i32, i32* %11
%30 = call i32 @XCreateGC(i32* %28, i32 %29, i32 0, i32* %12)
store i32 %30, i32* %13
%31 = load i32*, i32** %6
%32 = load i32, i32* %13
%33 = call i32 @XSetForeground(i32* %31, i32 %32, i32 0)
%34 = load i32*, i32** %6
%35 = load i32, i32* %11
%36 = load i32, i32* %13
%37 = load i32, i32* %8
%38 = load i32, i32* %9
%39 = call i32 @XFillRectangle(i32* %34, i32 %35, i32 %36, i32 0, i32 0, i32 %37, i32 %38)
%40 = load i32*, i32** %6
%41 = load i32, i32* %13
%42 = call i32 @XSetForeground(i32* %40, i32 %41, i32 1)
%43 = load i32, i32* %8
%44 = sdiv i32 %43, 2
store i32 %44, i32* %14
%45 = load i32, i32* %9
%46 = sdiv i32 %45, 2
store i32 %46, i32* %15
store float 0.000000e+00, float* %16
%47 = load i32, i32* %10
%48 = sitofp i32 %47 to double
%49 = fdiv double 0x401921FB4D12D84A, %48
%50 = fptrunc double %49 to float
store float %50, float* %17
%51 = load i32, i32* %8
%52 = sdiv i32 %51, 2
%53 = sitofp i32 %52 to float
store float %53, float* %18
store i32 0, i32* %19
br label %54
54: ; preds = %87, %5
%55 = load i32, i32* %19
%56 = load i32, i32* %10
%57 = icmp slt i32 %55, %56
br i1 %57, label %58, label %90
58: ; preds = %54
%59 = load i32, i32* %14
%60 = sitofp i32 %59 to float
%61 = load float, float* %18
%62 = load float, float* %16
%63 = call float @sin(float %62)
%64 = call float @llvm.fmuladd.f32(float %61, float %63, float %60)
%65 = fptosi float %64 to i32
store i32 %65, i32* %21
%66 = load i32, i32* %15
%67 = sitofp i32 %66 to float
%68 = load float, float* %18
%69 = load float, float* %16
%70 = call float @cos(float %69)
%71 = fneg float %68
%72 = call float @llvm.fmuladd.f32(float %71, float %70, float %67)
%73 = fptosi float %72 to i32
store i32 %73, i32* %22
%74 = load i32, i32* %21
%75 = load i32, i32* %19
%76 = sext i32 %75 to i64
%77 = getelementptr inbounds [100 x %struct.TYPE_3__], [100 x %struct.TYPE_3__]* %20, i64 0, i64 %76
%78 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %77, i32 0, i32 0
store i32 %74, i32* %78
%79 = load i32, i32* %22
%80 = load i32, i32* %19
%81 = sext i32 %80 to i64
%82 = getelementptr inbounds [100 x %struct.TYPE_3__], [100 x %struct.TYPE_3__]* %20, i64 0, i64 %81
%83 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %82, i32 0, i32 1
store i32 %79, i32* %83
%84 = load float, float* %17
%85 = load float, float* %16
%86 = fadd float %85, %84
store float %86, float* %16
br label %87
87: ; preds = %58
%88 = load i32, i32* %19
%89 = add nsw i32 %88, 1
store i32 %89, i32* %19
br label %54
90: ; preds = %54
%91 = load i32*, i32** %6
%92 = load i32, i32* %11
%93 = load i32, i32* %13
%94 = getelementptr inbounds [100 x %struct.TYPE_3__], [100 x %struct.TYPE_3__]* %20, i64 0, i64 0
%95 = load i32, i32* %10
%96 = load i32, i32* @Convex
%97 = load i32, i32* @CoordModeOrigin
%98 = call i32 @XFillPolygon(i32* %91, i32 %92, i32 %93, %struct.TYPE_3__* %94, i32 %95, i32 %96, i32 %97)
%99 = load i32*, i32** %6
%100 = load i32, i32* %7
%101 = load i32, i32* @ShapeBounding
%102 = load i32, i32* %11
%103 = load i32, i32* @ShapeSet
%104 = call i32 @XShapeCombineMask(i32* %99, i32 %100, i32 %101, i32 0, i32 0, i32 %102, i32 %103)
%105 = load i32*, i32** %6
%106 = load i32, i32* %13
%107 = call i32 @XFreeGC(i32* %105, i32 %106)
%108 = load i32*, i32** %6
%109 = load i32, i32* %11
%110 = call i32 @XFreePixmap(i32* %108, i32 %109)
ret void
}

LLVM IR (-O2):
%struct.TYPE_3__ = type { i32, i32 }
@Convex = global i32 0
@CoordModeOrigin = global i32 0
@ShapeBounding = global i32 0
@ShapeSet = global i32 0
define void @make_shape_mask(i32* %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca i32
%7 = alloca [100 x %struct.TYPE_3__]
%8 = bitcast i32* %6 to i8*
%9 = tail call i32 @XCreatePixmap(i32* %0, i32 %1, i32 %2, i32 %3, i32 1)
%10 = call i32 @XCreateGC(i32* %0, i32 %9, i32 0, i32* %6)
%11 = call i32 @XSetForeground(i32* %0, i32 %10, i32 0)
%12 = call i32 @XFillRectangle(i32* %0, i32 %9, i32 %10, i32 0, i32 0, i32 %2, i32 %3)
%13 = call i32 @XSetForeground(i32* %0, i32 %10, i32 1)
%14 = sdiv i32 %2, 2
%15 = sitofp i32 %4 to double
%16 = fdiv double 0x401921FB4D12D84A, %15
%17 = fptrunc double %16 to float
%18 = sitofp i32 %14 to float
%19 = bitcast [100 x %struct.TYPE_3__]* %7 to i8*
%20 = icmp sgt i32 %4, 0
br i1 %20, label %21, label %40
21: ; preds = %5
%22 = sdiv i32 %3, 2
%23 = sitofp i32 %22 to float
%24 = fneg float %18
%25 = zext i32 %4 to i64
br label %26
26: ; preds = %21, %26
%27 = phi i64 [ 0, %21 ], [ %38, %26 ]
%28 = phi float [ 0.000000e+00, %21 ], [ %37, %26 ]
%29 = call float @sin(float %28)
%30 = call float @llvm.fmuladd.f32(float %18, float %29, float %18)
%31 = fptosi float %30 to i32
%32 = call float @cos(float %28)
%33 = call float @llvm.fmuladd.f32(float %24, float %32, float %23)
%34 = fptosi float %33 to i32
%35 = getelementptr inbounds [100 x %struct.TYPE_3__], [100 x %struct.TYPE_3__]* %7, i64 0, i64 %27, i32 0
store i32 %31, i32* %35
%36 = getelementptr inbounds [100 x %struct.TYPE_3__], [100 x %struct.TYPE_3__]* %7, i64 0, i64 %27, i32 1
store i32 %34, i32* %36
%37 = fadd float %28, %17
%38 = add nuw nsw i64 %27, 1
%39 = icmp eq i64 %38, %25
br i1 %39, label %40, label %26
40: ; preds = %26, %5
%41 = getelementptr inbounds [100 x %struct.TYPE_3__], [100 x %struct.TYPE_3__]* %7, i64 0, i64 0
%42 = load i32, i32* @Convex
%43 = load i32, i32* @CoordModeOrigin
%44 = call i32 @XFillPolygon(i32* %0, i32 %9, i32 %10, %struct.TYPE_3__* %41, i32 %4, i32 %42, i32 %43)
%45 = load i32, i32* @ShapeBounding
%46 = load i32, i32* @ShapeSet
%47 = call i32 @XShapeCombineMask(i32* %0, i32 %1, i32 %45, i32 0, i32 0, i32 %9, i32 %46)
%48 = call i32 @XFreeGC(i32* %0, i32 %10)
%49 = call i32 @XFreePixmap(i32* %0, i32 %9)
ret void
}