#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 */
char *strchr(char const *, char);
int adjustpythagoras(double *num, int den, char nominal) {
  int c;
  double n;
  char *x;
  const char pylow[8] = "fcgdaeb";
  const char pyupp[8] = "FCGDAEB";
  const int m = 3;
  x = NULL;
  c = 0;
  x = strchr(pylow, nominal);
  if (x != NULL)
    c = (x - pylow) - m;
  x = strchr(pyupp, nominal);
  if (x != NULL)
    c = (x - pyupp) - m;
  n = *num +
      ((1.9550008653874328956590034067630767822266) * c * (double)den / 100.0);
  *num = n;
  return 1;
}


x86 assembly (clang, -O0):
<adjustpythagoras>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %dl,%al
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %al,-0xd(%rbp)
mov    0xee5(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xee2(%rip),%rax
mov    %rax,-0x38(%rbp)
movl   $0x3,-0x3c(%rbp)
movq   $0x0,-0x28(%rbp)
movl   $0x0,-0x14(%rbp)
lea    -0x30(%rbp),%rdi
movsbl -0xd(%rbp),%esi
call   1030 <strchr@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     117e <adjustpythagoras+0x6e>
mov    -0x28(%rbp),%rax
lea    -0x30(%rbp),%rcx
sub    %rcx,%rax
sub    $0x3,%rax
mov    %eax,-0x14(%rbp)
lea    -0x38(%rbp),%rdi
movsbl -0xd(%rbp),%esi
call   1030 <strchr@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     11ac <adjustpythagoras+0x9c>
mov    -0x28(%rbp),%rax
lea    -0x38(%rbp),%rcx
sub    %rcx,%rax
sub    $0x3,%rax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
cvtsi2sdl -0x14(%rbp),%xmm2
movsd  0xe47(%rip),%xmm1
mulsd  %xmm2,%xmm1
cvtsi2sdl -0xc(%rbp),%xmm2
mulsd  %xmm2,%xmm1
movsd  0xe2a(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,(%rax)
mov    $0x1,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<adjustpythagoras>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %edx,%ebp
mov    %esi,%r14d
mov    %rdi,%r15
movabs $0x62656164676366,%rax
mov    %rax,0x8(%rsp)
movabs $0x42454144474346,%rax
mov    %rax,(%rsp)
lea    0x8(%rsp),%rbx
mov    %rbx,%rdi
mov    %edx,%esi
call   1030 <strchr@plt>
mov    %eax,%ecx
sub    %ebx,%ecx
add    $0xfffffffd,%ecx
xor    %ebx,%ebx
test   %rax,%rax
cmovne %ecx,%ebx
mov    %rsp,%r12
mov    %r12,%rdi
mov    %ebp,%esi
call   1030 <strchr@plt>
mov    %eax,%ecx
sub    %r12d,%ecx
add    $0xfffffffd,%ecx
test   %rax,%rax
cmove  %ebx,%ecx
cvtsi2sd %ecx,%xmm0
mulsd  0xe7a(%rip),%xmm0
cvtsi2sd %r14d,%xmm1
mulsd  %xmm0,%xmm1
divsd  0xe71(%rip),%xmm1
addsd  (%r15),%xmm1
movsd  %xmm1,(%r15)
mov    $0x1,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.adjustpythagoras.pylow = [8 x i8] c"fcgdaeb\00"
@__const.adjustpythagoras.pyupp = [8 x i8] c"FCGDAEB\00"
define i32 @adjustpythagoras(double* %0, i32 %1, i8 signext %2) {
%4 = alloca double*
%5 = alloca i32
%6 = alloca i8
%7 = alloca i32
%8 = alloca double
%9 = alloca i8*
%10 = alloca [8 x i8]
%11 = alloca [8 x i8]
%12 = alloca i32
store double* %0, double** %4
store i32 %1, i32* %5
store i8 %2, i8* %6
%13 = bitcast [8 x i8]* %10 to i8*
%14 = bitcast [8 x i8]* %11 to i8*
store i32 3, i32* %12
store i8* null, i8** %9
store i32 0, i32* %7
%15 = getelementptr inbounds [8 x i8], [8 x i8]* %10, i64 0, i64 0
%16 = load i8, i8* %6
%17 = call i8* @strchr(i8* %15, i8 signext %16)
store i8* %17, i8** %9
%18 = load i8*, i8** %9
%19 = icmp ne i8* %18, null
br i1 %19, label %20, label %28
20: ; preds = %3
%21 = load i8*, i8** %9
%22 = getelementptr inbounds [8 x i8], [8 x i8]* %10, i64 0, i64 0
%23 = ptrtoint i8* %21 to i64
%24 = ptrtoint i8* %22 to i64
%25 = sub i64 %23, %24
%26 = sub nsw i64 %25, 3
%27 = trunc i64 %26 to i32
store i32 %27, i32* %7
br label %28
28: ; preds = %20, %3
%29 = getelementptr inbounds [8 x i8], [8 x i8]* %11, i64 0, i64 0
%30 = load i8, i8* %6
%31 = call i8* @strchr(i8* %29, i8 signext %30)
store i8* %31, i8** %9
%32 = load i8*, i8** %9
%33 = icmp ne i8* %32, null
br i1 %33, label %34, label %42
34: ; preds = %28
%35 = load i8*, i8** %9
%36 = getelementptr inbounds [8 x i8], [8 x i8]* %11, i64 0, i64 0
%37 = ptrtoint i8* %35 to i64
%38 = ptrtoint i8* %36 to i64
%39 = sub i64 %37, %38
%40 = sub nsw i64 %39, 3
%41 = trunc i64 %40 to i32
store i32 %41, i32* %7
br label %42
42: ; preds = %34, %28
%43 = load double*, double** %4
%44 = load double, double* %43
%45 = load i32, i32* %7
%46 = sitofp i32 %45 to double
%47 = fmul double 0x3FFF47AEFCC7DA00, %46
%48 = load i32, i32* %5
%49 = sitofp i32 %48 to double
%50 = fmul double %47, %49
%51 = fdiv double %50, 1.000000e+02
%52 = fadd double %44, %51
store double %52, double* %8
%53 = load double, double* %8
%54 = load double*, double** %4
store double %53, double* %54
ret i32 1
}

LLVM IR (-O2):
define i32 @adjustpythagoras(double* nocapture %0, i32 %1, i8 signext %2) {
%4 = alloca i64
%5 = alloca i64
%6 = bitcast i64* %4 to i8*
store i64 27696016688374630, i64* %4
%7 = bitcast i64* %5 to i8*
store i64 18653495083615046, i64* %5
%8 = call i8* @strchr(i8* %6, i8 signext %2)
%9 = icmp eq i8* %8, null
%10 = ptrtoint i8* %8 to i64
%11 = ptrtoint i64* %4 to i64
%12 = sub i64 %10, %11
%13 = trunc i64 %12 to i32
%14 = add i32 %13, -3
%15 = select i1 %9, i32 0, i32 %14
%16 = call i8* @strchr(i8* %7, i8 signext %2)
%17 = icmp eq i8* %16, null
%18 = ptrtoint i8* %16 to i64
%19 = ptrtoint i64* %5 to i64
%20 = sub i64 %18, %19
%21 = trunc i64 %20 to i32
%22 = add i32 %21, -3
%23 = select i1 %17, i32 %15, i32 %22
%24 = load double, double* %0
%25 = sitofp i32 %23 to double
%26 = fmul double %25, 0x3FFF47AEFCC7DA00
%27 = sitofp i32 %1 to double
%28 = fmul double %26, %27
%29 = fdiv double %28, 1.000000e+02
%30 = fadd double %24, %29
store double %30, double* %0
ret i32 1
}