#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*/ error(char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int sscanf(char *, char *, int *, ...);
int /*<<< orphan*/ stderr;
int check(char *pat, char **vars) {
  int low, high, x;
  char v;
  x = sscanf(pat, "%d <= %%%c <= %d", &low, &v, &high);
  if (x != 3 || !('0' <= v && v <= '9')) {
    fprintf(stderr, "warning: invalid use of '%%check' in \"%s\"\n", pat);
    fprintf(stderr, "format is '%%check min <= %%n <= max'\n");
    return 0;
  }
  if (vars[v - '0'] == 0) {
    fprintf(stderr, "error in pattern \"%s\"\n", pat);
    error("variable is not set\n");
  }
  if (sscanf(vars[v - '0'], "%d", &x) != 1)
    return 0;
  return low <= x && x <= high;
}


x86 assembly (clang, -O0):
<check>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xeb5(%rip),%rsi
lea    -0x1c(%rbp),%rdx
lea    -0x25(%rbp),%rcx
lea    -0x20(%rbp),%r8
mov    $0x0,%al
call   1040 <sscanf@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x3,-0x24(%rbp)
jne    1189 <check+0x59>
movsbl -0x25(%rbp),%ecx
mov    $0x30,%eax
cmp    %ecx,%eax
jg     1189 <check+0x59>
movsbl -0x25(%rbp),%eax
cmp    $0x39,%eax
jle    11c7 <check+0x97>
mov    0x2e50(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xe74(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    0x2e35(%rip),%rax
mov    (%rax),%edi
lea    0xe88(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1268 <check+0x138>
mov    -0x18(%rbp),%rax
movsbl -0x25(%rbp),%ecx
sub    $0x30,%ecx
movslq %ecx,%rcx
cmpq   $0x0,(%rax,%rcx,8)
jne    1207 <check+0xd7>
mov    0x2df9(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xe6f(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
lea    0xe78(%rip),%rdi
call   1050 <error@plt>
mov    -0x18(%rbp),%rax
movsbl -0x25(%rbp),%ecx
sub    $0x30,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xdee(%rip),%rsi
lea    -0x24(%rbp),%rdx
mov    $0x0,%al
call   1040 <sscanf@plt>
cmp    $0x1,%eax
je     1240 <check+0x110>
movl   $0x0,-0x4(%rbp)
jmp    1268 <check+0x138>
mov    -0x1c(%rbp),%ecx
xor    %eax,%eax
cmp    -0x24(%rbp),%ecx
mov    %al,-0x26(%rbp)
jg     125d <check+0x12d>
mov    -0x24(%rbp),%eax
cmp    -0x20(%rbp),%eax
setle  %al
mov    %al,-0x26(%rbp)
mov    -0x26(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xebb(%rip),%rsi
xor    %ebp,%ebp
lea    0xc(%rsp),%rdx
lea    0x3(%rsp),%rcx
lea    0x8(%rsp),%r8
xor    %eax,%eax
call   1040 <sscanf@plt>
mov    %eax,0x4(%rsp)
cmp    $0x3,%eax
jne    11ec <check+0xbc>
mov    0x3(%rsp),%al
cmp    $0x30,%al
jl     11ec <check+0xbc>
cmp    $0x3a,%al
jge    11ec <check+0xbc>
movzbl %al,%ecx
add    $0xffffffd0,%ecx
cmpq   $0x0,(%r14,%rcx,8)
jne    11ad <check+0x7d>
mov    0x2e56(%rip),%rax
mov    (%rax),%edi
lea    0xed0(%rip),%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1030 <fprintf@plt>
lea    0xed6(%rip),%rdi
call   1050 <error@plt>
mov    0x3(%rsp),%al
movsbq %al,%rax
mov    -0x180(%r14,%rax,8),%rdi
ff
lea    0xe4e(%rip),%rsi
xor    %ebp,%ebp
lea    0x4(%rsp),%rdx
xor    %eax,%eax
call   1040 <sscanf@plt>
cmp    $0x1,%eax
jne    1218 <check+0xe8>
mov    0x4(%rsp),%eax
cmp    %eax,0xc(%rsp)
setle  %cl
cmp    0x8(%rsp),%eax
setle  %al
and    %cl,%al
movzbl %al,%ebp
jmp    1218 <check+0xe8>
mov    0x2ded(%rip),%r14
mov    (%r14),%edi
lea    0xe14(%rip),%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    (%r14),%edi
lea    0xe2b(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    %ebp,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [17 x i8] c"%d <= %%%c <= %d\00"
@stderr = global i32 0
@.str.1 = [43 x i8] c"warning: invalid use of '%%check' in \22%s\22\0A\00"
@.str.2 = [39 x i8] c"format is '%%check min <= %%n <= max'\0A\00"
@.str.3 = [23 x i8] c"error in pattern \22%s\22\0A\00"
@.str.4 = [21 x i8] c"variable is not set\0A\00"
@.str.5 = [3 x i8] c"%d\00"
define i32 @check(i8* %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8
store i8* %0, i8** %4
store i8** %1, i8*** %5
%10 = load i8*, i8** %4
%11 = call i32 (i8*, i8*, i32*, ...) @sscanf(i8* %10, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32* %6, i8* %9, i32* %7)
store i32 %11, i32* %8
%12 = load i32, i32* %8
%13 = icmp ne i32 %12, 3
br i1 %13, label %22, label %14
14: ; preds = %2
%15 = load i8, i8* %9
%16 = sext i8 %15 to i32
%17 = icmp sle i32 48, %16
br i1 %17, label %18, label %22
18: ; preds = %14
%19 = load i8, i8* %9
%20 = sext i8 %19 to i32
%21 = icmp sle i32 %20, 57
br i1 %21, label %28, label %22
22: ; preds = %18, %14, %2
%23 = load i32, i32* @stderr
%24 = load i8*, i8** %4
%25 = call i32 (i32, i8*, ...) @fprintf(i32 %23, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0), i8* %24)
%26 = load i32, i32* @stderr
%27 = call i32 (i32, i8*, ...) @fprintf(i32 %26, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %3
br label %64
28: ; preds = %18
%29 = load i8**, i8*** %5
%30 = load i8, i8* %9
%31 = sext i8 %30 to i32
%32 = sub nsw i32 %31, 48
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i8*, i8** %29, i64 %33
%35 = load i8*, i8** %34
%36 = icmp eq i8* %35, null
br i1 %36, label %37, label %42
37: ; preds = %28
%38 = load i32, i32* @stderr
%39 = load i8*, i8** %4
%40 = call i32 (i32, i8*, ...) @fprintf(i32 %38, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i8* %39)
%41 = call i32 @error(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0))
br label %42
42: ; preds = %37, %28
%43 = load i8**, i8*** %5
%44 = load i8, i8* %9
%45 = sext i8 %44 to i32
%46 = sub nsw i32 %45, 48
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds i8*, i8** %43, i64 %47
%49 = load i8*, i8** %48
%50 = call i32 (i8*, i8*, i32*, ...) @sscanf(i8* %49, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %8)
%51 = icmp ne i32 %50, 1
br i1 %51, label %52, label %53
52: ; preds = %42
store i32 0, i32* %3
br label %64
53: ; preds = %42
%54 = load i32, i32* %6
%55 = load i32, i32* %8
%56 = icmp sle i32 %54, %55
br i1 %56, label %57, label %61
57: ; preds = %53
%58 = load i32, i32* %8
%59 = load i32, i32* %7
%60 = icmp sle i32 %58, %59
br label %61
61: ; preds = %57, %53
%62 = phi i1 [ false, %53 ], [ %60, %57 ]
%63 = zext i1 %62 to i32
store i32 %63, i32* %3
br label %64
64: ; preds = %61, %52, %22
%65 = load i32, i32* %3
ret i32 %65
}

LLVM IR (-O2):
@.str = [17 x i8] c"%d <= %%%c <= %d\00"
@stderr = global i32 0
@.str.1 = [43 x i8] c"warning: invalid use of '%%check' in \22%s\22\0A\00"
@.str.2 = [39 x i8] c"format is '%%check min <= %%n <= max'\0A\00"
@.str.3 = [23 x i8] c"error in pattern \22%s\22\0A\00"
@.str.4 = [21 x i8] c"variable is not set\0A\00"
@.str.5 = [3 x i8] c"%d\00"
define i32 @check(i8* %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8
%7 = bitcast i32* %3 to i8*
%8 = bitcast i32* %4 to i8*
%9 = bitcast i32* %5 to i8*
%10 = call i32 (i8*, i8*, i32*, ...) @sscanf(i8* %0, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32* %3, i8* %6, i32* %4)
store i32 %10, i32* %5
%11 = icmp eq i32 %10, 3
%12 = load i8, i8* %6
%13 = icmp sgt i8 %12, 47
%14 = select i1 %11, i1 %13, i1 false
%15 = icmp slt i8 %12, 58
%16 = select i1 %14, i1 %15, i1 false
br i1 %16, label %22, label %17
17: ; preds = %2
%18 = load i32, i32* @stderr
%19 = call i32 (i32, i8*, ...) @fprintf(i32 %18, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%20 = load i32, i32* @stderr
%21 = call i32 (i32, i8*, ...) @fprintf(i32 %20, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0))
br label %50
22: ; preds = %2
%23 = zext i8 %12 to i64
%24 = add nuw nsw i64 %23, 4294967248
%25 = and i64 %24, 4294967295
%26 = getelementptr inbounds i8*, i8** %1, i64 %25
%27 = load i8*, i8** %26
%28 = icmp eq i8* %27, null
br i1 %28, label %29, label %34
29: ; preds = %22
%30 = load i32, i32* @stderr
%31 = call i32 (i32, i8*, ...) @fprintf(i32 %30, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i8* %0)
%32 = call i32 @error(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0))
%33 = load i8, i8* %6
br label %34
34: ; preds = %29, %22
%35 = phi i8 [ %33, %29 ], [ %12, %22 ]
%36 = sext i8 %35 to i64
%37 = add nsw i64 %36, -48
%38 = getelementptr inbounds i8*, i8** %1, i64 %37
%39 = load i8*, i8** %38
%40 = call i32 (i8*, i8*, i32*, ...) @sscanf(i8* %39, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %5)
%41 = icmp eq i32 %40, 1
br i1 %41, label %42, label %50
42: ; preds = %34
%43 = load i32, i32* %3
%44 = load i32, i32* %5
%45 = icmp sle i32 %43, %44
%46 = load i32, i32* %4
%47 = icmp sle i32 %44, %46
%48 = select i1 %45, i1 %47, i1 false
%49 = zext i1 %48 to i32
br label %50
50: ; preds = %34, %42, %17
%51 = phi i32 [ %49, %42 ], [ 0, %17 ], [ 0, %34 ]
ret i32 %51
}