#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*/ array_line_entry(int, int, int, int);
int /*<<< orphan*/ bresline(int, int, int, int, int);
int /*<<< orphan*/ delay(int);
int /*<<< orphan*/ getmousepos(int *, int *, int *);
int /*<<< orphan*/ hidemouseptr();
int /*<<< orphan*/ showmouseptr();
void user_poly() {
  int inix, iniy, curx1, cury1, curx2, cury2;
  int mousex, mousey, button;
  getmousepos(&button, &mousex, &mousey);
  inix = mousex;
  iniy = mousey;
  curx1 = inix;
  cury1 = iniy;
  for (; button != 2; getmousepos(&button, &mousex, &mousey)) {
    if (button == 1) {
      curx2 = mousex;
      cury2 = mousey;
      hidemouseptr();
      array_line_entry(curx1, cury1, curx2, cury2);
      bresline(curx1, cury1, curx2, cury2, 1);
      showmouseptr();
      curx1 = curx2;
      cury1 = cury2;
      delay(200);
    }
  }
  hidemouseptr();
  array_line_entry(curx1, cury1, inix, iniy);
  bresline(curx1, cury1, inix, iniy, 1);
  showmouseptr();
}


x86 assembly (clang, -O0):
<user_poly>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
lea    -0x24(%rbp),%rdi
lea    -0x1c(%rbp),%rsi
lea    -0x20(%rbp),%rdx
call   1050 <getmousepos@plt>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
cmpl   $0x2,-0x24(%rbp)
je     1218 <user_poly+0xb8>
cmpl   $0x1,-0x24(%rbp)
jne    11fd <user_poly+0x9d>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    $0x0,%al
call   1080 <hidemouseptr@plt>
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
call   1030 <array_line_entry@plt>
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
mov    $0x1,%r8d
call   1060 <bresline@plt>
mov    $0x0,%al
call   1070 <showmouseptr@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    $0xc8,%edi
call   1040 <delay@plt>
jmp    1202 <user_poly+0xa2>
lea    -0x24(%rbp),%rdi
lea    -0x1c(%rbp),%rsi
lea    -0x20(%rbp),%rdx
call   1050 <getmousepos@plt>
jmp    1191 <user_poly+0x31>
mov    $0x0,%al
call   1080 <hidemouseptr@plt>
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    -0x4(%rbp),%edx
mov    -0x8(%rbp),%ecx
call   1030 <array_line_entry@plt>
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    -0x4(%rbp),%edx
mov    -0x8(%rbp),%ecx
mov    $0x1,%r8d
call   1060 <bresline@plt>
mov    $0x0,%al
call   1070 <showmouseptr@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<user_poly>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0x4(%rsp),%r14
lea    0xc(%rsp),%rbx
lea    0x8(%rsp),%r13
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %r13,%rdx
call   1050 <getmousepos@plt>
mov    0xc(%rsp),%r15d
mov    0x8(%rsp),%r12d
mov    %r12d,0x10(%rsp)
mov    %r12d,(%rsp)
mov    %r15d,0x14(%rsp)
jmp    1214 <user_poly+0xb4>
cs nopw 0x0(%rax,%rax,1)
nop
mov    0xc(%rsp),%r14d
mov    0x8(%rsp),%ebp
xor    %eax,%eax
call   1080 <hidemouseptr@plt>
mov    %r15d,%edi
mov    (%rsp),%r12d
mov    %r12d,%esi
mov    %r14d,%edx
mov    %ebp,%ecx
call   1030 <array_line_entry@plt>
mov    %r15d,%edi
mov    %r12d,%esi
mov    %r14d,%edx
mov    %ebp,%ecx
mov    $0x1,%r8d
call   1060 <bresline@plt>
xor    %eax,%eax
call   1070 <showmouseptr@plt>
mov    $0xc8,%edi
call   1040 <delay@plt>
mov    %ebp,(%rsp)
mov    %r14d,%r15d
lea    0x4(%rsp),%r14
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %r13,%rdx
call   1050 <getmousepos@plt>
mov    0x4(%rsp),%eax
cmp    $0x1,%eax
je     11b0 <user_poly+0x50>
cmp    $0x2,%eax
jne    1206 <user_poly+0xa6>
xor    %eax,%eax
call   1080 <hidemouseptr@plt>
mov    %r15d,%edi
mov    (%rsp),%r14d
mov    %r14d,%esi
mov    0x14(%rsp),%ebx
mov    %ebx,%edx
mov    0x10(%rsp),%ebp
mov    %ebp,%ecx
call   1030 <array_line_entry@plt>
mov    %r15d,%edi
mov    %r14d,%esi
mov    %ebx,%edx
mov    %ebp,%ecx
mov    $0x1,%r8d
call   1060 <bresline@plt>
xor    %eax,%eax
call   1070 <showmouseptr@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @user_poly() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = call i32 @getmousepos(i32* %9, i32* %7, i32* %8)
%11 = load i32, i32* %7
store i32 %11, i32* %1
%12 = load i32, i32* %8
store i32 %12, i32* %2
%13 = load i32, i32* %1
store i32 %13, i32* %3
%14 = load i32, i32* %2
store i32 %14, i32* %4
br label %15
15: ; preds = %40, %0
%16 = load i32, i32* %9
%17 = icmp ne i32 %16, 2
br i1 %17, label %18, label %42
18: ; preds = %15
%19 = load i32, i32* %9
%20 = icmp eq i32 %19, 1
br i1 %20, label %21, label %39
21: ; preds = %18
%22 = load i32, i32* %7
store i32 %22, i32* %5
%23 = load i32, i32* %8
store i32 %23, i32* %6
%24 = call i32 (...) @hidemouseptr()
%25 = load i32, i32* %3
%26 = load i32, i32* %4
%27 = load i32, i32* %5
%28 = load i32, i32* %6
%29 = call i32 @array_line_entry(i32 %25, i32 %26, i32 %27, i32 %28)
%30 = load i32, i32* %3
%31 = load i32, i32* %4
%32 = load i32, i32* %5
%33 = load i32, i32* %6
%34 = call i32 @bresline(i32 %30, i32 %31, i32 %32, i32 %33, i32 1)
%35 = call i32 (...) @showmouseptr()
%36 = load i32, i32* %5
store i32 %36, i32* %3
%37 = load i32, i32* %6
store i32 %37, i32* %4
%38 = call i32 @delay(i32 200)
br label %39
39: ; preds = %21, %18
br label %40
40: ; preds = %39
%41 = call i32 @getmousepos(i32* %9, i32* %7, i32* %8)
br label %15
42: ; preds = %15
%43 = call i32 (...) @hidemouseptr()
%44 = load i32, i32* %3
%45 = load i32, i32* %4
%46 = load i32, i32* %1
%47 = load i32, i32* %2
%48 = call i32 @array_line_entry(i32 %44, i32 %45, i32 %46, i32 %47)
%49 = load i32, i32* %3
%50 = load i32, i32* %4
%51 = load i32, i32* %1
%52 = load i32, i32* %2
%53 = call i32 @bresline(i32 %49, i32 %50, i32 %51, i32 %52, i32 1)
%54 = call i32 (...) @showmouseptr()
ret void
}

