#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 */
struct abctune {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ do_select(struct abctune *, int, int);
int sscanf(char *, char *, int *, int *);
void do_filter(struct abctune *t, char *sel) {
  int cur_sel, end_sel, n;
  for (;;) {
    if (sscanf(sel, "%d%n", &cur_sel, &n) != 1)
      break;
    sel += n;
    if (*sel == '-') {
      sel++;
      end_sel = (int)((unsigned)(~0) >> 1);
      if (sscanf(sel, "%d%n", &end_sel, &n) != 1)
        end_sel = (unsigned)~0 >> 1;
      else
        sel += n;
    } else
      end_sel = cur_sel;
    do_select(t, cur_sel, end_sel);
    if (*sel != ',')
      break;
    sel++;
  }
}


x86 assembly (clang, -O0):
<do_filter>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xec5(%rip),%rsi
lea    -0x14(%rbp),%rdx
lea    -0x1c(%rbp),%rcx
call   1040 <sscanf@plt>
cmp    $0x1,%eax
je     1156 <do_filter+0x36>
jmp    1208 <do_filter+0xe8>
mov    -0x1c(%rbp),%ecx
mov    -0x10(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    11cd <do_filter+0xad>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
movl   $0x7fffffff,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe6b(%rip),%rsi
lea    -0x18(%rbp),%rdx
lea    -0x1c(%rbp),%rcx
call   1040 <sscanf@plt>
cmp    $0x1,%eax
je     11b7 <do_filter+0x97>
movl   $0x7fffffff,-0x18(%rbp)
jmp    11c8 <do_filter+0xa8>
mov    -0x1c(%rbp),%ecx
mov    -0x10(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x10(%rbp)
jmp    11d3 <do_filter+0xb3>
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
call   1030 <do_select@plt>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2c,%eax
je     11f7 <do_filter+0xd7>
jmp    1208 <do_filter+0xe8>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1130 <do_filter+0x10>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<do_filter>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbp
mov    %rdi,%rbx
lea    0xec5(%rip),%rsi
lea    0x14(%rsp),%rdx
lea    0x10(%rsp),%rcx
mov    %rbp,%rdi
call   1040 <sscanf@plt>
cmp    $0x1,%eax
jne    1210 <do_filter+0xf0>
lea    0xea3(%rip),%r14
lea    0x10(%rsp),%r12
lea    0x14(%rsp),%r13
nopw   0x0(%rax,%rax,1)
movslq 0x10(%rsp),%rax
lea    (%rax,%rbp,1),%r15
cmpb   $0x2d,0x0(%rbp,%rax,1)
jne    11c0 <do_filter+0xa0>
add    $0x1,%r15
movl   $0x7fffffff,0xc(%rsp)
7f
mov    %r15,%rdi
mov    %r14,%rsi
lea    0xc(%rsp),%rdx
mov    %r12,%rcx
call   1040 <sscanf@plt>
cmp    $0x1,%eax
jne    11d0 <do_filter+0xb0>
movslq 0x10(%rsp),%rax
add    %rax,%r15
mov    0xc(%rsp),%edx
jmp    11dd <do_filter+0xbd>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    0x14(%rsp),%edx
mov    %edx,0xc(%rsp)
jmp    11dd <do_filter+0xbd>
nopw   0x0(%rax,%rax,1)
movl   $0x7fffffff,0xc(%rsp)
7f
mov    $0x7fffffff,%edx
mov    0x14(%rsp),%esi
mov    %rbx,%rdi
call   1030 <do_select@plt>
cmpb   $0x2c,(%r15)
jne    1210 <do_filter+0xf0>
add    $0x1,%r15
mov    %r15,%rdi
mov    %r14,%rsi
mov    %r13,%rdx
mov    %r12,%rcx
call   1040 <sscanf@plt>
mov    %r15,%rbp
cmp    $0x1,%eax
je     1170 <do_filter+0x50>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
%struct.abctune = type { i32 }
@.str = [5 x i8] c"%d%n\00"
define void @do_filter(%struct.abctune* %0, i8* nocapture %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = bitcast i32* %3 to i8*
%7 = bitcast i32* %4 to i8*
%8 = bitcast i32* %5 to i8*
%9 = call i32 @sscanf(i8* %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32* %3, i32* %5)
%10 = icmp eq i32 %9, 1
br i1 %10, label %14, label %41
11: ; preds = %33
%12 = call i32 @sscanf(i8* %40, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32* %3, i32* %5)
%13 = icmp eq i32 %12, 1
br i1 %13, label %14, label %41
14: ; preds = %2, %11
%15 = phi i8* [ %40, %11 ], [ %1, %2 ]
%16 = load i32, i32* %5
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8, i8* %15, i64 %17
%19 = load i8, i8* %18
%20 = icmp eq i8 %19, 45
br i1 %20, label %21, label %31
21: ; preds = %14
%22 = getelementptr inbounds i8, i8* %18, i64 1
store i32 2147483647, i32* %4
%23 = call i32 @sscanf(i8* %22, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32* %4, i32* %5)
%24 = icmp eq i32 %23, 1
br i1 %24, label %26, label %25
25: ; preds = %21
store i32 2147483647, i32* %4
br label %33
26: ; preds = %21
%27 = load i32, i32* %5
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8, i8* %22, i64 %28
%30 = load i32, i32* %4
br label %33
31: ; preds = %14
%32 = load i32, i32* %3
store i32 %32, i32* %4
br label %33
33: ; preds = %25, %26, %31
%34 = phi i32 [ 2147483647, %25 ], [ %30, %26 ], [ %32, %31 ]
%35 = phi i8* [ %22, %25 ], [ %29, %26 ], [ %18, %31 ]
%36 = load i32, i32* %3
%37 = call i32 @do_select(%struct.abctune* %0, i32 %36, i32 %34)
%38 = load i8, i8* %35
%39 = icmp eq i8 %38, 44
%40 = getelementptr inbounds i8, i8* %35, i64 1
br i1 %39, label %11, label %41
41: ; preds = %11, %33, %2
ret void
}