#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 *);
int /*<<< orphan*/ stderr;
char tohex(char, char);
int hexpairtochar(const char *cp, char *myochar) {
  char ochar = 0;
  int olen = 0;
  char c = cp[0];
  if (c) {
    char c2 = cp[1];
    if (c2) {
      ochar = tohex(c, c2);
      olen = 2;
    } else {
      fprintf(stderr, "Translating from uri: "
                      "A supposed hexadecimal input character pair "
                      "runs off the end of the input after 1 hex digit.\n");
      ochar = c;
      olen = 1;
    }
  } else {
    fprintf(stderr, "Translating from uri: "
                    "A supposed hexadecimal input character pair "
                    "runs off the end of the input.\n");
    ochar = '%';
    olen = 0;
  }
  *myochar = ochar;
  return olen;
}


x86 assembly (clang, -O0):
<hexpairtochar>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movb   $0x0,-0x11(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%al
mov    %al,-0x19(%rbp)
cmpb   $0x0,-0x19(%rbp)
je     11a7 <hexpairtochar+0x87>
mov    -0x8(%rbp),%rax
mov    0x1(%rax),%al
mov    %al,-0x1a(%rbp)
cmpb   $0x0,-0x1a(%rbp)
je     1180 <hexpairtochar+0x60>
mov    -0x19(%rbp),%al
movsbl %al,%edi
movsbl -0x1a(%rbp),%esi
call   1040 <tohex@plt>
mov    %al,-0x11(%rbp)
movl   $0x2,-0x18(%rbp)
jmp    11a2 <hexpairtochar+0x82>
mov    0x2e59(%rip),%rax
mov    (%rax),%edi
lea    0xe70(%rip),%rsi
call   1030 <fprintf@plt>
mov    -0x19(%rbp),%al
mov    %al,-0x11(%rbp)
movl   $0x1,-0x18(%rbp)
jmp    11c7 <hexpairtochar+0xa7>
mov    0x2e32(%rip),%rax
mov    (%rax),%edi
lea    0xebd(%rip),%rsi
call   1030 <fprintf@plt>
movb   $0x25,-0x11(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x11(%rbp),%cl
mov    -0x10(%rbp),%rax
mov    %cl,(%rax)
mov    -0x18(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hexpairtochar>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    (%rdi),%bl
test   %bl,%bl
je     1148 <hexpairtochar+0x28>
mov    0x1(%rdi),%al
test   %al,%al
je     1163 <hexpairtochar+0x43>
movsbl %bl,%edi
movsbl %al,%esi
call   1040 <tohex@plt>
mov    %eax,%ebx
mov    $0x2,%eax
jmp    117d <hexpairtochar+0x5d>
mov    0x2e91(%rip),%rax
mov    (%rax),%edi
lea    0xf1c(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0x25,%bl
xor    %eax,%eax
jmp    117d <hexpairtochar+0x5d>
mov    0x2e76(%rip),%rax
mov    (%rax),%edi
lea    0xe8d(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0x1,%eax
mov    %bl,(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [116 x i8] c"Translating from uri: A supposed hexadecimal input character pair runs off the end of the input after 1 hex digit.\0A\00"
@.str.1 = [98 x i8] c"Translating from uri: A supposed hexadecimal input character pair runs off the end of the input.\0A\00"
define i32 @hexpairtochar(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8
%6 = alloca i32
%7 = alloca i8
%8 = alloca i8
store i8* %0, i8** %3
store i8* %1, i8** %4
store i8 0, i8* %5
store i32 0, i32* %6
%9 = load i8*, i8** %3
%10 = getelementptr inbounds i8, i8* %9, i64 0
%11 = load i8, i8* %10
store i8 %11, i8* %7
%12 = load i8, i8* %7
%13 = icmp ne i8 %12, 0
br i1 %13, label %14, label %29
14: ; preds = %2
%15 = load i8*, i8** %3
%16 = getelementptr inbounds i8, i8* %15, i64 1
%17 = load i8, i8* %16
store i8 %17, i8* %8
%18 = load i8, i8* %8
%19 = icmp ne i8 %18, 0
br i1 %19, label %20, label %24
20: ; preds = %14
%21 = load i8, i8* %7
%22 = load i8, i8* %8
%23 = call signext i8 @tohex(i8 signext %21, i8 signext %22)
store i8 %23, i8* %5
store i32 2, i32* %6
br label %28
24: ; preds = %14
%25 = load i32, i32* @stderr
%26 = call i32 @fprintf(i32 %25, i8* getelementptr inbounds ([116 x i8], [116 x i8]* @.str, i64 0, i64 0))
%27 = load i8, i8* %7
store i8 %27, i8* %5
store i32 1, i32* %6
br label %28
28: ; preds = %24, %20
br label %32
29: ; preds = %2
%30 = load i32, i32* @stderr
%31 = call i32 @fprintf(i32 %30, i8* getelementptr inbounds ([98 x i8], [98 x i8]* @.str.1, i64 0, i64 0))
store i8 37, i8* %5
store i32 0, i32* %6
br label %32
32: ; preds = %29, %28
%33 = load i8, i8* %5
%34 = load i8*, i8** %4
store i8 %33, i8* %34
%35 = load i32, i32* %6
ret i32 %35
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [116 x i8] c"Translating from uri: A supposed hexadecimal input character pair runs off the end of the input after 1 hex digit.\0A\00"
@.str.1 = [98 x i8] c"Translating from uri: A supposed hexadecimal input character pair runs off the end of the input.\0A\00"
define i32 @hexpairtochar(i8* nocapture %0, i8* nocapture writeonly %1) {
%3 = load i8, i8* %0
%4 = icmp eq i8 %3, 0
br i1 %4, label %14, label %5
5: ; preds = %2
%6 = getelementptr inbounds i8, i8* %0, i64 1
%7 = load i8, i8* %6
%8 = icmp eq i8 %7, 0
br i1 %8, label %11, label %9
9: ; preds = %5
%10 = tail call signext i8 @tohex(i8 signext %3, i8 signext %7)
br label %17
11: ; preds = %5
%12 = load i32, i32* @stderr
%13 = tail call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([116 x i8], [116 x i8]* @.str, i64 0, i64 0))
br label %17
14: ; preds = %2
%15 = load i32, i32* @stderr
%16 = tail call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([98 x i8], [98 x i8]* @.str.1, i64 0, i64 0))
br label %17
17: ; preds = %9, %11, %14
%18 = phi i32 [ 0, %14 ], [ 2, %9 ], [ 1, %11 ]
%19 = phi i8 [ 37, %14 ], [ %10, %9 ], [ %3, %11 ]
store i8 %19, i8* %1
ret i32 %18
}