#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*/ EXIT_FAILURE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, int, ...);
int sscanf(char const *, char *, int *);
int /*<<< orphan*/ stderr;
int extract_decimals(const char *s, char prefix) {
  if (s && s[0] && s[0] == prefix) {
    int decimals;
    if (sscanf(s, "%*c%*d.%d", &decimals) == 1) {
      if (decimals < 0 || decimals > 16) {
        fprintf(stderr, "%s:%d decimals was %d, expected to be [0, 16]\n",
                "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                "outputs/2022-01-22/02-19-57/repos/WizardMac/ReadStat/refs/"
                "heads/master/src/bin/extract_metadata.c",
                74, decimals);
        exit(EXIT_FAILURE);
      }
      return decimals;
    }
    fprintf(stderr, "%s:%d not a number: %s\n",
            "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
            "2022-01-22/02-19-57/repos/WizardMac/ReadStat/refs/heads/master/"
            "src/bin/extract_metadata.c",
            79, &s[1]);
    exit(EXIT_FAILURE);
  } else {
    return -1;
  }
}


x86 assembly (clang, -O0):
<extract_decimals>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %sil,%al
mov    %rdi,-0x10(%rbp)
mov    %al,-0x11(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     121a <extract_decimals+0xea>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     121a <extract_decimals+0xea>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
movsbl -0x11(%rbp),%ecx
cmp    %ecx,%eax
jne    121a <extract_decimals+0xea>
mov    -0x10(%rbp),%rdi
lea    0xe85(%rip),%rsi
lea    -0x18(%rbp),%rdx
call   1040 <sscanf@plt>
cmp    $0x1,%eax
jne    11e1 <extract_decimals+0xb1>
cmpl   $0x0,-0x18(%rbp)
jl     11a1 <extract_decimals+0x71>
cmpl   $0x10,-0x18(%rbp)
jle    11d6 <extract_decimals+0xa6>
mov    0x2e38(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%r8d
lea    0xe55(%rip),%rsi
lea    0xe7d(%rip),%rdx
mov    $0x4a,%ecx
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    0x2e09(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1221 <extract_decimals+0xf1>
mov    0x2df8(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%r8
add    $0x1,%r8
lea    0xeda(%rip),%rsi
lea    0xe39(%rip),%rdx
mov    $0x4f,%ecx
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    0x2dc5(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<extract_decimals>:
push   %rbx
sub    $0x10,%rsp
mov    $0xffffffff,%eax
test   %rdi,%rdi
je     116f <extract_decimals+0x3f>
mov    %rdi,%rbx
mov    (%rdi),%cl
test   %cl,%cl
je     116f <extract_decimals+0x3f>
cmp    %sil,%cl
jne    116f <extract_decimals+0x3f>
lea    0xeac(%rip),%rsi
lea    0xc(%rsp),%rdx
mov    %rbx,%rdi
call   1040 <sscanf@plt>
cmp    $0x1,%eax
jne    1175 <extract_decimals+0x45>
mov    0xc(%rsp),%eax
cmp    $0x11,%eax
jae    11a1 <extract_decimals+0x71>
add    $0x10,%rsp
pop    %rbx
ret
mov    0x2e64(%rip),%rax
mov    (%rax),%edi
add    $0x1,%rbx
lea    0xf4a(%rip),%rsi
lea    0xea9(%rip),%rdx
mov    $0x4f,%ecx
mov    %rbx,%r8
xor    %eax,%eax
call   1030 <fprintf@plt>
jmp    11c7 <extract_decimals+0x97>
mov    0x2e38(%rip),%rcx
mov    (%rcx),%edi
lea    0xe59(%rip),%rsi
lea    0xe81(%rip),%rdx
mov    $0x4a,%ecx
mov    %eax,%r8d
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    0x2e0a(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@.str = [10 x i8] c"%*c%*d.%d\00"
@stderr = global i32 0
@.str.1 = [47 x i8] c"%s:%d decimals was %d, expected to be [0, 16]\0A\00"
@.str.2 = [154 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/WizardMac/ReadStat/refs/heads/master/src/bin/extract_metadata.c\00"
@EXIT_FAILURE = global i32 0
@.str.3 = [24 x i8] c"%s:%d not a number: %s\0A\00"
define i32 @extract_decimals(i8* %0, i8 signext %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8
%6 = alloca i32
store i8* %0, i8** %4
store i8 %1, i8* %5
%7 = load i8*, i8** %4
%8 = icmp ne i8* %7, null
br i1 %8, label %9, label %48
9: ; preds = %2
%10 = load i8*, i8** %4
%11 = getelementptr inbounds i8, i8* %10, i64 0
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %48
15: ; preds = %9
%16 = load i8*, i8** %4
%17 = getelementptr inbounds i8, i8* %16, i64 0
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = load i8, i8* %5
%21 = sext i8 %20 to i32
%22 = icmp eq i32 %19, %21
br i1 %22, label %23, label %48
23: ; preds = %15
%24 = load i8*, i8** %4
%25 = call i32 @sscanf(i8* %24, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32* %6)
%26 = icmp eq i32 %25, 1
br i1 %26, label %27, label %41
27: ; preds = %23
%28 = load i32, i32* %6
%29 = icmp slt i32 %28, 0
br i1 %29, label %33, label %30
30: ; preds = %27
%31 = load i32, i32* %6
%32 = icmp sgt i32 %31, 16
br i1 %32, label %33, label %39
33: ; preds = %30, %27
%34 = load i32, i32* @stderr
%35 = load i32, i32* %6
%36 = call i32 (i32, i8*, i8*, i32, ...) @fprintf(i32 %34, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([154 x i8], [154 x i8]* @.str.2, i64 0, i64 0), i32 74, i32 %35)
%37 = load i32, i32* @EXIT_FAILURE
%38 = call i32 @exit(i32 %37)
unreachable
39: ; preds = %30
%40 = load i32, i32* %6
store i32 %40, i32* %3
br label %49
41: ; preds = %23
%42 = load i32, i32* @stderr
%43 = load i8*, i8** %4
%44 = getelementptr inbounds i8, i8* %43, i64 1
%45 = call i32 (i32, i8*, i8*, i32, ...) @fprintf(i32 %42, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([154 x i8], [154 x i8]* @.str.2, i64 0, i64 0), i32 79, i8* %44)
%46 = load i32, i32* @EXIT_FAILURE
%47 = call i32 @exit(i32 %46)
unreachable
48: ; preds = %15, %9, %2
store i32 -1, i32* %3
br label %49
49: ; preds = %48, %39
%50 = load i32, i32* %3
ret i32 %50
}

LLVM IR (-O2):
@.str = [10 x i8] c"%*c%*d.%d\00"
@stderr = global i32 0
@.str.1 = [47 x i8] c"%s:%d decimals was %d, expected to be [0, 16]\0A\00"
@.str.2 = [154 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/WizardMac/ReadStat/refs/heads/master/src/bin/extract_metadata.c\00"
@EXIT_FAILURE = global i32 0
@.str.3 = [24 x i8] c"%s:%d not a number: %s\0A\00"
define i32 @extract_decimals(i8* %0, i8 signext %1) {
%3 = alloca i32
%4 = icmp eq i8* %0, null
br i1 %4, label %29, label %5
5: ; preds = %2
%6 = load i8, i8* %0
%7 = icmp ne i8 %6, 0
%8 = icmp eq i8 %6, %1
%9 = and i1 %7, %8
br i1 %9, label %10, label %29
10: ; preds = %5
%11 = bitcast i32* %3 to i8*
%12 = call i32 @sscanf(i8* %0, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32* %3)
%13 = icmp eq i32 %12, 1
br i1 %13, label %14, label %23
14: ; preds = %10
%15 = load i32, i32* %3
%16 = icmp ugt i32 %15, 16
br i1 %16, label %17, label %22
17: ; preds = %14
%18 = load i32, i32* @stderr
%19 = call i32 (i32, i8*, i8*, i32, ...) @fprintf(i32 %18, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([154 x i8], [154 x i8]* @.str.2, i64 0, i64 0), i32 74, i32 %15)
%20 = load i32, i32* @EXIT_FAILURE
%21 = call i32 @exit(i32 %20)
unreachable
22: ; preds = %14
br label %29
23: ; preds = %10
%24 = load i32, i32* @stderr
%25 = getelementptr inbounds i8, i8* %0, i64 1
%26 = call i32 (i32, i8*, i8*, i32, ...) @fprintf(i32 %24, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([154 x i8], [154 x i8]* @.str.2, i64 0, i64 0), i32 79, i8* %25)
%27 = load i32, i32* @EXIT_FAILURE
%28 = call i32 @exit(i32 %27)
unreachable
29: ; preds = %2, %5, %22
%30 = phi i32 [ %15, %22 ], [ -1, %5 ], [ -1, %2 ]
ret i32 %30
}