#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 DrawUpTriangles(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):
<DrawUpTriangles>:
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 <DrawUpTriangles+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),%xmm3
ff
movsd  -0xb0(%rbp),%xmm1
ff
movsd  -0xa8(%rbp),%xmm2
ff
movaps %xmm0,%xmm4
movsd  -0x90(%rbp),%xmm0
ff
mulsd  %xmm4,%xmm3
subsd  %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),%xmm2
ff
movsd  -0x98(%rbp),%xmm1
ff
movaps %xmm0,%xmm3
movsd  -0x90(%rbp),%xmm0
ff
mulsd  %xmm3,%xmm2
subsd  %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,-0x88(%rbp)
ff
movsd  -0x20(%rbp),%xmm1
movsd  0xd3a(%rip),%xmm2
mulsd  %xmm2,%xmm1
movsd  %xmm1,-0x80(%rbp)
call   1050 <sqrt@plt>
movsd  -0x88(%rbp),%xmm1
ff
movaps %xmm0,%xmm2
movsd  -0x80(%rbp),%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rax
mov    %rax,-0x50(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x74(%rbp)
test   %eax,%eax
je     1329 <DrawUpTriangles+0x1e9>
jmp    1318 <DrawUpTriangles+0x1d8>
mov    -0x74(%rbp),%eax
sub    $0x1,%eax
je     134f <DrawUpTriangles+0x20f>
jmp    1365 <DrawUpTriangles+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 <DrawUpTriangles+0x234>
mov    -0x4(%rbp),%edi
lea    -0x70(%rbp),%rsi
mov    $0x3,%edx
call   1060 <mypolygon@plt>
jmp    1374 <DrawUpTriangles+0x234>
mov    -0x24(%rbp),%esi
lea    0xca9(%rip),%rdi
call   1040 <printf@plt>
jmp    1379 <DrawUpTriangles+0x239>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1164 <DrawUpTriangles+0x24>
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<DrawUpTriangles>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
movsd  %xmm0,0x8(%rsp)
test   %edx,%edx
jle    1275 <DrawUpTriangles+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 <DrawUpTriangles+0x8b>
nop
lea    0xe71(%rip),%rdi
mov    %ebp,%esi
call   1040 <printf@plt>
add    $0x10,%r12
cmp    %r12,%r13
je     1275 <DrawUpTriangles+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 <DrawUpTriangles+0x130>
test   %ebp,%ebp
jne    11a0 <DrawUpTriangles+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 <DrawUpTriangles+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 <DrawUpTriangles+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 @DrawUpTriangles(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 = %117, %5
%14 = load i32, i32* %11
%15 = load i32, i32* %8
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %120
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 = fneg double %38
%41 = call double @llvm.fmuladd.f64(double %40, double %39, double %36)
%42 = fptosi double %41 to i64
%43 = getelementptr inbounds [4 x %struct.TYPE_5__], [4 x %struct.TYPE_5__]* %12, i64 0, i64 0
%44 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %43, i32 0, i32 0
store i64 %42, i64* %44
%45 = load %struct.TYPE_5__*, %struct.TYPE_5__** %7
%46 = load i32, i32* %11
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %45, i64 %47
%49 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %48, i32 0, i32 1
%50 = load i64, i64* %49
%51 = sitofp i64 %50 to double
%52 = load double, double* %9
%53 = fadd double %51, %52
%54 = fptosi double %53 to i64
%55 = getelementptr inbounds [4 x %struct.TYPE_5__], [4 x %struct.TYPE_5__]* %12, i64 0, i64 1
%56 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %55, i32 0, i32 1
store i64 %54, i64* %56
%57 = load %struct.TYPE_5__*, %struct.TYPE_5__** %7
%58 = load i32, i32* %11
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %57, i64 %59
%61 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %60, i32 0, i32 0
%62 = load i64, i64* %61
%63 = sitofp i64 %62 to double
%64 = load double, double* %9
%65 = fmul double %64, 0x3FD5555555555555
%66 = call double @sqrt(double 3.000000e+00)
%67 = fneg double %65
%68 = call double @llvm.fmuladd.f64(double %67, double %66, double %63)
%69 = fptosi double %68 to i64
%70 = getelementptr inbounds [4 x %struct.TYPE_5__], [4 x %struct.TYPE_5__]* %12, i64 0, i64 1
%71 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %70, i32 0, i32 0
store i64 %69, i64* %71
%72 = load %struct.TYPE_5__*, %struct.TYPE_5__** %7
%73 = load i32, i32* %11
%74 = sext i32 %73 to i64
%75 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %72, i64 %74
%76 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %75, i32 0, i32 1
%77 = load i64, i64* %76
%78 = getelementptr inbounds [4 x %struct.TYPE_5__], [4 x %struct.TYPE_5__]* %12, i64 0, i64 2
%79 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %78, i32 0, i32 1
store i64 %77, i64* %79
%80 = load %struct.TYPE_5__*, %struct.TYPE_5__** %7
%81 = load i32, i32* %11
%82 = sext i32 %81 to i64
%83 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %80, i64 %82
%84 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %83, i32 0, i32 0
%85 = load i64, i64* %84
%86 = sitofp i64 %85 to double
%87 = load double, double* %9
%88 = fmul double %87, 0x3FE5555555555555
%89 = call double @sqrt(double 3.000000e+00)
%90 = call double @llvm.fmuladd.f64(double %88, double %89, double %86)
%91 = fptosi double %90 to i64
%92 = getelementptr inbounds [4 x %struct.TYPE_5__], [4 x %struct.TYPE_5__]* %12, i64 0, i64 2
%93 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %92, i32 0, i32 0
store i64 %91, i64* %93
%94 = load i32, i32* %10
switch i32 %94, label %113 [
i32 0, label %95
i32 1, label %109
]
95: ; preds = %17
%96 = getelementptr inbounds [4 x %struct.TYPE_5__], [4 x %struct.TYPE_5__]* %12, i64 0, i64 0
%97 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %96, i32 0, i32 1
%98 = load i64, i64* %97
%99 = getelementptr inbounds [4 x %struct.TYPE_5__], [4 x %struct.TYPE_5__]* %12, i64 0, i64 3
%100 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %99, i32 0, i32 1
store i64 %98, i64* %100
%101 = getelementptr inbounds [4 x %struct.TYPE_5__], [4 x %struct.TYPE_5__]* %12, i64 0, i64 0
%102 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %101, i32 0, i32 0
%103 = load i64, i64* %102
%104 = getelementptr inbounds [4 x %struct.TYPE_5__], [4 x %struct.TYPE_5__]* %12, i64 0, i64 3
%105 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %104, i32 0, i32 0
store i64 %103, i64* %105
%106 = load i32, i32* %6
%107 = getelementptr inbounds [4 x %struct.TYPE_5__], [4 x %struct.TYPE_5__]* %12, i64 0, i64 0
%108 = call i32 @myline_polygon(i32 %106, %struct.TYPE_5__* %107, i32 4)
br label %116
109: ; preds = %17
%110 = load i32, i32* %6
%111 = getelementptr inbounds [4 x %struct.TYPE_5__], [4 x %struct.TYPE_5__]* %12, i64 0, i64 0
%112 = call i32 @mypolygon(i32 %110, %struct.TYPE_5__* %111, i32 3)
br label %116
113: ; preds = %17
%114 = load i32, i32* %10
%115 = call i32 @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str, i64 0, i64 0), i32 %114)
br label %116
116: ; preds = %113, %109, %95
br label %117
117: ; preds = %116
%118 = load i32, i32* %11
%119 = add nsw i32 %118, 1
store i32 %119, i32* %11
br label %13
120: ; 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 @DrawUpTriangles(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, 0xBFD5555555555555
%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, 0x3FE5555555555555
%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
}