#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_5__ TYPE_1__;

/* Type definitions */
struct TYPE_5__ {
  scalar_t__ y;
  scalar_t__ x;
};
typedef TYPE_1__ XPoint;

/* Variables and functions */
int /*<<< orphan*/ myline_polygon(int, TYPE_1__ *, int);
int /*<<< orphan*/ mypolygon(int, TYPE_1__ *, int);
int /*<<< orphan*/ printf(char *, int);
double sqrt(double);
void DrawDownTriangles(int mycolor, XPoint *myp, int no, double size,
                       int fill) {
  int i;
  XPoint points[4];
  for (i = 0; i < no; i++) {
    points[0].x = myp[i].x - size;
    points[0].y = myp[i].y + size * 0.33333333333333333333 * sqrt(3.0);
    points[1].x = myp[i].x + size;
    points[1].y = myp[i].y + size * 0.33333333333333333333 * sqrt(3.0);
    points[2].x = myp[i].x;
    points[2].y = myp[i].y - size * 0.66666666666666666666 * sqrt(3.0);
    switch (fill) {
    case 0:
      points[3].x = points[0].x;
      points[3].y = points[0].y;
      myline_polygon(mycolor, points, 4);
      break;
    case 1:
      mypolygon(mycolor, points, 3);
      break;
    default:
      printf("draw2dgraph:DrawTriangles: fill type %i not defined\n", fill);
    }
  }
}


