#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*/ fprintf(int /*<<< orphan*/, char *, char *, ...);
int /*<<< orphan*/ stderr;
int strtol(char *, char **, int);
int readPos(char *s, char **e, int min) {
  int d;
  d = strtol(s, e, 10);
  if (s == *e) {
    fprintf(stderr, "ill-formed integer \"%s\" ", s);
    return -1;
  }
  if (d < min) {
    fprintf(stderr, "integer \"%s\" less than %d", s, min);
    return -1;
  }
  return d;
}


x86 assembly (clang, -O0):
<readPos>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    $0xa,%edx
call   1040 <strtol@plt>
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rcx
cmp    (%rcx),%rax
jne    1180 <readPos+0x60>
mov    0x2e80(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xe93(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11bc <readPos+0x9c>
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11b6 <readPos+0x96>
mov    0x2e4d(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
mov    -0x1c(%rbp),%ecx
lea    0xe76(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11bc <readPos+0x9c>
mov    -0x20(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readPos>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%r14d
mov    %rsi,%rbp
mov    %rdi,%rbx
mov    $0xa,%edx
call   1040 <strtol@plt>
cmp    %rbx,0x0(%rbp)
je     1161 <readPos+0x41>
cmp    %r14d,%eax
jge    1180 <readPos+0x60>
mov    0x2e97(%rip),%rax
mov    (%rax),%edi
lea    0xec7(%rip),%rsi
mov    %rbx,%rdx
mov    %r14d,%ecx
xor    %eax,%eax
call   1030 <fprintf@plt>
jmp    117b <readPos+0x5b>
mov    0x2e78(%rip),%rax
mov    (%rax),%edi
lea    0xe8f(%rip),%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    $0xffffffff,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [25 x i8] c"ill-formed integer \22%s\22 \00"
@.str.1 = [26 x i8] c"integer \22%s\22 less than %d\00"
define i32 @readPos(i8* %0, i8** %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8**
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %5
store i8** %1, i8*** %6
store i32 %2, i32* %7
%9 = load i8*, i8** %5
%10 = load i8**, i8*** %6
%11 = call i32 @strtol(i8* %9, i8** %10, i32 10)
store i32 %11, i32* %8
%12 = load i8*, i8** %5
%13 = load i8**, i8*** %6
%14 = load i8*, i8** %13
%15 = icmp eq i8* %12, %14
br i1 %15, label %16, label %20
16: ; preds = %3
%17 = load i32, i32* @stderr
%18 = load i8*, i8** %5
%19 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %17, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %18)
store i32 -1, i32* %4
br label %31
20: ; preds = %3
%21 = load i32, i32* %8
%22 = load i32, i32* %7
%23 = icmp slt i32 %21, %22
br i1 %23, label %24, label %29
24: ; preds = %20
%25 = load i32, i32* @stderr
%26 = load i8*, i8** %5
%27 = load i32, i32* %7
%28 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %25, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i8* %26, i32 %27)
store i32 -1, i32* %4
br label %31
29: ; preds = %20
%30 = load i32, i32* %8
store i32 %30, i32* %4
br label %31
31: ; preds = %29, %24, %16
%32 = load i32, i32* %4
ret i32 %32
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [25 x i8] c"ill-formed integer \22%s\22 \00"
@.str.1 = [26 x i8] c"integer \22%s\22 less than %d\00"
define i32 @readPos(i8* %0, i8** nocapture %1, i32 %2) {
%4 = tail call i32 @strtol(i8* %0, i8** %1, i32 10)
%5 = load i8*, i8** %1
%6 = icmp eq i8* %5, %0
br i1 %6, label %7, label %10
7: ; preds = %3
%8 = load i32, i32* @stderr
%9 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %8, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %15
10: ; preds = %3
%11 = icmp slt i32 %4, %2
br i1 %11, label %12, label %15
12: ; preds = %10
%13 = load i32, i32* @stderr
%14 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %13, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i8* %0, i32 %2)
br label %15
15: ; preds = %10, %12, %7
%16 = phi i32 [ -1, %7 ], [ -1, %12 ], [ %4, %10 ]
ret i32 %16
}