#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");
      if (!decode_p && hex_p)
        free(data);
      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    171c <main+0x57c>
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    171c <main+0x57c>
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    171c <main+0x57c>
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    171c <main+0x57c>
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    171c <main+0x57c>
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    1600 <main+0x460>
lea    0xc6e(%rip),%rdi
call   10b0 <perror@plt>
cmpl   $0x0,-0x18(%rbp)
jne    15f4 <main+0x454>
cmpl   $0x0,-0x1c(%rbp)
je     15f4 <main+0x454>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
movl   $0x1,-0x4(%rbp)
jmp    171c <main+0x57c>
cmpl   $0x0,-0x18(%rbp)
je     1624 <main+0x484>
mov    -0x60(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x30(%rbp),%rdx
shr    $0x1,%rdx
call   10a0 <yubikey_modhex_decode@plt>
jmp    1635 <main+0x495>
mov    -0x60(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x30(%rbp),%rdx
call   1080 <yubikey_modhex_encode@plt>
cmpl   $0x0,-0x18(%rbp)
je     16aa <main+0x50a>
cmpl   $0x0,-0x1c(%rbp)
je     16aa <main+0x50a>
movq   $0x0,-0x58(%rbp)
mov    -0x58(%rbp),%rax
mov    -0x30(%rbp),%rcx
shr    $0x1,%rcx
cmp    %rcx,%rax
jae    1697 <main+0x4f7>
mov    -0x60(%rbp),%rax
mov    -0x58(%rbp),%rcx
movsbl (%rax,%rcx,1),%esi
and    $0xff,%esi
lea    0xc07(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x58(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x58(%rbp)
jmp    1651 <main+0x4b1>
lea    0x9e8(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    16ef <main+0x54f>
cmpl   $0x0,-0x18(%rbp)
je     16d8 <main+0x538>
mov    -0x60(%rbp),%rdi
mov    -0x30(%rbp),%rsi
shr    $0x1,%rsi
mov    0x2919(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%edx
call   10c0 <fwrite@plt>
jmp    16ea <main+0x54a>
mov    -0x60(%rbp),%rsi
lea    0xba8(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    16ef <main+0x54f>
mov    -0x60(%rbp),%rdi
call   1030 <free@plt>
cmpl   $0x0,-0x18(%rbp)
jne    1715 <main+0x575>
cmpl   $0x0,-0x1c(%rbp)
je     1715 <main+0x575>
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     157d <main+0x3bd>
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
cmpb   $0x0,0x7(%rsp)
jne    1548 <main+0x388>
jmp    1552 <main+0x392>
lea    0xae6(%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 %276
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 %276
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 %276
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 %276
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 %276
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 %212, label %201
201: ; preds = %193
%202 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.19, i64 0, i64 0))
%203 = load i32, i32* %7
%204 = icmp ne i32 %203, 0
br i1 %204, label %211, label %205
205: ; preds = %201
%206 = load i32, i32* %8
%207 = icmp ne i32 %206, 0
br i1 %207, label %208, label %211
208: ; preds = %205
%209 = load i8*, i8** %9
%210 = call i32 @free(i8* %209)
br label %211
211: ; preds = %208, %205, %201
store i32 1, i32* %3
br label %276
212: ; preds = %193
%213 = load i32, i32* %7
%214 = icmp ne i32 %213, 0
br i1 %214, label %215, label %221
215: ; preds = %212
%216 = load i8*, i8** %16
%217 = load i8*, i8** %9
%218 = load i64, i64* %10
%219 = udiv i64 %218, 2
%220 = call i32 @yubikey_modhex_decode(i8* %216, i8* %217, i64 %219)
br label %226
221: ; preds = %212
%222 = load i8*, i8** %16
%223 = load i8*, i8** %9
%224 = load i64, i64* %10
%225 = call i32 @yubikey_modhex_encode(i8* %222, i8* %223, i64 %224)
br label %226
226: ; preds = %221, %215
%227 = load i32, i32* %7
%228 = icmp ne i32 %227, 0
br i1 %228, label %229, label %251
229: ; preds = %226
%230 = load i32, i32* %8
%231 = icmp ne i32 %230, 0
br i1 %231, label %232, label %251
232: ; preds = %229
store i64 0, i64* %15
br label %233
233: ; preds = %246, %232
%234 = load i64, i64* %15
%235 = load i64, i64* %10
%236 = udiv i64 %235, 2
%237 = icmp ult i64 %234, %236
br i1 %237, label %238, label %249
238: ; preds = %233
%239 = load i8*, i8** %16
%240 = load i64, i64* %15
%241 = getelementptr inbounds i8, i8* %239, i64 %240
%242 = load i8, i8* %241
%243 = sext i8 %242 to i32
%244 = and i32 %243, 255
%245 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.22, i64 0, i64 0), i32 %244)
br label %246
246: ; preds = %238
%247 = load i64, i64* %15
%248 = add i64 %247, 1
store i64 %248, i64* %15
br label %233
249: ; preds = %233
%250 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %264
251: ; preds = %229, %226
%252 = load i32, i32* %7
%253 = icmp ne i32 %252, 0
br i1 %253, label %254, label %260
254: ; preds = %251
%255 = load i8*, i8** %16
%256 = load i64, i64* %10
%257 = udiv i64 %256, 2
%258 = load i32, i32* @stdout
%259 = call i32 @fwrite(i8* %255, i64 %257, i32 1, i32 %258)
br label %263
260: ; preds = %251
%261 = load i8*, i8** %16
%262 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.23, i64 0, i64 0), i8* %261)
br label %263
263: ; preds = %260, %254
br label %264
264: ; preds = %263, %249
%265 = load i8*, i8** %16
%266 = call i32 @free(i8* %265)
%267 = load i32, i32* %7
%268 = icmp ne i32 %267, 0
br i1 %268, label %275, label %269
269: ; preds = %264
%270 = load i32, i32* %8
%271 = icmp ne i32 %270, 0
br i1 %271, label %272, label %275
272: ; preds = %269
%273 = load i8*, i8** %9
%274 = call i32 @free(i8* %273)
br label %275
275: ; preds = %272, %269, %264
store i32 0, i32* %3
br label %276
276: ; preds = %275, %211, %146, %131, %121, %102, %19
%277 = load i32, i32* %3
ret i32 %277
}

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 %154
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 %154
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 %154
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 %154
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 %154
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 %126
122: ; preds = %114
%123 = tail call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.19, i64 0, i64 0))
br i1 %62, label %124, label %154
124: ; preds = %122
%125 = tail call i32 @free(i8* %116)
br label %154
126: ; preds = %114
br i1 %37, label %147, label %127
127: ; preds = %126
%128 = lshr i64 %117, 1
%129 = tail call i32 @yubikey_modhex_decode(i8* %120, i8* %116, i64 %128)
br i1 %61, label %130, label %144
130: ; preds = %127
%131 = icmp ult i64 %117, 2
br i1 %131, label %142, label %132
132: ; preds = %130
%133 = call i64 @llvm.umax.i64(i64 %128, i64 1)
br label %134
134: ; preds = %132, %134
%135 = phi i64 [ %140, %134 ], [ 0, %132 ]
%136 = getelementptr inbounds i8, i8* %120, i64 %135
%137 = load i8, i8* %136
%138 = zext i8 %137 to i32
%139 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.22, i64 0, i64 0), i32 %138)
%140 = add nuw nsw i64 %135, 1
%141 = icmp eq i64 %140, %133
br i1 %141, label %142, label %134
142: ; preds = %134, %130
%143 = tail call i32 @putchar(i32 10)
br label %150
144: ; preds = %127
%145 = load i32, i32* @stdout
%146 = tail call i32 @fwrite(i8* %120, i64 %128, i32 1, i32 %145)
br label %150
147: ; preds = %126
%148 = tail call i32 @yubikey_modhex_encode(i8* %120, i8* %116, i64 %117)
%149 = tail call i32 @puts(i8* %120)
br label %150
150: ; preds = %142, %147, %144
%151 = tail call i32 @free(i8* %120)
br i1 %62, label %152, label %154
152: ; preds = %150
%153 = tail call i32 @free(i8* %116)
br label %154
154: ; preds = %124, %122, %78, %103, %68, %150, %152, %54, %6
%155 = phi i32 [ 1, %6 ], [ 1, %54 ], [ 0, %150 ], [ 0, %152 ], [ 1, %68 ], [ 1, %103 ], [ 1, %78 ], [ 1, %122 ], [ 1, %124 ]
ret i32 %155
}