#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 pow(double, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, double *, double *, double *, double *,
                         double *);
int main() {
  double initial_payment, initial_exchange_rate, exchange_monthly_percentage,
      deposit_percentage, needed_amount;
  printf("Введите значения A, K, q, p, C:\n");
  scanf("%lf%lf%lf%lf%lf", &initial_payment, &initial_exchange_rate,
        &exchange_monthly_percentage, &deposit_percentage, &needed_amount);
  double exchange_monthly_rate = 1.0 + exchange_monthly_percentage / 100.0;
  double deposit_rate = 1.0 + deposit_percentage / 100.0;
  double sum = 0.0;
  for (int month_number = 1; month_number <= 12; ++month_number) {
    sum *= deposit_rate;
    double exchange_rate =
        initial_exchange_rate * pow(exchange_monthly_rate, month_number - 1.0);
    double payroll = month_number * initial_payment;
    sum += payroll / exchange_rate;
    if (sum >= needed_amount) {
      printf("\nНакопления превысят $%lf, на %d-(ы/о/и)й месяц.\n",
             needed_amount, month_number);
      return 0;
    }
  }
  printf("\nРанее чем через год накопления не превысят $%lf\n", needed_amount);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeec(%rip),%rdi
lea    -0x10(%rbp),%rsi
lea    -0x18(%rbp),%rdx
lea    -0x20(%rbp),%rcx
lea    -0x28(%rbp),%r8
lea    -0x30(%rbp),%r9
call   1040 <scanf@plt>
movsd  -0x20(%rbp),%xmm1
movsd  0xe8e(%rip),%xmm0
divsd  %xmm0,%xmm1
movsd  0xe7a(%rip),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x28(%rbp),%xmm1
movsd  0xe6c(%rip),%xmm0
divsd  %xmm0,%xmm1
movsd  0xe58(%rip),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x48(%rbp)
movl   $0x1,-0x4c(%rbp)
cmpl   $0xc,-0x4c(%rbp)
jg     127b <main+0x14b>
movsd  -0x40(%rbp),%xmm0
mulsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x38(%rbp),%xmm0
cvtsi2sdl -0x4c(%rbp),%xmm1
movsd  0xe0b(%rip),%xmm2
subsd  %xmm2,%xmm1
cvttsd2si %xmm1,%edi
call   1050 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x68(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
cvtsi2sdl -0x4c(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x60(%rbp),%xmm0
divsd  -0x58(%rbp),%xmm0
addsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
ucomisd -0x30(%rbp),%xmm0
jb     1268 <main+0x138>
movsd  -0x30(%rbp),%xmm0
mov    -0x4c(%rbp),%esi
lea    0xdfb(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1295 <main+0x165>
jmp    126d <main+0x13d>
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    11c0 <main+0x90>
movsd  -0x30(%rbp),%xmm0
lea    0xe18(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x50,%rsp
lea    0xf81(%rip),%rdi
call   1030 <puts@plt>
lea    0xec0(%rip),%rdi
lea    0x48(%rsp),%rsi
lea    0x40(%rsp),%rdx
lea    0x38(%rsp),%rcx
lea    0x30(%rsp),%r8
lea    0x28(%rsp),%r9
call   1050 <scanf@plt>
movsd  0x38(%rsp),%xmm2
movsd  0xe7c(%rip),%xmm0
divsd  %xmm0,%xmm2
movsd  0xe78(%rip),%xmm1
addsd  %xmm1,%xmm2
movsd  %xmm2,0x8(%rsp)
movsd  0x30(%rsp),%xmm2
divsd  %xmm0,%xmm2
addsd  %xmm1,%xmm2
movsd  %xmm2,(%rsp)
mov    $0x1,%ebx
xorpd  %xmm1,%xmm1
cs nopw 0x0(%rax,%rax,1)
mulsd  (%rsp),%xmm1
movsd  %xmm1,0x20(%rsp)
xorps  %xmm1,%xmm1
cvtsi2sd %ebx,%xmm1
movsd  %xmm1,0x10(%rsp)
movsd  0x40(%rsp),%xmm0
movsd  %xmm0,0x18(%rsp)
movapd %xmm1,%xmm0
addsd  0xe20(%rip),%xmm0
cvttsd2si %xmm0,%edi
movsd  0x8(%rsp),%xmm0
call   1060 <pow@plt>
movsd  0x10(%rsp),%xmm1
mulsd  0x18(%rsp),%xmm0
mulsd  0x48(%rsp),%xmm1
divsd  %xmm0,%xmm1
addsd  0x20(%rsp),%xmm1
movsd  0x28(%rsp),%xmm0
ucomisd %xmm0,%xmm1
jae    123f <main+0xff>
add    $0x1,%ebx
cmp    $0xd,%ebx
jne    11c0 <main+0x80>
lea    0xe41(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
jmp    124f <main+0x10f>
lea    0xde2(%rip),%rdi
mov    %ebx,%esi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [48 x i8] c"\D0\92\D0\B2\D0\B5\D0\B4\D0\B8\D1\82\D0\B5 \D0\B7\D0\BD\D0\B0\D1\87\D0\B5\D0\BD\D0\B8\D1\8F A, K, q, p, C:\0A\00"
@.str.1 = [16 x i8] c"%lf%lf%lf%lf%lf\00"
@.str.2 = [79 x i8] c"\0A\D0\9D\D0\B0\D0\BA\D0\BE\D0\BF\D0\BB\D0\B5\D0\BD\D0\B8\D1\8F \D0\BF\D1\80\D0\B5\D0\B2\D1\8B\D1\81\D1\8F\D1\82 $%lf, \D0\BD\D0\B0 %d-(\D1\8B/\D0\BE/\D0\B8)\D0\B9 \D0\BC\D0\B5\D1\81\D1\8F\D1\86.\0A\00"
@.str.3 = [86 x i8] c"\0A\D0\A0\D0\B0\D0\BD\D0\B5\D0\B5 \D1\87\D0\B5\D0\BC \D1\87\D0\B5\D1\80\D0\B5\D0\B7 \D0\B3\D0\BE\D0\B4 \D0\BD\D0\B0\D0\BA\D0\BE\D0\BF\D0\BB\D0\B5\D0\BD\D0\B8\D1\8F \D0\BD\D0\B5 \D0\BF\D1\80\D0\B5\D0\B2\D1\8B\D1\81\D1\8F\D1\82 $%lf\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca i32
%11 = alloca double
%12 = alloca double
store i32 0, i32* %1
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0))
%14 = call i32 @scanf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), double* %2, double* %3, double* %4, double* %5, double* %6)
%15 = load double, double* %4
%16 = fdiv double %15, 1.000000e+02
%17 = fadd double 1.000000e+00, %16
store double %17, double* %7
%18 = load double, double* %5
%19 = fdiv double %18, 1.000000e+02
%20 = fadd double 1.000000e+00, %19
store double %20, double* %8
store double 0.000000e+00, double* %9
store i32 1, i32* %10
br label %21
21: ; preds = %53, %0
%22 = load i32, i32* %10
%23 = icmp sle i32 %22, 12
br i1 %23, label %24, label %56
24: ; preds = %21
%25 = load double, double* %8
%26 = load double, double* %9
%27 = fmul double %26, %25
store double %27, double* %9
%28 = load double, double* %3
%29 = load double, double* %7
%30 = load i32, i32* %10
%31 = sitofp i32 %30 to double
%32 = fsub double %31, 1.000000e+00
%33 = fptosi double %32 to i32
%34 = call double @pow(double %29, i32 %33)
%35 = fmul double %28, %34
store double %35, double* %11
%36 = load i32, i32* %10
%37 = sitofp i32 %36 to double
%38 = load double, double* %2
%39 = fmul double %37, %38
store double %39, double* %12
%40 = load double, double* %12
%41 = load double, double* %11
%42 = fdiv double %40, %41
%43 = load double, double* %9
%44 = fadd double %43, %42
store double %44, double* %9
%45 = load double, double* %9
%46 = load double, double* %6
%47 = fcmp oge double %45, %46
br i1 %47, label %48, label %52
48: ; preds = %24
%49 = load double, double* %6
%50 = load i32, i32* %10
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([79 x i8], [79 x i8]* @.str.2, i64 0, i64 0), double %49, i32 %50)
store i32 0, i32* %1
br label %59
52: ; preds = %24
br label %53
53: ; preds = %52
%54 = load i32, i32* %10
%55 = add nsw i32 %54, 1
store i32 %55, i32* %10
br label %21
56: ; preds = %21
%57 = load double, double* %6
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([86 x i8], [86 x i8]* @.str.3, i64 0, i64 0), double %57)
store i32 0, i32* %1
br label %59
59: ; preds = %56, %48
%60 = load i32, i32* %1
ret i32 %60
}

