#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 */
double cos(unsigned int);
int /*<<< orphan*/ graph_fill_polygon(int *, unsigned int const, int, int, int,
                                      int /*<<< orphan*/, unsigned char *,
                                      unsigned int, unsigned int);
int /*<<< orphan*/ graph_rotate_points(int *, unsigned int const, double,
                                       double, double);
int /*<<< orphan*/ graph_scale_points(int *, unsigned int const, double, double,
                                      double);
double sin(unsigned int);
void transfer_draw_finger_pivot(double x, double y, double pivot_x,
                                double pivot_y, double pivot_radius,
                                double scale, double orientation,
                                unsigned char *img, unsigned int img_width,
                                unsigned int img_height) {
  unsigned int i, j;
  const unsigned int no_of_points = 64;
  int points[2000];
  for (i = 0; i < 2; i++) {
    for (j = 0; j < no_of_points; j++) {
      points[j * 2] = pivot_x + ((pivot_radius - (i * pivot_radius * 0.5)) *
                                 sin(j * 2 * 3.1415927 / no_of_points));
      points[j * 2 + 1] = pivot_y + ((pivot_radius - (i * pivot_radius * 0.5)) *
                                     cos(j * 2 * 3.1415927 / no_of_points));
    }
    graph_scale_points(points, no_of_points, x, y, scale);
    graph_rotate_points(points, no_of_points, x, y, orientation);
    if (i == 0) {
      graph_fill_polygon(points, no_of_points, 139, 139, 139, 0, img, img_width,
                         img_height);
    } else {
      graph_fill_polygon(points, no_of_points, 39, 39, 39, 0, img, img_width,
                         img_height);
    }
  }
}


