#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 /*<<< orphan*/ isinf(double);
int /*<<< orphan*/ isnan(double);
int /*<<< orphan*/ my_assert_notNull(char *, char const *);
int /*<<< orphan*/ my_log_error(char *, char const *);
int /*<<< orphan*/ my_memory_free(void *);
double my_parse_double(char const *);
char *my_subStringC_lastEnd(char const *, char);
char *my_subStringC_startLast(char const *, char);
int /*<<< orphan*/ *strchr(char const *, char);
double my_parse_fraction(const char *string) {
  my_assert_notNull("string", string);
  if (strchr(string, '/') == NULL)
    return my_parse_double(string);
  char *num = my_subStringC_startLast(string, '/');
  char *den = my_subStringC_lastEnd(string, '/');
  double frac = my_parse_double(num) / my_parse_double(den);
  if (!(!isnan(frac) && !isinf(frac)))
    my_log_error("error my_parse_fraction %s\n", string);
  (my_memory_free((void *)(num)));
  (my_memory_free((void *)(den)));
  return frac;
}


x86 assembly (clang, -O0):
<my_parse_fraction>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xe59(%rip),%rdi
call   1060 <my_assert_notNull@plt>
mov    -0x10(%rbp),%rdi
mov    $0x2f,%esi
call   1040 <strchr@plt>
cmp    $0x0,%rax
jne    11d7 <my_parse_fraction+0x47>
mov    -0x10(%rbp),%rdi
call   10b0 <my_parse_double@plt>
movsd  %xmm0,-0x8(%rbp)
jmp    1275 <my_parse_fraction+0xe5>
mov    -0x10(%rbp),%rdi
mov    $0x2f,%esi
call   1070 <my_subStringC_startLast@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x2f,%esi
call   10a0 <my_subStringC_lastEnd@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   10b0 <my_parse_double@plt>
movsd  %xmm0,-0x30(%rbp)
mov    -0x20(%rbp),%rdi
call   10b0 <my_parse_double@plt>
movaps %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
call   1080 <isnan@plt>
cmp    $0x0,%eax
jne    1249 <my_parse_fraction+0xb9>
movsd  -0x28(%rbp),%xmm0
call   1090 <isinf@plt>
cmp    $0x0,%eax
je     1259 <my_parse_fraction+0xc9>
mov    -0x10(%rbp),%rsi
lea    0xdb3(%rip),%rdi
call   1030 <my_log_error@plt>
mov    -0x18(%rbp),%rdi
call   1050 <my_memory_free@plt>
mov    -0x20(%rbp),%rdi
call   1050 <my_memory_free@plt>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<my_parse_fraction>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
lea    0xe5d(%rip),%rdi
mov    %rbx,%rsi
call   1060 <my_assert_notNull@plt>
mov    %rbx,%rdi
mov    $0x2f,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     1252 <my_parse_fraction+0xc2>
mov    %rbx,%rdi
mov    $0x2f,%esi
call   1070 <my_subStringC_startLast@plt>
mov    %rax,%r14
mov    %rbx,%rdi
mov    $0x2f,%esi
call   10a0 <my_subStringC_lastEnd@plt>
mov    %rax,%r15
mov    %r14,%rdi
call   10b0 <my_parse_double@plt>
movsd  %xmm0,0x8(%rsp)
mov    %r15,%rdi
call   10b0 <my_parse_double@plt>
movsd  0x8(%rsp),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
movapd %xmm1,%xmm0
call   1080 <isnan@plt>
test   %eax,%eax
jne    1223 <my_parse_fraction+0x93>
movsd  0x8(%rsp),%xmm0
call   1090 <isinf@plt>
test   %eax,%eax
je     1232 <my_parse_fraction+0xa2>
lea    0xddd(%rip),%rdi
mov    %rbx,%rsi
call   1030 <my_log_error@plt>
mov    %r14,%rdi
call   1050 <my_memory_free@plt>
mov    %r15,%rdi
call   1050 <my_memory_free@plt>
movsd  0x8(%rsp),%xmm0
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
mov    %rbx,%rdi
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
jmp    10b0 <my_parse_double@plt>

