#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 sscanf(char *, char *, long *, ...);
int scan_cats(char *s, long *x, long *y) {
  char dummy[2];
  *dummy = 0;
  if (sscanf(s, "%ld-%ld%1s", x, y, dummy) == 2)
    return (*dummy == 0 && *x <= *y);
  *dummy = 0;
  if (sscanf(s, "%ld%1s", x, dummy) == 1 && *dummy == 0) {
    *y = *x;
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<scan_cats>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
movb   $0x0,-0x22(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
lea    -0x22(%rbp),%r8
lea    0xec1(%rip),%rsi
mov    $0x0,%al
call   1030 <sscanf@plt>
cmp    $0x2,%eax
jne    1185 <scan_cats+0x75>
movsbl -0x22(%rbp),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x23(%rbp)
jne    1175 <scan_cats+0x65>
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    -0x20(%rbp),%rcx
cmp    (%rcx),%rax
setle  %al
mov    %al,-0x23(%rbp)
mov    -0x23(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
jmp    11da <scan_cats+0xca>
movb   $0x0,-0x22(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    -0x22(%rbp),%rcx
lea    0xe68(%rip),%rsi
mov    $0x0,%al
call   1030 <sscanf@plt>
cmp    $0x1,%eax
jne    11d3 <scan_cats+0xc3>
movsbl -0x22(%rbp),%eax
cmp    $0x0,%eax
jne    11d3 <scan_cats+0xc3>
mov    -0x18(%rbp),%rax
mov    (%rax),%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    11da <scan_cats+0xca>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<scan_cats>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %rdi,%rbp
movb   $0x0,0x6(%rsp)
lea    0xed4(%rip),%rsi
xor    %r15d,%r15d
lea    0x6(%rsp),%r8
mov    %rbx,%rdx
mov    %r14,%rcx
xor    %eax,%eax
call   1030 <sscanf@plt>
cmp    $0x2,%eax
jne    115c <scan_cats+0x4c>
cmpb   $0x0,0x6(%rsp)
jne    1192 <scan_cats+0x82>
mov    (%rbx),%rax
xor    %r15d,%r15d
cmp    (%r14),%rax
setle  %r15b
jmp    1192 <scan_cats+0x82>
movb   $0x0,0x6(%rsp)
lea    0xe9c(%rip),%rsi
lea    0x6(%rsp),%rcx
mov    %rbp,%rdi
mov    %rbx,%rdx
xor    %eax,%eax
call   1030 <sscanf@plt>
cmp    $0x1,%eax
jne    1192 <scan_cats+0x82>
cmpb   $0x0,0x6(%rsp)
jne    1192 <scan_cats+0x82>
mov    (%rbx),%rax
mov    %rax,(%r14)
mov    $0x1,%r15d
mov    %r15d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [11 x i8] c"%ld-%ld%1s\00"
@.str.1 = [7 x i8] c"%ld%1s\00"
define i32 @scan_cats(i8* %0, i64* %1, i64* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i64*
%7 = alloca i64*
%8 = alloca [2 x i8]
store i8* %0, i8** %5
store i64* %1, i64** %6
store i64* %2, i64** %7
%9 = getelementptr inbounds [2 x i8], [2 x i8]* %8, i64 0, i64 0
store i8 0, i8* %9
%10 = load i8*, i8** %5
%11 = load i64*, i64** %6
%12 = load i64*, i64** %7
%13 = getelementptr inbounds [2 x i8], [2 x i8]* %8, i64 0, i64 0
%14 = call i32 (i8*, i8*, i64*, ...) @sscanf(i8* %10, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i64* %11, i64* %12, i8* %13)
%15 = icmp eq i32 %14, 2
br i1 %15, label %16, label %30
16: ; preds = %3
%17 = getelementptr inbounds [2 x i8], [2 x i8]* %8, i64 0, i64 0
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %27
21: ; preds = %16
%22 = load i64*, i64** %6
%23 = load i64, i64* %22
%24 = load i64*, i64** %7
%25 = load i64, i64* %24
%26 = icmp sle i64 %23, %25
br label %27
27: ; preds = %21, %16
%28 = phi i1 [ false, %16 ], [ %26, %21 ]
%29 = zext i1 %28 to i32
store i32 %29, i32* %4
br label %47
30: ; preds = %3
%31 = getelementptr inbounds [2 x i8], [2 x i8]* %8, i64 0, i64 0
store i8 0, i8* %31
%32 = load i8*, i8** %5
%33 = load i64*, i64** %6
%34 = getelementptr inbounds [2 x i8], [2 x i8]* %8, i64 0, i64 0
%35 = call i32 (i8*, i8*, i64*, ...) @sscanf(i8* %32, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i64* %33, i8* %34)
%36 = icmp eq i32 %35, 1
br i1 %36, label %37, label %46
37: ; preds = %30
%38 = getelementptr inbounds [2 x i8], [2 x i8]* %8, i64 0, i64 0
%39 = load i8, i8* %38
%40 = sext i8 %39 to i32
%41 = icmp eq i32 %40, 0
br i1 %41, label %42, label %46
42: ; preds = %37
%43 = load i64*, i64** %6
%44 = load i64, i64* %43
%45 = load i64*, i64** %7
store i64 %44, i64* %45
store i32 1, i32* %4
br label %47
46: ; preds = %37, %30
store i32 0, i32* %4
br label %47
47: ; preds = %46, %42, %27
%48 = load i32, i32* %4
ret i32 %48
}

LLVM IR (-O2):
@.str = [11 x i8] c"%ld-%ld%1s\00"
@.str.1 = [7 x i8] c"%ld%1s\00"
define i32 @scan_cats(i8* nocapture %0, i64* %1, i64* %2) {
%4 = alloca [2 x i8]
%5 = getelementptr inbounds [2 x i8], [2 x i8]* %4, i64 0, i64 0
store i8 0, i8* %5
%6 = call i32 (i8*, i8*, i64*, ...) @sscanf(i8* %0, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i64* %1, i64* %2, i8* %5)
%7 = icmp eq i32 %6, 2
br i1 %7, label %8, label %16
8: ; preds = %3
%9 = load i8, i8* %5
%10 = icmp eq i8 %9, 0
br i1 %10, label %11, label %24
11: ; preds = %8
%12 = load i64, i64* %1
%13 = load i64, i64* %2
%14 = icmp sle i64 %12, %13
%15 = zext i1 %14 to i32
br label %24
16: ; preds = %3
store i8 0, i8* %5
%17 = call i32 (i8*, i8*, i64*, ...) @sscanf(i8* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i64* %1, i8* %5)
%18 = icmp eq i32 %17, 1
%19 = load i8, i8* %5
%20 = icmp eq i8 %19, 0
%21 = select i1 %18, i1 %20, i1 false
br i1 %21, label %22, label %24
22: ; preds = %16
%23 = load i64, i64* %1
store i64 %23, i64* %2
br label %24
24: ; preds = %16, %8, %11, %22
%25 = phi i32 [ 1, %22 ], [ 0, %8 ], [ %15, %11 ], [ 0, %16 ]
ret i32 %25
}