#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 pow(float, float);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, float *);
float sin(float);
main() {
  float S, N, x, k;
  k = 1.0;
  printf("Ââåäèòå x\n");
  scanf("%f", &x);
  N = pow(x, k) / k * sin(k * x);
  for (k = 1; S < 1; k++) {
    S = S + (pow(-1, k) * pow(x, k) / k * sin(k * x));
  }
  printf("S = %f\n", S);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movss  0xea9(%rip),%xmm0
movss  %xmm0,-0x14(%rbp)
lea    0xea5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xea9(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1050 <scanf@plt>
movss  -0x10(%rbp),%xmm0
movss  -0x14(%rbp),%xmm1
call   1060 <pow@plt>
divss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x14(%rbp),%xmm0
mulss  -0x10(%rbp),%xmm0
call   1040 <sin@plt>
movaps %xmm0,%xmm1
movss  -0x18(%rbp),%xmm0
mulss  %xmm1,%xmm0
movss  %xmm0,-0xc(%rbp)
movss  0xe45(%rip),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  0xe38(%rip),%xmm0
ucomiss -0x8(%rbp),%xmm0
jbe    1258 <main+0x118>
movss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x20(%rbp)
movss  -0x14(%rbp),%xmm1
movss  0xe1b(%rip),%xmm0
call   1060 <pow@plt>
movss  %xmm0,-0x24(%rbp)
movss  -0x10(%rbp),%xmm0
movss  -0x14(%rbp),%xmm1
call   1060 <pow@plt>
movaps %xmm0,%xmm1
movss  -0x24(%rbp),%xmm0
mulss  %xmm1,%xmm0
divss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x14(%rbp),%xmm0
mulss  -0x10(%rbp),%xmm0
call   1040 <sin@plt>
movss  -0x20(%rbp),%xmm1
movaps %xmm0,%xmm2
movss  -0x1c(%rbp),%xmm0
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x8(%rbp)
movss  0xdb7(%rip),%xmm0
addss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
jmp    11c0 <main+0x80>
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xdb5(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xecb(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb4(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1060 <scanf@plt>
movss  0x4(%rsp),%xmm0
ucomiss 0xe95(%rip),%xmm0
jae    118c <main+0x4c>
movss  0xe8f(%rip),%xmm1
ucomiss %xmm0,%xmm1
jae    118c <main+0x4c>
lea    0xe8a(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret
call   1050 <sin@plt>
jmp    117a <main+0x3a>

LLVM IR (-O0):
@.str = [18 x i8] c"\C3\82\C3\A2\C3\A5\C3\A4\C3\A8\C3\B2\C3\A5 x\0A\00"
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [8 x i8] c"S = %f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca float
%3 = alloca float
%4 = alloca float
%5 = alloca float
store i32 0, i32* %1
store float 1.000000e+00, float* %5
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %4)
%8 = load float, float* %4
%9 = load float, float* %5
%10 = call float @pow(float %8, float %9)
%11 = load float, float* %5
%12 = fdiv float %10, %11
%13 = load float, float* %5
%14 = load float, float* %4
%15 = fmul float %13, %14
%16 = call float @sin(float %15)
%17 = fmul float %12, %16
store float %17, float* %3
store float 1.000000e+00, float* %5
br label %18
18: ; preds = %36, %0
%19 = load float, float* %2
%20 = fcmp olt float %19, 1.000000e+00
br i1 %20, label %21, label %39
21: ; preds = %18
%22 = load float, float* %2
%23 = load float, float* %5
%24 = call float @pow(float -1.000000e+00, float %23)
%25 = load float, float* %4
%26 = load float, float* %5
%27 = call float @pow(float %25, float %26)
%28 = fmul float %24, %27
%29 = load float, float* %5
%30 = fdiv float %28, %29
%31 = load float, float* %5
%32 = load float, float* %4
%33 = fmul float %31, %32
%34 = call float @sin(float %33)
%35 = call float @llvm.fmuladd.f32(float %30, float %34, float %22)
store float %35, float* %2
br label %36
36: ; preds = %21
%37 = load float, float* %5
%38 = fadd float %37, 1.000000e+00
store float %38, float* %5
br label %18
39: ; preds = %18
%40 = load float, float* %2
%41 = fpext float %40 to double
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), double %41)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [8 x i8] c"S = %f\0A\00"
@str = [17 x i8] c"\C3\82\C3\A2\C3\A5\C3\A4\C3\A8\C3\B2\C3\A5 x\00"
define i32 @main() {
%1 = alloca float
%2 = bitcast float* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 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), float* %1)
%5 = load float, float* %1
%6 = fcmp oeq float %5, 0xFFF0000000000000
%7 = fcmp oeq float %5, 0x7FF0000000000000
%8 = or i1 %7, %6
br i1 %8, label %9, label %11
9: ; preds = %0
%10 = call float @sin(float %5)
br label %11
11: ; preds = %9, %0
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), double undef)
ret i32 0
}