LLVM IR (-O0):
@.str = [7 x i8] c"string\00"
@.str.1 = [28 x i8] c"error my_parse_fraction %s\0A\00"
define double @my_parse_fraction(i8* %0) {
%2 = alloca double
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca double
store i8* %0, i8** %3
%7 = load i8*, i8** %3
%8 = call i32 @my_assert_notNull(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %7)
%9 = load i8*, i8** %3
%10 = call i32* @strchr(i8* %9, i8 signext 47)
%11 = icmp eq i32* %10, null
br i1 %11, label %12, label %15
12: ; preds = %1
%13 = load i8*, i8** %3
%14 = call double @my_parse_double(i8* %13)
store double %14, double* %2
br label %41
15: ; preds = %1
%16 = load i8*, i8** %3
%17 = call i8* @my_subStringC_startLast(i8* %16, i8 signext 47)
store i8* %17, i8** %4
%18 = load i8*, i8** %3
%19 = call i8* @my_subStringC_lastEnd(i8* %18, i8 signext 47)
store i8* %19, i8** %5
%20 = load i8*, i8** %4
%21 = call double @my_parse_double(i8* %20)
%22 = load i8*, i8** %5
%23 = call double @my_parse_double(i8* %22)
%24 = fdiv double %21, %23
store double %24, double* %6
%25 = load double, double* %6
%26 = call i32 @isnan(double %25)
%27 = icmp ne i32 %26, 0
br i1 %27, label %32, label %28
28: ; preds = %15
%29 = load double, double* %6
%30 = call i32 @isinf(double %29)
%31 = icmp ne i32 %30, 0
br i1 %31, label %32, label %35
32: ; preds = %28, %15
%33 = load i8*, i8** %3
%34 = call i32 @my_log_error(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i8* %33)
br label %35
35: ; preds = %32, %28
%36 = load i8*, i8** %4
%37 = call i32 @my_memory_free(i8* %36)
%38 = load i8*, i8** %5
%39 = call i32 @my_memory_free(i8* %38)
%40 = load double, double* %6
store double %40, double* %2
br label %41
41: ; preds = %35, %12
%42 = load double, double* %2
ret double %42
}

LLVM IR (-O2):
@.str = [7 x i8] c"string\00"
@.str.1 = [28 x i8] c"error my_parse_fraction %s\0A\00"
define double @my_parse_fraction(i8* %0) {
%2 = tail call i32 @my_assert_notNull(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %0)
%3 = tail call i32* @strchr(i8* %0, i8 signext 47)
%4 = icmp eq i32* %3, null
br i1 %4, label %5, label %7
5: ; preds = %1
%6 = tail call double @my_parse_double(i8* %0)
br label %23
7: ; preds = %1
%8 = tail call i8* @my_subStringC_startLast(i8* %0, i8 signext 47)
%9 = tail call i8* @my_subStringC_lastEnd(i8* %0, i8 signext 47)
%10 = tail call double @my_parse_double(i8* %8)
%11 = tail call double @my_parse_double(i8* %9)
%12 = fdiv double %10, %11
%13 = tail call i32 @isnan(double %12)
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %18
15: ; preds = %7
%16 = tail call i32 @isinf(double %12)
%17 = icmp eq i32 %16, 0
br i1 %17, label %20, label %18
18: ; preds = %15, %7
%19 = tail call i32 @my_log_error(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i8* %0)
br label %20
20: ; preds = %18, %15
%21 = tail call i32 @my_memory_free(i8* %8)
%22 = tail call i32 @my_memory_free(i8* %9)
br label %23
23: ; preds = %20, %5
%24 = phi double [ %6, %5 ], [ %12, %20 ]
ret double %24
}