#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(int, int);
int round(int);
int sqrt(int);
int needed_xp(int level) {
  int a = round(level / 2);
  int b = (level - 1) / 2;
  int m = 2000;
  int n = 5000 - m;
  int c = m * (pow(2, a) - 1) + n * (pow(2, b) - 1);
  int d = sqrt(level - 1);
  double e = (pow(10, d)) / 0.2f;
  int f = round(c / e);
  int ret = f * e + 1;
  return ret;
}


x86 assembly (clang, -O0):
<needed_xp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%edi
call   1040 <round@plt>
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
sub    $0x1,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0xc(%rbp)
movl   $0x7d0,-0x10(%rbp)
mov    $0x1388,%eax
sub    -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
cvtsi2ssl -0x10(%rbp),%xmm0
movss  %xmm0,-0x34(%rbp)
mov    -0x8(%rbp),%esi
mov    $0x2,%edi
call   1030 <pow@plt>
movss  0xe7a(%rip),%xmm1
subss  %xmm1,%xmm0
movss  %xmm0,-0x38(%rbp)
cvtsi2ssl -0x14(%rbp),%xmm0
movss  %xmm0,-0x3c(%rbp)
mov    -0xc(%rbp),%esi
mov    $0x2,%edi
call   1030 <pow@plt>
movss  -0x3c(%rbp),%xmm1
movss  -0x38(%rbp),%xmm2
movaps %xmm0,%xmm3
movss  -0x34(%rbp),%xmm0
movss  0xe40(%rip),%xmm4
subss  %xmm4,%xmm3
mulss  %xmm3,%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
cvttss2si %xmm0,%eax
mov    %eax,-0x18(%rbp)
mov    -0x4(%rbp),%edi
sub    $0x1,%edi
call   1050 <sqrt@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%esi
mov    $0xa,%edi
call   1030 <pow@plt>
movss  0xe02(%rip),%xmm1
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
cvtsi2sdl -0x18(%rbp),%xmm0
divsd  -0x28(%rbp),%xmm0
cvttsd2si %xmm0,%edi
call   1040 <round@plt>
mov    %eax,-0x2c(%rbp)
cvtsi2sdl -0x2c(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xdc1(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x30(%rbp)
mov    -0x30(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<needed_xp>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
mov    %edi,%ebx
shr    $0x1f,%edi
add    %ebx,%edi
sar    %edi
call   1040 <round@plt>
mov    %ebx,%ebp
add    $0xffffffff,%ebp
mov    %ebp,%ecx
shr    $0x1f,%ecx
add    %ecx,%ebx
add    $0xffffffff,%ebx
sar    %ebx
mov    $0x2,%edi
mov    %eax,%esi
call   1030 <pow@plt>
addss  0xe97(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    $0x2,%edi
mov    %ebx,%esi
call   1030 <pow@plt>
addss  0xe7f(%rip),%xmm0
mulss  0xe7b(%rip),%xmm0
movaps (%rsp),%xmm1
mulss  0xe73(%rip),%xmm1
addss  %xmm0,%xmm1
movaps %xmm1,(%rsp)
mov    %ebp,%edi
call   1050 <sqrt@plt>
mov    $0xa,%edi
mov    %eax,%esi
call   1030 <pow@plt>
divss  0xe54(%rip),%xmm0
cvttps2dq (%rsp),%xmm1
cvtdq2pd %xmm1,%xmm1
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,(%rsp)
divsd  %xmm0,%xmm1
cvttsd2si %xmm1,%edi
call   1040 <round@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  (%rsp),%xmm0
addsd  0xe25(%rip),%xmm0
cvttsd2si %xmm0,%eax
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @needed_xp(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca double
%10 = alloca i32
%11 = alloca i32
store i32 %0, i32* %2
%12 = load i32, i32* %2
%13 = sdiv i32 %12, 2
%14 = call i32 @round(i32 %13)
store i32 %14, i32* %3
%15 = load i32, i32* %2
%16 = sub nsw i32 %15, 1
%17 = sdiv i32 %16, 2
store i32 %17, i32* %4
store i32 2000, i32* %5
%18 = load i32, i32* %5
%19 = sub nsw i32 5000, %18
store i32 %19, i32* %6
%20 = load i32, i32* %5
%21 = sitofp i32 %20 to float
%22 = load i32, i32* %3
%23 = call float @pow(i32 2, i32 %22)
%24 = fsub float %23, 1.000000e+00
%25 = load i32, i32* %6
%26 = sitofp i32 %25 to float
%27 = load i32, i32* %4
%28 = call float @pow(i32 2, i32 %27)
%29 = fsub float %28, 1.000000e+00
%30 = fmul float %26, %29
%31 = call float @llvm.fmuladd.f32(float %21, float %24, float %30)
%32 = fptosi float %31 to i32
store i32 %32, i32* %7
%33 = load i32, i32* %2
%34 = sub nsw i32 %33, 1
%35 = call i32 @sqrt(i32 %34)
store i32 %35, i32* %8
%36 = load i32, i32* %8
%37 = call float @pow(i32 10, i32 %36)
%38 = fdiv float %37, 0x3FC99999A0000000
%39 = fpext float %38 to double
store double %39, double* %9
%40 = load i32, i32* %7
%41 = sitofp i32 %40 to double
%42 = load double, double* %9
%43 = fdiv double %41, %42
%44 = fptosi double %43 to i32
%45 = call i32 @round(i32 %44)
store i32 %45, i32* %10
%46 = load i32, i32* %10
%47 = sitofp i32 %46 to double
%48 = load double, double* %9
%49 = call double @llvm.fmuladd.f64(double %47, double %48, double 1.000000e+00)
%50 = fptosi double %49 to i32
store i32 %50, i32* %11
%51 = load i32, i32* %11
ret i32 %51
}

LLVM IR (-O2):
define i32 @needed_xp(i32 %0) {
%2 = sdiv i32 %0, 2
%3 = tail call i32 @round(i32 %2)
%4 = add nsw i32 %0, -1
%5 = sdiv i32 %4, 2
%6 = tail call float @pow(i32 2, i32 %3)
%7 = fadd float %6, -1.000000e+00
%8 = tail call float @pow(i32 2, i32 %5)
%9 = fadd float %8, -1.000000e+00
%10 = fmul float %9, 3.000000e+03
%11 = tail call float @llvm.fmuladd.f32(float %7, float 2.000000e+03, float %10)
%12 = fptosi float %11 to i32
%13 = tail call i32 @sqrt(i32 %4)
%14 = tail call float @pow(i32 10, i32 %13)
%15 = fdiv float %14, 0x3FC99999A0000000
%16 = fpext float %15 to double
%17 = sitofp i32 %12 to double
%18 = fdiv double %17, %16
%19 = fptosi double %18 to i32
%20 = tail call i32 @round(i32 %19)
%21 = sitofp i32 %20 to double
%22 = tail call double @llvm.fmuladd.f64(double %21, double %16, double 1.000000e+00)
%23 = fptosi double %22 to i32
ret i32 %23
}