#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 int64_t;

/* Variables and functions */
int int_pow(int, int);
int64_t int_sin(int64_t a) {
  if (a < 0)
    a = 205887 - a;
  a %= 2 * 205887;
  if (a >= 205887 * 3 / 2)
    a -= 2 * 205887;
  if (a >= 205887 / 2)
    a = 205887 - a;
  return a - int_pow(a, 3) / 6 + int_pow(a, 5) / 120 - int_pow(a, 7) / 5040;
}


x86 assembly (clang, -O0):
<int_sin>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jge    1130 <int_sin+0x20>
mov    $0x3243f,%eax
sub    -0x4(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x6487e,%ecx
cltd
idiv   %ecx
mov    %edx,-0x4(%rbp)
cmpl   $0x4b65e,-0x4(%rbp)
jl     1156 <int_sin+0x46>
mov    -0x4(%rbp),%eax
sub    $0x6487e,%eax
mov    %eax,-0x4(%rbp)
cmpl   $0x1921f,-0x4(%rbp)
jl     116e <int_sin+0x5e>
mov    $0x3243f,%eax
sub    -0x4(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x4(%rbp),%edi
mov    $0x3,%esi
call   1030 <int_pow@plt>
mov    $0x6,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x10(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0xc(%rbp)
mov    -0x4(%rbp),%edi
mov    $0x5,%esi
call   1030 <int_pow@plt>
mov    $0x78,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0xc(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%edi
mov    $0x7,%esi
call   1030 <int_pow@plt>
mov    $0x13b0,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x8(%rbp),%eax
sub    %ecx,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<int_sin>:
push   %rbp
push   %r14
push   %rbx
mov    $0x3243f,%r14d
mov    $0x3243f,%eax
sub    %edi,%eax
test   %edi,%edi
cmovns %edi,%eax
cltq
imul   $0x517ccc83,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
sar    $0x11,%ecx
add    %edx,%ecx
imul   $0x6487e,%ecx,%ecx
mov    %eax,%edx
sub    %ecx,%edx
neg    %ecx
cmp    $0x4b65e,%edx
lea    -0x6487e(%rax,%rcx,1),%eax
cmovl  %edx,%eax
sub    %eax,%r14d
cmp    $0x1921f,%eax
cmovl  %eax,%r14d
mov    %r14d,%edi
mov    $0x3,%esi
call   1030 <int_pow@plt>
cltq
imul   $0xffffffffd5555555,%rax,%rbp
mov    %rbp,%rax
shr    $0x3f,%rax
shr    $0x20,%rbp
add    %eax,%ebp
add    %r14d,%ebp
mov    %r14d,%edi
mov    $0x5,%esi
call   1030 <int_pow@plt>
movslq %eax,%rbx
imul   $0xffffffff88888889,%rbx,%rax
shr    $0x20,%rax
add    %eax,%ebx
mov    %ebx,%eax
shr    $0x1f,%eax
sar    $0x6,%ebx
add    %eax,%ebx
add    %ebp,%ebx
mov    %r14d,%edi
mov    $0x7,%esi
call   1030 <int_pow@plt>
movslq %eax,%rcx
imul   $0x2ff2ff2f,%rcx,%rax
shr    $0x20,%rax
sub    %ecx,%eax
mov    %eax,%ecx
shr    $0x1f,%ecx
sar    $0xc,%eax
add    %ecx,%eax
add    %ebx,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @int_sin(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = icmp slt i32 %3, 0
br i1 %4, label %5, label %8
5: ; preds = %1
%6 = load i32, i32* %2
%7 = sub nsw i32 205887, %6
store i32 %7, i32* %2
br label %8
8: ; preds = %5, %1
%9 = load i32, i32* %2
%10 = srem i32 %9, 411774
store i32 %10, i32* %2
%11 = load i32, i32* %2
%12 = icmp sge i32 %11, 308830
br i1 %12, label %13, label %16
13: ; preds = %8
%14 = load i32, i32* %2
%15 = sub nsw i32 %14, 411774
store i32 %15, i32* %2
br label %16
16: ; preds = %13, %8
%17 = load i32, i32* %2
%18 = icmp sge i32 %17, 102943
br i1 %18, label %19, label %22
19: ; preds = %16
%20 = load i32, i32* %2
%21 = sub nsw i32 205887, %20
store i32 %21, i32* %2
br label %22
22: ; preds = %19, %16
%23 = load i32, i32* %2
%24 = load i32, i32* %2
%25 = call i32 @int_pow(i32 %24, i32 3)
%26 = sdiv i32 %25, 6
%27 = sub nsw i32 %23, %26
%28 = load i32, i32* %2
%29 = call i32 @int_pow(i32 %28, i32 5)
%30 = sdiv i32 %29, 120
%31 = add nsw i32 %27, %30
%32 = load i32, i32* %2
%33 = call i32 @int_pow(i32 %32, i32 7)
%34 = sdiv i32 %33, 5040
%35 = sub nsw i32 %31, %34
ret i32 %35
}

LLVM IR (-O2):
define i32 @int_sin(i32 %0) {
%2 = icmp slt i32 %0, 0
%3 = sub nsw i32 205887, %0
%4 = select i1 %2, i32 %3, i32 %0
%5 = srem i32 %4, 411774
%6 = icmp sgt i32 %5, 308829
%7 = add nsw i32 %5, -411774
%8 = select i1 %6, i32 %7, i32 %5
%9 = icmp sgt i32 %8, 102942
%10 = sub nsw i32 205887, %8
%11 = select i1 %9, i32 %10, i32 %8
%12 = tail call i32 @int_pow(i32 %11, i32 3)
%13 = sdiv i32 %12, -6
%14 = add nsw i32 %13, %11
%15 = tail call i32 @int_pow(i32 %11, i32 5)
%16 = sdiv i32 %15, 120
%17 = add nsw i32 %14, %16
%18 = tail call i32 @int_pow(i32 %11, i32 7)
%19 = sdiv i32 %18, -5040
%20 = add nsw i32 %17, %19
ret i32 %20
}