x86 assembly (clang, -O0):
<DrawDownTriangles>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movsd  %xmm0,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1387 <DrawDownTriangles+0x247>
mov    -0x10(%rbp),%rax
movslq -0x28(%rbp),%rcx
shl    $0x4,%rcx
cvtsi2sdq 0x8(%rax,%rcx,1),%xmm0
movsd  -0x20(%rbp),%xmm1
subsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rax
mov    %rax,-0x68(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x28(%rbp),%rcx
shl    $0x4,%rcx
cvtsi2sdq (%rax,%rcx,1),%xmm0
movsd  %xmm0,-0xb0(%rbp)
ff
movsd  -0x20(%rbp),%xmm0
movsd  0xe44(%rip),%xmm1
movsd  %xmm1,-0xa8(%rbp)
ff
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0xb8(%rbp)
ff
movsd  0xe30(%rip),%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
call   1050 <sqrt@plt>
movsd  -0xb8(%rbp),%xmm1
ff
movsd  -0xb0(%rbp),%xmm3
ff
movsd  -0xa8(%rbp),%xmm2
ff
movaps %xmm0,%xmm4
movsd  -0x90(%rbp),%xmm0
ff
mulsd  %xmm4,%xmm1
addsd  %xmm3,%xmm1
cvttsd2si %xmm1,%rax
mov    %rax,-0x70(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x28(%rbp),%rcx
shl    $0x4,%rcx
cvtsi2sdq 0x8(%rax,%rcx,1),%xmm1
movsd  -0x20(%rbp),%xmm3
addsd  %xmm3,%xmm1
cvttsd2si %xmm1,%rax
mov    %rax,-0x58(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x28(%rbp),%rcx
shl    $0x4,%rcx
cvtsi2sdq (%rax,%rcx,1),%xmm1
movsd  %xmm1,-0x98(%rbp)
ff
movsd  -0x20(%rbp),%xmm1
mulsd  %xmm2,%xmm1
movsd  %xmm1,-0xa0(%rbp)
ff
call   1050 <sqrt@plt>
movsd  -0xa0(%rbp),%xmm1
ff
movsd  -0x98(%rbp),%xmm2
ff
movaps %xmm0,%xmm3
movsd  -0x90(%rbp),%xmm0
ff
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
cvttsd2si %xmm1,%rax
mov    %rax,-0x60(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x28(%rbp),%rcx
shl    $0x4,%rcx
mov    0x8(%rax,%rcx,1),%rax
mov    %rax,-0x48(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x28(%rbp),%rcx
shl    $0x4,%rcx
cvtsi2sdq (%rax,%rcx,1),%xmm1
movsd  %xmm1,-0x80(%rbp)
movsd  -0x20(%rbp),%xmm1
movsd  0xd3d(%rip),%xmm2
mulsd  %xmm2,%xmm1
movsd  %xmm1,-0x88(%rbp)
ff
call   1050 <sqrt@plt>
movsd  -0x88(%rbp),%xmm1
ff
movaps %xmm0,%xmm2
movsd  -0x80(%rbp),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rax
mov    %rax,-0x50(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x74(%rbp)
test   %eax,%eax
je     1329 <DrawDownTriangles+0x1e9>
jmp    1318 <DrawDownTriangles+0x1d8>
mov    -0x74(%rbp),%eax
sub    $0x1,%eax
je     134f <DrawDownTriangles+0x20f>
jmp    1365 <DrawDownTriangles+0x225>
mov    -0x68(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x70(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x70(%rbp),%rsi
mov    $0x4,%edx
call   1030 <myline_polygon@plt>
jmp    1374 <DrawDownTriangles+0x234>
mov    -0x4(%rbp),%edi
lea    -0x70(%rbp),%rsi
mov    $0x3,%edx
call   1060 <mypolygon@plt>
jmp    1374 <DrawDownTriangles+0x234>
mov    -0x24(%rbp),%esi
lea    0xca9(%rip),%rdi
call   1040 <printf@plt>
jmp    1379 <DrawDownTriangles+0x239>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1164 <DrawDownTriangles+0x24>
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<DrawDownTriangles>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
movsd  %xmm0,0x8(%rsp)
test   %edx,%edx
jle    1275 <DrawDownTriangles+0x145>
mov    %ecx,%ebp
mov    %rsi,%rbx
mov    %edi,%r14d
movsd  0xea4(%rip),%xmm1
movsd  0x8(%rsp),%xmm0
mulsd  %xmm0,%xmm1
movsd  0xe9a(%rip),%xmm2
mulsd  %xmm0,%xmm2
mov    %edx,%r13d
shl    $0x4,%r13
xor    %r12d,%r12d
movsd  0xe8c(%rip),%xmm0
mulsd  %xmm0,%xmm1
movsd  %xmm1,0x18(%rsp)
mulsd  %xmm0,%xmm2
movsd  %xmm2,0x10(%rsp)
lea    0x20(%rsp),%r15
jmp    11bb <DrawDownTriangles+0x8b>
nop
lea    0xe71(%rip),%rdi
mov    %ebp,%esi
call   1040 <printf@plt>
add    $0x10,%r12
cmp    %r12,%r13
je     1275 <DrawDownTriangles+0x145>
mov    0x8(%rbx,%r12,1),%rdx
xorps  %xmm0,%xmm0
cvtsi2sd %rdx,%xmm0
movapd %xmm0,%xmm1
movsd  0x8(%rsp),%xmm3
subsd  %xmm3,%xmm1
cvttsd2si %xmm1,%rax
mov    %rax,0x28(%rsp)
xorps  %xmm1,%xmm1
cvtsi2sdq (%rbx,%r12,1),%xmm1
movsd  0x18(%rsp),%xmm2
addsd  %xmm1,%xmm2
cvttsd2si %xmm2,%rcx
mov    %rcx,0x20(%rsp)
addsd  %xmm3,%xmm0
cvttsd2si %xmm0,%rsi
mov    %rsi,0x38(%rsp)
mov    %rcx,0x30(%rsp)
mov    %rdx,0x48(%rsp)
addsd  0x10(%rsp),%xmm1
cvttsd2si %xmm1,%rdx
mov    %rdx,0x40(%rsp)
cmp    $0x1,%ebp
je     1260 <DrawDownTriangles+0x130>
test   %ebp,%ebp
jne    11a0 <DrawDownTriangles+0x70>
mov    %rax,0x58(%rsp)
mov    %rcx,0x50(%rsp)
mov    %r14d,%edi
mov    %r15,%rsi
mov    $0x4,%edx
call   1030 <myline_polygon@plt>
jmp    11ae <DrawDownTriangles+0x7e>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r14d,%edi
mov    %r15,%rsi
mov    $0x3,%edx
call   1050 <mypolygon@plt>
jmp    11ae <DrawDownTriangles+0x7e>
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.TYPE_5__ = type { i64, i64 }
@.str = [53 x i8] c"draw2dgraph:DrawTriangles: fill type %i not defined\0A\00"
define void @DrawDownTriangles(i32 %0, %struct.TYPE_5__* %1, i32 %2, double %3, i32 %4) {
%6 = alloca i32
%7 = alloca %struct.TYPE_5__*
%8 = alloca i32
%9 = alloca double
%10 = alloca i32
%11 = alloca i32
%12 = alloca [4 x %struct.TYPE_5__]
store i32 %0, i32* %6
store %struct.TYPE_5__* %1, %struct.TYPE_5__** %7
store i32 %2, i32* %8
store double %3, double* %9
store i32 %4, i32* %10
store i32 0, i32* %11
br label %13
13: ; preds = %116, %5
%14 = load i32, i32* %11
%15 = load i32, i32* %8
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %119
17: ; preds = %13
%18 = load %struct.TYPE_5__*, %struct.TYPE_5__** %7
%19 = load i32, i32* %11
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %18, i64 %20
%22 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %21, i32 0, i32 1
%23 = load i64, i64* %22
%24 = sitofp i64 %23 to double
%25 = load double, double* %9
%26 = fsub double %24, %25
%27 = fptosi double %26 to i64
%28 = getelementptr inbounds [4 x %struct.TYPE_5__], [4 x %struct.TYPE_5__]* %12, i64 0, i64 0
%29 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %28, i32 0, i32 1
store i64 %27, i64* %29
%30 = load %struct.TYPE_5__*, %struct.TYPE_5__** %7
%31 = load i32, i32* %11
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %30, i64 %32
%34 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %33, i32 0, i32 0
%35 = load i64, i64* %34
%36 = sitofp i64 %35 to double
%37 = load double, double* %9
%38 = fmul double %37, 0x3FD5555555555555
%39 = call double @sqrt(double 3.000000e+00)
%40 = call double @llvm.fmuladd.f64(double %38, double %39, double %36)
%41 = fptosi double %40 to i64
%42 = getelementptr inbounds [4 x %struct.TYPE_5__], [4 x %struct.TYPE_5__]* %12, i64 0, i64 0
%43 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %42, i32 0, i32 0
store i64 %41, i64* %43
%44 = load %struct.TYPE_5__*, %struct.TYPE_5__** %7
%45 = load i32, i32* %11
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %44, i64 %46
%48 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %47, i32 0, i32 1
%49 = load i64, i64* %48
%50 = sitofp i64 %49 to double
%51 = load double, double* %9
%52 = fadd double %50, %51
%53 = fptosi double %52 to i64
%54 = getelementptr inbounds [4 x %struct.TYPE_5__], [4 x %struct.TYPE_5__]* %12, i64 0, i64 1
%55 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %54, i32 0, i32 1
store i64 %53, i64* %55
%56 = load %struct.TYPE_5__*, %struct.TYPE_5__** %7
%57 = load i32, i32* %11
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %56, i64 %58
%60 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %59, i32 0, i32 0
%61 = load i64, i64* %60
%62 = sitofp i64 %61 to double
%63 = load double, double* %9
%64 = fmul double %63, 0x3FD5555555555555
%65 = call double @sqrt(double 3.000000e+00)
%66 = call double @llvm.fmuladd.f64(double %64, double %65, double %62)
%67 = fptosi double %66 to i64
%68 = getelementptr inbounds [4 x %struct.TYPE_5__], [4 x %struct.TYPE_5__]* %12, i64 0, i64 1
%69 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %68, i32 0, i32 0
store i64 %67, i64* %69
%70 = load %struct.TYPE_5__*, %struct.TYPE_5__** %7
%71 = load i32, i32* %11
%72 = sext i32 %71 to i64
%73 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %70, i64 %72
%74 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %73, i32 0, i32 1
%75 = load i64, i64* %74
%76 = getelementptr inbounds [4 x %struct.TYPE_5__], [4 x %struct.TYPE_5__]* %12, i64 0, i64 2
%77 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %76, i32 0, i32 1
store i64 %75, i64* %77
%78 = load %struct.TYPE_5__*, %struct.TYPE_5__** %7
%79 = load i32, i32* %11
%80 = sext i32 %79 to i64
%81 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %78, i64 %80
%82 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %81, i32 0, i32 0
%83 = load i64, i64* %82
%84 = sitofp i64 %83 to double
%85 = load double, double* %9
%86 = fmul double %85, 0x3FE5555555555555
%87 = call double @sqrt(double 3.000000e+00)
%88 = fneg double %86
%89 = call double @llvm.fmuladd.f64(double %88, double %87, double %84)
%90 = fptosi double %89 to i64
%91 = getelementptr inbounds [4 x %struct.TYPE_5__], [4 x %struct.TYPE_5__]* %12, i64 0, i64 2
%92 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %91, i32 0, i32 0
store i64 %90, i64* %92
%93 = load i32, i32* %10
switch i32 %93, label %112 [
i32 0, label %94
i32 1, label %108
]
94: ; preds = %17
%95 = getelementptr inbounds [4 x %struct.TYPE_5__], [4 x %struct.TYPE_5__]* %12, i64 0, i64 0
%96 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %95, i32 0, i32 1
%97 = load i64, i64* %96
%98 = getelementptr inbounds [4 x %struct.TYPE_5__], [4 x %struct.TYPE_5__]* %12, i64 0, i64 3
%99 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %98, i32 0, i32 1
store i64 %97, i64* %99
%100 = getelementptr inbounds [4 x %struct.TYPE_5__], [4 x %struct.TYPE_5__]* %12, i64 0, i64 0
%101 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %100, i32 0, i32 0
%102 = load i64, i64* %101
%103 = getelementptr inbounds [4 x %struct.TYPE_5__], [4 x %struct.TYPE_5__]* %12, i64 0, i64 3
%104 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %103, i32 0, i32 0
store i64 %102, i64* %104
%105 = load i32, i32* %6
%106 = getelementptr inbounds [4 x %struct.TYPE_5__], [4 x %struct.TYPE_5__]* %12, i64 0, i64 0
%107 = call i32 @myline_polygon(i32 %105, %struct.TYPE_5__* %106, i32 4)
br label %115
108: ; preds = %17
%109 = load i32, i32* %6
%110 = getelementptr inbounds [4 x %struct.TYPE_5__], [4 x %struct.TYPE_5__]* %12, i64 0, i64 0
%111 = call i32 @mypolygon(i32 %109, %struct.TYPE_5__* %110, i32 3)
br label %115
112: ; preds = %17
%113 = load i32, i32* %10
%114 = call i32 @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str, i64 0, i64 0), i32 %113)
br label %115
115: ; preds = %112, %108, %94
br label %116
116: ; preds = %115
%117 = load i32, i32* %11
%118 = add nsw i32 %117, 1
store i32 %118, i32* %11
br label %13
119: ; preds = %13
ret void
}

LLVM IR (-O2):
%struct.TYPE_5__ = type { i64, i64 }
@.str = [53 x i8] c"draw2dgraph:DrawTriangles: fill type %i not defined\0A\00"
define void @DrawDownTriangles(i32 %0, %struct.TYPE_5__* nocapture %1, i32 %2, double %3, i32 %4) {
%6 = alloca [4 x %struct.TYPE_5__]
%7 = bitcast [4 x %struct.TYPE_5__]* %6 to i8*
%8 = icmp sgt i32 %2, 0
br i1 %8, label %9, label %47
9: ; preds = %5
%10 = getelementptr inbounds [4 x %struct.TYPE_5__], [4 x %struct.TYPE_5__]* %6, i64 0, i64 0
%11 = getelementptr inbounds [4 x %struct.TYPE_5__], [4 x %struct.TYPE_5__]* %6, i64 0, i64 0, i32 1
%12 = fmul double %3, 0x3FD5555555555555
%13 = getelementptr inbounds [4 x %struct.TYPE_5__], [4 x %struct.TYPE_5__]* %6, i64 0, i64 0, i32 0
%14 = getelementptr inbounds [4 x %struct.TYPE_5__], [4 x %struct.TYPE_5__]* %6, i64 0, i64 1, i32 1
%15 = getelementptr inbounds [4 x %struct.TYPE_5__], [4 x %struct.TYPE_5__]* %6, i64 0, i64 1, i32 0
%16 = getelementptr inbounds [4 x %struct.TYPE_5__], [4 x %struct.TYPE_5__]* %6, i64 0, i64 2, i32 1
%17 = fmul double %3, 0xBFE5555555555555
%18 = getelementptr inbounds [4 x %struct.TYPE_5__], [4 x %struct.TYPE_5__]* %6, i64 0, i64 2, i32 0
%19 = getelementptr inbounds [4 x %struct.TYPE_5__], [4 x %struct.TYPE_5__]* %6, i64 0, i64 3, i32 1
%20 = getelementptr inbounds [4 x %struct.TYPE_5__], [4 x %struct.TYPE_5__]* %6, i64 0, i64 3, i32 0
%21 = zext i32 %2 to i64
br label %22
22: ; preds = %9, %44
%23 = phi i64 [ 0, %9 ], [ %45, %44 ]
%24 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %1, i64 %23, i32 1
%25 = load i64, i64* %24
%26 = sitofp i64 %25 to double
%27 = fsub double %26, %3
%28 = fptosi double %27 to i64
store i64 %28, i64* %11
%29 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %1, i64 %23, i32 0
%30 = load i64, i64* %29
%31 = sitofp i64 %30 to double
%32 = call double @llvm.fmuladd.f64(double %12, double 0x3FFBB67AE8584CAA, double %31)
%33 = fptosi double %32 to i64
store i64 %33, i64* %13
%34 = fadd double %26, %3
%35 = fptosi double %34 to i64
store i64 %35, i64* %14
store i64 %33, i64* %15
store i64 %25, i64* %16
%36 = call double @llvm.fmuladd.f64(double %17, double 0x3FFBB67AE8584CAA, double %31)
%37 = fptosi double %36 to i64
store i64 %37, i64* %18
switch i32 %4, label %42 [
i32 0, label %38
i32 1, label %40
]
38: ; preds = %22
store i64 %28, i64* %19
store i64 %33, i64* %20
%39 = call i32 @myline_polygon(i32 %0, %struct.TYPE_5__* %10, i32 4)
br label %44
40: ; preds = %22
%41 = call i32 @mypolygon(i32 %0, %struct.TYPE_5__* %10, i32 3)
br label %44
42: ; preds = %22
%43 = call i32 @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str, i64 0, i64 0), i32 %4)
br label %44
44: ; preds = %38, %40, %42
%45 = add nuw nsw i64 %23, 1
%46 = icmp eq i64 %45, %21
br i1 %46, label %47, label %22
47: ; preds = %44, %5
ret void
}