#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 ERANGE;
#define LONG_MAX 129
#define LONG_MIN 128
int errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, int, char *,
                           char *);
int /*<<< orphan*/ stderr;
char *strerror(int);
int strtol(char *, char **, int);
int check_intconv_error(char *intstr, int base, int perform_boundchecks,
                        int minvalue, int maxvalue) {
  int errnotmp = errno, temp = 0;
  char *endptr;
  errno = 0;
  temp = strtol(intstr, &endptr, base);
  if (errno == ERANGE) {
    switch ((long)temp) {
    case LONG_MIN:
      fprintf(stderr,
              "[ERROR] (%s:%d: errno: %s) "
              "Overflow:%s\n"
              "\n",
              "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
              "2022-01-22/02-19-57/repos/Lompik/mpd_info/refs/heads/master/src/"
              "parse_config.c",
              40, (errno == 0 ? "None" : strerror(errno)), intstr);
      break;
    case LONG_MAX:
      break;
      fprintf(stderr,
              "[ERROR] (%s:%d: errno: %s) "
              "underflow:%s\n"
              "\n",
              "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
              "2022-01-22/02-19-57/repos/Lompik/mpd_info/refs/heads/master/src/"
              "parse_config.c",
              45, (errno == 0 ? "None" : strerror(errno)), intstr);
    default:
      exit(0);
    }
  } else if (errno != 0) {
    fprintf(stderr,
            "[ERROR] (%s:%d: errno: %s) "
            "Error converting int:%s\n"
            "\n",
            "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
            "2022-01-22/02-19-57/repos/Lompik/mpd_info/refs/heads/master/src/"
            "parse_config.c",
            52, (errno == 0 ? "None" : strerror(errno)), intstr);
  } else if (*endptr != '\0') {
    fprintf(stderr,
            "[ERROR] (%s:%d: errno: %s) "
            "Garbage in the end string:%s\n"
            "\n",
            "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
            "2022-01-22/02-19-57/repos/Lompik/mpd_info/refs/heads/master/src/"
            "parse_config.c",
            56, (errno == 0 ? "None" : strerror(errno)), intstr);
  } else {
    if (perform_boundchecks == 1) {
      if (temp <= minvalue)
        return (minvalue);
      if (temp >= maxvalue)
        return (maxvalue);
    }
    return (temp);
  }
  errno = errnotmp;
  return (0);
}