LLVM IR (-O2):
@.str.1 = [16 x i8] c"%lf%lf%lf%lf%lf\00"
@.str.2 = [79 x i8] c"\0A\D0\9D\D0\B0\D0\BA\D0\BE\D0\BF\D0\BB\D0\B5\D0\BD\D0\B8\D1\8F \D0\BF\D1\80\D0\B5\D0\B2\D1\8B\D1\81\D1\8F\D1\82 $%lf, \D0\BD\D0\B0 %d-(\D1\8B/\D0\BE/\D0\B8)\D0\B9 \D0\BC\D0\B5\D1\81\D1\8F\D1\86.\0A\00"
@.str.3 = [86 x i8] c"\0A\D0\A0\D0\B0\D0\BD\D0\B5\D0\B5 \D1\87\D0\B5\D0\BC \D1\87\D0\B5\D1\80\D0\B5\D0\B7 \D0\B3\D0\BE\D0\B4 \D0\BD\D0\B0\D0\BA\D0\BE\D0\BF\D0\BB\D0\B5\D0\BD\D0\B8\D1\8F \D0\BD\D0\B5 \D0\BF\D1\80\D0\B5\D0\B2\D1\8B\D1\81\D1\8F\D1\82 $%lf\0A\00"
@str = [47 x i8] c"\D0\92\D0\B2\D0\B5\D0\B4\D0\B8\D1\82\D0\B5 \D0\B7\D0\BD\D0\B0\D1\87\D0\B5\D0\BD\D0\B8\D1\8F A, K, q, p, C:\00"
define i32 @main() {
%1 = alloca double
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = bitcast double* %1 to i8*
%7 = bitcast double* %2 to i8*
%8 = bitcast double* %3 to i8*
%9 = bitcast double* %4 to i8*
%10 = bitcast double* %5 to i8*
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @str, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), double* %1, double* %2, double* %3, double* %4, double* %5)
%13 = load double, double* %3
%14 = fdiv double %13, 1.000000e+02
%15 = fadd double %14, 1.000000e+00
%16 = load double, double* %4
%17 = fdiv double %16, 1.000000e+02
%18 = fadd double %17, 1.000000e+00
br label %19
19: ; preds = %0, %37
%20 = phi double [ 0.000000e+00, %0 ], [ %32, %37 ]
%21 = phi i32 [ 1, %0 ], [ %38, %37 ]
%22 = fmul double %18, %20
%23 = load double, double* %2
%24 = sitofp i32 %21 to double
%25 = fadd double %24, -1.000000e+00
%26 = fptosi double %25 to i32
%27 = call double @pow(double %15, i32 %26)
%28 = fmul double %23, %27
%29 = load double, double* %1
%30 = fmul double %29, %24
%31 = fdiv double %30, %28
%32 = fadd double %22, %31
%33 = load double, double* %5
%34 = fcmp ult double %32, %33
br i1 %34, label %37, label %35
35: ; preds = %19
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([79 x i8], [79 x i8]* @.str.2, i64 0, i64 0), double %33, i32 %21)
br label %42
37: ; preds = %19
%38 = add nuw nsw i32 %21, 1
%39 = icmp eq i32 %38, 13
br i1 %39, label %40, label %19
40: ; preds = %37
%41 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([86 x i8], [86 x i8]* @.str.3, i64 0, i64 0), double %33)
br label %42
42: ; preds = %35, %40
ret i32 0
}