#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*/ GC;
typedef int /*<<< orphan*/ Drawable;
typedef int /*<<< orphan*/ Display;

/* Variables and functions */
double M_PI;
int XDrawArc(int /*<<< orphan*/ *, int /*<<< orphan*/, int /*<<< orphan*/,
             short, short, int, int, int /*<<< orphan*/, int);
double cos(double);
scalar_t__ sin(double);
int DrawTopCircle(Display *display, Drawable d, GC gc, int x, int y,
                  unsigned int radius, int angle) {
  short coord_x, coord_y;
  double r_angle;
  r_angle = (angle / 64) * (M_PI / 180.0);
  coord_x = (short)(x - (int)radius * (int)(1.0 + sin(r_angle)));
  coord_y = (short)(y - (int)radius * (int)(1.0 - cos(r_angle)));
  return XDrawArc(display, d, gc, coord_x, coord_y, 2 * radius, 2 * radius, 0,
                  360 * 64);
}


x86 assembly (clang, -O0):
<DrawTopCircle>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    0x10(%rbp),%eax
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    %r8d,-0x18(%rbp)
mov    %r9d,-0x1c(%rbp)
mov    0x10(%rbp),%eax
mov    $0x40,%ecx
cltd
idiv   %ecx
cvtsi2sd %eax,%xmm0
mov    0x2e82(%rip),%rax
movsd  (%rax),%xmm1
movsd  0xe96(%rip),%xmm2
divsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x38(%rbp)
movsd  -0x28(%rbp),%xmm0
call   1040 <sin@plt>
mov    -0x38(%rbp),%ecx
mov    %rax,%rdx
mov    -0x34(%rbp),%eax
cvtsi2sd %rdx,%xmm1
movsd  0xe55(%rip),%xmm0
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edx
imul   %edx,%ecx
sub    %ecx,%eax
mov    %ax,-0x1e(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x30(%rbp)
movsd  -0x28(%rbp),%xmm0
call   1050 <cos@plt>
mov    -0x30(%rbp),%ecx
mov    -0x2c(%rbp),%eax
movaps %xmm0,%xmm1
movsd  0xe1d(%rip),%xmm0
subsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edx
imul   %edx,%ecx
sub    %ecx,%eax
mov    %ax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x1e(%rbp),%cx
mov    -0x20(%rbp),%r8w
mov    -0x1c(%rbp),%r9d
shl    $0x1,%r9d
mov    -0x1c(%rbp),%eax
shl    $0x1,%eax
xor    %r10d,%r10d
movswl %cx,%ecx
movswl %r8w,%r8d
mov    %eax,(%rsp)
movl   $0x0,0x8(%rsp)
movl   $0x5a00,0x10(%rsp)
call   1030 <XDrawArc@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<DrawTopCircle>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r9d,%ebx
mov    %r8d,%r13d
mov    %ecx,%ebp
mov    %edx,%r14d
mov    %esi,%r15d
mov    %rdi,%r12
mov    0x40(%rsp),%eax
lea    0x3f(%rax),%ecx
test   %eax,%eax
cmovns %eax,%ecx
sar    $0x6,%ecx
cvtsi2sd %ecx,%xmm1
mov    0x2e82(%rip),%rax
movsd  (%rax),%xmm0
divsd  0xe8e(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,(%rsp)
call   1040 <sin@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  0xe78(%rip),%xmm0
cvttsd2si %xmm0,%eax
imul   %ebx,%eax
sub    %eax,%ebp
movsd  (%rsp),%xmm0
call   1050 <cos@plt>
movsd  0xe5d(%rip),%xmm1
subsd  %xmm0,%xmm1
cvttsd2si %xmm1,%eax
imul   %ebx,%eax
sub    %eax,%r13d
add    %ebx,%ebx
sub    $0x8,%rsp
movswl %bp,%ecx
movswl %r13w,%r8d
mov    %r12,%rdi
mov    %r15d,%esi
mov    %r14d,%edx
mov    %ebx,%r9d
push   $0x5a00
push   $0x0
push   %rbx
call   1030 <XDrawArc@plt>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@M_PI = global double 0.000000e+00
define i32 @DrawTopCircle(i32* %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5, i32 %6) {
%8 = alloca i32*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i16
%16 = alloca i16
%17 = alloca double
store i32* %0, i32** %8
store i32 %1, i32* %9
store i32 %2, i32* %10
store i32 %3, i32* %11
store i32 %4, i32* %12
store i32 %5, i32* %13
store i32 %6, i32* %14
%18 = load i32, i32* %14
%19 = sdiv i32 %18, 64
%20 = sitofp i32 %19 to double
%21 = load double, double* @M_PI
%22 = fdiv double %21, 1.800000e+02
%23 = fmul double %20, %22
store double %23, double* %17
%24 = load i32, i32* %11
%25 = load i32, i32* %13
%26 = load double, double* %17
%27 = call i64 @sin(double %26)
%28 = sitofp i64 %27 to double
%29 = fadd double 1.000000e+00, %28
%30 = fptosi double %29 to i32
%31 = mul nsw i32 %25, %30
%32 = sub nsw i32 %24, %31
%33 = trunc i32 %32 to i16
store i16 %33, i16* %15
%34 = load i32, i32* %12
%35 = load i32, i32* %13
%36 = load double, double* %17
%37 = call double @cos(double %36)
%38 = fsub double 1.000000e+00, %37
%39 = fptosi double %38 to i32
%40 = mul nsw i32 %35, %39
%41 = sub nsw i32 %34, %40
%42 = trunc i32 %41 to i16
store i16 %42, i16* %16
%43 = load i32*, i32** %8
%44 = load i32, i32* %9
%45 = load i32, i32* %10
%46 = load i16, i16* %15
%47 = load i16, i16* %16
%48 = load i32, i32* %13
%49 = mul i32 2, %48
%50 = load i32, i32* %13
%51 = mul i32 2, %50
%52 = call i32 @XDrawArc(i32* %43, i32 %44, i32 %45, i16 signext %46, i16 signext %47, i32 %49, i32 %51, i32 0, i32 23040)
ret i32 %52
}

LLVM IR (-O2):
@M_PI = global double 0.000000e+00
define i32 @DrawTopCircle(i32* %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5, i32 %6) {
%8 = sdiv i32 %6, 64
%9 = sitofp i32 %8 to double
%10 = load double, double* @M_PI
%11 = fdiv double %10, 1.800000e+02
%12 = fmul double %11, %9
%13 = tail call i64 @sin(double %12)
%14 = sitofp i64 %13 to double
%15 = fadd double %14, 1.000000e+00
%16 = fptosi double %15 to i32
%17 = mul nsw i32 %16, %5
%18 = sub nsw i32 %3, %17
%19 = trunc i32 %18 to i16
%20 = tail call double @cos(double %12)
%21 = fsub double 1.000000e+00, %20
%22 = fptosi double %21 to i32
%23 = mul nsw i32 %22, %5
%24 = sub nsw i32 %4, %23
%25 = trunc i32 %24 to i16
%26 = shl i32 %5, 1
%27 = tail call i32 @XDrawArc(i32* %0, i32 %1, i32 %2, i16 signext %19, i16 signext %25, i32 %26, i32 %26, i32 0, i32 23040)
ret i32 %27
}