#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ write_regular_polygon(int, int, int, int, int, int, int, int,
                                         int /*<<< orphan*/ *);
int main() {
  FILE *f = fopen("regpoly.dat", "w");
  int x, y;
  for (x = 0; x < 8; x++)
    for (y = 0; y < 8; y++)
      write_regular_polygon(x * 100 + 50, y * 100 + 50, 45, x + 3,
                            ((2 * 3.14159265359) / 8) * y, 36 * x, 16 * (x + y),
                            255 - 36 * y, f);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xed2(%rip),%rdi
lea    0xed7(%rip),%rsi
call   1030 <fopen@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x8,-0x14(%rbp)
jge    11ed <main+0xcd>
movl   $0x0,-0x18(%rbp)
cmpl   $0x8,-0x18(%rbp)
jge    11da <main+0xba>
imul   $0x64,-0x14(%rbp),%edi
add    $0x32,%edi
imul   $0x64,-0x18(%rbp),%esi
add    $0x32,%esi
mov    -0x14(%rbp),%ecx
add    $0x3,%ecx
cvtsi2sdl -0x18(%rbp),%xmm1
movsd  0xe77(%rip),%xmm0
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%r8d
imul   $0x24,-0x14(%rbp),%r9d
mov    -0x14(%rbp),%r11d
add    -0x18(%rbp),%r11d
shl    $0x4,%r11d
imul   $0x24,-0x18(%rbp),%eax
mov    $0xff,%r10d
sub    %eax,%r10d
mov    -0x10(%rbp),%rax
mov    $0x2d,%edx
mov    %r11d,(%rsp)
mov    %r10d,0x8(%rsp)
mov    %rax,0x10(%rsp)
call   1040 <write_regular_polygon@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    115e <main+0x3e>
jmp    11df <main+0xbf>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    114d <main+0x2d>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xedb(%rip),%rdi
lea    0xee0(%rip),%rsi
call   1030 <fopen@plt>
mov    %rax,%r15
xor    %edx,%edx
movsd  0xeb2(%rip),%xmm1
xor    %ecx,%ecx
imul   $0x64,%ecx,%r12d
add    $0x32,%r12d
lea    0x3(%rcx),%esi
mov    %esi,0xc(%rsp)
mov    %rcx,0x10(%rsp)
lea    0x0(,%rcx,4),%ecx
lea    (%rcx,%rcx,8),%ebx
xorps  %xmm0,%xmm0
mov    $0xff,%r13d
mov    $0x32,%ebp
mov    %edx,0x8(%rsp)
mov    %edx,%r14d
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movsd  %xmm0,(%rsp)
movsd  (%rsp),%xmm0
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%r8d
sub    $0x8,%rsp
mov    %r12d,%edi
mov    %ebp,%esi
mov    $0x2d,%edx
mov    0x14(%rsp),%ecx
mov    %ebx,%r9d
push   %r15
push   %r13
push   %r14
call   1040 <write_regular_polygon@plt>
movsd  0xe3d(%rip),%xmm0
movsd  0xe2d(%rip),%xmm1
add    $0x20,%rsp
movsd  (%rsp),%xmm2
addsd  %xmm0,%xmm2
movsd  %xmm2,(%rsp)
movsd  (%rsp),%xmm0
add    $0xffffffdc,%r13d
add    $0x10,%r14d
add    $0x64,%ebp
cmp    $0xffffffdf,%r13d
jne    1190 <main+0x70>
mov    0x10(%rsp),%rcx
add    $0x1,%ecx
mov    0x8(%rsp),%edx
add    $0x10,%edx
cmp    $0x8,%ecx
jne    1150 <main+0x30>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [12 x i8] c"regpoly.dat\00"
@.str.1 = [2 x i8] c"w\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %5, i32** %2
store i32 0, i32* %3
br label %6
6: ; preds = %41, %0
%7 = load i32, i32* %3
%8 = icmp slt i32 %7, 8
br i1 %8, label %9, label %44
9: ; preds = %6
store i32 0, i32* %4
br label %10
10: ; preds = %37, %9
%11 = load i32, i32* %4
%12 = icmp slt i32 %11, 8
br i1 %12, label %13, label %40
13: ; preds = %10
%14 = load i32, i32* %3
%15 = mul nsw i32 %14, 100
%16 = add nsw i32 %15, 50
%17 = load i32, i32* %4
%18 = mul nsw i32 %17, 100
%19 = add nsw i32 %18, 50
%20 = load i32, i32* %3
%21 = add nsw i32 %20, 3
%22 = load i32, i32* %4
%23 = sitofp i32 %22 to double
%24 = fmul double 0x3FE921FB54442EEA, %23
%25 = fptosi double %24 to i32
%26 = load i32, i32* %3
%27 = mul nsw i32 36, %26
%28 = load i32, i32* %3
%29 = load i32, i32* %4
%30 = add nsw i32 %28, %29
%31 = mul nsw i32 16, %30
%32 = load i32, i32* %4
%33 = mul nsw i32 36, %32
%34 = sub nsw i32 255, %33
%35 = load i32*, i32** %2
%36 = call i32 @write_regular_polygon(i32 %16, i32 %19, i32 45, i32 %21, i32 %25, i32 %27, i32 %31, i32 %34, i32* %35)
br label %37
37: ; preds = %13
%38 = load i32, i32* %4
%39 = add nsw i32 %38, 1
store i32 %39, i32* %4
br label %10
40: ; preds = %10
br label %41
41: ; preds = %40
%42 = load i32, i32* %3
%43 = add nsw i32 %42, 1
store i32 %43, i32* %3
br label %6
44: ; preds = %6
ret i32 0
}

LLVM IR (-O2):
@.str = [12 x i8] c"regpoly.dat\00"
@.str.1 = [2 x i8] c"w\00"
define i32 @main() {
%1 = tail call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %2
2: ; preds = %0, %22
%3 = phi i32 [ 0, %0 ], [ %23, %22 ]
%4 = mul nuw nsw i32 %3, 100
%5 = add nuw nsw i32 %4, 50
%6 = add nuw nsw i32 %3, 3
%7 = mul nuw nsw i32 %3, 36
br label %8
8: ; preds = %2, %8
%9 = phi i32 [ 0, %2 ], [ %20, %8 ]
%10 = mul nuw nsw i32 %9, 100
%11 = add nuw nsw i32 %10, 50
%12 = sitofp i32 %9 to double
%13 = fmul double %12, 0x3FE921FB54442EEA
%14 = fptosi double %13 to i32
%15 = add nuw nsw i32 %9, %3
%16 = shl nsw i32 %15, 4
%17 = mul nsw i32 %9, -36
%18 = add nsw i32 %17, 255
%19 = tail call i32 @write_regular_polygon(i32 %5, i32 %11, i32 45, i32 %6, i32 %14, i32 %7, i32 %16, i32 %18, i32* %1)
%20 = add nuw nsw i32 %9, 1
%21 = icmp eq i32 %20, 8
br i1 %21, label %22, label %8
22: ; preds = %8
%23 = add nuw nsw i32 %3, 1
%24 = icmp eq i32 %23, 8
br i1 %24, label %25, label %2
25: ; preds = %22
ret i32 0
}