#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 */
double log2(double);
int sscanf(char *, char *, ...);
char *strtok(char *, char const *);
int lingot_config_scale_parse_shift(char *char_buffer, double *cents,
                                    short int *numerator,
                                    short int *denominator) {
  static const char *delim = "/";
  char *char_buffer_pointer1 = strtok(char_buffer, delim);
  char *char_buffer_pointer2 = strtok(NULL, delim);
  short int num, den;
  int result = 1;
  if (numerator != NULL) {
    *numerator = -1;
  }
  if (denominator != NULL) {
    *denominator = -1;
  }
  int n = 0;
  if (!char_buffer_pointer2) {
    if (!char_buffer_pointer1) {
      result = 0;
    } else {
      n = sscanf(char_buffer_pointer1, "%lf", cents);
      if (!n) {
        result = 0;
      }
    }
  } else {
    n = sscanf(char_buffer_pointer1, "%hd", &num);
    if (!n) {
      result = 0;
    } else {
      n = sscanf(char_buffer_pointer2, "%hd", &den);
      if (!n) {
        result = 0;
      } else {
        *cents = 1200.0 * log2(1.0 * num / den);
        if (numerator != NULL) {
          *numerator = num;
        }
        if (denominator != NULL) {
          *denominator = den;
        }
      }
    }
  }
  if (!result) {
    *numerator = 1;
    *denominator = 1;
    *cents = 0.0;
  }
  return result;
}


