#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*/ strcpy(char *, char *);
scalar_t__ strsep(char **, char *);
unsigned long strtoul(char *, char **, int);
int get_sequence(char *p, unsigned long *begin, unsigned long *end,
                 unsigned long *bytes) {
  char seq_field[50];
  char *cursor = seq_field;
  char *fp;
  strcpy(seq_field, p);
  fp = (char *)strsep(&cursor, ":");
  if ((cursor == (char *)NULL) || (fp == (char *)NULL))
    return (-1);
  else
    *begin = strtoul(fp, (char **)NULL, 10);
  fp = (char *)strsep(&cursor, "(");
  if ((cursor == (char *)NULL) || (fp == (char *)NULL))
    return (-1);
  else
    *end = strtoul(fp, (char **)NULL, 10);
  fp = (char *)strsep(&cursor, ")");
  if ((cursor == (char *)NULL) || (fp == (char *)NULL))
    return (-1);
  else
    *bytes = strtoul(fp, (char **)NULL, 10);
  return (0);
}


x86 assembly (clang, -O0):
<get_sequence>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
lea    -0x60(%rbp),%rax
mov    %rax,-0x68(%rbp)
lea    -0x60(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strcpy@plt>
lea    -0x68(%rbp),%rdi
lea    0xe98(%rip),%rsi
call   1040 <strsep@plt>
mov    %rax,-0x70(%rbp)
cmpq   $0x0,-0x68(%rbp)
je     1187 <get_sequence+0x57>
cmpq   $0x0,-0x70(%rbp)
jne    1193 <get_sequence+0x63>
movl   $0xffffffff,-0x4(%rbp)
jmp    125a <get_sequence+0x12a>
mov    -0x70(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1050 <strtoul@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
lea    -0x68(%rbp),%rdi
lea    0xe48(%rip),%rsi
call   1040 <strsep@plt>
mov    %rax,-0x70(%rbp)
cmpq   $0x0,-0x68(%rbp)
je     11d9 <get_sequence+0xa9>
cmpq   $0x0,-0x70(%rbp)
jne    11e5 <get_sequence+0xb5>
movl   $0xffffffff,-0x4(%rbp)
jmp    125a <get_sequence+0x12a>
mov    -0x70(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1050 <strtoul@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
lea    -0x68(%rbp),%rdi
lea    0xdf8(%rip),%rsi
call   1040 <strsep@plt>
mov    %rax,-0x70(%rbp)
cmpq   $0x0,-0x68(%rbp)
je     122b <get_sequence+0xfb>
cmpq   $0x0,-0x70(%rbp)
jne    1237 <get_sequence+0x107>
movl   $0xffffffff,-0x4(%rbp)
jmp    125a <get_sequence+0x12a>
mov    -0x70(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1050 <strtoul@plt>
mov    %rax,%rcx
mov    -0x28(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_sequence>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rsi,%rbx
mov    %rdi,%rsi
lea    0x10(%rsp),%rdi
mov    %rdi,0x8(%rsp)
call   1030 <strcpy@plt>
lea    0xea3(%rip),%rsi
lea    0x8(%rsp),%rdi
call   1040 <strsep@plt>
cmpq   $0x0,0x8(%rsp)
mov    $0xffffffff,%r12d
je     11ef <get_sequence+0xbf>
test   %rax,%rax
je     11ef <get_sequence+0xbf>
mov    %rax,%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1050 <strtoul@plt>
mov    %rax,(%rbx)
lea    0xe6f(%rip),%rsi
lea    0x8(%rsp),%rdi
call   1040 <strsep@plt>
cmpq   $0x0,0x8(%rsp)
je     11ef <get_sequence+0xbf>
test   %rax,%rax
je     11ef <get_sequence+0xbf>
mov    %rax,%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1050 <strtoul@plt>
mov    %rax,(%r15)
lea    0xe41(%rip),%rsi
lea    0x8(%rsp),%rdi
call   1040 <strsep@plt>
cmpq   $0x0,0x8(%rsp)
je     11ef <get_sequence+0xbf>
test   %rax,%rax
je     11ef <get_sequence+0xbf>
xor    %r12d,%r12d
mov    %rax,%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1050 <strtoul@plt>
mov    %rax,(%r14)
mov    %r12d,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [2 x i8] c":\00"
@.str.1 = [2 x i8] c"(\00"
@.str.2 = [2 x i8] c")\00"
define i32 @get_sequence(i8* %0, i64* %1, i64* %2, i64* %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i64*
%8 = alloca i64*
%9 = alloca i64*
%10 = alloca [50 x i8]
%11 = alloca i8*
%12 = alloca i8*
store i8* %0, i8** %6
store i64* %1, i64** %7
store i64* %2, i64** %8
store i64* %3, i64** %9
%13 = getelementptr inbounds [50 x i8], [50 x i8]* %10, i64 0, i64 0
store i8* %13, i8** %11
%14 = getelementptr inbounds [50 x i8], [50 x i8]* %10, i64 0, i64 0
%15 = load i8*, i8** %6
%16 = call i32 @strcpy(i8* %14, i8* %15)
%17 = call i64 @strsep(i8** %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%18 = inttoptr i64 %17 to i8*
store i8* %18, i8** %12
%19 = load i8*, i8** %11
%20 = icmp eq i8* %19, null
br i1 %20, label %24, label %21
21: ; preds = %4
%22 = load i8*, i8** %12
%23 = icmp eq i8* %22, null
br i1 %23, label %24, label %25
24: ; preds = %21, %4
store i32 -1, i32* %5
br label %56
25: ; preds = %21
%26 = load i8*, i8** %12
%27 = call i64 @strtoul(i8* %26, i8** null, i32 10)
%28 = load i64*, i64** %7
store i64 %27, i64* %28
br label %29
29: ; preds = %25
%30 = call i64 @strsep(i8** %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%31 = inttoptr i64 %30 to i8*
store i8* %31, i8** %12
%32 = load i8*, i8** %11
%33 = icmp eq i8* %32, null
br i1 %33, label %37, label %34
34: ; preds = %29
%35 = load i8*, i8** %12
%36 = icmp eq i8* %35, null
br i1 %36, label %37, label %38
37: ; preds = %34, %29
store i32 -1, i32* %5
br label %56
38: ; preds = %34
%39 = load i8*, i8** %12
%40 = call i64 @strtoul(i8* %39, i8** null, i32 10)
%41 = load i64*, i64** %8
store i64 %40, i64* %41
br label %42
42: ; preds = %38
%43 = call i64 @strsep(i8** %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%44 = inttoptr i64 %43 to i8*
store i8* %44, i8** %12
%45 = load i8*, i8** %11
%46 = icmp eq i8* %45, null
br i1 %46, label %50, label %47
47: ; preds = %42
%48 = load i8*, i8** %12
%49 = icmp eq i8* %48, null
br i1 %49, label %50, label %51
50: ; preds = %47, %42
store i32 -1, i32* %5
br label %56
51: ; preds = %47
%52 = load i8*, i8** %12
%53 = call i64 @strtoul(i8* %52, i8** null, i32 10)
%54 = load i64*, i64** %9
store i64 %53, i64* %54
br label %55
55: ; preds = %51
store i32 0, i32* %5
br label %56
56: ; preds = %55, %50, %37, %24
%57 = load i32, i32* %5
ret i32 %57
}

LLVM IR (-O2):
@.str = [2 x i8] c":\00"
@.str.1 = [2 x i8] c"(\00"
@.str.2 = [2 x i8] c")\00"
define i32 @get_sequence(i8* %0, i64* nocapture writeonly %1, i64* nocapture writeonly %2, i64* nocapture writeonly %3) {
%5 = alloca [50 x i8]
%6 = alloca i8*
%7 = getelementptr inbounds [50 x i8], [50 x i8]* %5, i64 0, i64 0
%8 = bitcast i8** %6 to i8*
store i8* %7, i8** %6
%9 = call i32 @strcpy(i8* %7, i8* %0)
%10 = call i64 @strsep(i8** %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%11 = load i8*, i8** %6
%12 = icmp eq i8* %11, null
%13 = icmp eq i64 %10, 0
%14 = select i1 %12, i1 true, i1 %13
br i1 %14, label %34, label %15
15: ; preds = %4
%16 = inttoptr i64 %10 to i8*
%17 = call i64 @strtoul(i8* nocapture %16, i8** null, i32 10)
store i64 %17, i64* %1
%18 = call i64 @strsep(i8** %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%19 = load i8*, i8** %6
%20 = icmp eq i8* %19, null
%21 = icmp eq i64 %18, 0
%22 = select i1 %20, i1 true, i1 %21
br i1 %22, label %34, label %23
23: ; preds = %15
%24 = inttoptr i64 %18 to i8*
%25 = call i64 @strtoul(i8* nocapture %24, i8** null, i32 10)
store i64 %25, i64* %2
%26 = call i64 @strsep(i8** %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%27 = load i8*, i8** %6
%28 = icmp eq i8* %27, null
%29 = icmp eq i64 %26, 0
%30 = select i1 %28, i1 true, i1 %29
br i1 %30, label %34, label %31
31: ; preds = %23
%32 = inttoptr i64 %26 to i8*
%33 = call i64 @strtoul(i8* nocapture %32, i8** null, i32 10)
store i64 %33, i64* %3
br label %34
34: ; preds = %23, %15, %4, %31
%35 = phi i32 [ 0, %31 ], [ -1, %4 ], [ -1, %15 ], [ -1, %23 ]
ret i32 %35
}