#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 */
char *readnumber(char *, int *, int);
char *readselector(char *arg, int selector[]) {
  if (*arg == '*')
    return ++arg;
  if (*arg == '-')
    arg++;
  else {
    arg = readnumber(arg, &selector[0], 10);
    if (*arg == '-')
      arg++;
    else {
      selector[1] = selector[0];
      return arg;
    }
  }
  return readnumber(arg, &selector[1], 10);
}


x86 assembly (clang, -O0):
<readselector>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2a,%eax
jne    1145 <readselector+0x35>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    %rax,-0x8(%rbp)
jmp    11d6 <readselector+0xc6>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    1166 <readselector+0x56>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    11bc <readselector+0xac>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    $0xa,%edx
call   1030 <readnumber@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    119d <readselector+0x8d>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    11b7 <readselector+0xa7>
mov    -0x18(%rbp),%rax
mov    (%rax),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,0x4(%rax)
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11d6 <readselector+0xc6>
jmp    11bc <readselector+0xac>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
add    $0x4,%rsi
mov    $0xa,%edx
call   1030 <readnumber@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readselector>:
push   %rbx
mov    %rsi,%rbx
mov    (%rdi),%al
cmp    $0x2d,%al
je     1139 <readselector+0x29>
cmp    $0x2a,%al
jne    1124 <readselector+0x14>
add    $0x1,%rdi
jmp    1154 <readselector+0x44>
mov    %rbx,%rsi
mov    $0xa,%edx
call   1030 <readnumber@plt>
mov    %rax,%rdi
cmpb   $0x2d,(%rax)
jne    114f <readselector+0x3f>
add    $0x1,%rdi
add    $0x4,%rbx
mov    %rbx,%rsi
mov    $0xa,%edx
pop    %rbx
jmp    1030 <readnumber@plt>
mov    (%rbx),%eax
mov    %eax,0x4(%rbx)
mov    %rdi,%rax
pop    %rbx
ret

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

LLVM IR (-O2):
define i8* @readselector(i8* %0, i32* %1) {
%3 = load i8, i8* %0
switch i8 %3, label %6 [
i8 42, label %4
i8 45, label %13
]
4: ; preds = %2
%5 = getelementptr inbounds i8, i8* %0, i64 1
br label %18
6: ; preds = %2
%7 = tail call i8* @readnumber(i8* %0, i32* %1, i32 10)
%8 = load i8, i8* %7
%9 = icmp eq i8 %8, 45
br i1 %9, label %13, label %10
10: ; preds = %6
%11 = load i32, i32* %1
%12 = getelementptr inbounds i32, i32* %1, i64 1
store i32 %11, i32* %12
br label %18
13: ; preds = %6, %2
%14 = phi i8* [ %0, %2 ], [ %7, %6 ]
%15 = getelementptr inbounds i8, i8* %14, i64 1
%16 = getelementptr inbounds i32, i32* %1, i64 1
%17 = tail call i8* @readnumber(i8* %15, i32* %16, i32 10)
br label %18
18: ; preds = %13, %10, %4
%19 = phi i8* [ %5, %4 ], [ %17, %13 ], [ %7, %10 ]
ret i8* %19
}