x86 assembly (clang, -O0):
<lingot_config_scale_parse_shift>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    0x2ee5(%rip),%rsi
call   1050 <strtok@plt>
mov    %rax,-0x28(%rbp)
mov    0x2ed5(%rip),%rsi
xor    %eax,%eax
mov    %eax,%edi
call   1050 <strtok@plt>
mov    %rax,-0x30(%rbp)
movl   $0x1,-0x38(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     118b <lingot_config_scale_parse_shift+0x5b>
mov    -0x18(%rbp),%rax
movw   $0xffff,(%rax)
cmpq   $0x0,-0x20(%rbp)
je     119f <lingot_config_scale_parse_shift+0x6f>
mov    -0x20(%rbp),%rax
movw   $0xffff,(%rax)
movl   $0x0,-0x3c(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    11fc <lingot_config_scale_parse_shift+0xcc>
cmpq   $0x0,-0x28(%rbp)
jne    11c8 <lingot_config_scale_parse_shift+0x98>
movl   $0x0,-0x38(%rbp)
jmp    11f7 <lingot_config_scale_parse_shift+0xc7>
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xe3b(%rip),%rsi
mov    $0x0,%al
call   1040 <sscanf@plt>
mov    %eax,-0x3c(%rbp)
cmpl   $0x0,-0x3c(%rbp)
jne    11f2 <lingot_config_scale_parse_shift+0xc2>
movl   $0x0,-0x38(%rbp)
jmp    11f7 <lingot_config_scale_parse_shift+0xc7>
jmp    12d1 <lingot_config_scale_parse_shift+0x1a1>
mov    -0x28(%rbp),%rdi
lea    0xe0f(%rip),%rsi
lea    -0x32(%rbp),%rdx
mov    $0x0,%al
call   1040 <sscanf@plt>
mov    %eax,-0x3c(%rbp)
cmpl   $0x0,-0x3c(%rbp)
jne    122b <lingot_config_scale_parse_shift+0xfb>
movl   $0x0,-0x38(%rbp)
jmp    12cc <lingot_config_scale_parse_shift+0x19c>
mov    -0x30(%rbp),%rdi
lea    0xde0(%rip),%rsi
lea    -0x34(%rbp),%rdx
mov    $0x0,%al
call   1040 <sscanf@plt>
mov    %eax,-0x3c(%rbp)
cmpl   $0x0,-0x3c(%rbp)
jne    125a <lingot_config_scale_parse_shift+0x12a>
movl   $0x0,-0x38(%rbp)
jmp    12c7 <lingot_config_scale_parse_shift+0x197>
movswl -0x32(%rbp),%eax
cvtsi2sd %eax,%xmm1
movsd  0xd9e(%rip),%xmm0
mulsd  %xmm1,%xmm0
movswl -0x34(%rbp),%eax
cvtsi2sd %eax,%xmm1
divsd  %xmm1,%xmm0
call   1030 <log2@plt>
movaps %xmm0,%xmm1
movsd  0xd76(%rip),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
cmpq   $0x0,-0x18(%rbp)
je     12ac <lingot_config_scale_parse_shift+0x17c>
mov    -0x32(%rbp),%cx
mov    -0x18(%rbp),%rax
mov    %cx,(%rax)
cmpq   $0x0,-0x20(%rbp)
je     12c2 <lingot_config_scale_parse_shift+0x192>
mov    -0x34(%rbp),%cx
mov    -0x20(%rbp),%rax
mov    %cx,(%rax)
jmp    12c7 <lingot_config_scale_parse_shift+0x197>
jmp    12cc <lingot_config_scale_parse_shift+0x19c>
jmp    12d1 <lingot_config_scale_parse_shift+0x1a1>
cmpl   $0x0,-0x38(%rbp)
jne    12f8 <lingot_config_scale_parse_shift+0x1c8>
mov    -0x18(%rbp),%rax
movw   $0x1,(%rax)
mov    -0x20(%rbp),%rax
movw   $0x1,(%rax)
mov    -0x10(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax)
mov    -0x38(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lingot_config_scale_parse_shift>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rcx,%r14
mov    %rdx,%r12
mov    %rsi,%r15
lea    0xebb(%rip),%rbx
mov    %rbx,%rsi
call   1050 <strtok@plt>
mov    %rax,%r13
xor    %edi,%edi
mov    %rbx,%rsi
call   1050 <strtok@plt>
mov    %rax,%rbx
test   %r12,%r12
je     1171 <lingot_config_scale_parse_shift+0x41>
movw   $0xffff,(%r12)
test   %r14,%r14
je     117c <lingot_config_scale_parse_shift+0x4c>
movw   $0xffff,(%r14)
test   %rbx,%rbx
je     1209 <lingot_config_scale_parse_shift+0xd9>
lea    0xe82(%rip),%rsi
lea    0xe(%rsp),%rdx
mov    %r13,%rdi
xor    %eax,%eax
call   1040 <sscanf@plt>
test   %eax,%eax
je     122d <lingot_config_scale_parse_shift+0xfd>
lea    0xe64(%rip),%rsi
lea    0xc(%rsp),%rdx
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <sscanf@plt>
test   %eax,%eax
je     122d <lingot_config_scale_parse_shift+0xfd>
movswl 0xe(%rsp),%eax
cvtsi2sd %eax,%xmm0
movswl 0xc(%rsp),%eax
cvtsi2sd %eax,%xmm1
divsd  %xmm1,%xmm0
call   1030 <log2@plt>
mulsd  0xe20(%rip),%xmm0
movsd  %xmm0,(%r15)
test   %r12,%r12
je     11f4 <lingot_config_scale_parse_shift+0xc4>
movzwl 0xe(%rsp),%eax
mov    %ax,(%r12)
mov    $0x1,%eax
test   %r14,%r14
je     1243 <lingot_config_scale_parse_shift+0x113>
movzwl 0xc(%rsp),%ecx
mov    %cx,(%r14)
jmp    1243 <lingot_config_scale_parse_shift+0x113>
test   %r13,%r13
je     122d <lingot_config_scale_parse_shift+0xfd>
lea    0xdf5(%rip),%rsi
mov    %r13,%rdi
mov    %r15,%rdx
xor    %eax,%eax
call   1040 <sscanf@plt>
mov    %eax,%ecx
mov    $0x1,%eax
test   %ecx,%ecx
jne    1243 <lingot_config_scale_parse_shift+0x113>
movw   $0x1,(%r12)
movw   $0x1,(%r14)
movq   $0x0,(%r15)
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@lingot_config_scale_parse_shift.delim = internal global i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i32 0, i32 0)
@.str = [2 x i8] c"/\00"
@.str.1 = [4 x i8] c"%lf\00"
@.str.2 = [4 x i8] c"%hd\00"
define i32 @lingot_config_scale_parse_shift(i8* %0, double* %1, i16* %2, i16* %3) {
%5 = alloca i8*
%6 = alloca double*
%7 = alloca i16*
%8 = alloca i16*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i16
%12 = alloca i16
%13 = alloca i32
%14 = alloca i32
store i8* %0, i8** %5
store double* %1, double** %6
store i16* %2, i16** %7
store i16* %3, i16** %8
%15 = load i8*, i8** %5
%16 = load i8*, i8** @lingot_config_scale_parse_shift.delim
%17 = call i8* @strtok(i8* %15, i8* %16)
store i8* %17, i8** %9
%18 = load i8*, i8** @lingot_config_scale_parse_shift.delim
%19 = call i8* @strtok(i8* null, i8* %18)
store i8* %19, i8** %10
store i32 1, i32* %13
%20 = load i16*, i16** %7
%21 = icmp ne i16* %20, null
br i1 %21, label %22, label %24
22: ; preds = %4
%23 = load i16*, i16** %7
store i16 -1, i16* %23
br label %24
24: ; preds = %22, %4
%25 = load i16*, i16** %8
%26 = icmp ne i16* %25, null
br i1 %26, label %27, label %29
27: ; preds = %24
%28 = load i16*, i16** %8
store i16 -1, i16* %28
br label %29
29: ; preds = %27, %24
store i32 0, i32* %14
%30 = load i8*, i8** %10
%31 = icmp ne i8* %30, null
br i1 %31, label %45, label %32
32: ; preds = %29
%33 = load i8*, i8** %9
%34 = icmp ne i8* %33, null
br i1 %34, label %36, label %35
35: ; preds = %32
store i32 0, i32* %13
br label %44
36: ; preds = %32
%37 = load i8*, i8** %9
%38 = load double*, double** %6
%39 = call i32 (i8*, i8*, ...) @sscanf(i8* %37, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %38)
store i32 %39, i32* %14
%40 = load i32, i32* %14
%41 = icmp ne i32 %40, 0
br i1 %41, label %43, label %42
42: ; preds = %36
store i32 0, i32* %13
br label %43
43: ; preds = %42, %36
br label %44
44: ; preds = %43, %35
br label %83
45: ; preds = %29
%46 = load i8*, i8** %9
%47 = call i32 (i8*, i8*, ...) @sscanf(i8* %46, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i16* %11)
store i32 %47, i32* %14
%48 = load i32, i32* %14
%49 = icmp ne i32 %48, 0
br i1 %49, label %51, label %50
50: ; preds = %45
store i32 0, i32* %13
br label %82
51: ; preds = %45
%52 = load i8*, i8** %10
%53 = call i32 (i8*, i8*, ...) @sscanf(i8* %52, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i16* %12)
store i32 %53, i32* %14
%54 = load i32, i32* %14
%55 = icmp ne i32 %54, 0
br i1 %55, label %57, label %56
56: ; preds = %51
store i32 0, i32* %13
br label %81
57: ; preds = %51
%58 = load i16, i16* %11
%59 = sext i16 %58 to i32
%60 = sitofp i32 %59 to double
%61 = fmul double 1.000000e+00, %60
%62 = load i16, i16* %12
%63 = sext i16 %62 to i32
%64 = sitofp i32 %63 to double
%65 = fdiv double %61, %64
%66 = call double @log2(double %65)
%67 = fmul double 1.200000e+03, %66
%68 = load double*, double** %6
store double %67, double* %68
%69 = load i16*, i16** %7
%70 = icmp ne i16* %69, null
br i1 %70, label %71, label %74
71: ; preds = %57
%72 = load i16, i16* %11
%73 = load i16*, i16** %7
store i16 %72, i16* %73
br label %74
74: ; preds = %71, %57
%75 = load i16*, i16** %8
%76 = icmp ne i16* %75, null
br i1 %76, label %77, label %80
77: ; preds = %74
%78 = load i16, i16* %12
%79 = load i16*, i16** %8
store i16 %78, i16* %79
br label %80
80: ; preds = %77, %74
br label %81
81: ; preds = %80, %56
br label %82
82: ; preds = %81, %50
br label %83
83: ; preds = %82, %44
%84 = load i32, i32* %13
%85 = icmp ne i32 %84, 0
br i1 %85, label %90, label %86
86: ; preds = %83
%87 = load i16*, i16** %7
store i16 1, i16* %87
%88 = load i16*, i16** %8
store i16 1, i16* %88
%89 = load double*, double** %6
store double 0.000000e+00, double* %89
br label %90
90: ; preds = %86, %83
%91 = load i32, i32* %13
ret i32 %91
}

LLVM IR (-O2):
@.str = [2 x i8] c"/\00"
@.str.1 = [4 x i8] c"%lf\00"
@.str.2 = [4 x i8] c"%hd\00"
define i32 @lingot_config_scale_parse_shift(i8* %0, double* %1, i16* writeonly %2, i16* writeonly %3) {
%5 = alloca i16
%6 = alloca i16
%7 = tail call i8* @strtok(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%8 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%9 = bitcast i16* %5 to i8*
%10 = bitcast i16* %6 to i8*
%11 = icmp eq i16* %2, null
br i1 %11, label %13, label %12
12: ; preds = %4
store i16 -1, i16* %2
br label %13
13: ; preds = %12, %4
%14 = icmp eq i16* %3, null
br i1 %14, label %16, label %15
15: ; preds = %13
store i16 -1, i16* %3
br label %16
16: ; preds = %15, %13
%17 = icmp eq i8* %8, null
br i1 %17, label %18, label %20
18: ; preds = %16
%19 = icmp eq i8* %7, null
br i1 %19, label %42, label %39
20: ; preds = %16
%21 = call i32 (i8*, i8*, ...) @sscanf(i8* %7, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i16* %5)
%22 = icmp eq i32 %21, 0
br i1 %22, label %42, label %23
23: ; preds = %20
%24 = call i32 (i8*, i8*, ...) @sscanf(i8* %8, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i16* %6)
%25 = icmp eq i32 %24, 0
br i1 %25, label %42, label %26
26: ; preds = %23
%27 = load i16, i16* %5
%28 = sitofp i16 %27 to double
%29 = load i16, i16* %6
%30 = sitofp i16 %29 to double
%31 = fdiv double %28, %30
%32 = call double @log2(double %31)
%33 = fmul double %32, 1.200000e+03
store double %33, double* %1
br i1 %11, label %36, label %34
34: ; preds = %26
%35 = load i16, i16* %5
store i16 %35, i16* %2
br label %36
36: ; preds = %34, %26
br i1 %14, label %43, label %37
37: ; preds = %36
%38 = load i16, i16* %6
store i16 %38, i16* %3
br label %43
39: ; preds = %18
%40 = tail call i32 (i8*, i8*, ...) @sscanf(i8* %7, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %1)
%41 = icmp eq i32 %40, 0
br i1 %41, label %42, label %43
42: ; preds = %23, %20, %18, %39
store i16 1, i16* %2
store i16 1, i16* %3
store double 0.000000e+00, double* %1
br label %43
43: ; preds = %37, %36, %42, %39
%44 = phi i32 [ 0, %42 ], [ 1, %39 ], [ 1, %36 ], [ 1, %37 ]
ret i32 %44
}