#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(float, float);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, float *, float *, float *);
void main() {
  float n, r, a, sum;
  printf("Enter the first term of the GP then Common Ratio then number of "
         "terms.\n");
  scanf("%f%f%f", &a, &r, &n);
  sum = (a * (1 - pow(r, n))) / (1 - r);
  printf("The sum of first %.0f terms is %f\n", n, sum);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xec5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeff(%rip),%rdi
lea    -0xc(%rbp),%rsi
lea    -0x8(%rbp),%rdx
lea    -0x4(%rbp),%rcx
call   1040 <scanf@plt>
movss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x8(%rbp),%xmm0
movss  -0x4(%rbp),%xmm1
call   1050 <pow@plt>
movss  -0x14(%rbp),%xmm0
mov    %eax,%ecx
mov    $0x1,%eax
sub    %ecx,%eax
cvtsi2ss %eax,%xmm1
mulss  %xmm1,%xmm0
movss  0xe6b(%rip),%xmm1
subss  -0x8(%rbp),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x4(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x10(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xe97(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
lea    0xee3(%rip),%rdi
call   1030 <puts@plt>
lea    0xead(%rip),%rdi
lea    0x14(%rsp),%rsi
lea    0x8(%rsp),%rdx
lea    0xc(%rsp),%rcx
call   1050 <scanf@plt>
movss  0x14(%rsp),%xmm0
movss  %xmm0,0x10(%rsp)
movss  0x8(%rsp),%xmm0
movss  0xc(%rsp),%xmm1
call   1060 <pow@plt>
mov    $0x1,%ecx
sub    %eax,%ecx
xorps  %xmm1,%xmm1
cvtsi2ss %ecx,%xmm1
mulss  0x10(%rsp),%xmm1
movss  0xe5c(%rip),%xmm0
subss  0x8(%rsp),%xmm0
divss  %xmm0,%xmm1
movss  0xc(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
cvtss2sd %xmm1,%xmm1
lea    0xe48(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
add    $0x18,%rsp
ret

LLVM IR (-O0):
@.str = [72 x i8] c"Enter the first term of the GP then Common Ratio then number of terms.\0A\00"
@.str.1 = [7 x i8] c"%f%f%f\00"
@.str.2 = [35 x i8] c"The sum of first %.0f terms is %f\0A\00"
define void @main() {
%1 = alloca float
%2 = alloca float
%3 = alloca float
%4 = alloca float
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([72 x i8], [72 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), float* %3, float* %2, float* %1)
%7 = load float, float* %3
%8 = load float, float* %2
%9 = load float, float* %1
%10 = call i32 @pow(float %8, float %9)
%11 = sub nsw i32 1, %10
%12 = sitofp i32 %11 to float
%13 = fmul float %7, %12
%14 = load float, float* %2
%15 = fsub float 1.000000e+00, %14
%16 = fdiv float %13, %15
store float %16, float* %4
%17 = load float, float* %1
%18 = fpext float %17 to double
%19 = load float, float* %4
%20 = fpext float %19 to double
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0), double %18, double %20)
ret void
}

LLVM IR (-O2):
@.str.1 = [7 x i8] c"%f%f%f\00"
@.str.2 = [35 x i8] c"The sum of first %.0f terms is %f\0A\00"
@str = [71 x i8] c"Enter the first term of the GP then Common Ratio then number of terms.\00"
define void @main() {
%1 = alloca float
%2 = alloca float
%3 = alloca float
%4 = bitcast float* %1 to i8*
%5 = bitcast float* %2 to i8*
%6 = bitcast float* %3 to i8*
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([71 x i8], [71 x i8]* @str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), float* %3, float* %2, float* %1)
%9 = load float, float* %3
%10 = load float, float* %2
%11 = load float, float* %1
%12 = call i32 @pow(float %10, float %11)
%13 = sub nsw i32 1, %12
%14 = sitofp i32 %13 to float
%15 = fmul float %9, %14
%16 = load float, float* %2
%17 = fsub float 1.000000e+00, %16
%18 = fdiv float %15, %17
%19 = load float, float* %1
%20 = fpext float %19 to double
%21 = fpext float %18 to double
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0), double %20, double %21)
ret void
}