x86 assembly (clang, -O0):
<transfer_draw_finger_pivot>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1ff0,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  %xmm3,-0x20(%rbp)
movsd  %xmm4,-0x28(%rbp)
movsd  %xmm5,-0x30(%rbp)
movsd  %xmm6,-0x38(%rbp)
mov    %rdi,-0x40(%rbp)
mov    %esi,-0x44(%rbp)
mov    %edx,-0x48(%rbp)
movl   $0x40,-0x54(%rbp)
movl   $0x0,-0x4c(%rbp)
cmpl   $0x2,-0x4c(%rbp)
jae    13cd <transfer_draw_finger_pivot+0x27d>
movl   $0x0,-0x50(%rbp)
cmpl   $0x40,-0x50(%rbp)
jae    12fb <transfer_draw_finger_pivot+0x1ab>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x1fd8(%rbp)
ff
movsd  -0x28(%rbp),%xmm0
mov    -0x4c(%rbp),%eax
cvtsi2sd %rax,%xmm1
mulsd  %xmm0,%xmm1
movsd  0xe29(%rip),%xmm2
movsd  %xmm2,-0x1fd0(%rbp)
ff
mulsd  %xmm2,%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x1fb8(%rbp)
ff
mov    -0x50(%rbp),%eax
add    %eax,%eax
cvtsi2sd %rax,%xmm0
movsd  0xe07(%rip),%xmm1
movsd  %xmm1,-0x1fc8(%rbp)
ff
mulsd  %xmm1,%xmm0
movsd  0xdfb(%rip),%xmm1
movsd  %xmm1,-0x1fc0(%rbp)
ff
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rax
mov    %eax,%edi
call   1040 <sin@plt>
movsd  -0x1fd8(%rbp),%xmm3
ff
movsd  -0x1fd0(%rbp),%xmm4
ff
movsd  -0x1fc8(%rbp),%xmm2
ff
movsd  -0x1fc0(%rbp),%xmm1
ff
movaps %xmm0,%xmm5
movsd  -0x1fb8(%rbp),%xmm0
ff
mulsd  %xmm5,%xmm0
addsd  %xmm3,%xmm0
cvttsd2si %xmm0,%ecx
mov    -0x50(%rbp),%eax
add    %eax,%eax
mov    %ecx,-0x1fa0(%rbp,%rax,4)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x1fb0(%rbp)
ff
movsd  -0x28(%rbp),%xmm0
mov    -0x4c(%rbp),%eax
cvtsi2sd %rax,%xmm3
mulsd  %xmm0,%xmm3
mulsd  %xmm4,%xmm3
subsd  %xmm3,%xmm0
movsd  %xmm0,-0x1fa8(%rbp)
ff
mov    -0x50(%rbp),%eax
add    %eax,%eax
cvtsi2sd %rax,%xmm0
mulsd  %xmm2,%xmm0
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rax
mov    %eax,%edi
call   1060 <cos@plt>
movsd  -0x1fb0(%rbp),%xmm1
ff
movaps %xmm0,%xmm2
movsd  -0x1fa8(%rbp),%xmm0
ff
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%ecx
mov    -0x50(%rbp),%eax
shl    $0x1,%eax
add    $0x1,%eax
mov    %eax,%eax
mov    %ecx,-0x1fa0(%rbp,%rax,4)
mov    -0x50(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x50(%rbp)
jmp    11a7 <transfer_draw_finger_pivot+0x57>
lea    -0x1fa0(%rbp),%rdi
movsd  -0x8(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm2
mov    $0x40,%esi
call   1030 <graph_scale_points@plt>
lea    -0x1fa0(%rbp),%rdi
movsd  -0x8(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  -0x38(%rbp),%xmm2
mov    $0x40,%esi
call   1070 <graph_rotate_points@plt>
cmpl   $0x0,-0x4c(%rbp)
jne    1382 <transfer_draw_finger_pivot+0x232>
lea    -0x1fa0(%rbp),%rdi
mov    -0x40(%rbp),%r11
mov    -0x44(%rbp),%r10d
mov    -0x48(%rbp),%eax
mov    $0x40,%esi
mov    $0x8b,%r8d
xor    %r9d,%r9d
mov    %r8d,%edx
mov    %r8d,%ecx
mov    %r11,(%rsp)
mov    %r10d,0x8(%rsp)
mov    %eax,0x10(%rsp)
call   1050 <graph_fill_polygon@plt>
jmp    13ba <transfer_draw_finger_pivot+0x26a>
lea    -0x1fa0(%rbp),%rdi
mov    -0x40(%rbp),%r11
mov    -0x44(%rbp),%r10d
mov    -0x48(%rbp),%eax
mov    $0x40,%esi
mov    $0x27,%r8d
xor    %r9d,%r9d
mov    %r8d,%edx
mov    %r8d,%ecx
mov    %r11,(%rsp)
mov    %r10d,0x8(%rsp)
mov    %eax,0x10(%rsp)
call   1050 <graph_fill_polygon@plt>
jmp    13bf <transfer_draw_finger_pivot+0x26f>
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    1196 <transfer_draw_finger_pivot+0x46>
add    $0x1ff0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<transfer_draw_finger_pivot>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1f80,%rsp
mov    %edx,%r12d
mov    %esi,%r15d
mov    %rdi,%r14
movsd  %xmm6,0x20(%rsp)
movsd  %xmm5,0x18(%rsp)
movsd  %xmm3,0x30(%rsp)
movsd  %xmm2,0x28(%rsp)
movsd  %xmm1,0x10(%rsp)
movsd  %xmm0,0x8(%rsp)
movsd  0xe6b(%rip),%xmm0
mulsd  %xmm4,%xmm0
mulsd  0xe67(%rip),%xmm0
movsd  %xmm4,0x38(%rsp)
addsd  %xmm4,%xmm0
movsd  %xmm0,(%rsp)
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %ebx,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
mulsd  0xe3e(%rip),%xmm0
mulsd  0xe3e(%rip),%xmm0
cvttsd2si %xmm0,%r13
mov    %r13d,%edi
call   1040 <sin@plt>
mulsd  (%rsp),%xmm0
addsd  0x28(%rsp),%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,0x40(%rsp,%rbx,4)
mov    %r13d,%edi
call   1060 <cos@plt>
mulsd  (%rsp),%xmm0
addsd  0x30(%rsp),%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,0x44(%rsp,%rbx,4)
add    $0x2,%rbx
cmp    $0x80,%rbx
jne    11c0 <transfer_draw_finger_pivot+0x70>
lea    0x40(%rsp),%r13
mov    %r13,%rdi
mov    $0x40,%esi
movsd  0x8(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
movsd  0x18(%rsp),%xmm2
call   1030 <graph_scale_points@plt>
mov    %r13,%rdi
mov    $0x40,%esi
movsd  0x8(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
movsd  0x20(%rsp),%xmm2
call   1070 <graph_rotate_points@plt>
sub    $0x8,%rsp
xor    %ebx,%ebx
mov    %r13,%rdi
mov    $0x40,%esi
mov    $0x8b,%edx
mov    $0x8b,%ecx
mov    $0x8b,%r8d
xor    %r9d,%r9d
push   %r12
push   %r15
push   %r14
call   1050 <graph_fill_polygon@plt>
add    $0x20,%rsp
movsd  0xd83(%rip),%xmm1
movsd  0x38(%rsp),%xmm0
mulsd  %xmm0,%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
mov    %ebx,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
mulsd  0xd4e(%rip),%xmm0
mulsd  0xd4e(%rip),%xmm0
cvttsd2si %xmm0,%r13
mov    %r13d,%edi
call   1040 <sin@plt>
mulsd  (%rsp),%xmm0
addsd  0x28(%rsp),%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,0x40(%rsp,%rbx,4)
mov    %r13d,%edi
call   1060 <cos@plt>
mulsd  (%rsp),%xmm0
addsd  0x30(%rsp),%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,0x44(%rsp,%rbx,4)
add    $0x2,%rbx
cmp    $0x80,%rbx
jne    12b0 <transfer_draw_finger_pivot+0x160>
lea    0x40(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x40,%esi
movsd  0x8(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
movsd  0x18(%rsp),%xmm2
call   1030 <graph_scale_points@plt>
mov    %rbx,%rdi
mov    $0x40,%esi
movsd  0x8(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
movsd  0x20(%rsp),%xmm2
call   1070 <graph_rotate_points@plt>
sub    $0x8,%rsp
mov    %rbx,%rdi
mov    $0x40,%esi
mov    $0x27,%edx
mov    $0x27,%ecx
mov    $0x27,%r8d
xor    %r9d,%r9d
push   %r12
push   %r15
push   %r14
call   1050 <graph_fill_polygon@plt>
add    $0x1fa0,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @transfer_draw_finger_pivot(double %0, double %1, double %2, double %3, double %4, double %5, double %6, i8* %7, i32 %8, i32 %9) {
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca double
%16 = alloca double
%17 = alloca double
%18 = alloca i8*
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32
%22 = alloca i32
%23 = alloca i32
%24 = alloca [2000 x i32]
store double %0, double* %11
store double %1, double* %12
store double %2, double* %13
store double %3, double* %14
store double %4, double* %15
store double %5, double* %16
store double %6, double* %17
store i8* %7, i8** %18
store i32 %8, i32* %19
store i32 %9, i32* %20
store i32 64, i32* %23
store i32 0, i32* %21
br label %25
25: ; preds = %105, %10
%26 = load i32, i32* %21
%27 = icmp ult i32 %26, 2
br i1 %27, label %28, label %108
28: ; preds = %25
store i32 0, i32* %22
br label %29
29: ; preds = %76, %28
%30 = load i32, i32* %22
%31 = icmp ult i32 %30, 64
br i1 %31, label %32, label %79
32: ; preds = %29
%33 = load double, double* %13
%34 = load double, double* %15
%35 = load i32, i32* %21
%36 = uitofp i32 %35 to double
%37 = load double, double* %15
%38 = fmul double %36, %37
%39 = fneg double %38
%40 = call double @llvm.fmuladd.f64(double %39, double 5.000000e-01, double %34)
%41 = load i32, i32* %22
%42 = mul i32 %41, 2
%43 = uitofp i32 %42 to double
%44 = fmul double %43, 0x400921FB5A7ED197
%45 = fdiv double %44, 6.400000e+01
%46 = fptoui double %45 to i32
%47 = call double @sin(i32 %46)
%48 = call double @llvm.fmuladd.f64(double %40, double %47, double %33)
%49 = fptosi double %48 to i32
%50 = load i32, i32* %22
%51 = mul i32 %50, 2
%52 = zext i32 %51 to i64
%53 = getelementptr inbounds [2000 x i32], [2000 x i32]* %24, i64 0, i64 %52
store i32 %49, i32* %53
%54 = load double, double* %14
%55 = load double, double* %15
%56 = load i32, i32* %21
%57 = uitofp i32 %56 to double
%58 = load double, double* %15
%59 = fmul double %57, %58
%60 = fneg double %59
%61 = call double @llvm.fmuladd.f64(double %60, double 5.000000e-01, double %55)
%62 = load i32, i32* %22
%63 = mul i32 %62, 2
%64 = uitofp i32 %63 to double
%65 = fmul double %64, 0x400921FB5A7ED197
%66 = fdiv double %65, 6.400000e+01
%67 = fptoui double %66 to i32
%68 = call double @cos(i32 %67)
%69 = call double @llvm.fmuladd.f64(double %61, double %68, double %54)
%70 = fptosi double %69 to i32
%71 = load i32, i32* %22
%72 = mul i32 %71, 2
%73 = add i32 %72, 1
%74 = zext i32 %73 to i64
%75 = getelementptr inbounds [2000 x i32], [2000 x i32]* %24, i64 0, i64 %74
store i32 %70, i32* %75
br label %76
76: ; preds = %32
%77 = load i32, i32* %22
%78 = add i32 %77, 1
store i32 %78, i32* %22
br label %29
79: ; preds = %29
%80 = getelementptr inbounds [2000 x i32], [2000 x i32]* %24, i64 0, i64 0
%81 = load double, double* %11
%82 = load double, double* %12
%83 = load double, double* %16
%84 = call i32 @graph_scale_points(i32* %80, i32 64, double %81, double %82, double %83)
%85 = getelementptr inbounds [2000 x i32], [2000 x i32]* %24, i64 0, i64 0
%86 = load double, double* %11
%87 = load double, double* %12
%88 = load double, double* %17
%89 = call i32 @graph_rotate_points(i32* %85, i32 64, double %86, double %87, double %88)
%90 = load i32, i32* %21
%91 = icmp eq i32 %90, 0
br i1 %91, label %92, label %98
92: ; preds = %79
%93 = getelementptr inbounds [2000 x i32], [2000 x i32]* %24, i64 0, i64 0
%94 = load i8*, i8** %18
%95 = load i32, i32* %19
%96 = load i32, i32* %20
%97 = call i32 @graph_fill_polygon(i32* %93, i32 64, i32 139, i32 139, i32 139, i32 0, i8* %94, i32 %95, i32 %96)
br label %104
98: ; preds = %79
%99 = getelementptr inbounds [2000 x i32], [2000 x i32]* %24, i64 0, i64 0
%100 = load i8*, i8** %18
%101 = load i32, i32* %19
%102 = load i32, i32* %20
%103 = call i32 @graph_fill_polygon(i32* %99, i32 64, i32 39, i32 39, i32 39, i32 0, i8* %100, i32 %101, i32 %102)
br label %104
104: ; preds = %98, %92
br label %105
105: ; preds = %104
%106 = load i32, i32* %21
%107 = add i32 %106, 1
store i32 %107, i32* %21
br label %25
108: ; preds = %25
ret void
}

LLVM IR (-O2):
define void @transfer_draw_finger_pivot(double %0, double %1, double %2, double %3, double %4, double %5, double %6, i8* %7, i32 %8, i32 %9) {
%11 = alloca [2000 x i32]
%12 = bitcast [2000 x i32]* %11 to i8*
%13 = getelementptr inbounds [2000 x i32], [2000 x i32]* %11, i64 0, i64 0
%14 = fmul double %4, -0.000000e+00
%15 = call double @llvm.fmuladd.f64(double %14, double 5.000000e-01, double %4)
br label %16
16: ; preds = %10, %16
%17 = phi i64 [ 0, %10 ], [ %33, %16 ]
%18 = shl nuw nsw i64 %17, 1
%19 = trunc i64 %18 to i32
%20 = uitofp i32 %19 to double
%21 = fmul double %20, 0x400921FB5A7ED197
%22 = fmul double %21, 1.562500e-02
%23 = fptoui double %22 to i32
%24 = call double @sin(i32 %23)
%25 = call double @llvm.fmuladd.f64(double %15, double %24, double %2)
%26 = fptosi double %25 to i32
%27 = getelementptr inbounds [2000 x i32], [2000 x i32]* %11, i64 0, i64 %18
store i32 %26, i32* %27
%28 = call double @cos(i32 %23)
%29 = call double @llvm.fmuladd.f64(double %15, double %28, double %3)
%30 = fptosi double %29 to i32
%31 = or i64 %18, 1
%32 = getelementptr inbounds [2000 x i32], [2000 x i32]* %11, i64 0, i64 %31
store i32 %30, i32* %32
%33 = add nuw nsw i64 %17, 1
%34 = icmp eq i64 %33, 64
br i1 %34, label %35, label %16
35: ; preds = %16
%36 = call i32 @graph_scale_points(i32* %13, i32 64, double %0, double %1, double %5)
%37 = call i32 @graph_rotate_points(i32* %13, i32 64, double %0, double %1, double %6)
%38 = call i32 @graph_fill_polygon(i32* %13, i32 64, i32 139, i32 139, i32 139, i32 0, i8* %7, i32 %8, i32 %9)
%39 = fneg double %4
%40 = call double @llvm.fmuladd.f64(double %39, double 5.000000e-01, double %4)
br label %41
41: ; preds = %41, %35
%42 = phi i64 [ 0, %35 ], [ %58, %41 ]
%43 = shl nuw nsw i64 %42, 1
%44 = trunc i64 %43 to i32
%45 = uitofp i32 %44 to double
%46 = fmul double %45, 0x400921FB5A7ED197
%47 = fmul double %46, 1.562500e-02
%48 = fptoui double %47 to i32
%49 = call double @sin(i32 %48)
%50 = call double @llvm.fmuladd.f64(double %40, double %49, double %2)
%51 = fptosi double %50 to i32
%52 = getelementptr inbounds [2000 x i32], [2000 x i32]* %11, i64 0, i64 %43
store i32 %51, i32* %52
%53 = call double @cos(i32 %48)
%54 = call double @llvm.fmuladd.f64(double %40, double %53, double %3)
%55 = fptosi double %54 to i32
%56 = or i64 %43, 1
%57 = getelementptr inbounds [2000 x i32], [2000 x i32]* %11, i64 0, i64 %56
store i32 %55, i32* %57
%58 = add nuw nsw i64 %42, 1
%59 = icmp eq i64 %58, 64
br i1 %59, label %60, label %41
60: ; preds = %41
%61 = call i32 @graph_scale_points(i32* %13, i32 64, double %0, double %1, double %5)
%62 = call i32 @graph_rotate_points(i32* %13, i32 64, double %0, double %1, double %6)
%63 = call i32 @graph_fill_polygon(i32* %13, i32 64, i32 39, i32 39, i32 39, i32 0, i8* %7, i32 %8, i32 %9)
ret void
}