#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*/ free(char *);
int /*<<< orphan*/ fwrite(char *, size_t, int, int /*<<< orphan*/);
char *malloc(int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdout;
char *strchr(char const *, char);
scalar_t__ strcmp(char *, char *);
size_t strlen(char *);
int /*<<< orphan*/ yubikey_modhex_decode(char *, char *, size_t);
int /*<<< orphan*/ yubikey_modhex_encode(char *, char *, size_t);
int main(int argc, char *argv[]) {
  int argi;
  int decode_p = 0;
  int hex_p = 0;
  char *data;
  size_t inlen;
  if (argc < 2) {
    printf("Usage: %s [-dh] <data>\n", argv[0]);
    printf("\n");
    printf("Convert input DATA as specified and print output to STDOUT.\n");
    printf("\n");
    printf(" -d: Decode data (the default is to encode data).\n");
    printf(" -h: Use hex encoding for all non-modhex data.\n");
    printf(" DATA: string with data to encode\n");
    printf("\n");
    printf("Examples:\n");
    printf("\n");
    printf("  ModHex encode ASCII-string \"test\":\n");
    printf("    %s test\n", argv[0]);
    printf("\n");
    printf("  Decode ModHex data \"ifhgieif\" into ASCII string:\n");
    printf("    %s -d ifhgieif\n", argv[0]);
    printf("\n");
    printf("  ModHex encode hex-encoded data \"b565716f\":\n");
    printf("    %s -h b565716f\n", argv[0]);
    printf("\n");
    printf("  Decode ModHex data \"nghgibhv\" and print hex-encode data:\n");
    printf("    %s -d -h nghgibhv\n", argv[0]);
    return 1;
  }
  argi = 1;
  while (argc > argi && (!decode_p || !hex_p)) {
    if (strcmp(argv[argi], "-d") == 0) {
      decode_p = 1;
      argi++;
    } else if (strcmp(argv[argi], "-h") == 0) {
      hex_p = 1;
      argi++;
    } else
      break;
  }
  if (argc < argi + 1) {
    printf("error: missing argument\n");
    return 1;
  }
  data = argv[argi];
  inlen = strlen(data);
  if (!decode_p && hex_p) {
    unsigned long i;
    char *tmp;
    if (inlen & 1) {
      printf("error: size of hex encoded input not even\n");
      return 1;
    }
    tmp = malloc(inlen / 2 + 1);
    if (!tmp) {
      perror("malloc");
      return 1;
    }
    for (i = 0; i < inlen; i++) {
      const char *hex = "0123456789abcdef";
      char *p;
      if ((p = strchr(hex, data[i])) == NULL) {
        printf("error: input not hex encoded at position %lu\n", i);
        free(tmp);
        return 1;
      }
      if (i & 1)
        tmp[i / 2] |= p - hex;
      else
        tmp[i / 2] = (p - hex) << 4;
    }
    tmp[i / 2] = '\0';
    inlen = inlen / 2;
    data = tmp;
  }
  {
    size_t i;
    char *buf = malloc(2 * inlen + 1);
    if (!buf) {
      perror("malloc");
      return 1;
    }
    if (decode_p)
      yubikey_modhex_decode(buf, data, inlen / 2);
    else
      yubikey_modhex_encode(buf, data, inlen);
    if (decode_p && hex_p) {
      for (i = 0; i < inlen / 2; i++)
        printf("%02x", buf[i] & 0xFF);
      printf("\n");
    } else if (decode_p)
      fwrite(buf, inlen / 2, 1, stdout);
    else
      printf("%s\n", buf);
    free(buf);
  }
  if (!decode_p && hex_p)
    free(data);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    1323 <main+0x183>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe24(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xe9c(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xe20(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xe80(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xe41(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xe66(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xe88(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xe48(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xe8f(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xe2c(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xe7e(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe8f(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xdfb(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xe80(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe9f(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xdca(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xe97(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xeb0(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xd99(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xea8(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xecf(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    16ff <main+0x55f>
movl   $0x1,-0x14(%rbp)
mov    -0x8(%rbp),%ecx
xor    %eax,%eax
cmp    -0x14(%rbp),%ecx
mov    %al,-0x61(%rbp)
jle    135c <main+0x1bc>
mov    $0x1,%al
cmpl   $0x0,-0x18(%rbp)
mov    %al,-0x62(%rbp)
je     1356 <main+0x1b6>
cmpl   $0x0,-0x1c(%rbp)
setne  %al
xor    $0xff,%al
mov    %al,-0x62(%rbp)
mov    -0x62(%rbp),%al
mov    %al,-0x61(%rbp)
mov    -0x61(%rbp),%al
test   $0x1,%al
jne    136c <main+0x1cc>
jmp    13e9 <main+0x249>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xe77(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    13a3 <main+0x203>
movl   $0x1,-0x18(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    13e4 <main+0x244>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xe43(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    13da <main+0x23a>
movl   $0x1,-0x1c(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    13df <main+0x23f>
jmp    13e9 <main+0x249>
jmp    13e4 <main+0x244>
jmp    132a <main+0x18a>
mov    -0x8(%rbp),%eax
mov    -0x14(%rbp),%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
jge    1414 <main+0x274>
lea    0xdfb(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    16ff <main+0x55f>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x30(%rbp)
cmpl   $0x0,-0x18(%rbp)
jne    15a9 <main+0x409>
cmpl   $0x0,-0x1c(%rbp)
je     15a9 <main+0x409>
mov    -0x30(%rbp),%rax
and    $0x1,%rax
cmp    $0x0,%rax
je     1471 <main+0x2d1>
lea    0xdb7(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    16ff <main+0x55f>
mov    -0x30(%rbp),%rax
shr    $0x1,%rax
add    $0x1,%rax
mov    %eax,%edi
call   1090 <malloc@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
jne    14ab <main+0x30b>
lea    0xda6(%rip),%rdi
call   10b0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    16ff <main+0x55f>
movq   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%rax
cmp    -0x30(%rbp),%rax
jae    1585 <main+0x3e5>
lea    0xd7f(%rip),%rax
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rdi
mov    -0x28(%rbp),%rax
mov    -0x38(%rbp),%rcx
movsbl (%rax,%rcx,1),%esi
call   1050 <strchr@plt>
mov    %rax,-0x50(%rbp)
cmp    $0x0,%rax
jne    1516 <main+0x376>
mov    -0x38(%rbp),%rsi
lea    0xd5e(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
movl   $0x1,-0x4(%rbp)
jmp    16ff <main+0x55f>
mov    -0x38(%rbp),%rax
and    $0x1,%rax
cmp    $0x0,%rax
je     154f <main+0x3af>
mov    -0x50(%rbp),%rsi
mov    -0x48(%rbp),%rax
sub    %rax,%rsi
mov    -0x40(%rbp),%rax
mov    -0x38(%rbp),%rcx
shr    $0x1,%rcx
movsbq (%rax,%rcx,1),%rdx
or     %rsi,%rdx
mov    %dl,(%rax,%rcx,1)
jmp    156f <main+0x3cf>
mov    -0x50(%rbp),%rax
mov    -0x48(%rbp),%rcx
sub    %rcx,%rax
shl    $0x4,%rax
mov    %al,%dl
mov    -0x40(%rbp),%rax
mov    -0x38(%rbp),%rcx
shr    $0x1,%rcx
mov    %dl,(%rax,%rcx,1)
jmp    1574 <main+0x3d4>
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
jmp    14b3 <main+0x313>
mov    -0x40(%rbp),%rax
mov    -0x38(%rbp),%rcx
shr    $0x1,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x30(%rbp),%rax
shr    $0x1,%rax
mov    %rax,-0x30(%rbp)
mov    -0x40(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x30(%rbp),%rax
shl    $0x1,%rax
add    $0x1,%rax
mov    %eax,%edi
call   1090 <malloc@plt>
mov    %rax,-0x60(%rbp)
cmpq   $0x0,-0x60(%rbp)
jne    15e3 <main+0x443>
lea    0xc6e(%rip),%rdi
call   10b0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    16ff <main+0x55f>
cmpl   $0x0,-0x18(%rbp)
je     1607 <main+0x467>
mov    -0x60(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x30(%rbp),%rdx
shr    $0x1,%rdx
call   10a0 <yubikey_modhex_decode@plt>
jmp    1618 <main+0x478>
mov    -0x60(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x30(%rbp),%rdx
call   1080 <yubikey_modhex_encode@plt>
cmpl   $0x0,-0x18(%rbp)
je     168d <main+0x4ed>
cmpl   $0x0,-0x1c(%rbp)
je     168d <main+0x4ed>
movq   $0x0,-0x58(%rbp)
mov    -0x58(%rbp),%rax
mov    -0x30(%rbp),%rcx
shr    $0x1,%rcx
cmp    %rcx,%rax
jae    167a <main+0x4da>
mov    -0x60(%rbp),%rax
mov    -0x58(%rbp),%rcx
movsbl (%rax,%rcx,1),%esi
and    $0xff,%esi
lea    0xc24(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x58(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x58(%rbp)
jmp    1634 <main+0x494>
lea    0xa05(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    16d2 <main+0x532>
cmpl   $0x0,-0x18(%rbp)
je     16bb <main+0x51b>
mov    -0x60(%rbp),%rdi
mov    -0x30(%rbp),%rsi
shr    $0x1,%rsi
mov    0x2936(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%edx
call   10c0 <fwrite@plt>
jmp    16cd <main+0x52d>
mov    -0x60(%rbp),%rsi
lea    0xbc5(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    16d2 <main+0x532>
mov    -0x60(%rbp),%rdi
call   1030 <free@plt>
cmpl   $0x0,-0x18(%rbp)
jne    16f8 <main+0x558>
cmpl   $0x0,-0x1c(%rbp)
je     16f8 <main+0x558>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbx
cmp    $0x2,%edi
jge    12eb <main+0x12b>
mov    (%rbx),%rsi
lea    0xe1c(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
lea    0xefb(%rip),%rdi
call   1050 <puts@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
lea    0xf21(%rip),%rdi
call   1050 <puts@plt>
lea    0xf47(%rip),%rdi
call   1050 <puts@plt>
lea    0xf6a(%rip),%rdi
call   1050 <puts@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
lea    0xf76(%rip),%rdi
call   1050 <puts@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
lea    0xf6a(%rip),%rdi
call   1050 <puts@plt>
mov    (%rbx),%rsi
lea    0xdb3(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
lea    0xf68(%rip),%rdi
call   1050 <puts@plt>
mov    (%rbx),%rsi
lea    0xd99(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
lea    0xf74(%rip),%rdi
call   1050 <puts@plt>
mov    (%rbx),%rsi
lea    0xd86(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
lea    0xf7a(%rip),%rdi
call   1050 <puts@plt>
mov    (%rbx),%rsi
lea    0xd73(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
mov    $0x1,%ebx
jmp    1552 <main+0x392>
mov    %edi,%r15d
xor    %r13d,%r13d
mov    $0x1,%ebp
lea    0xd67(%rip),%r14
xor    %r12d,%r12d
jmp    1323 <main+0x163>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    $0x1,%r13d
add    $0x1,%rbp
cmp    %rbp,%r15
je     141b <main+0x25b>
test   %r13d,%r13d
je     132d <main+0x16d>
test   %r12d,%r12d
jne    135b <main+0x19b>
mov    (%rbx,%rbp,8),%rdi
mov    %r14,%rsi
call   1090 <strcmp@plt>
test   %rax,%rax
je     1310 <main+0x150>
mov    (%rbx,%rbp,8),%rdi
lea    0xd1e(%rip),%rsi
call   1090 <strcmp@plt>
test   %rax,%rax
jne    135b <main+0x19b>
mov    $0x1,%r12d
jmp    1316 <main+0x156>
test   %r13d,%r13d
sete   %r14b
mov    (%rbx,%rbp,8),%rbp
mov    %rbp,%rdi
call   1060 <strlen@plt>
mov    %rax,%r15
test   %r12d,%r12d
setne  %al
and    %r14b,%al
je     1424 <main+0x264>
test   $0x1,%r15b
jne    1432 <main+0x272>
mov    %al,0x7(%rsp)
mov    %r15,%rbx
shr    %rbx
lea    0x1(%rbx),%edi
call   10b0 <malloc@plt>
mov    %rax,0x8(%rsp)
test   %rax,%rax
je     1563 <main+0x3a3>
test   %r15,%r15
je     1448 <main+0x288>
mov    %rbx,0x10(%rsp)
xor    %ebx,%ebx
lea    0xcb0(%rip),%r14
jmp    13f1 <main+0x231>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
sub    %r14b,%al
shl    $0x4,%al
mov    %rbx,%rcx
shr    %rcx
mov    0x8(%rsp),%rdx
mov    %al,(%rdx,%rcx,1)
add    $0x1,%rbx
cmp    %rbx,%r15
je     1472 <main+0x2b2>
movsbl 0x0(%rbp,%rbx,1),%esi
mov    %r14,%rdi
call   1070 <strchr@plt>
test   %rax,%rax
je     144d <main+0x28d>
test   $0x1,%bl
je     13d0 <main+0x210>
mov    %rbx,%rcx
shr    %rcx
sub    %r14b,%al
mov    0x8(%rsp),%rdx
or     %al,(%rdx,%rcx,1)
jmp    13e4 <main+0x224>
lea    0xcbd(%rip),%rdi
jmp    1439 <main+0x279>
mov    %al,0x7(%rsp)
mov    %r15d,%ebx
mov    %rbp,0x8(%rsp)
jmp    1487 <main+0x2c7>
lea    0xc7c(%rip),%rdi
call   1050 <puts@plt>
mov    $0x1,%ebx
jmp    1552 <main+0x392>
xor    %r15d,%r15d
jmp    147a <main+0x2ba>
lea    0xc2e(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
mov    0x8(%rsp),%rdi
call   1030 <free@plt>
mov    $0x1,%ebx
jmp    1552 <main+0x392>
shr    %r15
mov    0x10(%rsp),%rbx
mov    0x8(%rsp),%rax
movb   $0x0,(%rax,%r15,1)
mov    %rbx,%r15
lea    (%rbx,%rbx,1),%edi
add    $0x1,%edi
call   10b0 <malloc@plt>
test   %rax,%rax
je     1563 <main+0x3a3>
mov    %rax,%r14
test   %r13d,%r13d
je     1504 <main+0x344>
mov    %r15,%rbx
shr    %rbx
mov    %r14,%rdi
mov    0x8(%rsp),%rsi
mov    %rbx,%rdx
call   10c0 <yubikey_modhex_decode@plt>
test   %r12d,%r12d
je     151e <main+0x35e>
cmp    $0x2,%r15
jb     14f8 <main+0x338>
cmp    $0x2,%rbx
mov    $0x1,%ebp
cmovae %rbx,%rbp
lea    0xbd8(%rip),%r15
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
movzbl (%r14,%rbx,1),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1080 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    14e0 <main+0x320>
mov    $0xa,%edi
call   1040 <putchar@plt>
jmp    1537 <main+0x377>
mov    %r14,%rdi
mov    0x8(%rsp),%rsi
mov    %r15,%rdx
call   10a0 <yubikey_modhex_encode@plt>
mov    %r14,%rdi
call   1050 <puts@plt>
jmp    1537 <main+0x377>
mov    0x2abb(%rip),%rax
mov    (%rax),%ecx
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0x1,%edx
call   10e0 <fwrite@plt>
mov    %r14,%rdi
call   1030 <free@plt>
xor    %ebx,%ebx
cmpb   $0x0,0x7(%rsp)
je     1552 <main+0x392>
mov    0x8(%rsp),%rdi
call   1030 <free@plt>
mov    %ebx,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xb00(%rip),%rdi
call   10d0 <perror@plt>
mov    $0x1,%ebx
jmp    1552 <main+0x392>

LLVM IR (-O0):
@.str = [24 x i8] c"Usage: %s [-dh] <data>\0A\00"
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [61 x i8] c"Convert input DATA as specified and print output to STDOUT.\0A\00"
@.str.3 = [51 x i8] c" -d: Decode data (the default is to encode data).\0A\00"
@.str.4 = [48 x i8] c" -h: Use hex encoding for all non-modhex data.\0A\00"
@.str.5 = [35 x i8] c" DATA: string with data to encode\0A\00"
@.str.6 = [11 x i8] c"Examples:\0A\00"
@.str.7 = [38 x i8] c" ModHex encode ASCII-string \22test\22:\0A\00"
@.str.8 = [13 x i8] c" %s test\0A\00"
@.str.9 = [52 x i8] c" Decode ModHex data \22ifhgieif\22 into ASCII string:\0A\00"
@.str.10 = [20 x i8] c" %s -d ifhgieif\0A\00"
@.str.11 = [46 x i8] c" ModHex encode hex-encoded data \22b565716f\22:\0A\00"
@.str.12 = [20 x i8] c" %s -h b565716f\0A\00"
@.str.13 = [60 x i8] c" Decode ModHex data \22nghgibhv\22 and print hex-encode data:\0A\00"
@.str.14 = [23 x i8] c" %s -d -h nghgibhv\0A\00"
@.str.15 = [3 x i8] c"-d\00"
@.str.16 = [3 x i8] c"-h\00"
@.str.17 = [25 x i8] c"error: missing argument\0A\00"
@.str.18 = [43 x i8] c"error: size of hex encoded input not even\0A\00"
@.str.19 = [7 x i8] c"malloc\00"
@.str.20 = [17 x i8] c"0123456789abcdef\00"
@.str.21 = [46 x i8] c"error: input not hex encoded at position %lu\0A\00"
@.str.22 = [5 x i8] c"%02x\00"
@stdout = global i32 0
@.str.23 = [4 x i8] c"%s\0A\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 i32
%9 = alloca i8*
%10 = alloca i64
%11 = alloca i64
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca i8*
%15 = alloca i64
%16 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %7
store i32 0, i32* %8
%17 = load i32, i32* %4
%18 = icmp slt i32 %17, 2
br i1 %18, label %19, label %56
19: ; preds = %2
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 0
%22 = load i8*, i8** %21
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %22)
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.2, i64 0, i64 0))
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.3, i64 0, i64 0))
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.4, i64 0, i64 0))
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.5, i64 0, i64 0))
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0))
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.7, i64 0, i64 0))
%34 = load i8**, i8*** %5
%35 = getelementptr inbounds i8*, i8** %34, i64 0
%36 = load i8*, i8** %35
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0), i8* %36)
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.9, i64 0, i64 0))
%40 = load i8**, i8*** %5
%41 = getelementptr inbounds i8*, i8** %40, i64 0
%42 = load i8*, i8** %41
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.10, i64 0, i64 0), i8* %42)
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.11, i64 0, i64 0))
%46 = load i8**, i8*** %5
%47 = getelementptr inbounds i8*, i8** %46, i64 0
%48 = load i8*, i8** %47
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.12, i64 0, i64 0), i8* %48)
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.13, i64 0, i64 0))
%52 = load i8**, i8*** %5
%53 = getelementptr inbounds i8*, i8** %52, i64 0
%54 = load i8*, i8** %53
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.14, i64 0, i64 0), i8* %54)
store i32 1, i32* %3
br label %267
56: ; preds = %2
store i32 1, i32* %6
br label %57
57: ; preds = %96, %56
%58 = load i32, i32* %4
%59 = load i32, i32* %6
%60 = icmp sgt i32 %58, %59
br i1 %60, label %61, label %70
61: ; preds = %57
%62 = load i32, i32* %7
%63 = icmp ne i32 %62, 0
br i1 %63, label %64, label %68
64: ; preds = %61
%65 = load i32, i32* %8
%66 = icmp ne i32 %65, 0
%67 = xor i1 %66, true
br label %68
68: ; preds = %64, %61
%69 = phi i1 [ true, %61 ], [ %67, %64 ]
br label %70
70: ; preds = %68, %57
%71 = phi i1 [ false, %57 ], [ %69, %68 ]
br i1 %71, label %72, label %97
72: ; preds = %70
%73 = load i8**, i8*** %5
%74 = load i32, i32* %6
%75 = sext i32 %74 to i64
%76 = getelementptr inbounds i8*, i8** %73, i64 %75
%77 = load i8*, i8** %76
%78 = call i64 @strcmp(i8* %77, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.15, i64 0, i64 0))
%79 = icmp eq i64 %78, 0
br i1 %79, label %80, label %83
80: ; preds = %72
store i32 1, i32* %7
%81 = load i32, i32* %6
%82 = add nsw i32 %81, 1
store i32 %82, i32* %6
br label %96
83: ; preds = %72
%84 = load i8**, i8*** %5
%85 = load i32, i32* %6
%86 = sext i32 %85 to i64
%87 = getelementptr inbounds i8*, i8** %84, i64 %86
%88 = load i8*, i8** %87
%89 = call i64 @strcmp(i8* %88, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.16, i64 0, i64 0))
%90 = icmp eq i64 %89, 0
br i1 %90, label %91, label %94
91: ; preds = %83
store i32 1, i32* %8
%92 = load i32, i32* %6
%93 = add nsw i32 %92, 1
store i32 %93, i32* %6
br label %95
94: ; preds = %83
br label %97
95: ; preds = %91
br label %96
96: ; preds = %95, %80
br label %57
97: ; preds = %94, %70
%98 = load i32, i32* %4
%99 = load i32, i32* %6
%100 = add nsw i32 %99, 1
%101 = icmp slt i32 %98, %100
br i1 %101, label %102, label %104
102: ; preds = %97
%103 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.17, i64 0, i64 0))
store i32 1, i32* %3
br label %267
104: ; preds = %97
%105 = load i8**, i8*** %5
%106 = load i32, i32* %6
%107 = sext i32 %106 to i64
%108 = getelementptr inbounds i8*, i8** %105, i64 %107
%109 = load i8*, i8** %108
store i8* %109, i8** %9
%110 = load i8*, i8** %9
%111 = call i64 @strlen(i8* %110)
store i64 %111, i64* %10
%112 = load i32, i32* %7
%113 = icmp ne i32 %112, 0
br i1 %113, label %193, label %114
114: ; preds = %104
%115 = load i32, i32* %8
%116 = icmp ne i32 %115, 0
br i1 %116, label %117, label %193
117: ; preds = %114
%118 = load i64, i64* %10
%119 = and i64 %118, 1
%120 = icmp ne i64 %119, 0
br i1 %120, label %121, label %123
121: ; preds = %117
%122 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.18, i64 0, i64 0))
store i32 1, i32* %3
br label %267
123: ; preds = %117
%124 = load i64, i64* %10
%125 = udiv i64 %124, 2
%126 = add i64 %125, 1
%127 = trunc i64 %126 to i32
%128 = call i8* @malloc(i32 %127)
store i8* %128, i8** %12
%129 = load i8*, i8** %12
%130 = icmp ne i8* %129, null
br i1 %130, label %133, label %131
131: ; preds = %123
%132 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.19, i64 0, i64 0))
store i32 1, i32* %3
br label %267
133: ; preds = %123
store i64 0, i64* %11
br label %134
134: ; preds = %182, %133
%135 = load i64, i64* %11
%136 = load i64, i64* %10
%137 = icmp ult i64 %135, %136
br i1 %137, label %138, label %185
138: ; preds = %134
store i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.20, i64 0, i64 0), i8** %13
%139 = load i8*, i8** %13
%140 = load i8*, i8** %9
%141 = load i64, i64* %11
%142 = getelementptr inbounds i8, i8* %140, i64 %141
%143 = load i8, i8* %142
%144 = call i8* @strchr(i8* %139, i8 signext %143)
store i8* %144, i8** %14
%145 = icmp eq i8* %144, null
br i1 %145, label %146, label %151
146: ; preds = %138
%147 = load i64, i64* %11
%148 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.21, i64 0, i64 0), i64 %147)
%149 = load i8*, i8** %12
%150 = call i32 @free(i8* %149)
store i32 1, i32* %3
br label %267
151: ; preds = %138
%152 = load i64, i64* %11
%153 = and i64 %152, 1
%154 = icmp ne i64 %153, 0
br i1 %154, label %155, label %169
155: ; preds = %151
%156 = load i8*, i8** %14
%157 = load i8*, i8** %13
%158 = ptrtoint i8* %156 to i64
%159 = ptrtoint i8* %157 to i64
%160 = sub i64 %158, %159
%161 = load i8*, i8** %12
%162 = load i64, i64* %11
%163 = udiv i64 %162, 2
%164 = getelementptr inbounds i8, i8* %161, i64 %163
%165 = load i8, i8* %164
%166 = sext i8 %165 to i64
%167 = or i64 %166, %160
%168 = trunc i64 %167 to i8
store i8 %168, i8* %164
br label %181
169: ; preds = %151
%170 = load i8*, i8** %14
%171 = load i8*, i8** %13
%172 = ptrtoint i8* %170 to i64
%173 = ptrtoint i8* %171 to i64
%174 = sub i64 %172, %173
%175 = shl i64 %174, 4
%176 = trunc i64 %175 to i8
%177 = load i8*, i8** %12
%178 = load i64, i64* %11
%179 = udiv i64 %178, 2
%180 = getelementptr inbounds i8, i8* %177, i64 %179
store i8 %176, i8* %180
br label %181
181: ; preds = %169, %155
br label %182
182: ; preds = %181
%183 = load i64, i64* %11
%184 = add i64 %183, 1
store i64 %184, i64* %11
br label %134
185: ; preds = %134
%186 = load i8*, i8** %12
%187 = load i64, i64* %11
%188 = udiv i64 %187, 2
%189 = getelementptr inbounds i8, i8* %186, i64 %188
store i8 0, i8* %189
%190 = load i64, i64* %10
%191 = udiv i64 %190, 2
store i64 %191, i64* %10
%192 = load i8*, i8** %12
store i8* %192, i8** %9
br label %193
193: ; preds = %185, %114, %104
%194 = load i64, i64* %10
%195 = mul i64 2, %194
%196 = add i64 %195, 1
%197 = trunc i64 %196 to i32
%198 = call i8* @malloc(i32 %197)
store i8* %198, i8** %16
%199 = load i8*, i8** %16
%200 = icmp ne i8* %199, null
br i1 %200, label %203, label %201
201: ; preds = %193
%202 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.19, i64 0, i64 0))
store i32 1, i32* %3
br label %267
203: ; preds = %193
%204 = load i32, i32* %7
%205 = icmp ne i32 %204, 0
br i1 %205, label %206, label %212
206: ; preds = %203
%207 = load i8*, i8** %16
%208 = load i8*, i8** %9
%209 = load i64, i64* %10
%210 = udiv i64 %209, 2
%211 = call i32 @yubikey_modhex_decode(i8* %207, i8* %208, i64 %210)
br label %217
212: ; preds = %203
%213 = load i8*, i8** %16
%214 = load i8*, i8** %9
%215 = load i64, i64* %10
%216 = call i32 @yubikey_modhex_encode(i8* %213, i8* %214, i64 %215)
br label %217
217: ; preds = %212, %206
%218 = load i32, i32* %7
%219 = icmp ne i32 %218, 0
br i1 %219, label %220, label %242
220: ; preds = %217
%221 = load i32, i32* %8
%222 = icmp ne i32 %221, 0
br i1 %222, label %223, label %242
223: ; preds = %220
store i64 0, i64* %15
br label %224
224: ; preds = %237, %223
%225 = load i64, i64* %15
%226 = load i64, i64* %10
%227 = udiv i64 %226, 2
%228 = icmp ult i64 %225, %227
br i1 %228, label %229, label %240
229: ; preds = %224
%230 = load i8*, i8** %16
%231 = load i64, i64* %15
%232 = getelementptr inbounds i8, i8* %230, i64 %231
%233 = load i8, i8* %232
%234 = sext i8 %233 to i32
%235 = and i32 %234, 255
%236 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.22, i64 0, i64 0), i32 %235)
br label %237
237: ; preds = %229
%238 = load i64, i64* %15
%239 = add i64 %238, 1
store i64 %239, i64* %15
br label %224
240: ; preds = %224
%241 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %255
242: ; preds = %220, %217
%243 = load i32, i32* %7
%244 = icmp ne i32 %243, 0
br i1 %244, label %245, label %251
245: ; preds = %242
%246 = load i8*, i8** %16
%247 = load i64, i64* %10
%248 = udiv i64 %247, 2
%249 = load i32, i32* @stdout
%250 = call i32 @fwrite(i8* %246, i64 %248, i32 1, i32 %249)
br label %254
251: ; preds = %242
%252 = load i8*, i8** %16
%253 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.23, i64 0, i64 0), i8* %252)
br label %254
254: ; preds = %251, %245
br label %255
255: ; preds = %254, %240
%256 = load i8*, i8** %16
%257 = call i32 @free(i8* %256)
%258 = load i32, i32* %7
%259 = icmp ne i32 %258, 0
br i1 %259, label %266, label %260
260: ; preds = %255
%261 = load i32, i32* %8
%262 = icmp ne i32 %261, 0
br i1 %262, label %263, label %266
263: ; preds = %260
%264 = load i8*, i8** %9
%265 = call i32 @free(i8* %264)
br label %266
266: ; preds = %263, %260, %255
store i32 0, i32* %3
br label %267
267: ; preds = %266, %201, %146, %131, %121, %102, %19
%268 = load i32, i32* %3
ret i32 %268
}

