#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__ atoi(char *);
int /*<<< orphan*/ free(char *);
scalar_t__ malloc(int);
int /*<<< orphan*/ memset(char *, char, int);
char *strchr(char *, char);
int /*<<< orphan*/ strncpy(char *, char *, int);
char *strstr(char *, char *);
float prevailVSBY(char *visibility) {
  float Miles_vsby;
  char *temp, *Slash_ptr, *SM_KM_ptr;
  char numerator[3], denominator[3];
  if ((SM_KM_ptr = strstr(visibility, "SM")) == NULL)
    SM_KM_ptr = strstr(visibility, "KM");
  Slash_ptr = strchr(visibility, '/');
  if (Slash_ptr == NULL) {
    temp = (char *)malloc(sizeof(char) * ((SM_KM_ptr - visibility) + 1));
    memset(temp, '\0', (SM_KM_ptr - visibility) + 1);
    strncpy(temp, visibility, (SM_KM_ptr - visibility));
    Miles_vsby = (float)(atoi(temp));
    free(temp);
    return Miles_vsby;
  } else {
    memset(numerator, '\0', 3);
    memset(denominator, '\0', 3);
    strncpy(numerator, visibility, (Slash_ptr - visibility));
    strncpy(denominator, Slash_ptr + 1, (SM_KM_ptr - Slash_ptr));
    return (((float)(atoi(numerator))) / ((float)(atoi(denominator))));
  }
}


