#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 AES_BLOCK_SIZE;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ isxdigit(unsigned char);
int /*<<< orphan*/ stderr;
size_t strlen(char const *);
int toupper(unsigned char);
int normalize_buffer(const char *in, unsigned char *out,
                     unsigned long *length) {
  size_t sz;
  int i, m;
  unsigned char lo, hi, *p = (unsigned char *)in;
  unsigned char *q = out;
  if (!in) {
    fprintf(stderr, "error: missing hexstring, abort\n");
    return 15;
  }
  sz = strlen(in);
  if (sz > (*length * 2)) {
    fprintf(stderr, "warning: input hexstring is too long, truncating\n");
    sz = *length * 2;
  }
  *length = 0;
  for (i = 0; i < sz / 2; i++, p += 2, q++) {
    hi = *p;
    lo = *(p + 1);
    if (!isxdigit(hi)) {
      fprintf(stderr, "error: not a hexadecimal digit `0x%02x', abort\n", hi);
      return 15;
    }
    if (!isxdigit(lo)) {
      fprintf(stderr, "error: not a hexadecimal digit `0x%02x', abort\n", lo);
      return 15;
    }
    if (hi < 0x40)
      hi -= 0x30;
    else
      hi = toupper(hi) - 0x37;
    if (lo < 0x40)
      lo -= 0x30;
    else
      lo = toupper(lo) - 0x37;
    *q = hi << 4 | lo;
  }
  if (sz & 1) {
    hi = *p;
    if (!isxdigit(hi)) {
      fprintf(stderr, "error: not a hexadecimal digit `0x%02x', abort\n", hi);
      return 15;
    }
    if (hi < 0x40)
      hi -= 0x30;
    else
      hi = toupper(hi) - 0x37;
    *q = hi << 4;
    q++;
  }
  *length = sz / (2 * AES_BLOCK_SIZE) * AES_BLOCK_SIZE;
  m = sz % (2 * AES_BLOCK_SIZE);
  if (m > 0) {
    fprintf(stderr, "warning: add padding (%d)\n", (2 * AES_BLOCK_SIZE) - m);
    if (sz & 1)
      m++;
    for (i = 0; i < AES_BLOCK_SIZE - (m / 2); i++, q++)
      *q = 0;
    *length += AES_BLOCK_SIZE;
  }
  return 0;
}