LLVM IR (-O2):
@.str = [24 x i8] c"Usage: %s [-dh] <data>\0A\00"
@.str.8 = [13 x i8] c" %s test\0A\00"
@.str.10 = [20 x i8] c" %s -d ifhgieif\0A\00"
@.str.12 = [20 x i8] c" %s -h b565716f\0A\00"
@.str.14 = [23 x i8] c" %s -d -h nghgibhv\0A\00"
@.str.15 = [3 x i8] c"-d\00"
@.str.16 = [3 x i8] c"-h\00"
@.str.19 = [7 x i8] c"malloc\00"
@.str.20 = [17 x i8] c"0123456789abcdef\00"
@.str.21 = [46 x i8] c"error: input not hex encoded at position %lu\0A\00"
@.str.22 = [5 x i8] c"%02x\00"
@stdout = global i32 0
@str = [42 x i8] c"error: size of hex encoded input not even\00"
@str.24 = [24 x i8] c"error: missing argument\00"
@str.25 = [60 x i8] c"Convert input DATA as specified and print output to STDOUT.\00"
@str.26 = [50 x i8] c" -d: Decode data (the default is to encode data).\00"
@str.27 = [47 x i8] c" -h: Use hex encoding for all non-modhex data.\00"
@str.28 = [34 x i8] c" DATA: string with data to encode\00"
@str.29 = [10 x i8] c"Examples:\00"
@str.30 = [37 x i8] c" ModHex encode ASCII-string \22test\22:\00"
@str.31 = [51 x i8] c" Decode ModHex data \22ifhgieif\22 into ASCII string:\00"
@str.32 = [45 x i8] c" ModHex encode hex-encoded data \22b565716f\22:\00"
@str.33 = [59 x i8] c" Decode ModHex data \22nghgibhv\22 and print hex-encode data:\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %6, label %4
4: ; preds = %2
%5 = zext i32 %0 to i64
br label %33
6: ; preds = %2
%7 = load i8*, i8** %1
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %7)
%9 = tail call i32 @putchar(i32 10)
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([60 x i8], [60 x i8]* @str.25, i64 0, i64 0))
%11 = tail call i32 @putchar(i32 10)
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @str.26, i64 0, i64 0))
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @str.27, i64 0, i64 0))
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str.28, i64 0, i64 0))
%15 = tail call i32 @putchar(i32 10)
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str.29, i64 0, i64 0))
%17 = tail call i32 @putchar(i32 10)
%18 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str.30, i64 0, i64 0))
%19 = load i8*, i8** %1
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0), i8* %19)
%21 = tail call i32 @putchar(i32 10)
%22 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @str.31, i64 0, i64 0))
%23 = load i8*, i8** %1
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.10, i64 0, i64 0), i8* %23)
%25 = tail call i32 @putchar(i32 10)
%26 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @str.32, i64 0, i64 0))
%27 = load i8*, i8** %1
%28 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.12, i64 0, i64 0), i8* %27)
%29 = tail call i32 @putchar(i32 10)
%30 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([59 x i8], [59 x i8]* @str.33, i64 0, i64 0))
%31 = load i8*, i8** %1
%32 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.14, i64 0, i64 0), i8* %31)
br label %152
33: ; preds = %4, %49
%34 = phi i64 [ 1, %4 ], [ %52, %49 ]
%35 = phi i32 [ 0, %4 ], [ %51, %49 ]
%36 = phi i32 [ 0, %4 ], [ %50, %49 ]
%37 = icmp eq i32 %35, 0
%38 = icmp eq i32 %36, 0
%39 = select i1 %37, i1 true, i1 %38
br i1 %39, label %40, label %56
40: ; preds = %33
%41 = getelementptr inbounds i8*, i8** %1, i64 %34
%42 = load i8*, i8** %41
%43 = tail call i64 @strcmp(i8* %42, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.15, i64 0, i64 0))
%44 = icmp eq i64 %43, 0
br i1 %44, label %49, label %45
45: ; preds = %40
%46 = load i8*, i8** %41
%47 = tail call i64 @strcmp(i8* %46, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.16, i64 0, i64 0))
%48 = icmp eq i64 %47, 0
br i1 %48, label %49, label %56
49: ; preds = %45, %40
%50 = phi i32 [ %36, %40 ], [ 1, %45 ]
%51 = phi i32 [ 1, %40 ], [ %35, %45 ]
%52 = add nuw nsw i64 %34, 1
%53 = icmp eq i64 %52, %5
br i1 %53, label %54, label %33
54: ; preds = %49
%55 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.24, i64 0, i64 0))
br label %152
56: ; preds = %45, %33
%57 = and i64 %34, 4294967295
%58 = getelementptr inbounds i8*, i8** %1, i64 %57
%59 = load i8*, i8** %58
%60 = tail call i64 @strlen(i8* dereferenceable(1) %59)
%61 = icmp ne i32 %36, 0
%62 = select i1 %37, i1 %61, i1 false
br i1 %62, label %65, label %63
63: ; preds = %56
%64 = trunc i64 %60 to i32
br label %114
65: ; preds = %56
%66 = and i64 %60, 1
%67 = icmp eq i64 %66, 0
br i1 %67, label %70, label %68
68: ; preds = %65
%69 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @str, i64 0, i64 0))
br label %152
70: ; preds = %65
%71 = lshr i64 %60, 1
%72 = trunc i64 %71 to i32
%73 = add i32 %72, 1
%74 = tail call i8* @malloc(i32 %73)
%75 = icmp eq i8* %74, null
br i1 %75, label %78, label %76
76: ; preds = %70
%77 = icmp eq i64 %60, 0
br i1 %77, label %111, label %80
78: ; preds = %70
%79 = tail call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.19, i64 0, i64 0))
br label %152
80: ; preds = %76, %106
%81 = phi i64 [ %107, %106 ], [ 0, %76 ]
%82 = getelementptr inbounds i8, i8* %59, i64 %81
%83 = load i8, i8* %82
%84 = tail call i8* @strchr(i8* dereferenceable(17) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.20, i64 0, i64 0), i8 signext %83)
%85 = icmp eq i8* %84, null
br i1 %85, label %103, label %86
86: ; preds = %80
%87 = and i64 %81, 1
%88 = icmp eq i64 %87, 0
%89 = ptrtoint i8* %84 to i64
br i1 %88, label %97, label %90
90: ; preds = %86
%91 = lshr i64 %81, 1
%92 = getelementptr inbounds i8, i8* %74, i64 %91
%93 = load i8, i8* %92
%94 = trunc i64 %89 to i8
%95 = sub i8 %94, ptrtoint ([17 x i8]* @.str.20 to i8)
%96 = or i8 %93, %95
store i8 %96, i8* %92
br label %106
97: ; preds = %86
%98 = trunc i64 %89 to i8
%99 = sub i8 %98, ptrtoint ([17 x i8]* @.str.20 to i8)
%100 = shl i8 %99, 4
%101 = lshr i64 %81, 1
%102 = getelementptr inbounds i8, i8* %74, i64 %101
store i8 %100, i8* %102
br label %106
103: ; preds = %80
%104 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str.21, i64 0, i64 0), i64 %81)
%105 = tail call i32 @free(i8* %74)
br label %152
106: ; preds = %90, %97
%107 = add nuw i64 %81, 1
%108 = icmp eq i64 %107, %60
br i1 %108, label %109, label %80
109: ; preds = %106
%110 = lshr i64 %60, 1
br label %111
111: ; preds = %76, %109
%112 = phi i64 [ %110, %109 ], [ 0, %76 ]
%113 = getelementptr inbounds i8, i8* %74, i64 %112
store i8 0, i8* %113
br label %114
114: ; preds = %63, %111
%115 = phi i32 [ %64, %63 ], [ %72, %111 ]
%116 = phi i8* [ %59, %63 ], [ %74, %111 ]
%117 = phi i64 [ %60, %63 ], [ %71, %111 ]
%118 = shl i32 %115, 1
%119 = or i32 %118, 1
%120 = tail call i8* @malloc(i32 %119)
%121 = icmp eq i8* %120, null
br i1 %121, label %122, label %124
122: ; preds = %114
%123 = tail call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.19, i64 0, i64 0))
br label %152
124: ; preds = %114
br i1 %37, label %145, label %125
125: ; preds = %124
%126 = lshr i64 %117, 1
%127 = tail call i32 @yubikey_modhex_decode(i8* %120, i8* %116, i64 %126)
br i1 %61, label %128, label %142
128: ; preds = %125
%129 = icmp ult i64 %117, 2
br i1 %129, label %140, label %130
130: ; preds = %128
%131 = call i64 @llvm.umax.i64(i64 %126, i64 1)
br label %132
132: ; preds = %130, %132
%133 = phi i64 [ %138, %132 ], [ 0, %130 ]
%134 = getelementptr inbounds i8, i8* %120, i64 %133
%135 = load i8, i8* %134
%136 = zext i8 %135 to i32
%137 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.22, i64 0, i64 0), i32 %136)
%138 = add nuw nsw i64 %133, 1
%139 = icmp eq i64 %138, %131
br i1 %139, label %140, label %132
140: ; preds = %132, %128
%141 = tail call i32 @putchar(i32 10)
br label %148
142: ; preds = %125
%143 = load i32, i32* @stdout
%144 = tail call i32 @fwrite(i8* %120, i64 %126, i32 1, i32 %143)
br label %148
145: ; preds = %124
%146 = tail call i32 @yubikey_modhex_encode(i8* %120, i8* %116, i64 %117)
%147 = tail call i32 @puts(i8* %120)
br label %148
148: ; preds = %140, %145, %142
%149 = tail call i32 @free(i8* %120)
br i1 %62, label %150, label %152
150: ; preds = %148
%151 = tail call i32 @free(i8* %116)
br label %152
152: ; preds = %78, %103, %68, %122, %148, %150, %54, %6
%153 = phi i32 [ 1, %6 ], [ 1, %54 ], [ 0, %148 ], [ 0, %150 ], [ 1, %122 ], [ 1, %68 ], [ 1, %103 ], [ 1, %78 ]
ret i32 %153
}