#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*/ fprintf(int /*<<< orphan*/, char *, char const);
int /*<<< orphan*/ stderr;
unsigned long strtoul(char const *, char **, int);
int parse_unicode_notation(const char *s, const char opt) {
  char *endp;
  unsigned long res;
  if (((s[0] == 'U' || s[0] == 'u') && s[1] == '+') ||
      (s[0] == '0' && s[1] == 'x'))
    s += 2;
  if (*s == 0)
    goto parse_error;
  res = strtoul(s, &endp, 16);
  if (*endp != 0)
    goto parse_error;
  if (res > 0x10ffffu)
    goto parse_error;
  return (int)res;
parse_error:
  fprintf(stderr, "Invalid unicode value for -%c\n", opt);
  return -1;
}


x86 assembly (clang, -O0):
<parse_unicode_notation>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %sil,%al
mov    %rdi,-0x10(%rbp)
mov    %al,-0x11(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x55,%eax
je     1152 <parse_unicode_notation+0x32>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x75,%eax
jne    1163 <parse_unicode_notation+0x43>
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x2b,%eax
je     1184 <parse_unicode_notation+0x64>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x30,%eax
jne    1190 <parse_unicode_notation+0x70>
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x78,%eax
jne    1190 <parse_unicode_notation+0x70>
mov    -0x10(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    11a5 <parse_unicode_notation+0x85>
jmp    11ef <parse_unicode_notation+0xcf>
mov    -0x10(%rbp),%rdi
lea    -0x20(%rbp),%rsi
mov    $0x10,%edx
call   1040 <strtoul@plt>
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11d0 <parse_unicode_notation+0xb0>
jmp    11ef <parse_unicode_notation+0xcf>
cmpq   $0x10ffff,-0x28(%rbp)
jbe    11e3 <parse_unicode_notation+0xc3>
jmp    11ef <parse_unicode_notation+0xcf>
mov    -0x28(%rbp),%rax
mov    %eax,-0x4(%rbp)
jmp    120f <parse_unicode_notation+0xef>
mov    0x2dea(%rip),%rax
mov    (%rax),%edi
lea    0xe01(%rip),%rsi
movsbl -0x11(%rbp),%edx
call   1030 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_unicode_notation>:
push   %rbx
sub    $0x10,%rsp
mov    %esi,%ebx
mov    (%rdi),%al
cmp    $0x30,%al
je     113d <parse_unicode_notation+0x1d>
cmp    $0x75,%al
je     1135 <parse_unicode_notation+0x15>
cmp    $0x55,%al
jne    114a <parse_unicode_notation+0x2a>
cmpb   $0x2b,0x1(%rdi)
je     1143 <parse_unicode_notation+0x23>
jmp    114e <parse_unicode_notation+0x2e>
cmpb   $0x78,0x1(%rdi)
jne    114e <parse_unicode_notation+0x2e>
mov    0x2(%rdi),%al
add    $0x2,%rdi
test   %al,%al
je     116f <parse_unicode_notation+0x4f>
lea    0x8(%rsp),%rsi
mov    $0x10,%edx
call   1040 <strtoul@plt>
mov    0x8(%rsp),%rcx
cmpb   $0x0,(%rcx)
jne    116f <parse_unicode_notation+0x4f>
cmp    $0x10ffff,%rax
jbe    118c <parse_unicode_notation+0x6c>
mov    0x2e6a(%rip),%rax
mov    (%rax),%edi
movsbl %bl,%edx
lea    0xe7e(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0xffffffff,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [31 x i8] c"Invalid unicode value for -%c\0A\00"
define i32 @parse_unicode_notation(i8* %0, i8 signext %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8
%6 = alloca i8*
%7 = alloca i64
store i8* %0, i8** %4
store i8 %1, i8* %5
%8 = load i8*, i8** %4
%9 = getelementptr inbounds i8, i8* %8, i64 0
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
%12 = icmp eq i32 %11, 85
br i1 %12, label %19, label %13
13: ; preds = %2
%14 = load i8*, i8** %4
%15 = getelementptr inbounds i8, i8* %14, i64 0
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp eq i32 %17, 117
br i1 %18, label %19, label %25
19: ; preds = %13, %2
%20 = load i8*, i8** %4
%21 = getelementptr inbounds i8, i8* %20, i64 1
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = icmp eq i32 %23, 43
br i1 %24, label %37, label %25
25: ; preds = %19, %13
%26 = load i8*, i8** %4
%27 = getelementptr inbounds i8, i8* %26, i64 0
%28 = load i8, i8* %27
%29 = sext i8 %28 to i32
%30 = icmp eq i32 %29, 48
br i1 %30, label %31, label %40
31: ; preds = %25
%32 = load i8*, i8** %4
%33 = getelementptr inbounds i8, i8* %32, i64 1
%34 = load i8, i8* %33
%35 = sext i8 %34 to i32
%36 = icmp eq i32 %35, 120
br i1 %36, label %37, label %40
37: ; preds = %31, %19
%38 = load i8*, i8** %4
%39 = getelementptr inbounds i8, i8* %38, i64 2
store i8* %39, i8** %4
br label %40
40: ; preds = %37, %31, %25
%41 = load i8*, i8** %4
%42 = load i8, i8* %41
%43 = sext i8 %42 to i32
%44 = icmp eq i32 %43, 0
br i1 %44, label %45, label %46
45: ; preds = %40
br label %61
46: ; preds = %40
%47 = load i8*, i8** %4
%48 = call i64 @strtoul(i8* %47, i8** %6, i32 16)
store i64 %48, i64* %7
%49 = load i8*, i8** %6
%50 = load i8, i8* %49
%51 = sext i8 %50 to i32
%52 = icmp ne i32 %51, 0
br i1 %52, label %53, label %54
53: ; preds = %46
br label %61
54: ; preds = %46
%55 = load i64, i64* %7
%56 = icmp ugt i64 %55, 1114111
br i1 %56, label %57, label %58
57: ; preds = %54
br label %61
58: ; preds = %54
%59 = load i64, i64* %7
%60 = trunc i64 %59 to i32
store i32 %60, i32* %3
br label %65
61: ; preds = %57, %53, %45
%62 = load i32, i32* @stderr
%63 = load i8, i8* %5
%64 = call i32 @fprintf(i32 %62, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i8 signext %63)
store i32 -1, i32* %3
br label %65
65: ; preds = %61, %58
%66 = load i32, i32* %3
ret i32 %66
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [31 x i8] c"Invalid unicode value for -%c\0A\00"
define i32 @parse_unicode_notation(i8* %0, i8 signext %1) {
%3 = alloca i8*
%4 = bitcast i8** %3 to i8*
%5 = load i8, i8* %0
switch i8 %5, label %17 [
i8 85, label %6
i8 117, label %6
i8 48, label %10
]
6: ; preds = %2, %2
%7 = getelementptr inbounds i8, i8* %0, i64 1
%8 = load i8, i8* %7
%9 = icmp eq i8 %8, 43
br i1 %9, label %14, label %21
10: ; preds = %2
%11 = getelementptr inbounds i8, i8* %0, i64 1
%12 = load i8, i8* %11
%13 = icmp eq i8 %12, 120
br i1 %13, label %14, label %21
14: ; preds = %10, %6
%15 = getelementptr inbounds i8, i8* %0, i64 2
%16 = load i8, i8* %15
br label %17
17: ; preds = %14, %2
%18 = phi i8 [ %5, %2 ], [ %16, %14 ]
%19 = phi i8* [ %0, %2 ], [ %15, %14 ]
%20 = icmp eq i8 %18, 0
br i1 %20, label %31, label %21
21: ; preds = %6, %10, %17
%22 = phi i8* [ %19, %17 ], [ %0, %10 ], [ %0, %6 ]
%23 = call i64 @strtoul(i8* %22, i8** %3, i32 16)
%24 = load i8*, i8** %3
%25 = load i8, i8* %24
%26 = icmp ne i8 %25, 0
%27 = icmp ugt i64 %23, 1114111
%28 = select i1 %26, i1 true, i1 %27
br i1 %28, label %31, label %29
29: ; preds = %21
%30 = trunc i64 %23 to i32
br label %34
31: ; preds = %21, %17
%32 = load i32, i32* @stderr
%33 = tail call i32 @fprintf(i32 %32, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i8 signext %1)
br label %34
34: ; preds = %31, %29
%35 = phi i32 [ -1, %31 ], [ %30, %29 ]
ret i32 %35
}