#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 */
scalar_t__ isdigit(unsigned char);
int /*<<< orphan*/ isxdigit(unsigned char);
int ord2utf8(int, unsigned char *);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ strcmp(char *, char *);
scalar_t__ strncmp(unsigned char *, char *, int);
int strtol(unsigned char *, int /*<<< orphan*/ *, int);
int tolower(unsigned char);
int utf82ord(unsigned char *, int *);
int main(int argc, char **argv) {
  int i = 1;
  int show = 0;
  unsigned char buffer[64];
  if (argc > 1 && strcmp(argv[1], "-s") == 0) {
    show = 1;
    i = 2;
  }
  for (; i < argc; i++) {
    unsigned char *x = argv[i];
    if (strncmp(x, "0x", 2) == 0) {
      int j;
      int d = strtol(x + 2, NULL, 16);
      int rc = ord2utf8(d, buffer);
      printf("0x%08x => ", d);
      if (rc <= 0)
        printf("*** Error %d ***", rc);
      else {
        for (j = 0; j < rc; j++)
          printf("%02x ", buffer[j]);
        if (show) {
          printf(">");
          for (j = 0; j < rc; j++)
            printf("%c", buffer[j]);
          printf("<");
        }
      }
      printf("\n");
    } else {
      int d, rc;
      int j = 0;
      int y = 0;
      int z = 0;
      unsigned char *bptr;
      for (;;) {
        while (*x == ' ')
          x++;
        if (*x == 0 && !z)
          break;
        if (!isxdigit(*x)) {
          printf("Malformed hex string: %s\n", argv[i]);
          j = -1;
          break;
        }
        y = y * 16 + tolower(*x) - ((isdigit(*x)) ? '0' : 'W');
        x++;
        if (z) {
          buffer[j++] = y;
          y = 0;
        }
        z ^= 1;
      }
      buffer[j] = 0;
      bptr = buffer;
      while (*bptr != 0) {
        rc = utf82ord(bptr, &d);
        if (rc > 0) {
          printf("0x%08x <= ", d);
          for (j = 0; j < rc; j++)
            printf("%02x ", bptr[j]);
          if (show) {
            printf(">");
            for (j = 0; j < rc; j++)
              printf("%c", bptr[j]);
            printf("<");
          }
          printf("\n");
          bptr += rc;
        } else {
          printf("Malformed UTF-8 at offset %d <= ", -rc);
          while (*bptr != 0)
            printf("%02x ", *bptr++);
          printf("\n");
          break;
        }
      }
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    11ed <main+0x5d>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe30(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    11ed <main+0x5d>
movl   $0x1,-0x18(%rbp)
movl   $0x2,-0x14(%rbp)
jmp    11f2 <main+0x62>
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    161d <main+0x48d>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x68(%rbp)
mov    -0x68(%rbp),%rdi
lea    0xdea(%rip),%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    1334 <main+0x1a4>
mov    -0x68(%rbp),%rdi
add    $0x2,%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0x10,%edx
call   1090 <strtol@plt>
mov    %eax,-0x70(%rbp)
mov    -0x70(%rbp),%edi
lea    -0x60(%rbp),%rsi
call   1070 <ord2utf8@plt>
mov    %eax,-0x74(%rbp)
mov    -0x70(%rbp),%esi
lea    0xda7(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
cmpl   $0x0,-0x74(%rbp)
jg     1286 <main+0xf6>
mov    -0x74(%rbp),%esi
lea    0xd97(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1321 <main+0x191>
movl   $0x0,-0x6c(%rbp)
mov    -0x6c(%rbp),%eax
cmp    -0x74(%rbp),%eax
jge    12be <main+0x12e>
movslq -0x6c(%rbp),%rax
movzbl -0x60(%rbp,%rax,1),%esi
lea    0xd79(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x6c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x6c(%rbp)
jmp    128d <main+0xfd>
cmpl   $0x0,-0x18(%rbp)
je     131c <main+0x18c>
lea    0xd59(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x0,-0x6c(%rbp)
mov    -0x6c(%rbp),%eax
cmp    -0x74(%rbp),%eax
jge    130e <main+0x17e>
movslq -0x6c(%rbp),%rax
movzbl -0x60(%rbp,%rax,1),%esi
lea    0xd31(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x6c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x6c(%rbp)
jmp    12dd <main+0x14d>
lea    0xd18(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1321 <main+0x191>
lea    0xd1f(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    160a <main+0x47a>
movl   $0x0,-0x80(%rbp)
movl   $0x0,-0x84(%rbp)
movl   $0x0,-0x88(%rbp)
jmp    1354 <main+0x1c4>
mov    -0x68(%rbp),%rax
movzbl (%rax),%eax
cmp    $0x20,%eax
jne    1375 <main+0x1e5>
mov    -0x68(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x68(%rbp)
jmp    1354 <main+0x1c4>
mov    -0x68(%rbp),%rax
movzbl (%rax),%eax
cmp    $0x0,%eax
jne    1397 <main+0x207>
cmpl   $0x0,-0x88(%rbp)
jne    1397 <main+0x207>
jmp    147b <main+0x2eb>
mov    -0x68(%rbp),%rax
movzbl (%rax),%edi
call   10b0 <isxdigit@plt>
cmp    $0x0,%eax
jne    13d2 <main+0x242>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xc70(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0xffffffff,-0x80(%rbp)
jmp    147b <main+0x2eb>
mov    -0x84(%rbp),%eax
shl    $0x4,%eax
mov    %eax,-0x98(%rbp)
mov    -0x68(%rbp),%rax
movzbl (%rax),%edi
call   10a0 <tolower@plt>
mov    %eax,%ecx
mov    -0x98(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x94(%rbp)
mov    -0x68(%rbp),%rax
movzbl (%rax),%edi
call   1040 <isdigit@plt>
mov    %rax,%rsi
mov    -0x94(%rbp),%eax
mov    $0x57,%ecx
mov    $0x30,%edx
cmp    $0x0,%rsi
cmovne %edx,%ecx
sub    %ecx,%eax
mov    %eax,-0x84(%rbp)
mov    -0x68(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x68(%rbp)
cmpl   $0x0,-0x88(%rbp)
je     1467 <main+0x2d7>
mov    -0x84(%rbp),%eax
mov    %al,%cl
mov    -0x80(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x80(%rbp)
cltq
mov    %cl,-0x60(%rbp,%rax,1)
movl   $0x0,-0x84(%rbp)
mov    -0x88(%rbp),%eax
xor    $0x1,%eax
mov    %eax,-0x88(%rbp)
jmp    134f <main+0x1bf>
movslq -0x80(%rbp),%rax
movb   $0x0,-0x60(%rbp,%rax,1)
lea    -0x60(%rbp),%rax
mov    %rax,-0x90(%rbp)
mov    -0x90(%rbp),%rax
movzbl (%rax),%eax
cmp    $0x0,%eax
je     1605 <main+0x475>
mov    -0x90(%rbp),%rdi
lea    -0x78(%rbp),%rsi
call   1050 <utf82ord@plt>
mov    %eax,-0x7c(%rbp)
cmpl   $0x0,-0x7c(%rbp)
jle    159c <main+0x40c>
mov    -0x78(%rbp),%esi
lea    0xb80(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x0,-0x80(%rbp)
mov    -0x80(%rbp),%eax
cmp    -0x7c(%rbp),%eax
jge    150e <main+0x37e>
mov    -0x90(%rbp),%rax
movslq -0x80(%rbp),%rcx
movzbl (%rax,%rcx,1),%esi
lea    0xb29(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x80(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x80(%rbp)
jmp    14d7 <main+0x347>
cmpl   $0x0,-0x18(%rbp)
je     1572 <main+0x3e2>
lea    0xb09(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x0,-0x80(%rbp)
mov    -0x80(%rbp),%eax
cmp    -0x7c(%rbp),%eax
jge    1564 <main+0x3d4>
mov    -0x90(%rbp),%rax
movslq -0x80(%rbp),%rcx
movzbl (%rax,%rcx,1),%esi
lea    0xadb(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x80(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x80(%rbp)
jmp    152d <main+0x39d>
lea    0xac2(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xace(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x7c(%rbp),%ecx
mov    -0x90(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x90(%rbp)
jmp    1600 <main+0x470>
xor    %esi,%esi
sub    -0x7c(%rbp),%esi
lea    0xaac(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x90(%rbp),%rax
movzbl (%rax),%eax
cmp    $0x0,%eax
je     15ed <main+0x45d>
mov    -0x90(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x90(%rbp)
movzbl (%rax),%esi
lea    0xa41(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    15af <main+0x41f>
lea    0xa53(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1605 <main+0x475>
jmp    148f <main+0x2ff>
jmp    160a <main+0x47a>
jmp    160f <main+0x47f>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11f2 <main+0x62>
xor    %eax,%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
mov    %rsi,%r13
mov    %edi,%ebx
cmp    $0x2,%edi
jl     11e1 <main+0x41>
mov    0x8(%r13),%rdi
lea    0xe3d(%rip),%rsi
call   1090 <strcmp@plt>
xor    %ecx,%ecx
test   %rax,%rax
setne  0x3(%rsp)
sete   %cl
add    $0x1,%ecx
cmp    %ebx,%ecx
jl     11f3 <main+0x53>
jmp    14ee <main+0x34e>
mov    $0x1,%ecx
movb   $0x1,0x3(%rsp)
cmp    %ebx,%ecx
jge    14ee <main+0x34e>
mov    %ecx,%r12d
mov    %ebx,%eax
mov    %rax,0x18(%rsp)
lea    0xe1e(%rip),%r14
mov    %r13,0x8(%rsp)
jmp    1229 <main+0x89>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0x10(%rsp),%r12
add    $0x1,%r12
cmp    0x18(%rsp),%r12
je     14ee <main+0x34e>
mov    0x0(%r13,%r12,8),%rbx
mov    %rbx,%rdi
lea    0xdcb(%rip),%rsi
mov    $0x2,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
je     12d0 <main+0x130>
mov    %r12,0x10(%rsp)
xor    %r15d,%r15d
xor    %r13d,%r13d
xor    %r12d,%r12d
jmp    1260 <main+0xc0>
xor    $0x1,%r12d
nop
movzbl (%rbx),%eax
add    $0x1,%rbx
cmp    $0x20,%al
je     1260 <main+0xc0>
test   %al,%al
jne    1278 <main+0xd8>
test   %r12d,%r12d
je     1390 <main+0x1f0>
movzbl %al,%edi
call   10c0 <isxdigit@plt>
test   %eax,%eax
je     13a0 <main+0x200>
shl    $0x4,%r13d
movzbl -0x1(%rbx),%edi
call   10b0 <tolower@plt>
mov    %eax,%ebp
movzbl -0x1(%rbx),%edi
call   1050 <isdigit@plt>
test   %rax,%rax
lea    -0x57(%rbp,%r13,1),%eax
lea    -0x30(%rbp,%r13,1),%r13d
cmove  %eax,%r13d
test   %r12d,%r12d
je     125b <main+0xbb>
movslq %r15d,%rax
add    $0x1,%r15d
mov    %r13b,0x20(%rsp,%rax,1)
xor    %r13d,%r13d
jmp    125b <main+0xbb>
nopw   0x0(%rax,%rax,1)
add    $0x2,%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   10a0 <strtol@plt>
mov    %eax,%ebx
mov    %eax,%edi
lea    0x20(%rsp),%rsi
call   1080 <ord2utf8@plt>
mov    %eax,%r15d
lea    0xd0b(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1070 <printf@plt>
test   %r15d,%r15d
jle    14ce <main+0x32e>
mov    %r15d,%ebx
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movzbl 0x20(%rsp,%rbp,1),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    1320 <main+0x180>
cmpb   $0x0,0x3(%rsp)
jne    14df <main+0x33f>
mov    $0x3e,%edi
call   1030 <putchar@plt>
test   %r15d,%r15d
jle    1373 <main+0x1d3>
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movzbl 0x20(%rsp,%rbp,1),%edi
call   1030 <putchar@plt>
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    1360 <main+0x1c0>
mov    $0x3c,%edi
call   1030 <putchar@plt>
jmp    14df <main+0x33f>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    0x8(%rsp),%r13
jmp    13c3 <main+0x223>
nopw   0x0(%rax,%rax,1)
mov    0x8(%rsp),%r13
mov    0x10(%rsp),%rax
mov    0x0(%r13,%rax,8),%rsi
lea    0xc72(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    $0xffffffff,%r15d
movslq %r15d,%rax
movb   $0x0,0x20(%rsp,%rax,1)
cmpb   $0x0,0x20(%rsp)
je     1215 <main+0x75>
lea    0x20(%rsp),%r15
jmp    13fc <main+0x25c>
nopl   (%rax)
mov    $0xa,%edi
call   1030 <putchar@plt>
movslq %r12d,%rax
cmpb   $0x0,(%r15,%rax,1)
lea    (%r15,%rax,1),%r15
je     1215 <main+0x75>
mov    %r15,%rdi
lea    0x4(%rsp),%rsi
call   1060 <utf82ord@plt>
mov    %eax,%r12d
test   %eax,%eax
jle    1482 <main+0x2e2>
mov    0x4(%rsp),%esi
lea    0xc27(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %r12d,%ebp
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
movzbl (%r15,%rbx,1),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1430 <main+0x290>
cmpb   $0x0,0x3(%rsp)
jne    13e0 <main+0x240>
mov    $0x3e,%edi
call   1030 <putchar@plt>
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
movzbl (%r15,%rbx,1),%edi
call   1030 <putchar@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1460 <main+0x2c0>
mov    $0x3c,%edi
call   1030 <putchar@plt>
jmp    13e0 <main+0x240>
neg    %r12d
lea    0xbc1(%rip),%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1070 <printf@plt>
mov    (%r15),%al
test   %al,%al
je     120b <main+0x6b>
add    $0x1,%r15
cs nopw 0x0(%rax,%rax,1)
nop
movzbl %al,%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
movzbl (%r15),%eax
add    $0x1,%r15
test   %al,%al
jne    14b0 <main+0x310>
jmp    120b <main+0x6b>
lea    0xb3c(%rip),%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1070 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    121a <main+0x7a>
xor    %eax,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"-s\00"
@.str.1 = [3 x i8] c"0x\00"
@.str.2 = [11 x i8] c"0x%08x => \00"
@.str.3 = [17 x i8] c"*** Error %d ***\00"
@.str.4 = [6 x i8] c"%02x \00"
@.str.5 = [2 x i8] c">\00"
@.str.6 = [3 x i8] c"%c\00"
@.str.7 = [2 x i8] c"<\00"
@.str.8 = [2 x i8] c"\0A\00"
@.str.9 = [26 x i8] c"Malformed hex string: %s\0A\00"
@.str.10 = [11 x i8] c"0x%08x <= \00"
@.str.11 = [33 x i8] c"Malformed UTF-8 at offset %d <= \00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca [64 x i8]
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1, i32* %6
store i32 0, i32* %7
%19 = load i32, i32* %4
%20 = icmp sgt i32 %19, 1
br i1 %20, label %21, label %28
21: ; preds = %2
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 1
%24 = load i8*, i8** %23
%25 = call i64 @strcmp(i8* %24, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%26 = icmp eq i64 %25, 0
br i1 %26, label %27, label %28
27: ; preds = %21
store i32 1, i32* %7
store i32 2, i32* %6
br label %28
28: ; preds = %27, %21, %2
br label %29
29: ; preds = %235, %28
%30 = load i32, i32* %6
%31 = load i32, i32* %4
%32 = icmp slt i32 %30, %31
br i1 %32, label %33, label %238
33: ; preds = %29
%34 = load i8**, i8*** %5
%35 = load i32, i32* %6
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i8*, i8** %34, i64 %36
%38 = load i8*, i8** %37
store i8* %38, i8** %9
%39 = load i8*, i8** %9
%40 = call i64 @strncmp(i8* %39, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 2)
%41 = icmp eq i64 %40, 0
br i1 %41, label %42, label %95
42: ; preds = %33
%43 = load i8*, i8** %9
%44 = getelementptr inbounds i8, i8* %43, i64 2
%45 = call i32 @strtol(i8* %44, i32* null, i32 16)
store i32 %45, i32* %11
%46 = load i32, i32* %11
%47 = getelementptr inbounds [64 x i8], [64 x i8]* %8, i64 0, i64 0
%48 = call i32 @ord2utf8(i32 %46, i8* %47)
store i32 %48, i32* %12
%49 = load i32, i32* %11
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %49)
%51 = load i32, i32* %12
%52 = icmp sle i32 %51, 0
br i1 %52, label %53, label %56
53: ; preds = %42
%54 = load i32, i32* %12
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i32 %54)
br label %93
56: ; preds = %42
store i32 0, i32* %10
br label %57
57: ; preds = %68, %56
%58 = load i32, i32* %10
%59 = load i32, i32* %12
%60 = icmp slt i32 %58, %59
br i1 %60, label %61, label %71
61: ; preds = %57
%62 = load i32, i32* %10
%63 = sext i32 %62 to i64
%64 = getelementptr inbounds [64 x i8], [64 x i8]* %8, i64 0, i64 %63
%65 = load i8, i8* %64
%66 = zext i8 %65 to i32
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32 %66)
br label %68
68: ; preds = %61
%69 = load i32, i32* %10
%70 = add nsw i32 %69, 1
store i32 %70, i32* %10
br label %57
71: ; preds = %57
%72 = load i32, i32* %7
%73 = icmp ne i32 %72, 0
br i1 %73, label %74, label %92
74: ; preds = %71
%75 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
store i32 0, i32* %10
br label %76
76: ; preds = %87, %74
%77 = load i32, i32* %10
%78 = load i32, i32* %12
%79 = icmp slt i32 %77, %78
br i1 %79, label %80, label %90
80: ; preds = %76
%81 = load i32, i32* %10
%82 = sext i32 %81 to i64
%83 = getelementptr inbounds [64 x i8], [64 x i8]* %8, i64 0, i64 %82
%84 = load i8, i8* %83
%85 = zext i8 %84 to i32
%86 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32 %85)
br label %87
87: ; preds = %80
%88 = load i32, i32* %10
%89 = add nsw i32 %88, 1
store i32 %89, i32* %10
br label %76
90: ; preds = %76
%91 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
br label %92
92: ; preds = %90, %71
br label %93
93: ; preds = %92, %53
%94 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
br label %234
95: ; preds = %33
store i32 0, i32* %15
store i32 0, i32* %16
store i32 0, i32* %17
br label %96
96: ; preds = %151, %95
br label %97
97: ; preds = %102, %96
%98 = load i8*, i8** %9
%99 = load i8, i8* %98
%100 = zext i8 %99 to i32
%101 = icmp eq i32 %100, 32
br i1 %101, label %102, label %105
102: ; preds = %97
%103 = load i8*, i8** %9
%104 = getelementptr inbounds i8, i8* %103, i32 1
store i8* %104, i8** %9
br label %97
105: ; preds = %97
%106 = load i8*, i8** %9
%107 = load i8, i8* %106
%108 = zext i8 %107 to i32
%109 = icmp eq i32 %108, 0
br i1 %109, label %110, label %114
110: ; preds = %105
%111 = load i32, i32* %17
%112 = icmp ne i32 %111, 0
br i1 %112, label %114, label %113
113: ; preds = %110
br label %154
114: ; preds = %110, %105
%115 = load i8*, i8** %9
%116 = load i8, i8* %115
%117 = call i32 @isxdigit(i8 zeroext %116)
%118 = icmp ne i32 %117, 0
br i1 %118, label %126, label %119
119: ; preds = %114
%120 = load i8**, i8*** %5
%121 = load i32, i32* %6
%122 = sext i32 %121 to i64
%123 = getelementptr inbounds i8*, i8** %120, i64 %122
%124 = load i8*, i8** %123
%125 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.9, i64 0, i64 0), i8* %124)
store i32 -1, i32* %15
br label %154
126: ; preds = %114
%127 = load i32, i32* %16
%128 = mul nsw i32 %127, 16
%129 = load i8*, i8** %9
%130 = load i8, i8* %129
%131 = call i32 @tolower(i8 zeroext %130)
%132 = add nsw i32 %128, %131
%133 = load i8*, i8** %9
%134 = load i8, i8* %133
%135 = call i64 @isdigit(i8 zeroext %134)
%136 = icmp ne i64 %135, 0
%137 = zext i1 %136 to i64
%138 = select i1 %136, i32 48, i32 87
%139 = sub nsw i32 %132, %138
store i32 %139, i32* %16
%140 = load i8*, i8** %9
%141 = getelementptr inbounds i8, i8* %140, i32 1
store i8* %141, i8** %9
%142 = load i32, i32* %17
%143 = icmp ne i32 %142, 0
br i1 %143, label %144, label %151
144: ; preds = %126
%145 = load i32, i32* %16
%146 = trunc i32 %145 to i8
%147 = load i32, i32* %15
%148 = add nsw i32 %147, 1
store i32 %148, i32* %15
%149 = sext i32 %147 to i64
%150 = getelementptr inbounds [64 x i8], [64 x i8]* %8, i64 0, i64 %149
store i8 %146, i8* %150
store i32 0, i32* %16
br label %151
151: ; preds = %144, %126
%152 = load i32, i32* %17
%153 = xor i32 %152, 1
store i32 %153, i32* %17
br label %96
154: ; preds = %119, %113
%155 = load i32, i32* %15
%156 = sext i32 %155 to i64
%157 = getelementptr inbounds [64 x i8], [64 x i8]* %8, i64 0, i64 %156
store i8 0, i8* %157
%158 = getelementptr inbounds [64 x i8], [64 x i8]* %8, i64 0, i64 0
store i8* %158, i8** %18
br label %159
159: ; preds = %232, %154
%160 = load i8*, i8** %18
%161 = load i8, i8* %160
%162 = zext i8 %161 to i32
%163 = icmp ne i32 %162, 0
br i1 %163, label %164, label %233
164: ; preds = %159
%165 = load i8*, i8** %18
%166 = call i32 @utf82ord(i8* %165, i32* %13)
store i32 %166, i32* %14
%167 = load i32, i32* %14
%168 = icmp sgt i32 %167, 0
br i1 %168, label %169, label %215
169: ; preds = %164
%170 = load i32, i32* %13
%171 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.10, i64 0, i64 0), i32 %170)
store i32 0, i32* %15
br label %172
172: ; preds = %184, %169
%173 = load i32, i32* %15
%174 = load i32, i32* %14
%175 = icmp slt i32 %173, %174
br i1 %175, label %176, label %187
176: ; preds = %172
%177 = load i8*, i8** %18
%178 = load i32, i32* %15
%179 = sext i32 %178 to i64
%180 = getelementptr inbounds i8, i8* %177, i64 %179
%181 = load i8, i8* %180
%182 = zext i8 %181 to i32
%183 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32 %182)
br label %184
184: ; preds = %176
%185 = load i32, i32* %15
%186 = add nsw i32 %185, 1
store i32 %186, i32* %15
br label %172
187: ; preds = %172
%188 = load i32, i32* %7
%189 = icmp ne i32 %188, 0
br i1 %189, label %190, label %209
190: ; preds = %187
%191 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
store i32 0, i32* %15
br label %192
192: ; preds = %204, %190
%193 = load i32, i32* %15
%194 = load i32, i32* %14
%195 = icmp slt i32 %193, %194
br i1 %195, label %196, label %207
196: ; preds = %192
%197 = load i8*, i8** %18
%198 = load i32, i32* %15
%199 = sext i32 %198 to i64
%200 = getelementptr inbounds i8, i8* %197, i64 %199
%201 = load i8, i8* %200
%202 = zext i8 %201 to i32
%203 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32 %202)
br label %204
204: ; preds = %196
%205 = load i32, i32* %15
%206 = add nsw i32 %205, 1
store i32 %206, i32* %15
br label %192
207: ; preds = %192
%208 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
br label %209
209: ; preds = %207, %187
%210 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
%211 = load i32, i32* %14
%212 = load i8*, i8** %18
%213 = sext i32 %211 to i64
%214 = getelementptr inbounds i8, i8* %212, i64 %213
store i8* %214, i8** %18
br label %232
215: ; preds = %164
%216 = load i32, i32* %14
%217 = sub nsw i32 0, %216
%218 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.11, i64 0, i64 0), i32 %217)
br label %219
219: ; preds = %224, %215
%220 = load i8*, i8** %18
%221 = load i8, i8* %220
%222 = zext i8 %221 to i32
%223 = icmp ne i32 %222, 0
br i1 %223, label %224, label %230
224: ; preds = %219
%225 = load i8*, i8** %18
%226 = getelementptr inbounds i8, i8* %225, i32 1
store i8* %226, i8** %18
%227 = load i8, i8* %225
%228 = zext i8 %227 to i32
%229 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32 %228)
br label %219
230: ; preds = %219
%231 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
br label %233
232: ; preds = %209
br label %159
233: ; preds = %230, %159
br label %234
234: ; preds = %233, %93
br label %235
235: ; preds = %234
%236 = load i32, i32* %6
%237 = add nsw i32 %236, 1
store i32 %237, i32* %6
br label %29
238: ; preds = %29
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"-s\00"
@.str.1 = [3 x i8] c"0x\00"
@.str.2 = [11 x i8] c"0x%08x => \00"
@.str.3 = [17 x i8] c"*** Error %d ***\00"
@.str.4 = [6 x i8] c"%02x \00"
@.str.9 = [26 x i8] c"Malformed hex string: %s\0A\00"
@.str.10 = [11 x i8] c"0x%08x <= \00"
@.str.11 = [33 x i8] c"Malformed UTF-8 at offset %d <= \00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [64 x i8]
%4 = alloca i32
%5 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%6 = icmp sgt i32 %0, 1
br i1 %6, label %7, label %14
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = tail call i64 @strcmp(i8* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%11 = icmp eq i64 %10, 0
%12 = xor i1 %11, true
%13 = select i1 %11, i32 2, i32 1
br label %14
14: ; preds = %7, %2
%15 = phi i1 [ true, %2 ], [ %12, %7 ]
%16 = phi i32 [ 1, %2 ], [ %13, %7 ]
%17 = icmp slt i32 %16, %0
br i1 %17, label %18, label %164
18: ; preds = %14
%19 = bitcast i32* %4 to i8*
%20 = zext i32 %16 to i64
%21 = zext i32 %0 to i64
br label %22
22: ; preds = %18, %161
%23 = phi i64 [ %20, %18 ], [ %162, %161 ]
%24 = getelementptr inbounds i8*, i8** %1, i64 %23
%25 = load i8*, i8** %24
%26 = call i64 @strncmp(i8* %25, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 2)
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %64
28: ; preds = %22
%29 = getelementptr inbounds i8, i8* %25, i64 2
%30 = call i32 @strtol(i8* nocapture %29, i32* null, i32 16)
%31 = call i32 @ord2utf8(i32 %30, i8* %5)
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %30)
%33 = icmp slt i32 %31, 1
br i1 %33, label %36, label %34
34: ; preds = %28
%35 = zext i32 %31 to i64
br label %38
36: ; preds = %28
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i32 %31)
br label %62
38: ; preds = %34, %38
%39 = phi i64 [ 0, %34 ], [ %44, %38 ]
%40 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 %39
%41 = load i8, i8* %40
%42 = zext i8 %41 to i32
%43 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32 %42)
%44 = add nuw nsw i64 %39, 1
%45 = icmp eq i64 %44, %35
br i1 %45, label %46, label %38
46: ; preds = %38
br i1 %15, label %62, label %47
47: ; preds = %46
%48 = call i32 @putchar(i32 62)
%49 = icmp sgt i32 %31, 0
br i1 %49, label %50, label %60
50: ; preds = %47
%51 = zext i32 %31 to i64
br label %52
52: ; preds = %50, %52
%53 = phi i64 [ 0, %50 ], [ %58, %52 ]
%54 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 %53
%55 = load i8, i8* %54
%56 = zext i8 %55 to i32
%57 = call i32 @putchar(i32 %56)
%58 = add nuw nsw i64 %53, 1
%59 = icmp eq i64 %58, %51
br i1 %59, label %60, label %52
60: ; preds = %52, %47
%61 = call i32 @putchar(i32 60)
br label %62
62: ; preds = %46, %60, %36
%63 = call i32 @putchar(i32 10)
br label %161
64: ; preds = %22
br label %65
65: ; preds = %100, %64
%66 = phi i8* [ %25, %64 ], [ %74, %100 ]
%67 = phi i32 [ 0, %64 ], [ %101, %100 ]
%68 = phi i32 [ 0, %64 ], [ %102, %100 ]
%69 = phi i32 [ 0, %64 ], [ %103, %100 ]
br label %70
70: ; preds = %70, %65
%71 = phi i8* [ %66, %65 ], [ %74, %70 ]
%72 = load i8, i8* %71
%73 = icmp eq i8 %72, 32
%74 = getelementptr inbounds i8, i8* %71, i64 1
br i1 %73, label %70, label %75
75: ; preds = %70
%76 = icmp ne i8 %72, 0
%77 = icmp ne i32 %69, 0
%78 = select i1 %76, i1 true, i1 %77
br i1 %78, label %79, label %104
79: ; preds = %75
%80 = call i32 @isxdigit(i8 zeroext %72)
%81 = icmp eq i32 %80, 0
br i1 %81, label %82, label %85
82: ; preds = %79
%83 = load i8*, i8** %24
%84 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.9, i64 0, i64 0), i8* %83)
br label %104
85: ; preds = %79
%86 = shl nsw i32 %68, 4
%87 = load i8, i8* %71
%88 = call i32 @tolower(i8 zeroext %87)
%89 = add nsw i32 %88, %86
%90 = load i8, i8* %71
%91 = call i64 @isdigit(i8 zeroext %90)
%92 = icmp eq i64 %91, 0
%93 = select i1 %92, i32 -87, i32 -48
%94 = add i32 %89, %93
br i1 %77, label %95, label %100
95: ; preds = %85
%96 = trunc i32 %94 to i8
%97 = add nsw i32 %67, 1
%98 = sext i32 %67 to i64
%99 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 %98
store i8 %96, i8* %99
br label %100
100: ; preds = %95, %85
%101 = phi i32 [ %97, %95 ], [ %67, %85 ]
%102 = phi i32 [ 0, %95 ], [ %94, %85 ]
%103 = xor i32 %69, 1
br label %65
104: ; preds = %75, %82
%105 = phi i32 [ -1, %82 ], [ %67, %75 ]
%106 = sext i32 %105 to i64
%107 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 %106
store i8 0, i8* %107
%108 = load i8, i8* %5
%109 = icmp eq i8 %108, 0
br i1 %109, label %160, label %110
110: ; preds = %104, %139
%111 = phi i8* [ %142, %139 ], [ %5, %104 ]
%112 = call i32 @utf82ord(i8* %111, i32* %4)
%113 = icmp sgt i32 %112, 0
br i1 %113, label %114, label %145
114: ; preds = %110
%115 = load i32, i32* %4
%116 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.10, i64 0, i64 0), i32 %115)
%117 = zext i32 %112 to i64
br label %118
118: ; preds = %114, %118
%119 = phi i64 [ 0, %114 ], [ %124, %118 ]
%120 = getelementptr inbounds i8, i8* %111, i64 %119
%121 = load i8, i8* %120
%122 = zext i8 %121 to i32
%123 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32 %122)
%124 = add nuw nsw i64 %119, 1
%125 = icmp eq i64 %124, %117
br i1 %125, label %126, label %118
126: ; preds = %118
br i1 %15, label %139, label %127
127: ; preds = %126
%128 = call i32 @putchar(i32 62)
br label %129
129: ; preds = %127, %129
%130 = phi i64 [ 0, %127 ], [ %135, %129 ]
%131 = getelementptr inbounds i8, i8* %111, i64 %130
%132 = load i8, i8* %131
%133 = zext i8 %132 to i32
%134 = call i32 @putchar(i32 %133)
%135 = add nuw nsw i64 %130, 1
%136 = icmp eq i64 %135, %117
br i1 %136, label %137, label %129
137: ; preds = %129
%138 = call i32 @putchar(i32 60)
br label %139
139: ; preds = %137, %126
%140 = call i32 @putchar(i32 10)
%141 = sext i32 %112 to i64
%142 = getelementptr inbounds i8, i8* %111, i64 %141
%143 = load i8, i8* %142
%144 = icmp eq i8 %143, 0
br i1 %144, label %160, label %110
145: ; preds = %110
%146 = sub nsw i32 0, %112
%147 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.11, i64 0, i64 0), i32 %146)
%148 = load i8, i8* %111
%149 = icmp eq i8 %148, 0
br i1 %149, label %158, label %150
150: ; preds = %145, %150
%151 = phi i8 [ %156, %150 ], [ %148, %145 ]
%152 = phi i8* [ %154, %150 ], [ %111, %145 ]
%153 = zext i8 %151 to i32
%154 = getelementptr inbounds i8, i8* %152, i64 1
%155 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32 %153)
%156 = load i8, i8* %154
%157 = icmp eq i8 %156, 0
br i1 %157, label %158, label %150
158: ; preds = %150, %145
%159 = call i32 @putchar(i32 10)
br label %160
160: ; preds = %139, %104, %158
br label %161
161: ; preds = %160, %62
%162 = add nuw nsw i64 %23, 1
%163 = icmp eq i64 %162, %21
br i1 %163, label %164, label %22
164: ; preds = %161, %14
ret i32 0
}