#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__ ERANGE;
int /*<<< orphan*/ EXIT_FAILURE;
long LONG_MAX;
long LONG_MIN;
scalar_t__ errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
long labs(long);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ snprintf(char *, size_t, char *, char *);
int /*<<< orphan*/ stderr;
long strtol(char *, char **, int);
long mtime_long(char *mtime_str) {
  char *endptr;
  char perror_str[80 + 1];
  long mtime = strtol(mtime_str, &endptr, 10);
  if ((errno == ERANGE && (mtime == LONG_MAX || mtime == LONG_MIN)) ||
      (errno != 0 && mtime == 0)) {
    snprintf(perror_str, (size_t)80, "couldn't convert %s to a long\n",
             mtime_str);
    perror(perror_str);
    exit(EXIT_FAILURE);
  }
  if (endptr == mtime_str) {
    fprintf(stderr, "No digits were found\n");
    exit(EXIT_FAILURE);
  }
  if (*endptr != '\0') {
    fprintf(stderr, "Further characters after number: %s\n", endptr);
    exit(EXIT_FAILURE);
  }
  return (labs(mtime));
}


x86 assembly (clang, -O0):
<mtime_long>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x10(%rbp),%rsi
mov    $0xa,%edx
call   1060 <strtol@plt>
mov    %rax,-0x78(%rbp)
mov    0x2e34(%rip),%rax
mov    (%rax),%rax
mov    0x2e4a(%rip),%rcx
cmp    (%rcx),%rax
jne    11c7 <mtime_long+0x67>
mov    -0x78(%rbp),%rax
mov    0x2e1e(%rip),%rcx
cmp    (%rcx),%rax
je     11e3 <mtime_long+0x83>
mov    -0x78(%rbp),%rax
mov    0x2e2a(%rip),%rcx
cmp    (%rcx),%rax
je     11e3 <mtime_long+0x83>
mov    0x2df2(%rip),%rax
cmpq   $0x0,(%rax)
je     1213 <mtime_long+0xb3>
cmpq   $0x0,-0x78(%rbp)
jne    1213 <mtime_long+0xb3>
lea    -0x70(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    $0x50,%esi
lea    0xe09(%rip),%rdx
call   1040 <snprintf@plt>
lea    -0x70(%rbp),%rdi
call   1070 <perror@plt>
mov    0x2dac(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    -0x10(%rbp),%rax
cmp    -0x8(%rbp),%rax
jne    1246 <mtime_long+0xe6>
mov    0x2da8(%rip),%rax
mov    (%rax),%edi
lea    0xdee(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2d79(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     127f <mtime_long+0x11f>
mov    0x2d73(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xdcb(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2d40(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    -0x78(%rbp),%rdi
call   1030 <labs@plt>
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mtime_long>:
push   %r14
push   %rbx
sub    $0x68,%rsp
mov    %rdi,%rbx
lea    0x8(%rsp),%rsi
mov    $0xa,%edx
call   1050 <strtol@plt>
mov    0x2e50(%rip),%rcx
mov    (%rcx),%rcx
mov    0x2e66(%rip),%rdx
cmp    (%rdx),%rcx
jne    1197 <mtime_long+0x47>
mov    0x2e42(%rip),%rdx
cmp    (%rdx),%rax
je     11c5 <mtime_long+0x75>
mov    0x2e56(%rip),%rdx
cmp    (%rdx),%rax
je     11c5 <mtime_long+0x75>
test   %rcx,%rcx
je     11a1 <mtime_long+0x51>
test   %rax,%rax
je     11c5 <mtime_long+0x75>
mov    0x8(%rsp),%rdx
cmp    %rbx,%rdx
je     11eb <mtime_long+0x9b>
cmpb   $0x0,(%rdx)
jne    1204 <mtime_long+0xb4>
mov    %rax,%rcx
neg    %rcx
cmovs  %rax,%rcx
mov    %rcx,%rax
add    $0x68,%rsp
pop    %rbx
pop    %r14
ret
lea    0xe34(%rip),%rdx
lea    0x10(%rsp),%r14
mov    $0x50,%esi
mov    %r14,%rdi
mov    %rbx,%rcx
call   1030 <snprintf@plt>
mov    %r14,%rdi
call   1060 <perror@plt>
jmp    121b <mtime_long+0xcb>
mov    0x2dde(%rip),%rax
mov    (%rax),%edi
lea    0xe24(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
jmp    121b <mtime_long+0xcb>
mov    0x2dc5(%rip),%rax
mov    (%rax),%edi
lea    0xe21(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    0x2d96(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@errno = global i64 0
@ERANGE = global i64 0
@LONG_MAX = global i64 0
@LONG_MIN = global i64 0
@.str = [31 x i8] c"couldn't convert %s to a long\0A\00"
@EXIT_FAILURE = global i32 0
@stderr = global i32 0
@.str.1 = [22 x i8] c"No digits were found\0A\00"
@.str.2 = [37 x i8] c"Further characters after number: %s\0A\00"
define i64 @mtime_long(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca [81 x i8]
%5 = alloca i64
store i8* %0, i8** %2
%6 = load i8*, i8** %2
%7 = call i64 @strtol(i8* %6, i8** %3, i32 10)
store i64 %7, i64* %5
%8 = load i64, i64* @errno
%9 = load i64, i64* @ERANGE
%10 = icmp eq i64 %8, %9
br i1 %10, label %11, label %19
11: ; preds = %1
%12 = load i64, i64* %5
%13 = load i64, i64* @LONG_MAX
%14 = icmp eq i64 %12, %13
br i1 %14, label %25, label %15
15: ; preds = %11
%16 = load i64, i64* %5
%17 = load i64, i64* @LONG_MIN
%18 = icmp eq i64 %16, %17
br i1 %18, label %25, label %19
19: ; preds = %15, %1
%20 = load i64, i64* @errno
%21 = icmp ne i64 %20, 0
br i1 %21, label %22, label %33
22: ; preds = %19
%23 = load i64, i64* %5
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %33
25: ; preds = %22, %15, %11
%26 = getelementptr inbounds [81 x i8], [81 x i8]* %4, i64 0, i64 0
%27 = load i8*, i8** %2
%28 = call i32 @snprintf(i8* %26, i64 80, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i8* %27)
%29 = getelementptr inbounds [81 x i8], [81 x i8]* %4, i64 0, i64 0
%30 = call i32 @perror(i8* %29)
%31 = load i32, i32* @EXIT_FAILURE
%32 = call i32 @exit(i32 %31)
unreachable
33: ; preds = %22, %19
%34 = load i8*, i8** %3
%35 = load i8*, i8** %2
%36 = icmp eq i8* %34, %35
br i1 %36, label %37, label %42
37: ; preds = %33
%38 = load i32, i32* @stderr
%39 = call i32 (i32, i8*, ...) @fprintf(i32 %38, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
%40 = load i32, i32* @EXIT_FAILURE
%41 = call i32 @exit(i32 %40)
unreachable
42: ; preds = %33
%43 = load i8*, i8** %3
%44 = load i8, i8* %43
%45 = sext i8 %44 to i32
%46 = icmp ne i32 %45, 0
br i1 %46, label %47, label %53
47: ; preds = %42
%48 = load i32, i32* @stderr
%49 = load i8*, i8** %3
%50 = call i32 (i32, i8*, ...) @fprintf(i32 %48, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i8* %49)
%51 = load i32, i32* @EXIT_FAILURE
%52 = call i32 @exit(i32 %51)
unreachable
53: ; preds = %42
%54 = load i64, i64* %5
%55 = call i64 @labs(i64 %54)
ret i64 %55
}

LLVM IR (-O2):
@errno = global i64 0
@ERANGE = global i64 0
@LONG_MAX = global i64 0
@LONG_MIN = global i64 0
@.str = [31 x i8] c"couldn't convert %s to a long\0A\00"
@EXIT_FAILURE = global i32 0
@stderr = global i32 0
@.str.1 = [22 x i8] c"No digits were found\0A\00"
@.str.2 = [37 x i8] c"Further characters after number: %s\0A\00"
define i64 @mtime_long(i8* %0) {
%2 = alloca i8*
%3 = alloca [81 x i8]
%4 = bitcast i8** %2 to i8*
%5 = getelementptr inbounds [81 x i8], [81 x i8]* %3, i64 0, i64 0
%6 = call i64 @strtol(i8* %0, i8** %2, i32 10)
%7 = load i64, i64* @errno
%8 = load i64, i64* @ERANGE
%9 = icmp eq i64 %7, %8
br i1 %9, label %10, label %16
10: ; preds = %1
%11 = load i64, i64* @LONG_MAX
%12 = icmp eq i64 %6, %11
%13 = load i64, i64* @LONG_MIN
%14 = icmp eq i64 %6, %13
%15 = select i1 %12, i1 true, i1 %14
br i1 %15, label %20, label %16
16: ; preds = %10, %1
%17 = icmp ne i64 %7, 0
%18 = icmp eq i64 %6, 0
%19 = select i1 %17, i1 %18, i1 false
br i1 %19, label %20, label %25
20: ; preds = %16, %10
%21 = call i32 @snprintf(i8* %5, i64 80, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i8* %0)
%22 = call i32 @perror(i8* %5)
%23 = load i32, i32* @EXIT_FAILURE
%24 = call i32 @exit(i32 %23)
unreachable
25: ; preds = %16
%26 = load i8*, i8** %2
%27 = icmp eq i8* %26, %0
br i1 %27, label %28, label %33
28: ; preds = %25
%29 = load i32, i32* @stderr
%30 = tail call i32 (i32, i8*, ...) @fprintf(i32 %29, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
%31 = load i32, i32* @EXIT_FAILURE
%32 = tail call i32 @exit(i32 %31)
unreachable
33: ; preds = %25
%34 = load i8, i8* %26
%35 = icmp eq i8 %34, 0
br i1 %35, label %41, label %36
36: ; preds = %33
%37 = load i32, i32* @stderr
%38 = tail call i32 (i32, i8*, ...) @fprintf(i32 %37, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i8* %26)
%39 = load i32, i32* @EXIT_FAILURE
%40 = tail call i32 @exit(i32 %39)
unreachable
41: ; preds = %33
%42 = tail call i64 @llvm.abs.i64(i64 %6, i1 true)
ret i64 %42
}