#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 */

/* Variables and functions */
int /*<<< orphan*/ AddPolyPoint(int, int);
int /*<<< orphan*/ EndPolyLine();
int /*<<< orphan*/ StartPolyLine(int, int, int);
void DoSmallTriangles(int i) {
  int j, k;
  int x, y;
  for (j = 0; j < 10; j++) {
    for (k = 0; k < 5; k++) {
      x = j * 40 + 5 + i;
      y = k * 40 + 5;
      StartPolyLine(x, y, ((j + k) & 3) + 1);
      AddPolyPoint(x, y + 35);
      AddPolyPoint(x + 35, y + 30);
      EndPolyLine();
    }
  }
  StartPolyLine(100, 150, -1);
  AddPolyPoint(100, 100);
  AddPolyPoint(150, 100);
  AddPolyPoint(150, 150);
  EndPolyLine();
}


x86 assembly (clang, -O0):
<DoSmallTriangles>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0xa,-0x8(%rbp)
jge    11d2 <DoSmallTriangles+0xa2>
movl   $0x0,-0xc(%rbp)
cmpl   $0x5,-0xc(%rbp)
jge    11bf <DoSmallTriangles+0x8f>
imul   $0x28,-0x8(%rbp),%eax
add    $0x5,%eax
add    -0x4(%rbp),%eax
mov    %eax,-0x10(%rbp)
imul   $0x28,-0xc(%rbp),%eax
add    $0x5,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%edi
mov    -0x14(%rbp),%esi
mov    -0x8(%rbp),%edx
add    -0xc(%rbp),%edx
and    $0x3,%edx
add    $0x1,%edx
call   1050 <StartPolyLine@plt>
mov    -0x10(%rbp),%edi
mov    -0x14(%rbp),%esi
add    $0x23,%esi
call   1030 <AddPolyPoint@plt>
mov    -0x10(%rbp),%edi
add    $0x23,%edi
mov    -0x14(%rbp),%esi
add    $0x1e,%esi
call   1030 <AddPolyPoint@plt>
mov    $0x0,%al
call   1040 <EndPolyLine@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1153 <DoSmallTriangles+0x23>
jmp    11c4 <DoSmallTriangles+0x94>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1142 <DoSmallTriangles+0x12>
mov    $0x64,%edi
mov    $0x96,%esi
mov    $0xffffffff,%edx
call   1050 <StartPolyLine@plt>
mov    $0x64,%esi
mov    %esi,%edi
call   1030 <AddPolyPoint@plt>
mov    $0x96,%edi
mov    $0x64,%esi
call   1030 <AddPolyPoint@plt>
mov    $0x96,%esi
mov    %esi,%edi
call   1030 <AddPolyPoint@plt>
mov    $0x0,%al
call   1040 <EndPolyLine@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<DoSmallTriangles>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edi,%r15d
add    $0x28,%r15d
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
lea    -0x23(%r15),%ebp
mov    %ebx,%r14d
and    $0x3,%r14d
add    $0x1,%r14d
mov    %ebp,%edi
mov    $0x5,%esi
mov    %r14d,%edx
call   1050 <StartPolyLine@plt>
mov    %ebp,%edi
mov    $0x28,%esi
call   1030 <AddPolyPoint@plt>
mov    %r15d,%edi
mov    $0x23,%esi
call   1030 <AddPolyPoint@plt>
xor    %eax,%eax
call   1040 <EndPolyLine@plt>
lea    0x1(%rbx),%r12d
mov    %r12d,%edx
and    $0x3,%edx
add    $0x1,%edx
mov    %ebp,%edi
mov    $0x2d,%esi
call   1050 <StartPolyLine@plt>
mov    %ebp,%edi
mov    $0x50,%esi
call   1030 <AddPolyPoint@plt>
mov    %r15d,%edi
mov    $0x4b,%esi
call   1030 <AddPolyPoint@plt>
xor    %eax,%eax
call   1040 <EndPolyLine@plt>
lea    0x2(%rbx),%edx
and    $0x3,%edx
add    $0x1,%edx
mov    %ebp,%edi
mov    $0x55,%esi
call   1050 <StartPolyLine@plt>
mov    %ebp,%edi
mov    $0x78,%esi
call   1030 <AddPolyPoint@plt>
mov    %r15d,%edi
mov    $0x73,%esi
call   1030 <AddPolyPoint@plt>
xor    %eax,%eax
call   1040 <EndPolyLine@plt>
add    $0xffffffff,%ebx
and    $0x3,%ebx
add    $0x1,%ebx
mov    %ebp,%edi
mov    $0x7d,%esi
mov    %ebx,%edx
call   1050 <StartPolyLine@plt>
mov    %ebp,%edi
mov    $0xa0,%esi
call   1030 <AddPolyPoint@plt>
mov    %r15d,%edi
mov    $0x9b,%esi
call   1030 <AddPolyPoint@plt>
xor    %eax,%eax
call   1040 <EndPolyLine@plt>
mov    %ebp,%edi
mov    $0xa5,%esi
mov    %r14d,%edx
call   1050 <StartPolyLine@plt>
mov    %ebp,%edi
mov    $0xc8,%esi
call   1030 <AddPolyPoint@plt>
mov    %r15d,%edi
mov    $0xc3,%esi
call   1030 <AddPolyPoint@plt>
xor    %eax,%eax
call   1040 <EndPolyLine@plt>
add    $0x28,%r15d
mov    %r12d,%ebx
cmp    $0xa,%r12d
jne    1150 <DoSmallTriangles+0x20>
mov    $0x64,%edi
mov    $0x96,%esi
mov    $0xffffffff,%edx
call   1050 <StartPolyLine@plt>
mov    $0x64,%edi
mov    $0x64,%esi
call   1030 <AddPolyPoint@plt>
mov    $0x96,%edi
mov    $0x64,%esi
call   1030 <AddPolyPoint@plt>
mov    $0x96,%edi
mov    $0x96,%esi
call   1030 <AddPolyPoint@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <EndPolyLine@plt>

