#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 DoFlipTriangles(int i) {
  int j, x, y;
  for (j = 10; j < 150; j += 10) {
    x = j * 3;
    y = i;
    StartPolyLine(x, y, 4 + (j / 10));
    x = i + j * 2;
    y = 50 + i;
    AddPolyPoint(x, y);
    x = j * 4;
    y = 100 + i;
    AddPolyPoint(x, y);
    EndPolyLine();
  }
}


x86 assembly (clang, -O0):
<DoFlipTriangles>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0xa,-0x8(%rbp)
cmpl   $0x96,-0x8(%rbp)
jge    11cb <DoFlipTriangles+0x9b>
imul   $0x3,-0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,%edx
add    $0x4,%edx
call   1050 <StartPolyLine@plt>
mov    -0x4(%rbp),%eax
mov    -0x8(%rbp),%ecx
shl    $0x1,%ecx
add    %ecx,%eax
mov    %eax,-0xc(%rbp)
mov    -0x4(%rbp),%eax
add    $0x32,%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
call   1030 <AddPolyPoint@plt>
mov    -0x8(%rbp),%eax
shl    $0x2,%eax
mov    %eax,-0xc(%rbp)
mov    -0x4(%rbp),%eax
add    $0x64,%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
call   1030 <AddPolyPoint@plt>
mov    $0x0,%al
call   1040 <EndPolyLine@plt>
mov    -0x8(%rbp),%eax
add    $0xa,%eax
mov    %eax,-0x8(%rbp)
jmp    1142 <DoFlipTriangles+0x12>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<DoFlipTriangles>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edi,%r12d
lea    0x32(%r12),%eax
mov    %eax,0x4(%rsp)
lea    0x64(%r12),%eax
mov    %eax,(%rsp)
lea    0x14(%r12),%r13d
mov    $0x1e,%ebx
mov    $0x28,%ebp
mov    $0x5,%r14d
xor    %r15d,%r15d
nopw   0x0(%rax,%rax,1)
mov    %ebx,%edi
mov    %r12d,%esi
mov    %r14d,%edx
call   1050 <StartPolyLine@plt>
mov    %r13d,%edi
mov    0x4(%rsp),%esi
call   1030 <AddPolyPoint@plt>
mov    %ebp,%edi
mov    (%rsp),%esi
call   1030 <AddPolyPoint@plt>
xor    %eax,%eax
call   1040 <EndPolyLine@plt>
add    $0xa,%r15d
add    $0x14,%r13d
add    $0x1e,%ebx
add    $0x28,%ebp
add    $0x1,%r14d
cmp    $0x8c,%r15d
jb     1170 <DoFlipTriangles+0x40>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @DoFlipTriangles(i32 %0) {
%2 = add nsw i32 %0, 50
%3 = add nsw i32 %0, 100
br label %4
4: ; preds = %1, %4
%5 = phi i32 [ 10, %1 ], [ %18, %4 ]
%6 = mul nuw nsw i32 %5, 3
%7 = trunc i32 %5 to i8
%8 = udiv i8 %7, 10
%9 = add nuw nsw i8 %8, 4
%10 = zext i8 %9 to i32
%11 = tail call i32 @StartPolyLine(i32 %6, i32 %0, i32 %10)
%12 = shl nuw nsw i32 %5, 1
%13 = add nsw i32 %12, %0
%14 = tail call i32 @AddPolyPoint(i32 %13, i32 %2)
%15 = shl nuw nsw i32 %5, 2
%16 = tail call i32 @AddPolyPoint(i32 %15, i32 %3)
%17 = tail call i32 (...) @EndPolyLine()
%18 = add nuw nsw i32 %5, 10
%19 = icmp ult i32 %5, 140
br i1 %19, label %4, label %20
20: ; preds = %4
ret void
}