#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 */
scalar_t__ equals(char const *, char *);
double get_double(char const *);
double get_scale(const char *v, const char *u) {
  if (equals(u, "M/PIX"))
    return get_double(v);
  if (equals(u, "KM/PIX"))
    return get_double(v) * 1000.0;
  if (equals(u, "M/PIXEL"))
    return get_double(v);
  if (equals(u, "KM/PIXEL"))
    return get_double(v) * 1000.0;
  return get_double(v);
}


x86 assembly (clang, -O0):
<get_scale>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xece(%rip),%rsi
call   1040 <equals@plt>
cmp    $0x0,%rax
je     115d <get_scale+0x3d>
mov    -0x10(%rbp),%rdi
call   1030 <get_double@plt>
movsd  %xmm0,-0x8(%rbp)
jmp    120a <get_scale+0xea>
mov    -0x18(%rbp),%rdi
lea    0xea0(%rip),%rsi
call   1040 <equals@plt>
cmp    $0x0,%rax
je     1196 <get_scale+0x76>
mov    -0x10(%rbp),%rdi
call   1030 <get_double@plt>
movsd  0xe78(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    120a <get_scale+0xea>
mov    -0x18(%rbp),%rdi
lea    0xe6f(%rip),%rsi
call   1040 <equals@plt>
cmp    $0x0,%rax
je     11c3 <get_scale+0xa3>
mov    -0x10(%rbp),%rdi
call   1030 <get_double@plt>
movsd  %xmm0,-0x8(%rbp)
jmp    120a <get_scale+0xea>
mov    -0x18(%rbp),%rdi
lea    0xe41(%rip),%rsi
call   1040 <equals@plt>
cmp    $0x0,%rax
je     11fc <get_scale+0xdc>
mov    -0x10(%rbp),%rdi
call   1030 <get_double@plt>
movsd  0xe12(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    120a <get_scale+0xea>
mov    -0x10(%rbp),%rdi
call   1030 <get_double@plt>
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_scale>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
lea    0xed8(%rip),%rsi
mov    %rbx,%rdi
call   1040 <equals@plt>
test   %rax,%rax
je     114d <get_scale+0x2d>
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <get_double@plt>
lea    0xeb4(%rip),%rsi
mov    %rbx,%rdi
call   1040 <equals@plt>
test   %rax,%rax
je     1179 <get_scale+0x59>
mov    %r14,%rdi
call   1030 <get_double@plt>
mulsd  0xe8f(%rip),%xmm0
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
lea    0xe90(%rip),%rsi
mov    %rbx,%rdi
call   1040 <equals@plt>
test   %rax,%rax
jne    113e <get_scale+0x1e>
lea    0xe7b(%rip),%rsi
mov    %rbx,%rdi
call   1040 <equals@plt>
mov    %rax,%rbx
mov    %r14,%rdi
call   1030 <get_double@plt>
test   %rbx,%rbx
jne    1169 <get_scale+0x49>
jmp    1171 <get_scale+0x51>

LLVM IR (-O0):
@.str = [6 x i8] c"M/PIX\00"
@.str.1 = [7 x i8] c"KM/PIX\00"
@.str.2 = [8 x i8] c"M/PIXEL\00"
@.str.3 = [9 x i8] c"KM/PIXEL\00"
define double @get_scale(i8* %0, i8* %1) {
%3 = alloca double
%4 = alloca i8*
%5 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
%6 = load i8*, i8** %5
%7 = call i64 @equals(i8* %6, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%8 = icmp ne i64 %7, 0
br i1 %8, label %9, label %12
9: ; preds = %2
%10 = load i8*, i8** %4
%11 = call double @get_double(i8* %10)
store double %11, double* %3
br label %38
12: ; preds = %2
%13 = load i8*, i8** %5
%14 = call i64 @equals(i8* %13, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %20
16: ; preds = %12
%17 = load i8*, i8** %4
%18 = call double @get_double(i8* %17)
%19 = fmul double %18, 1.000000e+03
store double %19, double* %3
br label %38
20: ; preds = %12
%21 = load i8*, i8** %5
%22 = call i64 @equals(i8* %21, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%23 = icmp ne i64 %22, 0
br i1 %23, label %24, label %27
24: ; preds = %20
%25 = load i8*, i8** %4
%26 = call double @get_double(i8* %25)
store double %26, double* %3
br label %38
27: ; preds = %20
%28 = load i8*, i8** %5
%29 = call i64 @equals(i8* %28, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%30 = icmp ne i64 %29, 0
br i1 %30, label %31, label %35
31: ; preds = %27
%32 = load i8*, i8** %4
%33 = call double @get_double(i8* %32)
%34 = fmul double %33, 1.000000e+03
store double %34, double* %3
br label %38
35: ; preds = %27
%36 = load i8*, i8** %4
%37 = call double @get_double(i8* %36)
store double %37, double* %3
br label %38
38: ; preds = %35, %31, %24, %16, %9
%39 = load double, double* %3
ret double %39
}

LLVM IR (-O2):
@.str = [6 x i8] c"M/PIX\00"
@.str.1 = [7 x i8] c"KM/PIX\00"
@.str.2 = [8 x i8] c"M/PIXEL\00"
@.str.3 = [9 x i8] c"KM/PIXEL\00"
define double @get_scale(i8* %0, i8* %1) {
%3 = tail call i64 @equals(i8* %1, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i64 %3, 0
br i1 %4, label %7, label %5
5: ; preds = %2
%6 = tail call double @get_double(i8* %0)
br label %24
7: ; preds = %2
%8 = tail call i64 @equals(i8* %1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%9 = icmp eq i64 %8, 0
br i1 %9, label %13, label %10
10: ; preds = %7
%11 = tail call double @get_double(i8* %0)
%12 = fmul double %11, 1.000000e+03
br label %24
13: ; preds = %7
%14 = tail call i64 @equals(i8* %1, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
br i1 %15, label %18, label %16
16: ; preds = %13
%17 = tail call double @get_double(i8* %0)
br label %24
18: ; preds = %13
%19 = tail call i64 @equals(i8* %1, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%20 = icmp eq i64 %19, 0
%21 = tail call double @get_double(i8* %0)
%22 = fmul double %21, 1.000000e+03
%23 = select i1 %20, double %21, double %22
br label %24
24: ; preds = %18, %16, %10, %5
%25 = phi double [ %6, %5 ], [ %12, %10 ], [ %17, %16 ], [ %23, %18 ]
ret double %25
}