#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 atoi(char *);
double pow(double, int);
double ScaleFactor(char *s) {
  int n;
  if (*s == 0)
    return (1.0);
  if (*s == 'E') {
    n = atoi(s + 1);
    return (pow(10.0, n));
  }
  if (*s == 'B') {
    n = atoi(s + 1);
    return (pow(2.0, n));
  }
  return (1.0);
}


x86 assembly (clang, -O0):
<ScaleFactor>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    114e <ScaleFactor+0x2e>
movsd  0xebc(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11cf <ScaleFactor+0xaf>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x45,%eax
jne    1188 <ScaleFactor+0x68>
mov    -0x10(%rbp),%rdi
add    $0x1,%rdi
call   1040 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
movsd  0xe97(%rip),%xmm0
call   1030 <pow@plt>
movsd  %xmm0,-0x8(%rbp)
jmp    11cf <ScaleFactor+0xaf>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x42,%eax
jne    11c2 <ScaleFactor+0xa2>
mov    -0x10(%rbp),%rdi
add    $0x1,%rdi
call   1040 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
movsd  0xe55(%rip),%xmm0
call   1030 <pow@plt>
movsd  %xmm0,-0x8(%rbp)
jmp    11cf <ScaleFactor+0xaf>
movsd  0xe36(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ScaleFactor>:
push   %rax
mov    (%rdi),%al
cmp    $0x45,%al
je     1135 <ScaleFactor+0x15>
cmp    $0x42,%al
jne    1158 <ScaleFactor+0x38>
movsd  0xed5(%rip),%xmm0
jmp    113d <ScaleFactor+0x1d>
movsd  0xec3(%rip),%xmm0
movsd  %xmm0,(%rsp)
add    $0x1,%rdi
call   1040 <atoi@plt>
movsd  (%rsp),%xmm0
mov    %eax,%edi
pop    %rax
jmp    1030 <pow@plt>
movsd  0xeb0(%rip),%xmm0
pop    %rax
ret

LLVM IR (-O0):
define double @ScaleFactor(i8* %0) {
%2 = alloca double
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = load i8, i8* %5
%7 = sext i8 %6 to i32
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %10
9: ; preds = %1
store double 1.000000e+00, double* %2
br label %33
10: ; preds = %1
%11 = load i8*, i8** %3
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = icmp eq i32 %13, 69
br i1 %14, label %15, label %21
15: ; preds = %10
%16 = load i8*, i8** %3
%17 = getelementptr inbounds i8, i8* %16, i64 1
%18 = call i32 @atoi(i8* %17)
store i32 %18, i32* %4
%19 = load i32, i32* %4
%20 = call double @pow(double 1.000000e+01, i32 %19)
store double %20, double* %2
br label %33
21: ; preds = %10
%22 = load i8*, i8** %3
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = icmp eq i32 %24, 66
br i1 %25, label %26, label %32
26: ; preds = %21
%27 = load i8*, i8** %3
%28 = getelementptr inbounds i8, i8* %27, i64 1
%29 = call i32 @atoi(i8* %28)
store i32 %29, i32* %4
%30 = load i32, i32* %4
%31 = call double @pow(double 2.000000e+00, i32 %30)
store double %31, double* %2
br label %33
32: ; preds = %21
store double 1.000000e+00, double* %2
br label %33
33: ; preds = %32, %26, %15, %9
%34 = load double, double* %2
ret double %34
}

LLVM IR (-O2):
define double @ScaleFactor(i8* nocapture %0) {
%2 = load i8, i8* %0
switch i8 %2, label %9 [
i8 66, label %3
i8 69, label %4
]
3: ; preds = %1
br label %4
4: ; preds = %1, %3
%5 = phi double [ 2.000000e+00, %3 ], [ 1.000000e+01, %1 ]
%6 = getelementptr inbounds i8, i8* %0, i64 1
%7 = tail call i32 @atoi(i8* %6)
%8 = tail call double @pow(double %5, i32 %7)
br label %9
9: ; preds = %4, %1
%10 = phi double [ 1.000000e+00, %1 ], [ %8, %4 ]
ret double %10
}