x86 assembly (clang, -O0):
<normalize_buffer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1192 <normalize_buffer+0x52>
mov    0x2e62(%rip),%rax
mov    (%rax),%edi
lea    0xe81(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0xf,-0x4(%rbp)
jmp    14b8 <normalize_buffer+0x378>
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    (%rcx),%rcx
shl    $0x1,%rcx
cmp    %rcx,%rax
jbe    11dd <normalize_buffer+0x9d>
mov    0x2e1a(%rip),%rax
mov    (%rax),%edi
lea    0xe5a(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
shl    $0x1,%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rax
movq   $0x0,(%rax)
movl   $0x0,-0x2c(%rbp)
movslq -0x2c(%rbp),%rax
mov    -0x28(%rbp),%rcx
shr    $0x1,%rcx
cmp    %rcx,%rax
jae    131a <normalize_buffer+0x1da>
mov    -0x40(%rbp),%rax
mov    (%rax),%al
mov    %al,-0x32(%rbp)
mov    -0x40(%rbp),%rax
mov    0x1(%rax),%al
mov    %al,-0x31(%rbp)
movzbl -0x32(%rbp),%edi
call   1060 <isxdigit@plt>
cmp    $0x0,%eax
jne    1250 <normalize_buffer+0x110>
mov    0x2da8(%rip),%rax
mov    (%rax),%edi
movzbl -0x32(%rbp),%edx
lea    0xe16(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0xf,-0x4(%rbp)
jmp    14b8 <normalize_buffer+0x378>
movzbl -0x31(%rbp),%edi
call   1060 <isxdigit@plt>
cmp    $0x0,%eax
jne    1289 <normalize_buffer+0x149>
mov    0x2d6f(%rip),%rax
mov    (%rax),%edi
movzbl -0x31(%rbp),%edx
lea    0xddd(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0xf,-0x4(%rbp)
jmp    14b8 <normalize_buffer+0x378>
movzbl -0x32(%rbp),%eax
cmp    $0x40,%eax
jge    12a5 <normalize_buffer+0x165>
movzbl -0x32(%rbp),%eax
sub    $0x30,%eax
mov    %al,-0x32(%rbp)
jmp    12b4 <normalize_buffer+0x174>
movzbl -0x32(%rbp),%edi
call   1030 <toupper@plt>
sub    $0x37,%eax
mov    %al,-0x32(%rbp)
movzbl -0x31(%rbp),%eax
cmp    $0x40,%eax
jge    12d0 <normalize_buffer+0x190>
movzbl -0x31(%rbp),%eax
sub    $0x30,%eax
mov    %al,-0x31(%rbp)
jmp    12df <normalize_buffer+0x19f>
movzbl -0x31(%rbp),%edi
call   1030 <toupper@plt>
sub    $0x37,%eax
mov    %al,-0x31(%rbp)
movzbl -0x32(%rbp),%eax
shl    $0x4,%eax
movzbl -0x31(%rbp),%ecx
or     %ecx,%eax
mov    %al,%cl
mov    -0x48(%rbp),%rax
mov    %cl,(%rax)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x40(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x40(%rbp)
mov    -0x48(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x48(%rbp)
jmp    11ef <normalize_buffer+0xaf>
mov    -0x28(%rbp),%rax
and    $0x1,%rax
cmp    $0x0,%rax
je     13b4 <normalize_buffer+0x274>
mov    -0x40(%rbp),%rax
mov    (%rax),%al
mov    %al,-0x32(%rbp)
movzbl -0x32(%rbp),%edi
call   1060 <isxdigit@plt>
cmp    $0x0,%eax
jne    136e <normalize_buffer+0x22e>
mov    0x2c8a(%rip),%rax
mov    (%rax),%edi
movzbl -0x32(%rbp),%edx
lea    0xcf8(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0xf,-0x4(%rbp)
jmp    14b8 <normalize_buffer+0x378>
movzbl -0x32(%rbp),%eax
cmp    $0x40,%eax
jge    138a <normalize_buffer+0x24a>
movzbl -0x32(%rbp),%eax
sub    $0x30,%eax
mov    %al,-0x32(%rbp)
jmp    1399 <normalize_buffer+0x259>
movzbl -0x32(%rbp),%edi
call   1030 <toupper@plt>
sub    $0x37,%eax
mov    %al,-0x32(%rbp)
movzbl -0x32(%rbp),%eax
shl    $0x4,%eax
mov    %al,%cl
mov    -0x48(%rbp),%rax
mov    %cl,(%rax)
mov    -0x48(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x48(%rbp)
mov    -0x28(%rbp),%rax
mov    0x2c29(%rip),%rcx
mov    (%rcx),%ecx
shl    $0x1,%ecx
movslq %ecx,%rcx
xor    %edx,%edx
div    %rcx
mov    %rax,%rcx
mov    0x2c12(%rip),%rax
movslq (%rax),%rax
imul   %rax,%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x28(%rbp),%rax
mov    0x2bf9(%rip),%rcx
mov    (%rcx),%ecx
shl    $0x1,%ecx
movslq %ecx,%rcx
xor    %edx,%edx
div    %rcx
mov    %edx,%eax
mov    %eax,-0x30(%rbp)
cmpl   $0x0,-0x30(%rbp)
jle    14b1 <normalize_buffer+0x371>
mov    0x2bc6(%rip),%rax
mov    (%rax),%edi
mov    0x2bcd(%rip),%rax
mov    (%rax),%edx
shl    $0x1,%edx
sub    -0x30(%rbp),%edx
lea    0xc59(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x28(%rbp),%rax
and    $0x1,%rax
cmp    $0x0,%rax
je     144c <normalize_buffer+0x30c>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    %eax,-0x4c(%rbp)
mov    0x2b88(%rip),%rax
mov    (%rax),%ecx
mov    -0x30(%rbp),%eax
mov    $0x2,%esi
cltd
idiv   %esi
mov    %eax,%edx
mov    -0x4c(%rbp),%eax
sub    %edx,%ecx
cmp    %ecx,%eax
jge    149d <normalize_buffer+0x35d>
mov    -0x48(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x48(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x48(%rbp)
jmp    1453 <normalize_buffer+0x313>
mov    0x2b44(%rip),%rax
movslq (%rax),%rcx
mov    -0x20(%rbp),%rax
add    (%rax),%rcx
mov    %rcx,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<normalize_buffer>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %rdi,%rdi
je     1229 <normalize_buffer+0xe9>
mov    %rdx,%r15
mov    %rsi,%r12
mov    %rdi,%r13
call   1040 <strlen@plt>
mov    %rax,%r14
mov    (%r15),%rax
add    %rax,%rax
cmp    %rax,%r14
jbe    118d <normalize_buffer+0x4d>
mov    0x2e61(%rip),%rax
mov    (%rax),%edi
lea    0xea1(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    (%r15),%r14
add    %r14,%r14
movq   $0x0,(%r15)
cmp    $0x2,%r14
jb     1262 <normalize_buffer+0x122>
mov    %r15,(%rsp)
mov    %r14,%r15
shr    %r15
jmp    11da <normalize_buffer+0x9a>
nopw   0x0(%rax,%rax,1)
mov    %ebx,%edi
call   1030 <toupper@plt>
mov    %eax,%ebx
add    $0xc9,%ebx
shl    $0x4,%ebp
or     %ebx,%ebp
mov    %bpl,(%r12)
add    $0x2,%r13
add    $0x1,%r12
add    $0xffffffffffffffff,%r15
je     125e <normalize_buffer+0x11e>
movzbl 0x0(%r13),%ebp
movzbl 0x1(%r13),%ebx
mov    %ebp,%edi
call   1060 <isxdigit@plt>
test   %eax,%eax
je     124a <normalize_buffer+0x10a>
mov    %ebx,%edi
call   1060 <isxdigit@plt>
test   %eax,%eax
je     1282 <normalize_buffer+0x142>
cmp    $0x3f,%bpl
ja     1210 <normalize_buffer+0xd0>
add    $0xffffffd0,%ebp
cmp    $0x3f,%bl
ja     11b0 <normalize_buffer+0x70>
jmp    1224 <normalize_buffer+0xe4>
xchg   %ax,%ax
mov    %ebp,%edi
call   1030 <toupper@plt>
mov    %eax,%ebp
add    $0xc9,%ebp
cmp    $0x3f,%bl
ja     11b0 <normalize_buffer+0x70>
add    $0xffffffd0,%ebx
jmp    11bf <normalize_buffer+0x7f>
mov    0x2da8(%rip),%rax
mov    (%rax),%edi
lea    0xdc7(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0xf,%ebx
jmp    135e <normalize_buffer+0x21e>
mov    0x2d87(%rip),%rax
mov    (%rax),%edi
lea    0xdf9(%rip),%rsi
mov    %ebp,%edx
jmp    1294 <normalize_buffer+0x154>
mov    (%rsp),%r15
test   $0x1,%r14b
je     12bf <normalize_buffer+0x17f>
movzbl 0x0(%r13),%ebx
mov    %ebx,%edi
call   1060 <isxdigit@plt>
test   %eax,%eax
je     1282 <normalize_buffer+0x142>
cmp    $0x3f,%bl
ja     12a5 <normalize_buffer+0x165>
add    $0xffffffd0,%ebx
jmp    12b4 <normalize_buffer+0x174>
mov    0x2d4f(%rip),%rax
mov    (%rax),%edi
lea    0xdc1(%rip),%rsi
mov    %ebx,%edx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0xf,%ebx
jmp    135e <normalize_buffer+0x21e>
mov    %ebx,%edi
call   1030 <toupper@plt>
mov    %eax,%ebx
add    $0xc9,%ebx
shl    $0x4,%bl
mov    %bl,(%r12)
add    $0x1,%r12
mov    0x2d22(%rip),%rbp
movslq 0x0(%rbp),%rsi
lea    (%rsi,%rsi,1),%rcx
mov    %r14,%rax
or     %rsi,%rax
shr    $0x20,%rax
je     12e7 <normalize_buffer+0x1a7>
mov    %r14,%rax
xor    %edx,%edx
div    %rcx
mov    %rdx,%r13
jmp    12f1 <normalize_buffer+0x1b1>
mov    %r14d,%eax
xor    %edx,%edx
div    %ecx
mov    %edx,%r13d
imul   %rsi,%rax
mov    %rax,(%r15)
test   %r13d,%r13d
jle    135c <normalize_buffer+0x21c>
and    $0x1,%r14d
mov    0x2cd0(%rip),%rax
mov    (%rax),%edi
sub    %r13d,%ecx
lea    0xd6f(%rip),%rsi
xor    %ebx,%ebx
mov    %ecx,%edx
xor    %eax,%eax
call   1050 <fprintf@plt>
add    %r13d,%r14d
shr    %r14d
mov    0x0(%rbp),%eax
mov    %eax,%ecx
sub    %r14d,%ecx
test   %ecx,%ecx
jle    1355 <normalize_buffer+0x215>
xor    %ecx,%ecx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movb   $0x0,(%r12,%rcx,1)
mov    0x0(%rbp),%eax
mov    %eax,%edx
sub    %r14d,%edx
add    $0x1,%rcx
cmp    %edx,%ecx
jl     1340 <normalize_buffer+0x200>
cltq
add    %rax,(%r15)
jmp    135e <normalize_buffer+0x21e>
xor    %ebx,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [33 x i8] c"error: missing hexstring, abort\0A\00"
@.str.1 = [50 x i8] c"warning: input hexstring is too long, truncating\0A\00"
@.str.2 = [48 x i8] c"error: not a hexadecimal digit `0x%02x', abort\0A\00"
@AES_BLOCK_SIZE = global i32 0
@.str.3 = [27 x i8] c"warning: add padding (%d)\0A\00"
define i32 @normalize_buffer(i8* %0, i8* %1, i64* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i64*
%8 = alloca i64
%9 = alloca i32
%10 = alloca i32
%11 = alloca i8
%12 = alloca i8
%13 = alloca i8*
%14 = alloca i8*
store i8* %0, i8** %5
store i8* %1, i8** %6
store i64* %2, i64** %7
%15 = load i8*, i8** %5
store i8* %15, i8** %13
%16 = load i8*, i8** %6
store i8* %16, i8** %14
%17 = load i8*, i8** %5
%18 = icmp ne i8* %17, null
br i1 %18, label %22, label %19
19: ; preds = %3
%20 = load i32, i32* @stderr
%21 = call i32 (i32, i8*, ...) @fprintf(i32 %20, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
store i32 15, i32* %4
br label %201
22: ; preds = %3
%23 = load i8*, i8** %5
%24 = call i64 @strlen(i8* %23)
store i64 %24, i64* %8
%25 = load i64, i64* %8
%26 = load i64*, i64** %7
%27 = load i64, i64* %26
%28 = mul i64 %27, 2
%29 = icmp ugt i64 %25, %28
br i1 %29, label %30, label %36
30: ; preds = %22
%31 = load i32, i32* @stderr
%32 = call i32 (i32, i8*, ...) @fprintf(i32 %31, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.1, i64 0, i64 0))
%33 = load i64*, i64** %7
%34 = load i64, i64* %33
%35 = mul i64 %34, 2
store i64 %35, i64* %8
br label %36
36: ; preds = %30, %22
%37 = load i64*, i64** %7
store i64 0, i64* %37
store i32 0, i32* %9
br label %38
38: ; preds = %104, %36
%39 = load i32, i32* %9
%40 = sext i32 %39 to i64
%41 = load i64, i64* %8
%42 = udiv i64 %41, 2
%43 = icmp ult i64 %40, %42
br i1 %43, label %44, label %111
44: ; preds = %38
%45 = load i8*, i8** %13
%46 = load i8, i8* %45
store i8 %46, i8* %12
%47 = load i8*, i8** %13
%48 = getelementptr inbounds i8, i8* %47, i64 1
%49 = load i8, i8* %48
store i8 %49, i8* %11
%50 = load i8, i8* %12
%51 = call i32 @isxdigit(i8 zeroext %50)
%52 = icmp ne i32 %51, 0
br i1 %52, label %58, label %53
53: ; preds = %44
%54 = load i32, i32* @stderr
%55 = load i8, i8* %12
%56 = zext i8 %55 to i32
%57 = call i32 (i32, i8*, ...) @fprintf(i32 %54, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.2, i64 0, i64 0), i32 %56)
store i32 15, i32* %4
br label %201
58: ; preds = %44
%59 = load i8, i8* %11
%60 = call i32 @isxdigit(i8 zeroext %59)
%61 = icmp ne i32 %60, 0
br i1 %61, label %67, label %62
62: ; preds = %58
%63 = load i32, i32* @stderr
%64 = load i8, i8* %11
%65 = zext i8 %64 to i32
%66 = call i32 (i32, i8*, ...) @fprintf(i32 %63, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.2, i64 0, i64 0), i32 %65)
store i32 15, i32* %4
br label %201
67: ; preds = %58
%68 = load i8, i8* %12
%69 = zext i8 %68 to i32
%70 = icmp slt i32 %69, 64
br i1 %70, label %71, label %76
71: ; preds = %67
%72 = load i8, i8* %12
%73 = zext i8 %72 to i32
%74 = sub nsw i32 %73, 48
%75 = trunc i32 %74 to i8
store i8 %75, i8* %12
br label %81
76: ; preds = %67
%77 = load i8, i8* %12
%78 = call i32 @toupper(i8 zeroext %77)
%79 = sub nsw i32 %78, 55
%80 = trunc i32 %79 to i8
store i8 %80, i8* %12
br label %81
81: ; preds = %76, %71
%82 = load i8, i8* %11
%83 = zext i8 %82 to i32
%84 = icmp slt i32 %83, 64
br i1 %84, label %85, label %90
85: ; preds = %81
%86 = load i8, i8* %11
%87 = zext i8 %86 to i32
%88 = sub nsw i32 %87, 48
%89 = trunc i32 %88 to i8
store i8 %89, i8* %11
br label %95
90: ; preds = %81
%91 = load i8, i8* %11
%92 = call i32 @toupper(i8 zeroext %91)
%93 = sub nsw i32 %92, 55
%94 = trunc i32 %93 to i8
store i8 %94, i8* %11
br label %95
95: ; preds = %90, %85
%96 = load i8, i8* %12
%97 = zext i8 %96 to i32
%98 = shl i32 %97, 4
%99 = load i8, i8* %11
%100 = zext i8 %99 to i32
%101 = or i32 %98, %100
%102 = trunc i32 %101 to i8
%103 = load i8*, i8** %14
store i8 %102, i8* %103
br label %104
104: ; preds = %95
%105 = load i32, i32* %9
%106 = add nsw i32 %105, 1
store i32 %106, i32* %9
%107 = load i8*, i8** %13
%108 = getelementptr inbounds i8, i8* %107, i64 2
store i8* %108, i8** %13
%109 = load i8*, i8** %14
%110 = getelementptr inbounds i8, i8* %109, i32 1
store i8* %110, i8** %14
br label %38
111: ; preds = %38
%112 = load i64, i64* %8
%113 = and i64 %112, 1
%114 = icmp ne i64 %113, 0
br i1 %114, label %115, label %148
115: ; preds = %111
%116 = load i8*, i8** %13
%117 = load i8, i8* %116
store i8 %117, i8* %12
%118 = load i8, i8* %12
%119 = call i32 @isxdigit(i8 zeroext %118)
%120 = icmp ne i32 %119, 0
br i1 %120, label %126, label %121
121: ; preds = %115
%122 = load i32, i32* @stderr
%123 = load i8, i8* %12
%124 = zext i8 %123 to i32
%125 = call i32 (i32, i8*, ...) @fprintf(i32 %122, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.2, i64 0, i64 0), i32 %124)
store i32 15, i32* %4
br label %201
126: ; preds = %115
%127 = load i8, i8* %12
%128 = zext i8 %127 to i32
%129 = icmp slt i32 %128, 64
br i1 %129, label %130, label %135
130: ; preds = %126
%131 = load i8, i8* %12
%132 = zext i8 %131 to i32
%133 = sub nsw i32 %132, 48
%134 = trunc i32 %133 to i8
store i8 %134, i8* %12
br label %140
135: ; preds = %126
%136 = load i8, i8* %12
%137 = call i32 @toupper(i8 zeroext %136)
%138 = sub nsw i32 %137, 55
%139 = trunc i32 %138 to i8
store i8 %139, i8* %12
br label %140
140: ; preds = %135, %130
%141 = load i8, i8* %12
%142 = zext i8 %141 to i32
%143 = shl i32 %142, 4
%144 = trunc i32 %143 to i8
%145 = load i8*, i8** %14
store i8 %144, i8* %145
%146 = load i8*, i8** %14
%147 = getelementptr inbounds i8, i8* %146, i32 1
store i8* %147, i8** %14
br label %148
148: ; preds = %140, %111
%149 = load i64, i64* %8
%150 = load i32, i32* @AES_BLOCK_SIZE
%151 = mul nsw i32 2, %150
%152 = sext i32 %151 to i64
%153 = udiv i64 %149, %152
%154 = load i32, i32* @AES_BLOCK_SIZE
%155 = sext i32 %154 to i64
%156 = mul i64 %153, %155
%157 = load i64*, i64** %7
store i64 %156, i64* %157
%158 = load i64, i64* %8
%159 = load i32, i32* @AES_BLOCK_SIZE
%160 = mul nsw i32 2, %159
%161 = sext i32 %160 to i64
%162 = urem i64 %158, %161
%163 = trunc i64 %162 to i32
store i32 %163, i32* %10
%164 = load i32, i32* %10
%165 = icmp sgt i32 %164, 0
br i1 %165, label %166, label %200
166: ; preds = %148
%167 = load i32, i32* @stderr
%168 = load i32, i32* @AES_BLOCK_SIZE
%169 = mul nsw i32 2, %168
%170 = load i32, i32* %10
%171 = sub nsw i32 %169, %170
%172 = call i32 (i32, i8*, ...) @fprintf(i32 %167, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i32 %171)
%173 = load i64, i64* %8
%174 = and i64 %173, 1
%175 = icmp ne i64 %174, 0
br i1 %175, label %176, label %179
176: ; preds = %166
%177 = load i32, i32* %10
%178 = add nsw i32 %177, 1
store i32 %178, i32* %10
br label %179
179: ; preds = %176, %166
store i32 0, i32* %9
br label %180
180: ; preds = %189, %179
%181 = load i32, i32* %9
%182 = load i32, i32* @AES_BLOCK_SIZE
%183 = load i32, i32* %10
%184 = sdiv i32 %183, 2
%185 = sub nsw i32 %182, %184
%186 = icmp slt i32 %181, %185
br i1 %186, label %187, label %194
187: ; preds = %180
%188 = load i8*, i8** %14
store i8 0, i8* %188
br label %189
189: ; preds = %187
%190 = load i32, i32* %9
%191 = add nsw i32 %190, 1
store i32 %191, i32* %9
%192 = load i8*, i8** %14
%193 = getelementptr inbounds i8, i8* %192, i32 1
store i8* %193, i8** %14
br label %180
194: ; preds = %180
%195 = load i32, i32* @AES_BLOCK_SIZE
%196 = sext i32 %195 to i64
%197 = load i64*, i64** %7
%198 = load i64, i64* %197
%199 = add i64 %198, %196
store i64 %199, i64* %197
br label %200
200: ; preds = %194, %148
store i32 0, i32* %4
br label %201
201: ; preds = %200, %121, %62, %53, %19
%202 = load i32, i32* %4
ret i32 %202
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [33 x i8] c"error: missing hexstring, abort\0A\00"
@.str.1 = [50 x i8] c"warning: input hexstring is too long, truncating\0A\00"
@.str.2 = [48 x i8] c"error: not a hexadecimal digit `0x%02x', abort\0A\00"
@AES_BLOCK_SIZE = global i32 0
@.str.3 = [27 x i8] c"warning: add padding (%d)\0A\00"
define i32 @normalize_buffer(i8* %0, i8* nocapture writeonly %1, i64* nocapture %2) {
%4 = icmp eq i8* %0, null
br i1 %4, label %5, label %8
5: ; preds = %3
%6 = load i32, i32* @stderr
%7 = tail call i32 (i32, i8*, ...) @fprintf(i32 %6, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
br label %130
8: ; preds = %3
%9 = tail call i64 @strlen(i8* %0)
%10 = load i64, i64* %2
%11 = shl i64 %10, 1
%12 = icmp ugt i64 %9, %11
br i1 %12, label %13, label %18
13: ; preds = %8
%14 = load i32, i32* @stderr
%15 = tail call i32 (i32, i8*, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.1, i64 0, i64 0))
%16 = load i64, i64* %2
%17 = shl i64 %16, 1
br label %18
18: ; preds = %13, %8
%19 = phi i64 [ %17, %13 ], [ %9, %8 ]
store i64 0, i64* %2
%20 = icmp ult i64 %19, 2
br i1 %20, label %69, label %21
21: ; preds = %18
%22 = lshr i64 %19, 1
br label %23
23: ; preds = %21, %60
%24 = phi i64 [ 0, %21 ], [ %65, %60 ]
%25 = phi i8* [ %1, %21 ], [ %67, %60 ]
%26 = phi i8* [ %0, %21 ], [ %66, %60 ]
%27 = load i8, i8* %26
%28 = getelementptr inbounds i8, i8* %26, i64 1
%29 = load i8, i8* %28
%30 = tail call i32 @isxdigit(i8 zeroext %27)
%31 = icmp eq i32 %30, 0
br i1 %31, label %32, label %36
32: ; preds = %23
%33 = load i32, i32* @stderr
%34 = zext i8 %27 to i32
%35 = tail call i32 (i32, i8*, ...) @fprintf(i32 %33, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.2, i64 0, i64 0), i32 %34)
br label %130
36: ; preds = %23
%37 = tail call i32 @isxdigit(i8 zeroext %29)
%38 = icmp eq i32 %37, 0
br i1 %38, label %39, label %43
39: ; preds = %36
%40 = load i32, i32* @stderr
%41 = zext i8 %29 to i32
%42 = tail call i32 (i32, i8*, ...) @fprintf(i32 %40, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.2, i64 0, i64 0), i32 %41)
br label %130
43: ; preds = %36
%44 = icmp ult i8 %27, 64
br i1 %44, label %45, label %48
45: ; preds = %43
%46 = zext i8 %27 to i32
%47 = add nsw i32 %46, -48
br label %51
48: ; preds = %43
%49 = tail call i32 @toupper(i8 zeroext %27)
%50 = add i32 %49, 201
br label %51
51: ; preds = %48, %45
%52 = phi i32 [ %47, %45 ], [ %50, %48 ]
%53 = icmp ult i8 %29, 64
br i1 %53, label %54, label %57
54: ; preds = %51
%55 = zext i8 %29 to i32
%56 = add nsw i32 %55, -48
br label %60
57: ; preds = %51
%58 = tail call i32 @toupper(i8 zeroext %29)
%59 = add i32 %58, 201
br label %60
60: ; preds = %57, %54
%61 = phi i32 [ %56, %54 ], [ %59, %57 ]
%62 = shl i32 %52, 4
%63 = or i32 %61, %62
%64 = trunc i32 %63 to i8
store i8 %64, i8* %25
%65 = add nuw nsw i64 %24, 1
%66 = getelementptr inbounds i8, i8* %26, i64 2
%67 = getelementptr inbounds i8, i8* %25, i64 1
%68 = icmp eq i64 %65, %22
br i1 %68, label %69, label %23
69: ; preds = %60, %18
%70 = phi i8* [ %0, %18 ], [ %66, %60 ]
%71 = phi i8* [ %1, %18 ], [ %67, %60 ]
%72 = and i64 %19, 1
%73 = icmp eq i64 %72, 0
br i1 %73, label %95, label %74
74: ; preds = %69
%75 = load i8, i8* %70
%76 = tail call i32 @isxdigit(i8 zeroext %75)
%77 = icmp eq i32 %76, 0
br i1 %77, label %78, label %82
78: ; preds = %74
%79 = load i32, i32* @stderr
%80 = zext i8 %75 to i32
%81 = tail call i32 (i32, i8*, ...) @fprintf(i32 %79, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.2, i64 0, i64 0), i32 %80)
br label %130
82: ; preds = %74
%83 = icmp ult i8 %75, 64
br i1 %83, label %84, label %87
84: ; preds = %82
%85 = zext i8 %75 to i32
%86 = add nsw i32 %85, -48
br label %90
87: ; preds = %82
%88 = tail call i32 @toupper(i8 zeroext %75)
%89 = add i32 %88, 201
br label %90
90: ; preds = %87, %84
%91 = phi i32 [ %86, %84 ], [ %89, %87 ]
%92 = trunc i32 %91 to i8
%93 = shl i8 %92, 4
store i8 %93, i8* %71
%94 = getelementptr inbounds i8, i8* %71, i64 1
br label %95
95: ; preds = %90, %69
%96 = phi i8* [ %94, %90 ], [ %71, %69 ]
%97 = load i32, i32* @AES_BLOCK_SIZE
%98 = shl nsw i32 %97, 1
%99 = sext i32 %98 to i64
%100 = udiv i64 %19, %99
%101 = sext i32 %97 to i64
%102 = mul i64 %100, %101
store i64 %102, i64* %2
%103 = urem i64 %19, %99
%104 = trunc i64 %103 to i32
%105 = icmp sgt i32 %104, 0
br i1 %105, label %106, label %130
106: ; preds = %95
%107 = load i32, i32* @stderr
%108 = sub nsw i32 %98, %104
%109 = tail call i32 (i32, i8*, ...) @fprintf(i32 %107, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i32 %108)
%110 = xor i1 %73, true
%111 = zext i1 %110 to i32
%112 = add nuw nsw i32 %104, %111
%113 = lshr i32 %112, 1
%114 = load i32, i32* @AES_BLOCK_SIZE
%115 = sub i32 %114, %113
%116 = icmp sgt i32 %115, 0
br i1 %116, label %117, label %125
117: ; preds = %106, %117
%118 = phi i8* [ %121, %117 ], [ %96, %106 ]
%119 = phi i32 [ %120, %117 ], [ 0, %106 ]
store i8 0, i8* %118
%120 = add nuw nsw i32 %119, 1
%121 = getelementptr inbounds i8, i8* %118, i64 1
%122 = load i32, i32* @AES_BLOCK_SIZE
%123 = sub i32 %122, %113
%124 = icmp slt i32 %120, %123
br i1 %124, label %117, label %125
125: ; preds = %117, %106
%126 = phi i32 [ %114, %106 ], [ %122, %117 ]
%127 = sext i32 %126 to i64
%128 = load i64, i64* %2
%129 = add i64 %128, %127
store i64 %129, i64* %2
br label %130
130: ; preds = %95, %125, %78, %39, %32, %5
%131 = phi i32 [ 15, %39 ], [ 15, %32 ], [ 15, %78 ], [ 15, %5 ], [ 0, %125 ], [ 0, %95 ]
ret i32 %131
}