#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 */
float fact(int);
scalar_t__ pow(int, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int n, i;
  float sum = 0;
  printf("Enter the length of the series: ");
  scanf("%d", &n);
  for (i = 1; i <= n; i++)
    sum += ((float)pow(i, i)) / fact(i);
  printf("Sum of the series: %.2f\n", sum);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x10(%rbp)
lea    0xea2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb5(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
movl   $0x1,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     11c9 <main+0x89>
mov    -0xc(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1060 <pow@plt>
cvtsi2ss %rax,%xmm0
movss  %xmm0,-0x14(%rbp)
mov    -0xc(%rbp),%edi
call   1040 <fact@plt>
movaps %xmm0,%xmm1
movss  -0x14(%rbp),%xmm0
divss  %xmm1,%xmm0
addss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    117c <main+0x3c>
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe4b(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xeb4(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xec5(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
cmpl   $0x0,0x4(%rsp)
jle    11b7 <main+0x77>
xorps  %xmm0,%xmm0
movss  %xmm0,0xc(%rsp)
add    $0x1,%ebx
mov    %ebx,%edi
mov    %ebx,%esi
call   1060 <pow@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
movss  %xmm0,0x8(%rsp)
mov    %ebx,%edi
call   1040 <fact@plt>
movss  0x8(%rsp),%xmm1
divss  %xmm0,%xmm1
movss  0xc(%rsp),%xmm0
addss  %xmm1,%xmm0
cmp    0x4(%rsp),%ebx
jl     1170 <main+0x30>
cvtss2sd %xmm0,%xmm0
jmp    11ba <main+0x7a>
xorps  %xmm0,%xmm0
lea    0xe63(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [33 x i8] c"Enter the length of the series: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [25 x i8] c"Sum of the series: %.2f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca float
store i32 0, i32* %1
store float 0.000000e+00, float* %4
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
store i32 1, i32* %3
br label %7
7: ; preds = %21, %0
%8 = load i32, i32* %3
%9 = load i32, i32* %2
%10 = icmp sle i32 %8, %9
br i1 %10, label %11, label %24
11: ; preds = %7
%12 = load i32, i32* %3
%13 = load i32, i32* %3
%14 = call i64 @pow(i32 %12, i32 %13)
%15 = sitofp i64 %14 to float
%16 = load i32, i32* %3
%17 = call float @fact(i32 %16)
%18 = fdiv float %15, %17
%19 = load float, float* %4
%20 = fadd float %19, %18
store float %20, float* %4
br label %21
21: ; preds = %11
%22 = load i32, i32* %3
%23 = add nsw i32 %22, 1
store i32 %23, i32* %3
br label %7
24: ; preds = %7
%25 = load float, float* %4
%26 = fpext float %25 to double
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), double %26)
%28 = load i32, i32* %1
ret i32 %28
}

LLVM IR (-O2):
@.str = [33 x i8] c"Enter the length of the series: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [25 x i8] c"Sum of the series: %.2f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%5 = load i32, i32* %1
%6 = icmp slt i32 %5, 1
br i1 %6, label %20, label %7
7: ; preds = %0, %7
%8 = phi float [ %14, %7 ], [ 0.000000e+00, %0 ]
%9 = phi i32 [ %15, %7 ], [ 1, %0 ]
%10 = call i64 @pow(i32 %9, i32 %9)
%11 = sitofp i64 %10 to float
%12 = call float @fact(i32 %9)
%13 = fdiv float %11, %12
%14 = fadd float %8, %13
%15 = add nuw nsw i32 %9, 1
%16 = load i32, i32* %1
%17 = icmp slt i32 %9, %16
br i1 %17, label %7, label %18
18: ; preds = %7
%19 = fpext float %14 to double
br label %20
20: ; preds = %18, %0
%21 = phi double [ 0.000000e+00, %0 ], [ %19, %18 ]
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), double %21)
ret i32 0
}