#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*/ createLine(float, float, float, float);
int rand();
float round(int);
void createPolygon() {
  float points[3][2];
  int x_size, y_size;
  for (int i = 0; i < 3; i++) {
    points[i][0] = round(rand() % 500);
    points[i][1] = round(rand() % 500);
  }
  for (int i = 1; i < 3; i++) {
    createLine(points[i - 1][0], points[i - 1][1], points[i][0], points[i][1]);
  }
  createLine(points[0][0], points[0][1], points[3 - 1][0], points[3 - 1][1]);
}


x86 assembly (clang, -O0):
<createPolygon>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x2c(%rbp)
cmpl   $0x3,-0x2c(%rbp)
jge    1197 <createPolygon+0x67>
mov    $0x0,%al
call   1050 <rand@plt>
mov    $0x1f4,%ecx
cltd
idiv   %ecx
mov    %edx,%edi
call   1040 <round@plt>
movslq -0x2c(%rbp),%rax
movss  %xmm0,-0x20(%rbp,%rax,8)
mov    $0x0,%al
call   1050 <rand@plt>
mov    $0x1f4,%ecx
cltd
idiv   %ecx
mov    %edx,%edi
call   1040 <round@plt>
movslq -0x2c(%rbp),%rax
movss  %xmm0,-0x1c(%rbp,%rax,8)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    113f <createPolygon+0xf>
movl   $0x1,-0x30(%rbp)
cmpl   $0x3,-0x30(%rbp)
jge    11eb <createPolygon+0xbb>
mov    -0x30(%rbp),%eax
sub    $0x1,%eax
cltq
movss  -0x20(%rbp,%rax,8),%xmm0
mov    -0x30(%rbp),%eax
sub    $0x1,%eax
cltq
movss  -0x1c(%rbp,%rax,8),%xmm1
movslq -0x30(%rbp),%rax
movss  -0x20(%rbp,%rax,8),%xmm2
movslq -0x30(%rbp),%rax
movss  -0x1c(%rbp,%rax,8),%xmm3
call   1030 <createLine@plt>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    119e <createPolygon+0x6e>
movss  -0x20(%rbp),%xmm0
movss  -0x1c(%rbp),%xmm1
movss  -0x10(%rbp),%xmm2
movss  -0xc(%rbp),%xmm3
call   1030 <createLine@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<createPolygon>:
sub    $0x18,%rsp
xor    %eax,%eax
call   1050 <rand@plt>
movslq %eax,%rdi
imul   $0x10624dd3,%rdi,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x25,%rax
add    %ecx,%eax
imul   $0x1f4,%eax,%eax
sub    %eax,%edi
call   1040 <round@plt>
movss  %xmm0,0x14(%rsp)
xor    %eax,%eax
call   1050 <rand@plt>
movslq %eax,%rdi
imul   $0x10624dd3,%rdi,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x25,%rax
add    %ecx,%eax
imul   $0x1f4,%eax,%eax
sub    %eax,%edi
call   1040 <round@plt>
movss  %xmm0,0x10(%rsp)
xor    %eax,%eax
call   1050 <rand@plt>
movslq %eax,%rdi
imul   $0x10624dd3,%rdi,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x25,%rax
add    %ecx,%eax
imul   $0x1f4,%eax,%eax
sub    %eax,%edi
call   1040 <round@plt>
movss  %xmm0,0xc(%rsp)
xor    %eax,%eax
call   1050 <rand@plt>
movslq %eax,%rdi
imul   $0x10624dd3,%rdi,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x25,%rax
add    %ecx,%eax
imul   $0x1f4,%eax,%eax
sub    %eax,%edi
call   1040 <round@plt>
movss  %xmm0,0x8(%rsp)
xor    %eax,%eax
call   1050 <rand@plt>
movslq %eax,%rdi
imul   $0x10624dd3,%rdi,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x25,%rax
add    %ecx,%eax
imul   $0x1f4,%eax,%eax
sub    %eax,%edi
call   1040 <round@plt>
movss  %xmm0,0x4(%rsp)
xor    %eax,%eax
call   1050 <rand@plt>
movslq %eax,%rdi
imul   $0x10624dd3,%rdi,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x25,%rax
add    %ecx,%eax
imul   $0x1f4,%eax,%eax
sub    %eax,%edi
call   1040 <round@plt>
movss  %xmm0,(%rsp)
movss  0x14(%rsp),%xmm0
movss  0x10(%rsp),%xmm1
movss  0xc(%rsp),%xmm2
movss  0x8(%rsp),%xmm3
call   1030 <createLine@plt>
movss  0xc(%rsp),%xmm0
movss  0x8(%rsp),%xmm1
movss  0x4(%rsp),%xmm2
movss  (%rsp),%xmm3
call   1030 <createLine@plt>
movss  0x14(%rsp),%xmm0
movss  0x10(%rsp),%xmm1
movss  0x4(%rsp),%xmm2
movss  (%rsp),%xmm3
add    $0x18,%rsp
jmp    1030 <createLine@plt>

