#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*/ LOG_INFO;
char *conf_get_str(char *, char *);
int sscanf(char *, char *, int *, int *, int *);
int /*<<< orphan*/ xlog(int /*<<< orphan*/, 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:
    xlog(LOG_INFO, "conf_match_num: %s:%s %d==%d?", section, tag, val, x);
    return x == val;
  case 3:
    xlog(LOG_INFO, "conf_match_num: %s:%s %d<=%d<=%d?", section, tag, min, x,
         max);
    return min <= x && max >= x;
  default:
    xlog(LOG_INFO, "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    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <conf_get_str@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    116b <conf_match_num+0x3b>
movl   $0x0,-0x4(%rbp)
jmp    1270 <conf_match_num+0x140>
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     11ec <conf_match_num+0xbc>
jmp    1246 <conf_match_num+0x116>
mov    0x2e2a(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rcx
mov    -0x2c(%rbp),%r8d
mov    -0x1c(%rbp),%r9d
lea    0xe3a(%rip),%rsi
mov    $0x0,%al
call   1040 <xlog@plt>
mov    -0x1c(%rbp),%eax
cmp    -0x2c(%rbp),%eax
sete   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
jmp    1270 <conf_match_num+0x140>
mov    0x2ded(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rcx
mov    -0x30(%rbp),%r8d
mov    -0x1c(%rbp),%r9d
mov    -0x34(%rbp),%eax
lea    0xe18(%rip),%rsi
mov    %eax,(%rsp)
mov    $0x0,%al
call   1040 <xlog@plt>
mov    -0x30(%rbp),%ecx
xor    %eax,%eax
cmp    -0x1c(%rbp),%ecx
mov    %al,-0x3d(%rbp)
jg     1236 <conf_match_num+0x106>
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    1270 <conf_match_num+0x140>
mov    0x2d93(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rcx
mov    -0x28(%rbp),%r8
lea    0xde7(%rip),%rsi
mov    $0x0,%al
call   1040 <xlog@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<conf_match_num>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x20,%rsp
mov    %edx,%r14d
mov    %rsi,%r15
mov    %rdi,%r12
call   1030 <conf_get_str@plt>
test   %rax,%rax
je     11aa <conf_match_num+0x7a>
mov    %rax,%rbx
lea    0xea7(%rip),%rsi
lea    0x1c(%rsp),%rdx
lea    0x18(%rsp),%rcx
lea    0x14(%rsp),%r8
mov    %rax,%rdi
call   1050 <sscanf@plt>
cmp    $0x3,%eax
je     11ae <conf_match_num+0x7e>
cmp    $0x1,%eax
jne    11f0 <conf_match_num+0xc0>
mov    0x2e5f(%rip),%rax
mov    (%rax),%edi
mov    0x1c(%rsp),%r8d
lea    0xe7a(%rip),%rsi
mov    %r12,%rdx
mov    %r15,%rcx
mov    %r14d,%r9d
xor    %eax,%eax
call   1040 <xlog@plt>
cmp    %r14d,0x1c(%rsp)
sete   %bpl
jmp    1212 <conf_match_num+0xe2>
xor    %ebp,%ebp
jmp    1212 <conf_match_num+0xe2>
mov    0x2e2b(%rip),%rax
mov    (%rax),%edi
mov    0x18(%rsp),%r8d
mov    0x14(%rsp),%eax
mov    %eax,(%rsp)
lea    0xe5d(%rip),%rsi
mov    %r12,%rdx
mov    %r15,%rcx
mov    %r14d,%r9d
xor    %eax,%eax
call   1040 <xlog@plt>
cmp    %r14d,0x18(%rsp)
setle  %al
cmp    %r14d,0x14(%rsp)
setge  %bpl
and    %al,%bpl
jmp    1212 <conf_match_num+0xe2>
mov    0x2de9(%rip),%rax
mov    (%rax),%edi
lea    0xe49(%rip),%rsi
xor    %ebp,%ebp
mov    %r12,%rdx
mov    %r15,%rcx
mov    %rbx,%r8
xor    %eax,%eax
call   1040 <xlog@plt>
movzbl %bpl,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [9 x i8] c"%d,%d:%d\00"
@LOG_INFO = global i32 0
@.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 %59
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 %52 [
i32 1, label %23
i32 3, label %34
]
23: ; preds = %19
%24 = load i32, i32* @LOG_INFO
%25 = load i8*, i8** %5
%26 = load i8*, i8** %6
%27 = load i32, i32* %9
%28 = load i32, i32* %7
%29 = call i32 (i32, i8*, i8*, i8*, ...) @xlog(i32 %24, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* %25, i8* %26, i32 %27, i32 %28)
%30 = load i32, i32* %7
%31 = load i32, i32* %9
%32 = icmp eq i32 %30, %31
%33 = zext i1 %32 to i32
store i32 %33, i32* %4
br label %59
34: ; preds = %19
%35 = load i32, i32* @LOG_INFO
%36 = load i8*, i8** %5
%37 = load i8*, i8** %6
%38 = load i32, i32* %10
%39 = load i32, i32* %7
%40 = load i32, i32* %11
%41 = call i32 (i32, i8*, i8*, i8*, ...) @xlog(i32 %35, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i8* %36, i8* %37, i32 %38, i32 %39, i32 %40)
%42 = load i32, i32* %10
%43 = load i32, i32* %7
%44 = icmp sle i32 %42, %43
br i1 %44, label %45, label %49
45: ; preds = %34
%46 = load i32, i32* %11
%47 = load i32, i32* %7
%48 = icmp sge i32 %46, %47
br label %49
49: ; preds = %45, %34
%50 = phi i1 [ false, %34 ], [ %48, %45 ]
%51 = zext i1 %50 to i32
store i32 %51, i32* %4
br label %59
52: ; preds = %19
%53 = load i32, i32* @LOG_INFO
%54 = load i8*, i8** %5
%55 = load i8*, i8** %6
%56 = load i8*, i8** %8
%57 = call i32 (i32, i8*, i8*, i8*, ...) @xlog(i32 %53, i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.3, i64 0, i64 0), i8* %54, i8* %55, i8* %56)
br label %58
58: ; preds = %52
store i32 0, i32* %4
br label %59
59: ; preds = %58, %49, %23, %18
%60 = load i32, i32* %4
ret i32 %60
}

LLVM IR (-O2):
@.str = [9 x i8] c"%d,%d:%d\00"
@LOG_INFO = global i32 0
@.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 %33, 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 %30 [
i32 1, label %14
i32 3, label %20
]
14: ; preds = %12
%15 = load i32, i32* @LOG_INFO
%16 = load i32, i32* %4
%17 = call i32 (i32, i8*, i8*, i8*, ...) @xlog(i32 %15, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* %0, i8* %1, i32 %16, i32 %2)
%18 = load i32, i32* %4
%19 = icmp eq i32 %18, %2
br label %33
20: ; preds = %12
%21 = load i32, i32* @LOG_INFO
%22 = load i32, i32* %5
%23 = load i32, i32* %6
%24 = call i32 (i32, i8*, i8*, i8*, ...) @xlog(i32 %21, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i8* %0, i8* %1, i32 %22, i32 %2, i32 %23)
%25 = load i32, i32* %5
%26 = icmp sle i32 %25, %2
%27 = load i32, i32* %6
%28 = icmp sge i32 %27, %2
%29 = select i1 %26, i1 %28, i1 false
br label %33
30: ; preds = %12
%31 = load i32, i32* @LOG_INFO
%32 = call i32 (i32, i8*, i8*, i8*, ...) @xlog(i32 %31, i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.3, i64 0, i64 0), i8* %0, i8* %1, i8* %7)
br label %33
33: ; preds = %3, %30, %20, %14
%34 = phi i1 [ false, %30 ], [ %29, %20 ], [ %19, %14 ], [ false, %3 ]
%35 = zext i1 %34 to i32
ret i32 %35
}