#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 */
typedef int intmax_t;
typedef int int8_t;

/* Variables and functions */
int sscanf(char *, char *, int *, int *);
int getNum(char *str, uintptr_t *val, int8_t *opt) {
  int f, n;
  intmax_t v;
  *opt = 0;
  f = sscanf(str, " %ji %n", &v, &n);
  if (f == 1) {
    *val = v;
    *opt = 1;
    return n;
  }
  f = sscanf(str, " v%ji %n", &v, &n);
  if (f == 1) {
    *val = v;
    if (v < 150)
      *opt = 2;
    else
      *opt = -2;
    return n;
  }
  f = sscanf(str, " p%ji %n", &v, &n);
  if (f == 1) {
    *val = v;
    if (v < 10)
      *opt = 3;
    else
      *opt = -3;
    return n;
  }
  return 0;
}


x86 assembly (clang, -O0):
<getNum>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x10(%rbp),%rdi
lea    0xec7(%rip),%rsi
lea    -0x2c(%rbp),%rdx
lea    -0x28(%rbp),%rcx
call   1030 <sscanf@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x1,-0x24(%rbp)
jne    1173 <getNum+0x63>
movslq -0x2c(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x20(%rbp),%rax
movl   $0x1,(%rax)
mov    -0x28(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1239 <getNum+0x129>
mov    -0x10(%rbp),%rdi
lea    0xe8a(%rip),%rsi
lea    -0x2c(%rbp),%rdx
lea    -0x28(%rbp),%rcx
call   1030 <sscanf@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x1,-0x24(%rbp)
jne    11d4 <getNum+0xc4>
movslq -0x2c(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
cmpl   $0x96,-0x2c(%rbp)
jge    11bf <getNum+0xaf>
mov    -0x20(%rbp),%rax
movl   $0x2,(%rax)
jmp    11c9 <getNum+0xb9>
mov    -0x20(%rbp),%rax
movl   $0xfffffffe,(%rax)
mov    -0x28(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1239 <getNum+0x129>
mov    -0x10(%rbp),%rdi
lea    0xe32(%rip),%rsi
lea    -0x2c(%rbp),%rdx
lea    -0x28(%rbp),%rcx
call   1030 <sscanf@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x1,-0x24(%rbp)
jne    1232 <getNum+0x122>
movslq -0x2c(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
cmpl   $0xa,-0x2c(%rbp)
jge    121d <getNum+0x10d>
mov    -0x20(%rbp),%rax
movl   $0x3,(%rax)
jmp    1227 <getNum+0x117>
mov    -0x20(%rbp),%rax
movl   $0xfffffffd,(%rax)
mov    -0x28(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1239 <getNum+0x129>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getNum>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%r15
mov    %rsi,%r14
mov    %rdi,%rbx
movl   $0x0,(%rdx)
lea    0xed1(%rip),%rsi
lea    0x8(%rsp),%rdx
lea    0xc(%rsp),%rcx
call   1030 <sscanf@plt>
cmp    $0x1,%eax
jne    1154 <getNum+0x44>
movslq 0x8(%rsp),%rax
mov    %rax,(%r14)
movl   $0x1,(%r15)
jmp    11cf <getNum+0xbf>
lea    0xead(%rip),%rsi
lea    0x8(%rsp),%rdx
lea    0xc(%rsp),%rcx
mov    %rbx,%rdi
call   1030 <sscanf@plt>
cmp    $0x1,%eax
jne    1191 <getNum+0x81>
movslq 0x8(%rsp),%rax
xor    %ecx,%ecx
cmp    $0x96,%rax
setl   %cl
mov    %rax,(%r14)
lea    -0x2(,%rcx,4),%eax
mov    %eax,(%r15)
jmp    11cf <getNum+0xbf>
lea    0xe79(%rip),%rsi
lea    0x8(%rsp),%rdx
lea    0xc(%rsp),%rcx
mov    %rbx,%rdi
call   1030 <sscanf@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x1,%ecx
jne    11d3 <getNum+0xc3>
movslq 0x8(%rsp),%rax
cmp    $0xa,%rax
mov    %rax,(%r14)
mov    $0x3,%eax
mov    $0xfffffffd,%ecx
cmovl  %eax,%ecx
mov    %ecx,(%r15)
mov    0xc(%rsp),%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

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