LLVM IR (-O0):
define void @DoSmallTriangles(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %2
store i32 0, i32* %3
br label %7
7: ; preds = %45, %1
%8 = load i32, i32* %3
%9 = icmp slt i32 %8, 10
br i1 %9, label %10, label %48
10: ; preds = %7
store i32 0, i32* %4
br label %11
11: ; preds = %41, %10
%12 = load i32, i32* %4
%13 = icmp slt i32 %12, 5
br i1 %13, label %14, label %44
14: ; preds = %11
%15 = load i32, i32* %3
%16 = mul nsw i32 %15, 40
%17 = add nsw i32 %16, 5
%18 = load i32, i32* %2
%19 = add nsw i32 %17, %18
store i32 %19, i32* %5
%20 = load i32, i32* %4
%21 = mul nsw i32 %20, 40
%22 = add nsw i32 %21, 5
store i32 %22, i32* %6
%23 = load i32, i32* %5
%24 = load i32, i32* %6
%25 = load i32, i32* %3
%26 = load i32, i32* %4
%27 = add nsw i32 %25, %26
%28 = and i32 %27, 3
%29 = add nsw i32 %28, 1
%30 = call i32 @StartPolyLine(i32 %23, i32 %24, i32 %29)
%31 = load i32, i32* %5
%32 = load i32, i32* %6
%33 = add nsw i32 %32, 35
%34 = call i32 @AddPolyPoint(i32 %31, i32 %33)
%35 = load i32, i32* %5
%36 = add nsw i32 %35, 35
%37 = load i32, i32* %6
%38 = add nsw i32 %37, 30
%39 = call i32 @AddPolyPoint(i32 %36, i32 %38)
%40 = call i32 (...) @EndPolyLine()
br label %41
41: ; preds = %14
%42 = load i32, i32* %4
%43 = add nsw i32 %42, 1
store i32 %43, i32* %4
br label %11
44: ; preds = %11
br label %45
45: ; preds = %44
%46 = load i32, i32* %3
%47 = add nsw i32 %46, 1
store i32 %47, i32* %3
br label %7
48: ; preds = %7
%49 = call i32 @StartPolyLine(i32 100, i32 150, i32 -1)
%50 = call i32 @AddPolyPoint(i32 100, i32 100)
%51 = call i32 @AddPolyPoint(i32 150, i32 100)
%52 = call i32 @AddPolyPoint(i32 150, i32 150)
%53 = call i32 (...) @EndPolyLine()
ret void
}

LLVM IR (-O2):
define void @DoSmallTriangles(i32 %0) {
%2 = add i32 %0, 5
br label %3
3: ; preds = %1, %3
%4 = phi i32 [ 0, %1 ], [ %14, %3 ]
%5 = mul nuw nsw i32 %4, 40
%6 = add i32 %2, %5
%7 = add nsw i32 %6, 35
%8 = and i32 %4, 3
%9 = add nuw nsw i32 %8, 1
%10 = tail call i32 @StartPolyLine(i32 %6, i32 5, i32 %9)
%11 = tail call i32 @AddPolyPoint(i32 %6, i32 40)
%12 = tail call i32 @AddPolyPoint(i32 %7, i32 35)
%13 = tail call i32 (...) @EndPolyLine()
%14 = add nuw nsw i32 %4, 1
%15 = and i32 %14, 3
%16 = add nuw nsw i32 %15, 1
%17 = tail call i32 @StartPolyLine(i32 %6, i32 45, i32 %16)
%18 = tail call i32 @AddPolyPoint(i32 %6, i32 80)
%19 = tail call i32 @AddPolyPoint(i32 %7, i32 75)
%20 = tail call i32 (...) @EndPolyLine()
%21 = add nuw nsw i32 %4, 2
%22 = and i32 %21, 3
%23 = add nuw nsw i32 %22, 1
%24 = tail call i32 @StartPolyLine(i32 %6, i32 85, i32 %23)
%25 = tail call i32 @AddPolyPoint(i32 %6, i32 120)
%26 = tail call i32 @AddPolyPoint(i32 %7, i32 115)
%27 = tail call i32 (...) @EndPolyLine()
%28 = add nuw nsw i32 %4, 3
%29 = and i32 %28, 3
%30 = add nuw nsw i32 %29, 1
%31 = tail call i32 @StartPolyLine(i32 %6, i32 125, i32 %30)
%32 = tail call i32 @AddPolyPoint(i32 %6, i32 160)
%33 = tail call i32 @AddPolyPoint(i32 %7, i32 155)
%34 = tail call i32 (...) @EndPolyLine()
%35 = and i32 %4, 3
%36 = add nuw nsw i32 %35, 1
%37 = tail call i32 @StartPolyLine(i32 %6, i32 165, i32 %36)
%38 = tail call i32 @AddPolyPoint(i32 %6, i32 200)
%39 = tail call i32 @AddPolyPoint(i32 %7, i32 195)
%40 = tail call i32 (...) @EndPolyLine()
%41 = icmp eq i32 %14, 10
br i1 %41, label %42, label %3
42: ; preds = %3
%43 = tail call i32 @StartPolyLine(i32 100, i32 150, i32 -1)
%44 = tail call i32 @AddPolyPoint(i32 100, i32 100)
%45 = tail call i32 @AddPolyPoint(i32 150, i32 100)
%46 = tail call i32 @AddPolyPoint(i32 150, i32 150)
%47 = tail call i32 (...) @EndPolyLine()
ret void
}