#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, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, ...);
main() {
  float x, S;
  int N, k;
  printf("Введите x=");
  scanf("%f", &x);
  printf("Введите N=");
  scanf("%d", &N);
  if (N <= 0) {
    printf("N не должен быть отрицательным или равным 0");
  } else {
    for (k = 0; k <= N; k++) {
      S += (k / 2.0 + 1 / pow(2, k) + (1 + k * x) / (1 + k * pow(x, 2)));
    }
    printf("Выражение S=%f", S);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf46(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
lea    0xebc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec0(%rip),%rdi
lea    -0x10(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
cmpl   $0x0,-0x10(%rbp)
jg     119c <main+0x6c>
lea    0xea7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1285 <main+0x155>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x10(%rbp),%eax
jg     126e <main+0x13e>
cvtsi2sdl -0x14(%rbp),%xmm0
movsd  0xe4c(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x14(%rbp),%edi
movss  0xe34(%rip),%xmm0
call   1050 <pow@plt>
movsd  -0x30(%rbp),%xmm0
mov    %eax,%ecx
mov    $0x1,%eax
cltd
idiv   %ecx
cvtsi2sd %eax,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
cvtsi2ssl -0x14(%rbp),%xmm0
movss  -0x8(%rbp),%xmm1
mulss  %xmm1,%xmm0
movss  0xdf9(%rip),%xmm1
addss  %xmm1,%xmm0
movss  %xmm0,-0x24(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
movss  -0x8(%rbp),%xmm0
mov    $0x2,%edi
call   1050 <pow@plt>
movss  -0x24(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
imul   %ecx,%eax
add    $0x1,%eax
cvtsi2ss %eax,%xmm2
divss  %xmm2,%xmm0
cvtss2sd %xmm0,%xmm0
addsd  %xmm0,%xmm1
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0xc(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11a3 <main+0x73>
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe07(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x28,%rsp
lea    0xed3(%rip),%rdi
xor    %ebp,%ebp
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xf4d(%rip),%rdi
lea    0x1c(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
lea    0xec2(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xec6(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
cmpl   $0x0,0xc(%rsp)
jle    124e <main+0x11e>
mov    $0xffffffff,%ebx
nopw   0x0(%rax,%rax,1)
movsd  %xmm0,0x20(%rsp)
add    $0x1,%ebx
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
mulsd  0xe58(%rip),%xmm0
movsd  %xmm0,0x10(%rsp)
movss  0xe52(%rip),%xmm0
mov    %ebx,%edi
call   1050 <pow@plt>
lea    0x1(%rax),%ecx
cmp    $0x3,%ecx
cmovae %ebp,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
xorps  %xmm1,%xmm1
cvtsi2ss %ebx,%xmm1
addsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
movss  0x1c(%rsp),%xmm0
mulss  %xmm0,%xmm1
addss  0xe1a(%rip),%xmm1
movss  %xmm1,0x18(%rsp)
mov    $0x2,%edi
call   1050 <pow@plt>
imul   %ebx,%eax
add    $0x1,%eax
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
movss  0x18(%rsp),%xmm1
divss  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
addsd  0x10(%rsp),%xmm0
addsd  0x20(%rsp),%xmm0
cvtsd2ss %xmm0,%xmm0
cvtss2sd %xmm0,%xmm0
cmp    0xc(%rsp),%ebx
jl     1190 <main+0x60>
lea    0xe40(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    125c <main+0x12c>
lea    0xde2(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [18 x i8] c"\D0\92\D0\B2\D0\B5\D0\B4\D0\B8\D1\82\D0\B5 x=\00"
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [18 x i8] c"\D0\92\D0\B2\D0\B5\D0\B4\D0\B8\D1\82\D0\B5 N=\00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [78 x i8] c"N \D0\BD\D0\B5 \D0\B4\D0\BE\D0\BB\D0\B6\D0\B5\D0\BD \D0\B1\D1\8B\D1\82\D1\8C \D0\BE\D1\82\D1\80\D0\B8\D1\86\D0\B0\D1\82\D0\B5\D0\BB\D1\8C\D0\BD\D1\8B\D0\BC \D0\B8\D0\BB\D0\B8 \D1\80\D0\B0\D0\B2\D0\BD\D1\8B\D0\BC 0\00"
@.str.5 = [24 x i8] c"\D0\92\D1\8B\D1\80\D0\B0\D0\B6\D0\B5\D0\BD\D0\B8\D0\B5 S=%f\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca float
%3 = alloca float
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%7 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %2)
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
%9 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %4)
%10 = load i32, i32* %4
%11 = icmp sle i32 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %0
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([78 x i8], [78 x i8]* @.str.4, i64 0, i64 0))
br label %52
14: ; preds = %0
store i32 0, i32* %5
br label %15
15: ; preds = %45, %14
%16 = load i32, i32* %5
%17 = load i32, i32* %4
%18 = icmp sle i32 %16, %17
br i1 %18, label %19, label %48
19: ; preds = %15
%20 = load i32, i32* %5
%21 = sitofp i32 %20 to double
%22 = fdiv double %21, 2.000000e+00
%23 = load i32, i32* %5
%24 = call i32 @pow(float 2.000000e+00, i32 %23)
%25 = sdiv i32 1, %24
%26 = sitofp i32 %25 to double
%27 = fadd double %22, %26
%28 = load i32, i32* %5
%29 = sitofp i32 %28 to float
%30 = load float, float* %2
%31 = call float @llvm.fmuladd.f32(float %29, float %30, float 1.000000e+00)
%32 = load i32, i32* %5
%33 = load float, float* %2
%34 = call i32 @pow(float %33, i32 2)
%35 = mul nsw i32 %32, %34
%36 = add nsw i32 1, %35
%37 = sitofp i32 %36 to float
%38 = fdiv float %31, %37
%39 = fpext float %38 to double
%40 = fadd double %27, %39
%41 = load float, float* %3
%42 = fpext float %41 to double
%43 = fadd double %42, %40
%44 = fptrunc double %43 to float
store float %44, float* %3
br label %45
45: ; preds = %19
%46 = load i32, i32* %5
%47 = add nsw i32 %46, 1
store i32 %47, i32* %5
br label %15
48: ; preds = %15
%49 = load float, float* %3
%50 = fpext float %49 to double
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0), double %50)
br label %52
52: ; preds = %48, %12
ret i32 0
}

LLVM IR (-O2):
@.str = [18 x i8] c"\D0\92\D0\B2\D0\B5\D0\B4\D0\B8\D1\82\D0\B5 x=\00"
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [18 x i8] c"\D0\92\D0\B2\D0\B5\D0\B4\D0\B8\D1\82\D0\B5 N=\00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [78 x i8] c"N \D0\BD\D0\B5 \D0\B4\D0\BE\D0\BB\D0\B6\D0\B5\D0\BD \D0\B1\D1\8B\D1\82\D1\8C \D0\BE\D1\82\D1\80\D0\B8\D1\86\D0\B0\D1\82\D0\B5\D0\BB\D1\8C\D0\BD\D1\8B\D0\BC \D0\B8\D0\BB\D0\B8 \D1\80\D0\B0\D0\B2\D0\BD\D1\8B\D0\BC 0\00"
@.str.5 = [24 x i8] c"\D0\92\D1\8B\D1\80\D0\B0\D0\B6\D0\B5\D0\BD\D0\B8\D0\B5 S=%f\00"
define i32 @main() {
%1 = alloca float
%2 = alloca i32
%3 = bitcast float* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%6 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %1)
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
%8 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %2)
%9 = load i32, i32* %2
%10 = icmp slt i32 %9, 1
br i1 %10, label %11, label %13
11: ; preds = %0
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([78 x i8], [78 x i8]* @.str.4, i64 0, i64 0))
br label %42
13: ; preds = %0, %13
%14 = phi i32 [ %36, %13 ], [ 0, %0 ]
%15 = phi double [ %37, %13 ], [ undef, %0 ]
%16 = sitofp i32 %14 to double
%17 = fmul double %16, 5.000000e-01
%18 = call i32 @pow(float 2.000000e+00, i32 %14)
%19 = add i32 %18, 1
%20 = icmp ult i32 %19, 3
%21 = select i1 %20, i32 %18, i32 0
%22 = sitofp i32 %21 to double
%23 = fadd double %17, %22
%24 = sitofp i32 %14 to float
%25 = load float, float* %1
%26 = call float @llvm.fmuladd.f32(float %24, float %25, float 1.000000e+00)
%27 = call i32 @pow(float %25, i32 2)
%28 = mul nsw i32 %27, %14
%29 = add nsw i32 %28, 1
%30 = sitofp i32 %29 to float
%31 = fdiv float %26, %30
%32 = fpext float %31 to double
%33 = fadd double %23, %32
%34 = fadd double %15, %33
%35 = fptrunc double %34 to float
%36 = add nuw nsw i32 %14, 1
%37 = fpext float %35 to double
%38 = load i32, i32* %2
%39 = icmp slt i32 %14, %38
br i1 %39, label %13, label %40
40: ; preds = %13
%41 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0), double %37)
br label %42
42: ; preds = %40, %11
ret i32 0
}