#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 log10(double);
double pow(double, double);
void illumina2phred(char *src, int n) {
  int i, s, q;
  double p;
  for (i = 0; i < n; i++) {
    s = src[i] - 64;
    p = (1.0 - (1.0 / (1.0 + pow(10.0, ((double)(s) / 10.0)))));
    q = ((int)-(10.0 * log10(1.0 - (p))));
    src[i] = q + 33;
  }
}


x86 assembly (clang, -O0):
<illumina2phred>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11fe <illumina2phred+0xde>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
sub    $0x40,%eax
mov    %eax,-0x14(%rbp)
cvtsi2sdl -0x14(%rbp),%xmm1
movsd  0xe9f(%rip),%xmm0
divsd  %xmm0,%xmm1
movsd  0xe93(%rip),%xmm0
call   1030 <pow@plt>
movaps %xmm0,%xmm1
movsd  0xe8b(%rip),%xmm0
addsd  %xmm1,%xmm0
movsd  0xe7f(%rip),%xmm1
divsd  %xmm0,%xmm1
movsd  0xe73(%rip),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xe62(%rip),%xmm0
subsd  -0x20(%rbp),%xmm0
call   1040 <log10@plt>
movaps %xmm0,%xmm1
movsd  0xe45(%rip),%xmm0
mulsd  %xmm1,%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
add    $0x21,%eax
mov    %al,%dl
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1136 <illumina2phred+0x16>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<illumina2phred>:
push   %r15
push   %r14
push   %rbx
test   %esi,%esi
jle    11a4 <illumina2phred+0x84>
mov    %rdi,%r15
mov    %esi,%r14d
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsbl (%r15,%rbx,1),%eax
add    $0xffffffc0,%eax
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
movsd  0xea9(%rip),%xmm0
divsd  %xmm0,%xmm1
call   1030 <pow@plt>
movsd  0xea0(%rip),%xmm2
addsd  %xmm2,%xmm0
movapd %xmm2,%xmm1
divsd  %xmm0,%xmm1
addsd  0xe94(%rip),%xmm1
addsd  %xmm2,%xmm1
movapd %xmm1,%xmm0
call   1040 <log10@plt>
mulsd  0xe87(%rip),%xmm0
cvttsd2si %xmm0,%eax
add    $0x21,%al
mov    %al,(%r15,%rbx,1)
add    $0x1,%rbx
cmp    %rbx,%r14
jne    1140 <illumina2phred+0x20>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @illumina2phred(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca double
store i8* %0, i8** %3
store i32 %1, i32* %4
store i32 0, i32* %5
br label %9
9: ; preds = %41, %2
%10 = load i32, i32* %5
%11 = load i32, i32* %4
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %44
13: ; preds = %9
%14 = load i8*, i8** %3
%15 = load i32, i32* %5
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8, i8* %14, i64 %16
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = sub nsw i32 %19, 64
store i32 %20, i32* %6
%21 = load i32, i32* %6
%22 = sitofp i32 %21 to double
%23 = fdiv double %22, 1.000000e+01
%24 = call double @pow(double 1.000000e+01, double %23)
%25 = fadd double 1.000000e+00, %24
%26 = fdiv double 1.000000e+00, %25
%27 = fsub double 1.000000e+00, %26
store double %27, double* %8
%28 = load double, double* %8
%29 = fsub double 1.000000e+00, %28
%30 = call double @log10(double %29)
%31 = fmul double 1.000000e+01, %30
%32 = fneg double %31
%33 = fptosi double %32 to i32
store i32 %33, i32* %7
%34 = load i32, i32* %7
%35 = add nsw i32 %34, 33
%36 = trunc i32 %35 to i8
%37 = load i8*, i8** %3
%38 = load i32, i32* %5
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i8, i8* %37, i64 %39
store i8 %36, i8* %40
br label %41
41: ; preds = %13
%42 = load i32, i32* %5
%43 = add nsw i32 %42, 1
store i32 %43, i32* %5
br label %9
44: ; preds = %9
ret void
}

LLVM IR (-O2):
define void @illumina2phred(i8* nocapture %0, i32 %1) {
%3 = icmp sgt i32 %1, 0
br i1 %3, label %4, label %26
4: ; preds = %2
%5 = zext i32 %1 to i64
br label %6
6: ; preds = %4, %6
%7 = phi i64 [ 0, %4 ], [ %24, %6 ]
%8 = getelementptr inbounds i8, i8* %0, i64 %7
%9 = load i8, i8* %8
%10 = sext i8 %9 to i32
%11 = add nsw i32 %10, -64
%12 = sitofp i32 %11 to double
%13 = fdiv double %12, 1.000000e+01
%14 = tail call double @pow(double 1.000000e+01, double %13)
%15 = fadd double %14, 1.000000e+00
%16 = fdiv double 1.000000e+00, %15
%17 = fadd double %16, -1.000000e+00
%18 = fadd double %17, 1.000000e+00
%19 = tail call double @log10(double %18)
%20 = fmul double %19, -1.000000e+01
%21 = fptosi double %20 to i32
%22 = trunc i32 %21 to i8
%23 = add i8 %22, 33
store i8 %23, i8* %8
%24 = add nuw nsw i64 %7, 1
%25 = icmp eq i64 %24, %5
br i1 %25, label %26, label %6
26: ; preds = %6, %2
ret void
}