#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 */
struct gff3Ann {
  int dummy;
};

/* Variables and functions */
scalar_t__ isxdigit(char);
int /*<<< orphan*/ raiseInvalidEscape(struct gff3Ann *, char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
long strtol(char *, char **, int);
char convertEscape(struct gff3Ann *g3a, char *esc, char *src) {
  if (!(isxdigit(esc[1]) && isxdigit(esc[1])))
    raiseInvalidEscape(g3a, src);
  char num[3], *end;
  strncpy(num, esc + 1, 2);
  num[2] = '\0';
  long val = strtol(num, &end, 16);
  if ((end == num) || (*end != '\0'))
    raiseInvalidEscape(g3a, src);
  return (char)val;
}


x86 assembly (clang, -O0):
<convertEscape>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%edi
call   1060 <isxdigit@plt>
cmp    $0x0,%rax
je     1182 <convertEscape+0x42>
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%edi
call   1060 <isxdigit@plt>
cmp    $0x0,%rax
jne    118f <convertEscape+0x4f>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <raiseInvalidEscape@plt>
lea    -0x1b(%rbp),%rdi
mov    -0x10(%rbp),%rsi
add    $0x1,%rsi
mov    $0x2,%edx
call   1030 <strncpy@plt>
movb   $0x0,-0x19(%rbp)
lea    -0x1b(%rbp),%rdi
lea    -0x28(%rbp),%rsi
mov    $0x10,%edx
call   1040 <strtol@plt>
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rax
lea    -0x1b(%rbp),%rcx
cmp    %rcx,%rax
je     11e0 <convertEscape+0xa0>
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11ed <convertEscape+0xad>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <raiseInvalidEscape@plt>
mov    -0x30(%rbp),%rax
movsbl %al,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<convertEscape>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %rdi,%r15
movsbl 0x1(%rsi),%edi
add    $0x1,%rbx
call   1060 <isxdigit@plt>
test   %rax,%rax
je     1173 <convertEscape+0x33>
movsbl (%rbx),%edi
call   1060 <isxdigit@plt>
test   %rax,%rax
jne    117e <convertEscape+0x3e>
mov    %r15,%rdi
mov    %r14,%rsi
call   1050 <raiseInvalidEscape@plt>
lea    0xd(%rsp),%r12
mov    %r12,%rdi
mov    %rbx,%rsi
mov    $0x2,%edx
call   1030 <strncpy@plt>
movb   $0x0,0xf(%rsp)
lea    0x10(%rsp),%rsi
mov    %r12,%rdi
mov    $0x10,%edx
call   1040 <strtol@plt>
mov    %rax,%rbx
mov    0x10(%rsp),%rax
cmp    %r12,%rax
je     11bc <convertEscape+0x7c>
cmpb   $0x0,(%rax)
je     11c7 <convertEscape+0x87>
mov    %r15,%rdi
mov    %r14,%rsi
call   1050 <raiseInvalidEscape@plt>
mov    %ebx,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
%struct.gff3Ann = type { i32 }
define signext i8 @convertEscape(%struct.gff3Ann* %0, i8* %1, i8* %2) {
%4 = alloca [3 x i8]
%5 = alloca i8*
%6 = getelementptr inbounds i8, i8* %1, i64 1
%7 = load i8, i8* %6
%8 = tail call i64 @isxdigit(i8 signext %7)
%9 = icmp eq i64 %8, 0
br i1 %9, label %14, label %10
10: ; preds = %3
%11 = load i8, i8* %6
%12 = tail call i64 @isxdigit(i8 signext %11)
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %10, %3
%15 = tail call i32 @raiseInvalidEscape(%struct.gff3Ann* %0, i8* %2)
br label %16
16: ; preds = %14, %10
%17 = getelementptr inbounds [3 x i8], [3 x i8]* %4, i64 0, i64 0
%18 = bitcast i8** %5 to i8*
%19 = call i32 @strncpy(i8* %17, i8* %6, i32 2)
%20 = getelementptr inbounds [3 x i8], [3 x i8]* %4, i64 0, i64 2
store i8 0, i8* %20
%21 = call i64 @strtol(i8* %17, i8** %5, i32 16)
%22 = load i8*, i8** %5
%23 = icmp eq i8* %22, %17
br i1 %23, label %27, label %24
24: ; preds = %16
%25 = load i8, i8* %22
%26 = icmp eq i8 %25, 0
br i1 %26, label %29, label %27
27: ; preds = %24, %16
%28 = call i32 @raiseInvalidEscape(%struct.gff3Ann* %0, i8* %2)
br label %29
29: ; preds = %27, %24
%30 = trunc i64 %21 to i8
ret i8 %30
}