LLVM IR (-O2):
define void @user_poly() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = bitcast i32* %1 to i8*
%5 = bitcast i32* %2 to i8*
%6 = bitcast i32* %3 to i8*
%7 = call i32 @getmousepos(i32* %3, i32* %1, i32* %2)
%8 = load i32, i32* %1
%9 = load i32, i32* %2
br label %10
10: ; preds = %22, %0
%11 = phi i32 [ %9, %0 ], [ %23, %22 ]
%12 = phi i32 [ %8, %0 ], [ %24, %22 ]
%13 = load i32, i32* %3
switch i32 %13, label %22 [
i32 2, label %26
i32 1, label %14
]
14: ; preds = %10
%15 = load i32, i32* %1
%16 = load i32, i32* %2
%17 = call i32 (...) @hidemouseptr()
%18 = call i32 @array_line_entry(i32 %12, i32 %11, i32 %15, i32 %16)
%19 = call i32 @bresline(i32 %12, i32 %11, i32 %15, i32 %16, i32 1)
%20 = call i32 (...) @showmouseptr()
%21 = call i32 @delay(i32 200)
br label %22
22: ; preds = %10, %14
%23 = phi i32 [ %16, %14 ], [ %11, %10 ]
%24 = phi i32 [ %15, %14 ], [ %12, %10 ]
%25 = call i32 @getmousepos(i32* %3, i32* %1, i32* %2)
br label %10
26: ; preds = %10
%27 = call i32 (...) @hidemouseptr()
%28 = call i32 @array_line_entry(i32 %12, i32 %11, i32 %8, i32 %9)
%29 = call i32 @bresline(i32 %12, i32 %11, i32 %8, i32 %9, i32 1)
%30 = call i32 (...) @showmouseptr()
ret void
}