#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__ {
  short x;
  short y;
};
typedef TYPE_1__ XPoint;

/* Variables and functions */
int /*<<< orphan*/ RotateCoordinates(short *, short *, short, short, short);
void CalculateTriangleCoordinates(XPoint *points, short x, short y,
                                  unsigned short width, unsigned short height,
                                  short angle) {
  points[0].x = (short)(x - (width / 2));
  points[0].y = y;
  points[1].x = (short)(x + (width / 2));
  points[1].y = y;
  points[2].x = x;
  points[2].y = (short)(y + height);
  points[3].x = points[0].x;
  points[3].y = points[0].y;
  {
    int i;
    for (i = 0; i < 4; i++) {
      RotateCoordinates(&(points[i].x), &(points[i].y), x, y, angle);
    }
  }
}


x86 assembly (clang, -O0):
<CalculateTriangleCoordinates>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %r8d,-0x30(%rbp)
mov    %ecx,%eax
mov    -0x30(%rbp),%ecx
mov    %eax,-0x2c(%rbp)
mov    %edx,%eax
mov    -0x2c(%rbp),%edx
mov    %eax,-0x28(%rbp)
mov    %esi,%eax
mov    -0x28(%rbp),%esi
mov    %eax,-0x24(%rbp)
mov    %rdi,%r8
mov    -0x24(%rbp),%edi
mov    %r9w,%ax
mov    %r8,-0x8(%rbp)
mov    %di,-0xa(%rbp)
mov    %si,-0xc(%rbp)
mov    %dx,-0xe(%rbp)
mov    %cx,-0x10(%rbp)
mov    %ax,-0x12(%rbp)
movswl -0xa(%rbp),%eax
mov    %eax,-0x20(%rbp)
movzwl -0xe(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x20(%rbp),%eax
sub    %ecx,%eax
mov    %ax,%cx
mov    -0x8(%rbp),%rax
mov    %cx,(%rax)
mov    -0xc(%rbp),%cx
mov    -0x8(%rbp),%rax
mov    %cx,0x2(%rax)
movswl -0xa(%rbp),%eax
mov    %eax,-0x1c(%rbp)
movzwl -0xe(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
add    %ecx,%eax
mov    %ax,%cx
mov    -0x8(%rbp),%rax
mov    %cx,0x4(%rax)
mov    -0xc(%rbp),%cx
mov    -0x8(%rbp),%rax
mov    %cx,0x6(%rax)
mov    -0xa(%rbp),%cx
mov    -0x8(%rbp),%rax
mov    %cx,0x8(%rax)
movswl -0xc(%rbp),%eax
movzwl -0x10(%rbp),%ecx
add    %ecx,%eax
mov    %ax,%cx
mov    -0x8(%rbp),%rax
mov    %cx,0xa(%rax)
mov    -0x8(%rbp),%rax
mov    (%rax),%cx
mov    -0x8(%rbp),%rax
mov    %cx,0xc(%rax)
mov    -0x8(%rbp),%rax
mov    0x2(%rax),%cx
mov    -0x8(%rbp),%rax
mov    %cx,0xe(%rax)
movl   $0x0,-0x18(%rbp)
cmpl   $0x4,-0x18(%rbp)
jge    1250 <CalculateTriangleCoordinates+0x140>
mov    -0x8(%rbp),%rdi
movslq -0x18(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdi
mov    -0x8(%rbp),%rsi
movslq -0x18(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
add    $0x2,%rsi
mov    -0xa(%rbp),%cx
mov    -0xc(%rbp),%ax
movswl %cx,%edx
movswl %ax,%ecx
movswl -0x12(%rbp),%r8d
call   1030 <RotateCoordinates@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11fe <CalculateTriangleCoordinates+0xee>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CalculateTriangleCoordinates>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r9d,%r14d
mov    %edx,%ebp
mov    %esi,%ebx
shr    %ecx
mov    %esi,%eax
sub    %ecx,%eax
mov    %ax,(%rdi)
lea    0x2(%rdi),%rsi
mov    %bp,0x2(%rdi)
add    %ebx,%ecx
lea    0x4(%rdi),%r15
mov    %cx,0x4(%rdi)
lea    0x6(%rdi),%r12
mov    %bp,0x6(%rdi)
lea    0x8(%rdi),%rcx
mov    %rcx,0x10(%rsp)
mov    %bx,0x8(%rdi)
add    %edx,%r8d
lea    0xa(%rdi),%r13
mov    %r8w,0xa(%rdi)
lea    0xc(%rdi),%rcx
mov    %rcx,0x8(%rsp)
mov    %ax,0xc(%rdi)
lea    0xe(%rdi),%rax
mov    %rax,(%rsp)
mov    %bp,0xe(%rdi)
mov    %ebx,%edx
mov    %ebp,%ecx
mov    %r9d,%r8d
call   1030 <RotateCoordinates@plt>
mov    %r15,%rdi
mov    %r12,%rsi
mov    %ebx,%edx
mov    %ebp,%ecx
mov    %r14d,%r8d
call   1030 <RotateCoordinates@plt>
mov    0x10(%rsp),%rdi
mov    %r13,%rsi
mov    %ebx,%edx
mov    %ebp,%ecx
mov    %r14d,%r8d
call   1030 <RotateCoordinates@plt>
mov    0x8(%rsp),%rdi
mov    (%rsp),%rsi
mov    %ebx,%edx
mov    %ebp,%ecx
mov    %r14d,%r8d
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <RotateCoordinates@plt>

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

LLVM IR (-O2):
%struct.TYPE_3__ = type { i16, i16 }
define void @CalculateTriangleCoordinates(%struct.TYPE_3__* %0, i16 signext %1, i16 signext %2, i16 zeroext %3, i16 zeroext %4, i16 signext %5) {
%7 = lshr i16 %3, 1
%8 = sub i16 %1, %7
%9 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %0, i64 0, i32 0
store i16 %8, i16* %9
%10 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %0, i64 0, i32 1
store i16 %2, i16* %10
%11 = add i16 %7, %1
%12 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %0, i64 1, i32 0
store i16 %11, i16* %12
%13 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %0, i64 1, i32 1
store i16 %2, i16* %13
%14 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %0, i64 2, i32 0
store i16 %1, i16* %14
%15 = add i16 %4, %2
%16 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %0, i64 2, i32 1
store i16 %15, i16* %16
%17 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %0, i64 3, i32 0
store i16 %8, i16* %17
%18 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %0, i64 3, i32 1
store i16 %2, i16* %18
%19 = tail call i32 @RotateCoordinates(i16* %9, i16* %10, i16 signext %1, i16 signext %2, i16 signext %5)
%20 = tail call i32 @RotateCoordinates(i16* %12, i16* %13, i16 signext %1, i16 signext %2, i16 signext %5)
%21 = tail call i32 @RotateCoordinates(i16* %14, i16* %16, i16 signext %1, i16 signext %2, i16 signext %5)
%22 = tail call i32 @RotateCoordinates(i16* %17, i16* %18, i16 signext %1, i16 signext %2, i16 signext %5)
ret void
}