#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 atoi(char *);
char *strchr(char *, char);
int strcspn(char *, char *);
scalar_t__ strlen(char *);
char *get_range(char *string, int *low_index, int *high_index) {
  int is_range;
  int num_chars;
  char *p;
  num_chars = strcspn(string, " \t");
  string[num_chars] = '\0';
  p = strchr(string, '-');
  if (p) {
    *p = '\0';
    is_range = 1;
  } else {
    is_range = 0;
  }
  *low_index = atoi(string) - 1;
  string += strlen(string) + 1;
  if (is_range) {
    *high_index = atoi(string) - 1;
    string += strlen(string) + 1;
  } else {
    *high_index = *low_index;
  }
  return string;
}


x86 assembly (clang, -O0):
<get_range>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xea1(%rip),%rsi
call   1050 <strcspn@plt>
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x20(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x8(%rbp),%rdi
mov    $0x2d,%esi
call   1040 <strchr@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     11a3 <get_range+0x63>
mov    -0x28(%rbp),%rax
movb   $0x0,(%rax)
movl   $0x1,-0x1c(%rbp)
jmp    11aa <get_range+0x6a>
movl   $0x0,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <atoi@plt>
mov    %eax,%ecx
sub    $0x1,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
add    $0x1,%rax
add    -0x8(%rbp),%rax
mov    %rax,-0x8(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     120b <get_range+0xcb>
mov    -0x8(%rbp),%rdi
call   1060 <atoi@plt>
mov    %eax,%ecx
sub    $0x1,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
add    $0x1,%rax
add    -0x8(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1217 <get_range+0xd7>
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_range>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
lea    0xea8(%rip),%rsi
call   1050 <strcspn@plt>
cltq
movb   $0x0,(%rbx,%rax,1)
mov    %rbx,%rdi
mov    $0x2d,%esi
call   1040 <strchr@plt>
mov    %rax,%r12
test   %rax,%rax
je     117d <get_range+0x3d>
movb   $0x0,(%r12)
mov    %rbx,%rdi
call   1060 <atoi@plt>
mov    %eax,%ebp
add    $0xffffffff,%ebp
mov    %ebp,(%r15)
mov    %rbx,%rdi
call   1030 <strlen@plt>
add    %rax,%rbx
add    $0x1,%rbx
test   %r12,%r12
je     11c0 <get_range+0x80>
mov    %rbx,%rdi
call   1060 <atoi@plt>
add    $0xffffffff,%eax
mov    %eax,(%r14)
mov    %rbx,%rdi
call   1030 <strlen@plt>
add    %rax,%rbx
add    $0x1,%rbx
jmp    11c3 <get_range+0x83>
mov    %ebp,(%r14)
mov    %rbx,%rax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c" \09\00"
define i8* @get_range(i8* %0, i32* nocapture writeonly %1, i32* nocapture writeonly %2) {
%4 = tail call i32 @strcspn(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%5 = sext i32 %4 to i64
%6 = getelementptr inbounds i8, i8* %0, i64 %5
store i8 0, i8* %6
%7 = tail call i8* @strchr(i8* dereferenceable(1) %0, i8 signext 45)
%8 = icmp eq i8* %7, null
br i1 %8, label %10, label %9
9: ; preds = %3
store i8 0, i8* %7
br label %10
10: ; preds = %3, %9
%11 = tail call i32 @atoi(i8* %0)
%12 = add nsw i32 %11, -1
store i32 %12, i32* %1
%13 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%14 = add nsw i64 %13, 1
%15 = getelementptr inbounds i8, i8* %0, i64 %14
br i1 %8, label %22, label %16
16: ; preds = %10
%17 = tail call i32 @atoi(i8* %15)
%18 = add nsw i32 %17, -1
store i32 %18, i32* %2
%19 = tail call i64 @strlen(i8* dereferenceable(1) %15)
%20 = add nsw i64 %19, 1
%21 = getelementptr inbounds i8, i8* %15, i64 %20
br label %23
22: ; preds = %10
store i32 %12, i32* %2
br label %23
23: ; preds = %22, %16
%24 = phi i8* [ %21, %16 ], [ %15, %22 ]
ret i8* %24
}