#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 fact(int);
double pow(double, int);
int /*<<< orphan*/ printf(char *, double);
int /*<<< orphan*/ scanf(char *, double *, int *);
int main(int argc, const char *argv[]) {
  int i, n;
  double x, sum = 0;
  scanf("%lf%d", &x, &n);
  for (i = 1; i <= n; i++) {
    sum += pow(-1, i - 1) * (pow(x, i) / fact(i));
  }
  printf("%.4lf\n", sum);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
lea    0xea3(%rip),%rdi
lea    -0x20(%rbp),%rsi
lea    -0x18(%rbp),%rdx
call   1050 <scanf@plt>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jg     11e8 <main+0xa8>
mov    -0x14(%rbp),%edi
sub    $0x1,%edi
movsd  0xe6d(%rip),%xmm0
call   1060 <pow@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x20(%rbp),%xmm0
mov    -0x14(%rbp),%edi
call   1060 <pow@plt>
movsd  %xmm0,-0x38(%rbp)
mov    -0x14(%rbp),%edi
call   1040 <fact@plt>
movsd  -0x38(%rbp),%xmm2
movaps %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
divsd  %xmm1,%xmm2
movsd  -0x28(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1179 <main+0x39>
movsd  -0x28(%rbp),%xmm0
lea    0xe1a(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x30,%rsp
lea    0xebc(%rip),%rdi
lea    0x28(%rsp),%rsi
lea    0xc(%rsp),%rdx
call   1050 <scanf@plt>
cmpl   $0x0,0xc(%rsp)
jle    11ca <main+0x8a>
xorpd  %xmm0,%xmm0
xor    %edi,%edi
nopl   0x0(%rax,%rax,1)
movsd  %xmm0,0x20(%rsp)
lea    0x1(%rdi),%ebx
movsd  0xe7f(%rip),%xmm0
call   1060 <pow@plt>
movsd  %xmm0,0x18(%rsp)
movsd  0x28(%rsp),%xmm0
mov    %ebx,%edi
call   1060 <pow@plt>
movsd  %xmm0,0x10(%rsp)
mov    %ebx,%edi
call   1040 <fact@plt>
movsd  0x10(%rsp),%xmm1
divsd  %xmm0,%xmm1
movsd  0x20(%rsp),%xmm0
mulsd  0x18(%rsp),%xmm1
addsd  %xmm1,%xmm0
mov    %ebx,%edi
cmp    0xc(%rsp),%ebx
jl     1170 <main+0x30>
jmp    11ce <main+0x8e>
xorpd  %xmm0,%xmm0
lea    0xe39(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [6 x i8] c"%lf%d\00"
@.str.1 = [7 x i8] c"%.4lf\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca double
%9 = alloca double
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store double 0.000000e+00, double* %9
%10 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), double* %8, i32* %7)
store i32 1, i32* %6
br label %11
11: ; preds = %27, %2
%12 = load i32, i32* %6
%13 = load i32, i32* %7
%14 = icmp sle i32 %12, %13
br i1 %14, label %15, label %30
15: ; preds = %11
%16 = load i32, i32* %6
%17 = sub nsw i32 %16, 1
%18 = call double @pow(double -1.000000e+00, i32 %17)
%19 = load double, double* %8
%20 = load i32, i32* %6
%21 = call double @pow(double %19, i32 %20)
%22 = load i32, i32* %6
%23 = call double @fact(i32 %22)
%24 = fdiv double %21, %23
%25 = load double, double* %9
%26 = call double @llvm.fmuladd.f64(double %18, double %24, double %25)
store double %26, double* %9
br label %27
27: ; preds = %15
%28 = load i32, i32* %6
%29 = add nsw i32 %28, 1
store i32 %29, i32* %6
br label %11
30: ; preds = %11
%31 = load double, double* %9
%32 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), double %31)
ret i32 0
}

LLVM IR (-O2):
@.str = [6 x i8] c"%lf%d\00"
@.str.1 = [7 x i8] c"%.4lf\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca double
%5 = bitcast i32* %3 to i8*
%6 = bitcast double* %4 to i8*
%7 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), double* %4, i32* %3)
%8 = load i32, i32* %3
%9 = icmp slt i32 %8, 1
br i1 %9, label %23, label %10
10: ; preds = %2, %10
%11 = phi double [ %19, %10 ], [ 0.000000e+00, %2 ]
%12 = phi i32 [ %20, %10 ], [ 1, %2 ]
%13 = add nsw i32 %12, -1
%14 = call double @pow(double -1.000000e+00, i32 %13)
%15 = load double, double* %4
%16 = call double @pow(double %15, i32 %12)
%17 = call double @fact(i32 %12)
%18 = fdiv double %16, %17
%19 = call double @llvm.fmuladd.f64(double %14, double %18, double %11)
%20 = add nuw nsw i32 %12, 1
%21 = load i32, i32* %3
%22 = icmp slt i32 %12, %21
br i1 %22, label %10, label %23
23: ; preds = %10, %2
%24 = phi double [ 0.000000e+00, %2 ], [ %19, %10 ]
%25 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), double %24)
ret i32 0
}