x86 assembly (clang, -O0):
<prevailVSBY>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe79(%rip),%rsi
call   1090 <strstr@plt>
mov    %rax,-0x30(%rbp)
cmp    $0x0,%rax
jne    11ae <prevailVSBY+0x3e>
mov    -0x10(%rbp),%rdi
lea    0xe5e(%rip),%rsi
call   1090 <strstr@plt>
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x2f,%esi
call   1050 <strchr@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    124a <prevailVSBY+0xda>
mov    -0x30(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    %rcx,%rax
add    $0x1,%rax
shl    $0x0,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x30(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    %rcx,%rax
add    $0x1,%rax
mov    %eax,%edx
xor    %esi,%esi
call   1060 <memset@plt>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x30(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,%edx
call   1040 <strncpy@plt>
mov    -0x20(%rbp),%rdi
call   1080 <atoi@plt>
cvtsi2ss %rax,%xmm0
movss  %xmm0,-0x14(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
movss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    12d1 <prevailVSBY+0x161>
lea    -0x33(%rbp),%rdi
xor    %esi,%esi
mov    $0x3,%edx
call   1060 <memset@plt>
lea    -0x36(%rbp),%rdi
xor    %esi,%esi
mov    $0x3,%edx
call   1060 <memset@plt>
lea    -0x33(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x28(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,%edx
call   1040 <strncpy@plt>
lea    -0x36(%rbp),%rdi
mov    -0x28(%rbp),%rsi
add    $0x1,%rsi
mov    -0x30(%rbp),%rax
mov    -0x28(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,%edx
call   1040 <strncpy@plt>
lea    -0x33(%rbp),%rdi
call   1080 <atoi@plt>
cvtsi2ss %rax,%xmm0
movss  %xmm0,-0x3c(%rbp)
lea    -0x36(%rbp),%rdi
call   1080 <atoi@plt>
movss  -0x3c(%rbp),%xmm0
cvtsi2ss %rax,%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<prevailVSBY>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%r14
lea    0xe78(%rip),%rsi
call   1090 <strstr@plt>
mov    %rax,%r12
test   %rax,%rax
jne    11a7 <prevailVSBY+0x37>
lea    0xe67(%rip),%rsi
mov    %r14,%rdi
call   1090 <strstr@plt>
mov    %rax,%r12
mov    %r14,%rdi
mov    $0x2f,%esi
call   1050 <strchr@plt>
test   %rax,%rax
je     123f <prevailVSBY+0xcf>
mov    %rax,%rbx
lea    0x15(%rsp),%r15
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x3,%edx
call   1060 <memset@plt>
lea    0x12(%rsp),%r13
mov    %r13,%rdi
xor    %esi,%esi
mov    $0x3,%edx
call   1060 <memset@plt>
mov    %ebx,%edx
sub    %r14d,%edx
mov    %r15,%rdi
mov    %r14,%rsi
call   1040 <strncpy@plt>
mov    %rbx,%rsi
add    $0x1,%rsi
sub    %ebx,%r12d
mov    %r13,%rdi
mov    %r12d,%edx
call   1040 <strncpy@plt>
mov    %r15,%rdi
call   1080 <atoi@plt>
cvtsi2ss %rax,%xmm0
movss  %xmm0,0xc(%rsp)
mov    %r13,%rdi
call   1080 <atoi@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
movss  0xc(%rsp),%xmm1
divss  %xmm0,%xmm1
movaps %xmm1,%xmm0
jmp    128c <prevailVSBY+0x11c>
sub    %r14d,%r12d
lea    0x1(%r12),%ebp
mov    %ebp,%edi
call   1070 <malloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
xor    %esi,%esi
mov    %ebp,%edx
call   1060 <memset@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r12d,%edx
call   1040 <strncpy@plt>
mov    %rbx,%rdi
call   1080 <atoi@plt>
cvtsi2ss %rax,%xmm0
movss  %xmm0,0xc(%rsp)
mov    %rbx,%rdi
call   1030 <free@plt>
movss  0xc(%rsp),%xmm0
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"SM\00"
@.str.1 = [3 x i8] c"KM\00"
define float @prevailVSBY(i8* %0) {
%2 = alloca float
%3 = alloca i8*
%4 = alloca float
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca [3 x i8]
%9 = alloca [3 x i8]
store i8* %0, i8** %3
%10 = load i8*, i8** %3
%11 = call i8* @strstr(i8* %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i8* %11, i8** %7
%12 = icmp eq i8* %11, null
br i1 %12, label %13, label %16
13: ; preds = %1
%14 = load i8*, i8** %3
%15 = call i8* @strstr(i8* %14, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i8* %15, i8** %7
br label %16
16: ; preds = %13, %1
%17 = load i8*, i8** %3
%18 = call i8* @strchr(i8* %17, i8 signext 47)
store i8* %18, i8** %6
%19 = load i8*, i8** %6
%20 = icmp eq i8* %19, null
br i1 %20, label %21, label %56
21: ; preds = %16
%22 = load i8*, i8** %7
%23 = load i8*, i8** %3
%24 = ptrtoint i8* %22 to i64
%25 = ptrtoint i8* %23 to i64
%26 = sub i64 %24, %25
%27 = add nsw i64 %26, 1
%28 = mul i64 1, %27
%29 = trunc i64 %28 to i32
%30 = call i64 @malloc(i32 %29)
%31 = inttoptr i64 %30 to i8*
store i8* %31, i8** %5
%32 = load i8*, i8** %5
%33 = load i8*, i8** %7
%34 = load i8*, i8** %3
%35 = ptrtoint i8* %33 to i64
%36 = ptrtoint i8* %34 to i64
%37 = sub i64 %35, %36
%38 = add nsw i64 %37, 1
%39 = trunc i64 %38 to i32
%40 = call i32 @memset(i8* %32, i8 signext 0, i32 %39)
%41 = load i8*, i8** %5
%42 = load i8*, i8** %3
%43 = load i8*, i8** %7
%44 = load i8*, i8** %3
%45 = ptrtoint i8* %43 to i64
%46 = ptrtoint i8* %44 to i64
%47 = sub i64 %45, %46
%48 = trunc i64 %47 to i32
%49 = call i32 @strncpy(i8* %41, i8* %42, i32 %48)
%50 = load i8*, i8** %5
%51 = call i64 @atoi(i8* %50)
%52 = sitofp i64 %51 to float
store float %52, float* %4
%53 = load i8*, i8** %5
%54 = call i32 @free(i8* %53)
%55 = load float, float* %4
store float %55, float* %2
br label %87
56: ; preds = %16
%57 = getelementptr inbounds [3 x i8], [3 x i8]* %8, i64 0, i64 0
%58 = call i32 @memset(i8* %57, i8 signext 0, i32 3)
%59 = getelementptr inbounds [3 x i8], [3 x i8]* %9, i64 0, i64 0
%60 = call i32 @memset(i8* %59, i8 signext 0, i32 3)
%61 = getelementptr inbounds [3 x i8], [3 x i8]* %8, i64 0, i64 0
%62 = load i8*, i8** %3
%63 = load i8*, i8** %6
%64 = load i8*, i8** %3
%65 = ptrtoint i8* %63 to i64
%66 = ptrtoint i8* %64 to i64
%67 = sub i64 %65, %66
%68 = trunc i64 %67 to i32
%69 = call i32 @strncpy(i8* %61, i8* %62, i32 %68)
%70 = getelementptr inbounds [3 x i8], [3 x i8]* %9, i64 0, i64 0
%71 = load i8*, i8** %6
%72 = getelementptr inbounds i8, i8* %71, i64 1
%73 = load i8*, i8** %7
%74 = load i8*, i8** %6
%75 = ptrtoint i8* %73 to i64
%76 = ptrtoint i8* %74 to i64
%77 = sub i64 %75, %76
%78 = trunc i64 %77 to i32
%79 = call i32 @strncpy(i8* %70, i8* %72, i32 %78)
%80 = getelementptr inbounds [3 x i8], [3 x i8]* %8, i64 0, i64 0
%81 = call i64 @atoi(i8* %80)
%82 = sitofp i64 %81 to float
%83 = getelementptr inbounds [3 x i8], [3 x i8]* %9, i64 0, i64 0
%84 = call i64 @atoi(i8* %83)
%85 = sitofp i64 %84 to float
%86 = fdiv float %82, %85
store float %86, float* %2
br label %87
87: ; preds = %56, %21
%88 = load float, float* %2
ret float %88
}

LLVM IR (-O2):
@.str = [3 x i8] c"SM\00"
@.str.1 = [3 x i8] c"KM\00"
define float @prevailVSBY(i8* %0) {
%2 = alloca [3 x i8]
%3 = alloca [3 x i8]
%4 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 0
%5 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 0
%6 = tail call i8* @strstr(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i8* %6, null
br i1 %7, label %8, label %10
8: ; preds = %1
%9 = tail call i8* @strstr(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %10
10: ; preds = %8, %1
%11 = phi i8* [ %9, %8 ], [ %6, %1 ]
%12 = tail call i8* @strchr(i8* dereferenceable(1) %0, i8 signext 47)
%13 = icmp eq i8* %12, null
br i1 %13, label %14, label %27
14: ; preds = %10
%15 = ptrtoint i8* %11 to i64
%16 = ptrtoint i8* %0 to i64
%17 = sub i64 %15, %16
%18 = trunc i64 %17 to i32
%19 = add i32 %18, 1
%20 = tail call i64 @malloc(i32 %19)
%21 = inttoptr i64 %20 to i8*
%22 = tail call i32 @memset(i8* %21, i8 signext 0, i32 %19)
%23 = tail call i32 @strncpy(i8* %21, i8* %0, i32 %18)
%24 = tail call i64 @atoi(i8* %21)
%25 = sitofp i64 %24 to float
%26 = tail call i32 @free(i8* %21)
br label %45
27: ; preds = %10
%28 = call i32 @memset(i8* %4, i8 signext 0, i32 3)
%29 = call i32 @memset(i8* %5, i8 signext 0, i32 3)
%30 = ptrtoint i8* %12 to i64
%31 = ptrtoint i8* %0 to i64
%32 = sub i64 %30, %31
%33 = trunc i64 %32 to i32
%34 = call i32 @strncpy(i8* %4, i8* %0, i32 %33)
%35 = getelementptr inbounds i8, i8* %12, i64 1
%36 = ptrtoint i8* %11 to i64
%37 = sub i64 %36, %30
%38 = trunc i64 %37 to i32
%39 = call i32 @strncpy(i8* %5, i8* %35, i32 %38)
%40 = call i64 @atoi(i8* %4)
%41 = sitofp i64 %40 to float
%42 = call i64 @atoi(i8* %5)
%43 = sitofp i64 %42 to float
%44 = fdiv float %41, %43
br label %45
45: ; preds = %27, %14
%46 = phi float [ %25, %14 ], [ %44, %27 ]
ret float %46
}