LLVM IR (-O0):
define void @createPolygon() {
%1 = alloca [3 x [2 x float]]
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %4
br label %6
6: ; preds = %24, %0
%7 = load i32, i32* %4
%8 = icmp slt i32 %7, 3
br i1 %8, label %9, label %27
9: ; preds = %6
%10 = call i32 (...) @rand()
%11 = srem i32 %10, 500
%12 = call float @round(i32 %11)
%13 = load i32, i32* %4
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds [3 x [2 x float]], [3 x [2 x float]]* %1, i64 0, i64 %14
%16 = getelementptr inbounds [2 x float], [2 x float]* %15, i64 0, i64 0
store float %12, float* %16
%17 = call i32 (...) @rand()
%18 = srem i32 %17, 500
%19 = call float @round(i32 %18)
%20 = load i32, i32* %4
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [3 x [2 x float]], [3 x [2 x float]]* %1, i64 0, i64 %21
%23 = getelementptr inbounds [2 x float], [2 x float]* %22, i64 0, i64 1
store float %19, float* %23
br label %24
24: ; preds = %9
%25 = load i32, i32* %4
%26 = add nsw i32 %25, 1
store i32 %26, i32* %4
br label %6
27: ; preds = %6
store i32 1, i32* %5
br label %28
28: ; preds = %55, %27
%29 = load i32, i32* %5
%30 = icmp slt i32 %29, 3
br i1 %30, label %31, label %58
31: ; preds = %28
%32 = load i32, i32* %5
%33 = sub nsw i32 %32, 1
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [3 x [2 x float]], [3 x [2 x float]]* %1, i64 0, i64 %34
%36 = getelementptr inbounds [2 x float], [2 x float]* %35, i64 0, i64 0
%37 = load float, float* %36
%38 = load i32, i32* %5
%39 = sub nsw i32 %38, 1
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds [3 x [2 x float]], [3 x [2 x float]]* %1, i64 0, i64 %40
%42 = getelementptr inbounds [2 x float], [2 x float]* %41, i64 0, i64 1
%43 = load float, float* %42
%44 = load i32, i32* %5
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds [3 x [2 x float]], [3 x [2 x float]]* %1, i64 0, i64 %45
%47 = getelementptr inbounds [2 x float], [2 x float]* %46, i64 0, i64 0
%48 = load float, float* %47
%49 = load i32, i32* %5
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds [3 x [2 x float]], [3 x [2 x float]]* %1, i64 0, i64 %50
%52 = getelementptr inbounds [2 x float], [2 x float]* %51, i64 0, i64 1
%53 = load float, float* %52
%54 = call i32 @createLine(float %37, float %43, float %48, float %53)
br label %55
55: ; preds = %31
%56 = load i32, i32* %5
%57 = add nsw i32 %56, 1
store i32 %57, i32* %5
br label %28
58: ; preds = %28
%59 = getelementptr inbounds [3 x [2 x float]], [3 x [2 x float]]* %1, i64 0, i64 0
%60 = getelementptr inbounds [2 x float], [2 x float]* %59, i64 0, i64 0
%61 = load float, float* %60
%62 = getelementptr inbounds [3 x [2 x float]], [3 x [2 x float]]* %1, i64 0, i64 0
%63 = getelementptr inbounds [2 x float], [2 x float]* %62, i64 0, i64 1
%64 = load float, float* %63
%65 = getelementptr inbounds [3 x [2 x float]], [3 x [2 x float]]* %1, i64 0, i64 2
%66 = getelementptr inbounds [2 x float], [2 x float]* %65, i64 0, i64 0
%67 = load float, float* %66
%68 = getelementptr inbounds [3 x [2 x float]], [3 x [2 x float]]* %1, i64 0, i64 2
%69 = getelementptr inbounds [2 x float], [2 x float]* %68, i64 0, i64 1
%70 = load float, float* %69
%71 = call i32 @createLine(float %61, float %64, float %67, float %70)
ret void
}

LLVM IR (-O2):
define void @createPolygon() {
%1 = tail call i32 (...) @rand()
%2 = srem i32 %1, 500
%3 = tail call float @round(i32 %2)
%4 = tail call i32 (...) @rand()
%5 = srem i32 %4, 500
%6 = tail call float @round(i32 %5)
%7 = tail call i32 (...) @rand()
%8 = srem i32 %7, 500
%9 = tail call float @round(i32 %8)
%10 = tail call i32 (...) @rand()
%11 = srem i32 %10, 500
%12 = tail call float @round(i32 %11)
%13 = tail call i32 (...) @rand()
%14 = srem i32 %13, 500
%15 = tail call float @round(i32 %14)
%16 = tail call i32 (...) @rand()
%17 = srem i32 %16, 500
%18 = tail call float @round(i32 %17)
%19 = tail call i32 @createLine(float %3, float %6, float %9, float %12)
%20 = tail call i32 @createLine(float %9, float %12, float %15, float %18)
%21 = tail call i32 @createLine(float %3, float %6, float %15, float %18)
ret void
}