#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 pow(int, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *, int *);
int main() {
  int a, sum = 0, n, x, i, j, b = 1;
  printf("Enter the value of both n and x\n");
  scanf("%d %d", &n, &x);
  for (i = 0, j = 0; i <= n; j++, i++) {
    if ((i % 2) == 0) {
    } else {
      a = pow((-1), j) * pow(x, i);
      b = i * b;
      sum = sum + (a / b);
    }
  }
  printf("The sum of sine taylor series is \n");
  printf("1-x+x^3/3+...");
  printf("%d", sum);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x1,-0x20(%rbp)
lea    0xeac(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xebf(%rip),%rdi
lea    -0x10(%rbp),%rsi
lea    -0x14(%rbp),%rdx
call   1040 <scanf@plt>
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x10(%rbp),%eax
jg     1205 <main+0xd5>
mov    -0x18(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11a2 <main+0x72>
jmp    11e9 <main+0xb9>
mov    -0x1c(%rbp),%esi
mov    $0xffffffff,%edi
call   1050 <pow@plt>
mov    %eax,-0x28(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
call   1050 <pow@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%eax
imul   %ecx,%eax
mov    %eax,-0x8(%rbp)
mov    -0x18(%rbp),%eax
imul   -0x20(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%eax
cltd
idivl  -0x20(%rbp)
mov    %eax,%ecx
mov    -0x24(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0xc(%rbp)
jmp    11ee <main+0xbe>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    117d <main+0x4d>
lea    0xe1b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe30(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%esi
lea    0xdf9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
lea    0xec6(%rip),%rdi
call   1030 <puts@plt>
lea    0xea6(%rip),%rdi
mov    %rsp,%rsi
lea    0x4(%rsp),%rdx
call   1050 <scanf@plt>
mov    (%rsp),%eax
test   %eax,%eax
js     11ba <main+0x7a>
xor    %ebx,%ebx
mov    $0x1,%r15d
xor    %r14d,%r14d
jmp    1189 <main+0x49>
nopl   0x0(%rax,%rax,1)
lea    0x1(%rbx),%ecx
cmp    %eax,%ebx
mov    %ecx,%ebx
jge    11bd <main+0x7d>
test   $0x1,%bl
je     1180 <main+0x40>
mov    $0xffffffff,%edi
mov    %ebx,%esi
call   1060 <pow@plt>
mov    %eax,%ebp
mov    0x4(%rsp),%edi
mov    %ebx,%esi
call   1060 <pow@plt>
imul   %ebp,%eax
imul   %ebx,%r15d
cltd
idiv   %r15d
add    %eax,%r14d
mov    (%rsp),%eax
jmp    1180 <main+0x40>
xor    %r14d,%r14d
lea    0xe70(%rip),%rdi
call   1030 <puts@plt>
lea    0xe36(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe25(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [33 x i8] c"Enter the value of both n and x\0A\00"
@.str.1 = [6 x i8] c"%d %d\00"
@.str.2 = [35 x i8] c"The sum of sine taylor series is \0A\00"
@.str.3 = [14 x i8] c"1-x+x^3/3+...\00"
@.str.4 = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %3
store i32 1, i32* %8
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %4, i32* %5)
store i32 0, i32* %6
store i32 0, i32* %7
br label %11
11: ; preds = %36, %0
%12 = load i32, i32* %6
%13 = load i32, i32* %4
%14 = icmp sle i32 %12, %13
br i1 %14, label %15, label %41
15: ; preds = %11
%16 = load i32, i32* %6
%17 = srem i32 %16, 2
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %15
br label %35
20: ; preds = %15
%21 = load i32, i32* %7
%22 = call i32 @pow(i32 -1, i32 %21)
%23 = load i32, i32* %5
%24 = load i32, i32* %6
%25 = call i32 @pow(i32 %23, i32 %24)
%26 = mul nsw i32 %22, %25
store i32 %26, i32* %2
%27 = load i32, i32* %6
%28 = load i32, i32* %8
%29 = mul nsw i32 %27, %28
store i32 %29, i32* %8
%30 = load i32, i32* %3
%31 = load i32, i32* %2
%32 = load i32, i32* %8
%33 = sdiv i32 %31, %32
%34 = add nsw i32 %30, %33
store i32 %34, i32* %3
br label %35
35: ; preds = %20, %19
br label %36
36: ; preds = %35
%37 = load i32, i32* %7
%38 = add nsw i32 %37, 1
store i32 %38, i32* %7
%39 = load i32, i32* %6
%40 = add nsw i32 %39, 1
store i32 %40, i32* %6
br label %11
41: ; preds = %11
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0))
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
%44 = load i32, i32* %3
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 %44)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [6 x i8] c"%d %d\00"
@.str.3 = [14 x i8] c"1-x+x^3/3+...\00"
@.str.4 = [3 x i8] c"%d\00"
@str = [32 x i8] c"Enter the value of both n and x\00"
@str.5 = [34 x i8] c"The sum of sine taylor series is \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %1, i32* %2)
%7 = load i32, i32* %1
%8 = icmp slt i32 %7, 0
br i1 %8, label %31, label %9
9: ; preds = %0, %25
%10 = phi i32 [ %26, %25 ], [ %7, %0 ]
%11 = phi i32 [ %28, %25 ], [ 1, %0 ]
%12 = phi i32 [ %29, %25 ], [ 0, %0 ]
%13 = phi i32 [ %27, %25 ], [ 0, %0 ]
%14 = and i32 %12, 1
%15 = icmp eq i32 %14, 0
br i1 %15, label %25, label %16
16: ; preds = %9
%17 = call i32 @pow(i32 -1, i32 %12)
%18 = load i32, i32* %2
%19 = call i32 @pow(i32 %18, i32 %12)
%20 = mul nsw i32 %19, %17
%21 = mul nsw i32 %11, %12
%22 = sdiv i32 %20, %21
%23 = add nsw i32 %22, %13
%24 = load i32, i32* %1
br label %25
25: ; preds = %16, %9
%26 = phi i32 [ %10, %9 ], [ %24, %16 ]
%27 = phi i32 [ %13, %9 ], [ %23, %16 ]
%28 = phi i32 [ %11, %9 ], [ %21, %16 ]
%29 = add nuw nsw i32 %12, 1
%30 = icmp slt i32 %12, %26
br i1 %30, label %9, label %31
31: ; preds = %25, %0
%32 = phi i32 [ 0, %0 ], [ %27, %25 ]
%33 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str.5, i64 0, i64 0))
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 %32)
ret i32 0
}