#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 */
char *conf_get_str(char *, char *);
int sscanf(char *, char *, int *, int *, int *);
int /*<<< orphan*/ warnx(char *, char *, char *, ...);
int conf_match_num(char *section, char *tag, int x) {
  char *value = conf_get_str(section, tag);
  int val, min, max, n;
  if (!value)
    return 0;
  n = sscanf(value, "%d,%d:%d", &val, &min, &max);
  switch (n) {
  case 1:
    warnx("conf_match_num: %s:%s %d==%d?", section, tag, val, x);
    return x == val;
  case 3:
    warnx("conf_match_num: %s:%s %d<=%d<=%d?", section, tag, min, x, max);
    return min <= x && max >= x;
  default:
    warnx("conf_match_num: section %s tag %s: invalid number spec %s", section,
          tag, value);
  }
  return 0;
}


x86 assembly (clang, -O0):
<conf_match_num>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <conf_get_str@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    116b <conf_match_num+0x3b>
movl   $0x0,-0x4(%rbp)
jmp    1251 <conf_match_num+0x121>
mov    -0x28(%rbp),%rdi
lea    0xe8a(%rip),%rsi
lea    -0x2c(%rbp),%rdx
lea    -0x30(%rbp),%rcx
lea    -0x34(%rbp),%r8
call   1050 <sscanf@plt>
mov    %eax,-0x38(%rbp)
mov    -0x38(%rbp),%eax
mov    %eax,-0x3c(%rbp)
sub    $0x1,%eax
je     11af <conf_match_num+0x7f>
jmp    119e <conf_match_num+0x6e>
mov    -0x3c(%rbp),%eax
sub    $0x3,%eax
je     11e2 <conf_match_num+0xb2>
jmp    1230 <conf_match_num+0x100>
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x2c(%rbp),%ecx
mov    -0x1c(%rbp),%r8d
lea    0xe44(%rip),%rdi
mov    $0x0,%al
call   1030 <warnx@plt>
mov    -0x1c(%rbp),%eax
cmp    -0x2c(%rbp),%eax
sete   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
jmp    1251 <conf_match_num+0x121>
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x30(%rbp),%ecx
mov    -0x1c(%rbp),%r8d
mov    -0x34(%rbp),%r9d
lea    0xe2b(%rip),%rdi
mov    $0x0,%al
call   1030 <warnx@plt>
mov    -0x30(%rbp),%ecx
xor    %eax,%eax
cmp    -0x1c(%rbp),%ecx
mov    %al,-0x3d(%rbp)
jg     1220 <conf_match_num+0xf0>
mov    -0x34(%rbp),%eax
cmp    -0x1c(%rbp),%eax
setge  %al
mov    %al,-0x3d(%rbp)
mov    -0x3d(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
jmp    1251 <conf_match_num+0x121>
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x28(%rbp),%rcx
lea    0xe06(%rip),%rdi
mov    $0x0,%al
call   1030 <warnx@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<conf_match_num>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %edx,%r14d
mov    %rsi,%r15
mov    %rdi,%r12
call   1040 <conf_get_str@plt>
test   %rax,%rax
je     11a0 <conf_match_num+0x70>
mov    %rax,%rbx
lea    0xea7(%rip),%rsi
lea    0xc(%rsp),%rdx
lea    0x8(%rsp),%rcx
lea    0x4(%rsp),%r8
mov    %rax,%rdi
call   1050 <sscanf@plt>
cmp    $0x3,%eax
je     11a4 <conf_match_num+0x74>
cmp    $0x1,%eax
jne    11da <conf_match_num+0xaa>
mov    0xc(%rsp),%ecx
lea    0xe84(%rip),%rdi
mov    %r12,%rsi
mov    %r15,%rdx
mov    %r14d,%r8d
xor    %eax,%eax
call   1030 <warnx@plt>
cmp    %r14d,0xc(%rsp)
sete   %bpl
jmp    11f3 <conf_match_num+0xc3>
xor    %ebp,%ebp
jmp    11f3 <conf_match_num+0xc3>
mov    0x8(%rsp),%ecx
mov    0x4(%rsp),%r9d
lea    0xe73(%rip),%rdi
mov    %r12,%rsi
mov    %r15,%rdx
mov    %r14d,%r8d
xor    %eax,%eax
call   1030 <warnx@plt>
cmp    %r14d,0x8(%rsp)
setle  %al
cmp    %r14d,0x4(%rsp)
setge  %bpl
and    %al,%bpl
jmp    11f3 <conf_match_num+0xc3>
lea    0xe68(%rip),%rdi
xor    %ebp,%ebp
mov    %r12,%rsi
mov    %r15,%rdx
mov    %rbx,%rcx
xor    %eax,%eax
call   1030 <warnx@plt>
movzbl %bpl,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [9 x i8] c"%d,%d:%d\00"
@.str.1 = [30 x i8] c"conf_match_num: %s:%s %d==%d?\00"
@.str.2 = [34 x i8] c"conf_match_num: %s:%s %d<=%d<=%d?\00"
@.str.3 = [58 x i8] c"conf_match_num: section %s tag %s: invalid number spec %s\00"
define i32 @conf_match_num(i8* %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
%13 = load i8*, i8** %5
%14 = load i8*, i8** %6
%15 = call i8* @conf_get_str(i8* %13, i8* %14)
store i8* %15, i8** %8
%16 = load i8*, i8** %8
%17 = icmp ne i8* %16, null
br i1 %17, label %19, label %18
18: ; preds = %3
store i32 0, i32* %4
br label %56
19: ; preds = %3
%20 = load i8*, i8** %8
%21 = call i32 @sscanf(i8* %20, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32* %9, i32* %10, i32* %11)
store i32 %21, i32* %12
%22 = load i32, i32* %12
switch i32 %22, label %50 [
i32 1, label %23
i32 3, label %33
]
23: ; preds = %19
%24 = load i8*, i8** %5
%25 = load i8*, i8** %6
%26 = load i32, i32* %9
%27 = load i32, i32* %7
%28 = call i32 (i8*, i8*, i8*, ...) @warnx(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* %24, i8* %25, i32 %26, i32 %27)
%29 = load i32, i32* %7
%30 = load i32, i32* %9
%31 = icmp eq i32 %29, %30
%32 = zext i1 %31 to i32
store i32 %32, i32* %4
br label %56
33: ; preds = %19
%34 = load i8*, i8** %5
%35 = load i8*, i8** %6
%36 = load i32, i32* %10
%37 = load i32, i32* %7
%38 = load i32, i32* %11
%39 = call i32 (i8*, i8*, i8*, ...) @warnx(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i8* %34, i8* %35, i32 %36, i32 %37, i32 %38)
%40 = load i32, i32* %10
%41 = load i32, i32* %7
%42 = icmp sle i32 %40, %41
br i1 %42, label %43, label %47
43: ; preds = %33
%44 = load i32, i32* %11
%45 = load i32, i32* %7
%46 = icmp sge i32 %44, %45
br label %47
47: ; preds = %43, %33
%48 = phi i1 [ false, %33 ], [ %46, %43 ]
%49 = zext i1 %48 to i32
store i32 %49, i32* %4
br label %56
50: ; preds = %19
%51 = load i8*, i8** %5
%52 = load i8*, i8** %6
%53 = load i8*, i8** %8
%54 = call i32 (i8*, i8*, i8*, ...) @warnx(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.3, i64 0, i64 0), i8* %51, i8* %52, i8* %53)
br label %55
55: ; preds = %50
store i32 0, i32* %4
br label %56
56: ; preds = %55, %47, %23, %18
%57 = load i32, i32* %4
ret i32 %57
}

