#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 /*<<< orphan*/ get_var(char const *, size_t, char *);
int /*<<< orphan*/ printf(char *, double);
double strtoull(int /*<<< orphan*/, int /*<<< orphan*/ *, int);
void f_qcachehitrate(const char *buffer, size_t len) {
  double qcache_hits, qcache_inserts;
  qcache_hits = strtoull(get_var(buffer, len, "Qcache_hits"), NULL, 10);
  qcache_inserts = strtoull(get_var(buffer, len, "Qcache_inserts"), NULL, 10);
  printf("%0.2f", (qcache_hits * 100.0 / (qcache_hits + qcache_inserts)));
}


x86 assembly (clang, -O0):
<f_qcachehitrate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
lea    0xeb9(%rip),%rdx
call   1040 <get_var@plt>
mov    %eax,%edi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1050 <strtoull@plt>
movsd  %xmm0,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
lea    0xe9c(%rip),%rdx
call   1040 <get_var@plt>
mov    %eax,%edi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1050 <strtoull@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  0xe66(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
addsd  -0x20(%rbp),%xmm1
divsd  %xmm1,%xmm0
lea    0xe6f(%rip),%rdi
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<f_qcachehitrate>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xec7(%rip),%rdx
call   1040 <get_var@plt>
mov    %eax,%edi
xor    %esi,%esi
mov    $0xa,%edx
call   1050 <strtoull@plt>
movsd  %xmm0,(%rsp)
lea    0xeb4(%rip),%rdx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <get_var@plt>
mov    %eax,%edi
xor    %esi,%esi
mov    $0xa,%edx
call   1050 <strtoull@plt>
movsd  0xe7f(%rip),%xmm1
movsd  (%rsp),%xmm2
mulsd  %xmm2,%xmm1
addsd  %xmm2,%xmm0
divsd  %xmm0,%xmm1
lea    0xe8a(%rip),%rdi
movapd %xmm1,%xmm0
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [12 x i8] c"Qcache_hits\00"
@.str.1 = [15 x i8] c"Qcache_inserts\00"
@.str.2 = [6 x i8] c"%0.2f\00"
define void @f_qcachehitrate(i8* %0, i64 %1) {
%3 = alloca i8*
%4 = alloca i64
%5 = alloca double
%6 = alloca double
store i8* %0, i8** %3
store i64 %1, i64* %4
%7 = load i8*, i8** %3
%8 = load i64, i64* %4
%9 = call i32 @get_var(i8* %7, i64 %8, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%10 = call double @strtoull(i32 %9, i32* null, i32 10)
store double %10, double* %5
%11 = load i8*, i8** %3
%12 = load i64, i64* %4
%13 = call i32 @get_var(i8* %11, i64 %12, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
%14 = call double @strtoull(i32 %13, i32* null, i32 10)
store double %14, double* %6
%15 = load double, double* %5
%16 = fmul double %15, 1.000000e+02
%17 = load double, double* %5
%18 = load double, double* %6
%19 = fadd double %17, %18
%20 = fdiv double %16, %19
%21 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), double %20)
ret void
}

LLVM IR (-O2):
@.str = [12 x i8] c"Qcache_hits\00"
@.str.1 = [15 x i8] c"Qcache_inserts\00"
@.str.2 = [6 x i8] c"%0.2f\00"
define void @f_qcachehitrate(i8* %0, i64 %1) {
%3 = tail call i32 @get_var(i8* %0, i64 %1, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%4 = tail call double @strtoull(i32 %3, i32* null, i32 10)
%5 = tail call i32 @get_var(i8* %0, i64 %1, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
%6 = tail call double @strtoull(i32 %5, i32* null, i32 10)
%7 = fmul double %4, 1.000000e+02
%8 = fadd double %4, %6
%9 = fdiv double %7, %8
%10 = tail call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), double %9)
ret void
}