#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 XFillArc(int /*<<< orphan*/ *, int /*<<< orphan*/, int /*<<< orphan*/,
             short, short, int, int, int /*<<< orphan*/, int);
int cos(double);
scalar_t__ rint(int);
int sin(double);
int FillTopCircle(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)(rint(x - radius * (1 + sin(r_angle))));
  coord_y = (short)(rint(y - radius * (1 - cos(r_angle))));
  return XFillArc(display, d, gc, coord_x, coord_y, 2 * radius, 2 * radius, 0,
                  360 * 64);
}


x86 assembly (clang, -O0):
<FillTopCircle>:
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    0x2e72(%rip),%rax
movsd  (%rax),%xmm1
movsd  0xe7e(%rip),%xmm2
divsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x34(%rbp)
movsd  -0x28(%rbp),%xmm0
call   1030 <sin@plt>
mov    -0x38(%rbp),%edi
mov    %eax,%ecx
mov    -0x34(%rbp),%eax
add    $0x1,%ecx
imul   %ecx,%eax
sub    %eax,%edi
call   1040 <rint@plt>
mov    %ax,-0x1e(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x2c(%rbp)
movsd  -0x28(%rbp),%xmm0
call   1050 <cos@plt>
mov    -0x30(%rbp),%edi
mov    %eax,%edx
mov    -0x2c(%rbp),%eax
mov    $0x1,%ecx
sub    %edx,%ecx
imul   %ecx,%eax
sub    %eax,%edi
call   1040 <rint@plt>
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   1060 <XFillArc@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<FillTopCircle>:
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    0x2e72(%rip),%rax
movsd  (%rax),%xmm0
divsd  0xe7e(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,(%rsp)
call   1030 <sin@plt>
not    %eax
imul   %ebx,%eax
add    %eax,%ebp
mov    %ebp,%edi
call   1040 <rint@plt>
mov    %rax,%rbp
movsd  (%rsp),%xmm0
call   1050 <cos@plt>
lea    -0x1(%rax),%edi
imul   %ebx,%edi
add    %r13d,%edi
call   1040 <rint@plt>
add    %ebx,%ebx
sub    $0x8,%rsp
movswl %bp,%ecx
movswl %ax,%r8d
mov    %r12,%rdi
mov    %r15d,%esi
mov    %r14d,%edx
mov    %ebx,%r9d
push   $0x5a00
push   $0x0
push   %rbx
call   1060 <XFillArc@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 @FillTopCircle(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 i32 @sin(double %26)
%28 = add nsw i32 1, %27
%29 = mul i32 %25, %28
%30 = sub i32 %24, %29
%31 = call i64 @rint(i32 %30)
%32 = trunc i64 %31 to i16
store i16 %32, i16* %15
%33 = load i32, i32* %12
%34 = load i32, i32* %13
%35 = load double, double* %17
%36 = call i32 @cos(double %35)
%37 = sub nsw i32 1, %36
%38 = mul i32 %34, %37
%39 = sub i32 %33, %38
%40 = call i64 @rint(i32 %39)
%41 = trunc i64 %40 to i16
store i16 %41, i16* %16
%42 = load i32*, i32** %8
%43 = load i32, i32* %9
%44 = load i32, i32* %10
%45 = load i16, i16* %15
%46 = load i16, i16* %16
%47 = load i32, i32* %13
%48 = mul i32 2, %47
%49 = load i32, i32* %13
%50 = mul i32 2, %49
%51 = call i32 @XFillArc(i32* %42, i32 %43, i32 %44, i16 signext %45, i16 signext %46, i32 %48, i32 %50, i32 0, i32 23040)
ret i32 %51
}

LLVM IR (-O2):
@M_PI = global double 0.000000e+00
define i32 @FillTopCircle(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 i32 @sin(double %12)
%14 = xor i32 %13, -1
%15 = mul i32 %14, %5
%16 = add i32 %15, %3
%17 = tail call i64 @rint(i32 %16)
%18 = trunc i64 %17 to i16
%19 = tail call i32 @cos(double %12)
%20 = add i32 %19, -1
%21 = mul i32 %20, %5
%22 = add i32 %21, %4
%23 = tail call i64 @rint(i32 %22)
%24 = trunc i64 %23 to i16
%25 = shl i32 %5, 1
%26 = tail call i32 @XFillArc(i32* %0, i32 %1, i32 %2, i16 signext %18, i16 signext %24, i32 %25, i32 %25, i32 0, i32 23040)
ret i32 %26
}