LLVM IR (-O2):
@.str = [9 x i8] c"%d,%d:%d\00"
@.str.1 = [30 x i8] c"conf_match_num: %s:%s %d==%d?\00"
@.str.2 = [34 x i8] c"conf_match_num: %s:%s %d<=%d<=%d?\00"
@.str.3 = [58 x i8] c"conf_match_num: section %s tag %s: invalid number spec %s\00"
define i32 @conf_match_num(i8* %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = tail call i8* @conf_get_str(i8* %0, i8* %1)
%8 = bitcast i32* %4 to i8*
%9 = bitcast i32* %5 to i8*
%10 = bitcast i32* %6 to i8*
%11 = icmp eq i8* %7, null
br i1 %11, label %30, label %12
12: ; preds = %3
%13 = call i32 @sscanf(i8* %7, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32* %4, i32* %5, i32* %6)
switch i32 %13, label %28 [
i32 1, label %14
i32 3, label %19
]
14: ; preds = %12
%15 = load i32, i32* %4
%16 = call i32 (i8*, i8*, i8*, ...) @warnx(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* %0, i8* %1, i32 %15, i32 %2)
%17 = load i32, i32* %4
%18 = icmp eq i32 %17, %2
br label %30
19: ; preds = %12
%20 = load i32, i32* %5
%21 = load i32, i32* %6
%22 = call i32 (i8*, i8*, i8*, ...) @warnx(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i8* %0, i8* %1, i32 %20, i32 %2, i32 %21)
%23 = load i32, i32* %5
%24 = icmp sle i32 %23, %2
%25 = load i32, i32* %6
%26 = icmp sge i32 %25, %2
%27 = select i1 %24, i1 %26, i1 false
br label %30
28: ; preds = %12
%29 = call i32 (i8*, i8*, i8*, ...) @warnx(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.3, i64 0, i64 0), i8* %0, i8* %1, i8* %7)
br label %30
30: ; preds = %3, %28, %19, %14
%31 = phi i1 [ false, %28 ], [ %27, %19 ], [ %18, %14 ], [ false, %3 ]
%32 = zext i1 %31 to i32
ret i32 %32
}