x86 assembly (clang, -O0):
<check_intconv_error>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8d,-0x20(%rbp)
mov    0x2e70(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
mov    0x2e5d(%rip),%rax
movl   $0x0,(%rax)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%edx
lea    -0x30(%rbp),%rsi
call   1040 <strtol@plt>
mov    %eax,-0x28(%rbp)
mov    0x2e3d(%rip),%rax
mov    (%rax),%eax
mov    0x2e4c(%rip),%rcx
cmp    (%rcx),%eax
jne    1249 <check_intconv_error+0x109>
movslq -0x28(%rbp),%rax
mov    %rax,-0x38(%rbp)
sub    $0x80,%rax
je     11d2 <check_intconv_error+0x92>
jmp    11bd <check_intconv_error+0x7d>
mov    -0x38(%rbp),%rax
sub    $0x81,%rax
je     1238 <check_intconv_error+0xf8>
jmp    123d <check_intconv_error+0xfd>
mov    0x2dff(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x3c(%rbp)
mov    0x2deb(%rip),%rax
cmpl   $0x0,(%rax)
jne    11fe <check_intconv_error+0xbe>
lea    0xec3(%rip),%rax
mov    %rax,-0x48(%rbp)
jmp    1210 <check_intconv_error+0xd0>
mov    0x2dcb(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
mov    %rax,-0x48(%rbp)
mov    -0x3c(%rbp),%edi
mov    -0x48(%rbp),%r8
mov    -0x10(%rbp),%r9
lea    0xdde(%rip),%rsi
lea    0xe00(%rip),%rdx
mov    $0x28,%ecx
call   1030 <fprintf@plt>
jmp    1244 <check_intconv_error+0x104>
jmp    1244 <check_intconv_error+0x104>
xor    %edi,%edi
call   1050 <exit@plt>
jmp    1387 <check_intconv_error+0x247>
mov    0x2d80(%rip),%rax
cmpl   $0x0,(%rax)
je     12bf <check_intconv_error+0x17f>
mov    0x2d78(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4c(%rbp)
mov    0x2d64(%rip),%rax
cmpl   $0x0,(%rax)
jne    1285 <check_intconv_error+0x145>
lea    0xe3c(%rip),%rax
mov    %rax,-0x58(%rbp)
jmp    1297 <check_intconv_error+0x157>
mov    0x2d44(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
mov    %rax,-0x58(%rbp)
mov    -0x4c(%rbp),%edi
mov    -0x58(%rbp),%r8
mov    -0x10(%rbp),%r9
lea    0xe14(%rip),%rsi
lea    0xd79(%rip),%rdx
mov    $0x34,%ecx
call   1030 <fprintf@plt>
jmp    1382 <check_intconv_error+0x242>
mov    -0x30(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1335 <check_intconv_error+0x1f5>
mov    0x2d02(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x5c(%rbp)
mov    0x2cee(%rip),%rax
cmpl   $0x0,(%rax)
jne    12fb <check_intconv_error+0x1bb>
lea    0xdc6(%rip),%rax
mov    %rax,-0x68(%rbp)
jmp    130d <check_intconv_error+0x1cd>
mov    0x2cce(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
mov    %rax,-0x68(%rbp)
mov    -0x5c(%rbp),%edi
mov    -0x68(%rbp),%r8
mov    -0x10(%rbp),%r9
lea    0xdd3(%rip),%rsi
lea    0xd03(%rip),%rdx
mov    $0x38,%ecx
call   1030 <fprintf@plt>
jmp    137d <check_intconv_error+0x23d>
cmpl   $0x1,-0x18(%rbp)
jne    1372 <check_intconv_error+0x232>
mov    -0x28(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jg     1356 <check_intconv_error+0x216>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    139a <check_intconv_error+0x25a>
mov    -0x28(%rbp),%eax
cmp    -0x20(%rbp),%eax
jl     136d <check_intconv_error+0x22d>
mov    -0x20(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    139a <check_intconv_error+0x25a>
jmp    1372 <check_intconv_error+0x232>
mov    -0x28(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    139a <check_intconv_error+0x25a>
jmp    1382 <check_intconv_error+0x242>
jmp    1387 <check_intconv_error+0x247>
mov    -0x24(%rbp),%ecx
mov    0x2c3f(%rip),%rax
mov    %ecx,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_intconv_error>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8d,%r14d
mov    %ecx,%ebp
mov    %edx,%r15d
mov    %esi,%edx
mov    %rdi,%rbx
mov    0x2e71(%rip),%r12
mov    (%r12),%r13d
movl   $0x0,(%r12)
mov    %rsp,%rsi
call   1040 <strtol@plt>
mov    (%r12),%edi
mov    0x2e6a(%rip),%rcx
cmp    (%rcx),%edi
jne    11b3 <check_intconv_error+0x73>
cltq
cmp    $0x81,%rax
je     1231 <check_intconv_error+0xf1>
cmp    $0x80,%rax
jne    125e <check_intconv_error+0x11e>
mov    0x2e35(%rip),%rax
mov    (%rax),%ebp
test   %edi,%edi
je     120d <check_intconv_error+0xcd>
call   1060 <strerror@plt>
mov    %rax,%r8
jmp    1214 <check_intconv_error+0xd4>
test   %edi,%edi
je     11df <check_intconv_error+0x9f>
mov    0x2e1a(%rip),%rax
mov    (%rax),%ebp
call   1060 <strerror@plt>
lea    0xef1(%rip),%rsi
lea    0xe56(%rip),%rdx
mov    %ebp,%edi
mov    $0x34,%ecx
mov    %rax,%r8
jmp    1229 <check_intconv_error+0xe9>
mov    (%rsp),%rcx
cmpb   $0x0,(%rcx)
je     1248 <check_intconv_error+0x108>
mov    0x2de9(%rip),%rax
mov    (%rax),%edi
lea    0xefa(%rip),%rsi
lea    0xe2a(%rip),%rdx
lea    0xeb2(%rip),%r8
mov    $0x38,%ecx
jmp    1229 <check_intconv_error+0xe9>
lea    0xea4(%rip),%r8
lea    0xde5(%rip),%rsi
lea    0xe07(%rip),%rdx
mov    %ebp,%edi
mov    $0x28,%ecx
mov    %rbx,%r9
call   1030 <fprintf@plt>
mov    %r13d,(%r12)
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
cmp    $0x1,%r15d
jne    125a <check_intconv_error+0x11a>
cmp    %ebp,%eax
jle    1237 <check_intconv_error+0xf7>
mov    %r14d,%ebp
cmp    %r14d,%eax
jge    1237 <check_intconv_error+0xf7>
mov    %eax,%ebp
jmp    1237 <check_intconv_error+0xf7>
xor    %edi,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@errno = global i32 0
@ERANGE = global i32 0
@stderr = global i32 0
@.str = [41 x i8] c"[ERROR] (%s:%d: errno: %s) Overflow:%s\0A\0A\00"
@.str.1 = [143 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/Lompik/mpd_info/refs/heads/master/src/parse_config.c\00"
@.str.2 = [5 x i8] c"None\00"
@.str.3 = [53 x i8] c"[ERROR] (%s:%d: errno: %s) Error converting int:%s\0A\0A\00"
@.str.4 = [58 x i8] c"[ERROR] (%s:%d: errno: %s) Garbage in the end string:%s\0A\0A\00"
define i32 @check_intconv_error(i8* %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i8*
store i8* %0, i8** %7
store i32 %1, i32* %8
store i32 %2, i32* %9
store i32 %3, i32* %10
store i32 %4, i32* %11
%15 = load i32, i32* @errno
store i32 %15, i32* %12
store i32 0, i32* %13
store i32 0, i32* @errno
%16 = load i8*, i8** %7
%17 = load i32, i32* %8
%18 = call i32 @strtol(i8* %16, i8** %14, i32 %17)
store i32 %18, i32* %13
%19 = load i32, i32* @errno
%20 = load i32, i32* @ERANGE
%21 = icmp eq i32 %19, %20
br i1 %21, label %22, label %41
22: ; preds = %5
%23 = load i32, i32* %13
%24 = sext i32 %23 to i64
switch i64 %24, label %38 [
i64 128, label %25
i64 129, label %37
]
25: ; preds = %22
%26 = load i32, i32* @stderr
%27 = load i32, i32* @errno
%28 = icmp eq i32 %27, 0
br i1 %28, label %29, label %30
29: ; preds = %25
br label %33
30: ; preds = %25
%31 = load i32, i32* @errno
%32 = call i8* @strerror(i32 %31)
br label %33
33: ; preds = %30, %29
%34 = phi i8* [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), %29 ], [ %32, %30 ]
%35 = load i8*, i8** %7
%36 = call i32 @fprintf(i32 %26, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([143 x i8], [143 x i8]* @.str.1, i64 0, i64 0), i32 40, i8* %34, i8* %35)
br label %40
37: ; preds = %22
br label %40
38: ; preds = %22
%39 = call i32 @exit(i32 0)
unreachable
40: ; preds = %37, %33
br label %93
41: ; preds = %5
%42 = load i32, i32* @errno
%43 = icmp ne i32 %42, 0
br i1 %43, label %44, label %56
44: ; preds = %41
%45 = load i32, i32* @stderr
%46 = load i32, i32* @errno
%47 = icmp eq i32 %46, 0
br i1 %47, label %48, label %49
48: ; preds = %44
br label %52
49: ; preds = %44
%50 = load i32, i32* @errno
%51 = call i8* @strerror(i32 %50)
br label %52
52: ; preds = %49, %48
%53 = phi i8* [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), %48 ], [ %51, %49 ]
%54 = load i8*, i8** %7
%55 = call i32 @fprintf(i32 %45, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([143 x i8], [143 x i8]* @.str.1, i64 0, i64 0), i32 52, i8* %53, i8* %54)
br label %92
56: ; preds = %41
%57 = load i8*, i8** %14
%58 = load i8, i8* %57
%59 = sext i8 %58 to i32
%60 = icmp ne i32 %59, 0
br i1 %60, label %61, label %73
61: ; preds = %56
%62 = load i32, i32* @stderr
%63 = load i32, i32* @errno
%64 = icmp eq i32 %63, 0
br i1 %64, label %65, label %66
65: ; preds = %61
br label %69
66: ; preds = %61
%67 = load i32, i32* @errno
%68 = call i8* @strerror(i32 %67)
br label %69
69: ; preds = %66, %65
%70 = phi i8* [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), %65 ], [ %68, %66 ]
%71 = load i8*, i8** %7
%72 = call i32 @fprintf(i32 %62, i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([143 x i8], [143 x i8]* @.str.1, i64 0, i64 0), i32 56, i8* %70, i8* %71)
br label %91
73: ; preds = %56
%74 = load i32, i32* %9
%75 = icmp eq i32 %74, 1
br i1 %75, label %76, label %89
76: ; preds = %73
%77 = load i32, i32* %13
%78 = load i32, i32* %10
%79 = icmp sle i32 %77, %78
br i1 %79, label %80, label %82
80: ; preds = %76
%81 = load i32, i32* %10
store i32 %81, i32* %6
br label %95
82: ; preds = %76
%83 = load i32, i32* %13
%84 = load i32, i32* %11
%85 = icmp sge i32 %83, %84
br i1 %85, label %86, label %88
86: ; preds = %82
%87 = load i32, i32* %11
store i32 %87, i32* %6
br label %95
88: ; preds = %82
br label %89
89: ; preds = %88, %73
%90 = load i32, i32* %13
store i32 %90, i32* %6
br label %95
91: ; preds = %69
br label %92
92: ; preds = %91, %52
br label %93
93: ; preds = %92, %40
%94 = load i32, i32* %12
store i32 %94, i32* @errno
store i32 0, i32* %6
br label %95
95: ; preds = %93, %89, %86, %80
%96 = load i32, i32* %6
ret i32 %96
}

LLVM IR (-O2):
@errno = global i32 0
@ERANGE = global i32 0
@stderr = global i32 0
@.str = [41 x i8] c"[ERROR] (%s:%d: errno: %s) Overflow:%s\0A\0A\00"
@.str.1 = [143 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/Lompik/mpd_info/refs/heads/master/src/parse_config.c\00"
@.str.2 = [5 x i8] c"None\00"
@.str.3 = [53 x i8] c"[ERROR] (%s:%d: errno: %s) Error converting int:%s\0A\0A\00"
@.str.4 = [58 x i8] c"[ERROR] (%s:%d: errno: %s) Garbage in the end string:%s\0A\0A\00"
define i32 @check_intconv_error(i8* %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca i8*
%7 = load i32, i32* @errno
%8 = bitcast i8** %6 to i8*
store i32 0, i32* @errno
%9 = call i32 @strtol(i8* %0, i8** %6, i32 %1)
%10 = load i32, i32* @errno
%11 = load i32, i32* @ERANGE
%12 = icmp eq i32 %10, %11
br i1 %12, label %13, label %25
13: ; preds = %5
%14 = sext i32 %9 to i64
switch i64 %14, label %23 [
i64 128, label %15
i64 129, label %45
]
15: ; preds = %13
%16 = load i32, i32* @stderr
%17 = icmp eq i32 %10, 0
br i1 %17, label %20, label %18
18: ; preds = %15
%19 = tail call i8* @strerror(i32 %10)
br label %20
20: ; preds = %15, %18
%21 = phi i8* [ %19, %18 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), %15 ]
%22 = tail call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([143 x i8], [143 x i8]* @.str.1, i64 0, i64 0), i32 40, i8* %21, i8* %0)
br label %45
23: ; preds = %13
%24 = tail call i32 @exit(i32 0)
unreachable
25: ; preds = %5
%26 = icmp eq i32 %10, 0
br i1 %26, label %31, label %27
27: ; preds = %25
%28 = load i32, i32* @stderr
%29 = tail call i8* @strerror(i32 %10)
%30 = tail call i32 @fprintf(i32 %28, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([143 x i8], [143 x i8]* @.str.1, i64 0, i64 0), i32 52, i8* %29, i8* %0)
br label %45
31: ; preds = %25
%32 = load i8*, i8** %6
%33 = load i8, i8* %32
%34 = icmp eq i8 %33, 0
br i1 %34, label %38, label %35
35: ; preds = %31
%36 = load i32, i32* @stderr
%37 = tail call i32 @fprintf(i32 %36, i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([143 x i8], [143 x i8]* @.str.1, i64 0, i64 0), i32 56, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %0)
br label %45
38: ; preds = %31
%39 = icmp eq i32 %2, 1
br i1 %39, label %40, label %44
40: ; preds = %38
%41 = icmp sgt i32 %9, %3
br i1 %41, label %42, label %46
42: ; preds = %40
%43 = icmp slt i32 %9, %4
br i1 %43, label %44, label %46
44: ; preds = %42, %38
br label %46
45: ; preds = %27, %35, %20, %13
store i32 %7, i32* @errno
br label %46
46: ; preds = %42, %40, %45, %44
%47 = phi i32 [ 0, %45 ], [ %9, %44 ], [ %3, %40 ], [ %4, %42 ]
ret i32 %47
}