#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 n, x, i, j, sum = 0, b = 1, a;
  printf("Enter the numbers n and x");
  scanf("%d %d", &n, &x);
  for (i = 0; i <= n; i++) {
    a = pow(x, i);
    b = i * b;
    sum = sum + (a / b);
  }
  printf("The exponential series sum \n");
  printf("1+x+x^/2!+.. is \n");
  printf("%d", sum);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x1,-0x1c(%rbp)
lea    0xeac(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb8(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
call   1040 <scanf@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     11bf <main+0x8f>
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
call   1050 <pow@plt>
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%eax
imul   -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%eax
cltd
idivl  -0x1c(%rbp)
mov    %eax,%ecx
mov    -0x24(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1176 <main+0x46>
lea    0xe5a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe69(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%esi
lea    0xe38(%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   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xeb1(%rip),%rdi
xor    %r14d,%r14d
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeba(%rip),%rdi
lea    0x8(%rsp),%rsi
lea    0xc(%rsp),%rdx
call   1050 <scanf@plt>
cmpl   $0x0,0x8(%rsp)
js     11ad <main+0x6d>
xor    %r14d,%r14d
mov    $0x1,%ebx
mov    $0xffffffff,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%ebp
mov    0xc(%rsp),%edi
mov    %ebp,%esi
call   1060 <pow@plt>
imul   %ebp,%ebx
cltd
idiv   %ebx
add    %eax,%r14d
cmp    0x8(%rsp),%ebp
jl     1190 <main+0x50>
lea    0xe6c(%rip),%rdi
call   1030 <puts@plt>
lea    0xe7c(%rip),%rdi
call   1030 <puts@plt>
lea    0xe51(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [26 x i8] c"Enter the numbers n and x\00"
@.str.1 = [6 x i8] c"%d %d\00"
@.str.2 = [29 x i8] c"The exponential series sum \0A\00"
@.str.3 = [18 x i8] c"1+x+x^/2!+.. is \0A\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* %6
store i32 1, i32* %7
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 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* %2, i32* %3)
store i32 0, i32* %4
br label %11
11: ; preds = %27, %0
%12 = load i32, i32* %4
%13 = load i32, i32* %2
%14 = icmp sle i32 %12, %13
br i1 %14, label %15, label %30
15: ; preds = %11
%16 = load i32, i32* %3
%17 = load i32, i32* %4
%18 = call i32 @pow(i32 %16, i32 %17)
store i32 %18, i32* %8
%19 = load i32, i32* %4
%20 = load i32, i32* %7
%21 = mul nsw i32 %19, %20
store i32 %21, i32* %7
%22 = load i32, i32* %6
%23 = load i32, i32* %8
%24 = load i32, i32* %7
%25 = sdiv i32 %23, %24
%26 = add nsw i32 %22, %25
store i32 %26, i32* %6
br label %27
27: ; preds = %15
%28 = load i32, i32* %4
%29 = add nsw i32 %28, 1
store i32 %29, i32* %4
br label %11
30: ; preds = %11
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
%33 = load i32, i32* %6
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 %33)
ret i32 0
}

LLVM IR (-O2):
@.str = [26 x i8] c"Enter the numbers n and x\00"
@.str.1 = [6 x i8] c"%d %d\00"
@.str.4 = [3 x i8] c"%d\00"
@str = [28 x i8] c"The exponential series sum \00"
@str.5 = [17 x i8] c"1+x+x^/2!+.. 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 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 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 %21, label %9
9: ; preds = %0, %9
%10 = phi i32 [ %18, %9 ], [ 0, %0 ]
%11 = phi i32 [ %15, %9 ], [ 1, %0 ]
%12 = phi i32 [ %17, %9 ], [ 0, %0 ]
%13 = load i32, i32* %2
%14 = call i32 @pow(i32 %13, i32 %10)
%15 = mul nsw i32 %10, %11
%16 = sdiv i32 %14, %15
%17 = add nsw i32 %16, %12
%18 = add nuw nsw i32 %10, 1
%19 = load i32, i32* %1
%20 = icmp slt i32 %10, %19
br i1 %20, label %9, label %21
21: ; preds = %9, %0
%22 = phi i32 [ 0, %0 ], [ %17, %9 ]
%23 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str, i64 0, i64 0))
%24 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.5, i64 0, i64 0))
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 %22)
ret i32 0
}