#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 */
typedef struct TYPE_2__ TYPE_1__;

/* Type definitions */
struct TYPE_2__ {
  scalar_t__ h;
};
typedef TYPE_1__ SHA512_CTX;
typedef int /*<<< orphan*/ EVP_MD_CTX;
typedef int /*<<< orphan*/ EVP_MD;

/* Variables and functions */
int /*<<< orphan*/ EVP_DigestUpdate(int /*<<< orphan*/ *, unsigned char *, int);
int /*<<< orphan*/ *EVP_MD_CTX_md(int /*<<< orphan*/ *);
scalar_t__ EVP_MD_CTX_md_data(int /*<<< orphan*/ *);
int EVP_MD_block_size(int /*<<< orphan*/ const *);
int EVP_MD_size(int /*<<< orphan*/ const *);
int /*<<< orphan*/ htole64(int);
char *malloc(int);
int /*<<< orphan*/ memset(unsigned char *, char, int);
int /*<<< orphan*/ sprintf(char *, char *, int /*<<< orphan*/);
unsigned char strntoul(char *, int, int);
char *sha1_extend(EVP_MD_CTX *mdctx, char *signature, int length) {
  const EVP_MD *md = EVP_MD_CTX_md(mdctx);
  int length_modulo = EVP_MD_block_size(md);
  int length_bytes = length_modulo / 8;
  int trunc_length = length % length_modulo;
  int padding = ((trunc_length) < (length_modulo - length_bytes))
                    ? ((length_modulo - length_bytes) - trunc_length)
                    : ((2 * length_modulo - length_bytes) - trunc_length);
  unsigned char data[length + padding + length_bytes];
  memset(data, 'A', length + padding + length_bytes);
  EVP_DigestUpdate(mdctx, data, length + padding + length_bytes);
  unsigned char *h_data =
      (unsigned char *)((SHA512_CTX *)EVP_MD_CTX_md_data(mdctx))->h;
  int h_data_size = EVP_MD_size(md);
  int sha_switch = length_modulo / 16;
  int i = 0, j = 0;
  while (i < h_data_size) {
    for (j = 0; j < sha_switch; j++) {
      h_data[i + j] = strntoul(signature + 2 * (i + sha_switch - 1 - j), 2, 16);
    }
    i += sha_switch;
  }
  char *output = malloc((2 * (padding + length_bytes) + 1) * sizeof(char));
  output[0] = '8';
  output[1] = '0';
  for (i = 1; i < 2 * (padding + length_bytes); i++)
    output[i] = '0';
  if (length_modulo == 128)
    sprintf(output + 2 * padding, "%032lu", htole64(8 * length));
  else
    sprintf(output + 2 * padding, "%016lu", htole64(8 * length));
  output[2 * (padding + length_bytes)] = 0;
  return output;
}


x86 assembly (clang, -O0):
<sha1_extend>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
call   1090 <EVP_MD_CTX_md@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   10c0 <EVP_MD_block_size@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    %eax,-0x28(%rbp)
mov    -0x14(%rbp),%eax
cltd
idivl  -0x24(%rbp)
mov    %edx,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    -0x24(%rbp),%ecx
sub    -0x28(%rbp),%ecx
cmp    %ecx,%eax
jge    1209 <sha1_extend+0x69>
mov    -0x24(%rbp),%eax
sub    -0x28(%rbp),%eax
sub    -0x2c(%rbp),%eax
mov    %eax,-0x64(%rbp)
jmp    1218 <sha1_extend+0x78>
mov    -0x24(%rbp),%eax
shl    $0x1,%eax
sub    -0x28(%rbp),%eax
sub    -0x2c(%rbp),%eax
mov    %eax,-0x64(%rbp)
mov    -0x64(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x14(%rbp),%eax
mov    -0x30(%rbp),%ecx
add    %ecx,%eax
mov    -0x28(%rbp),%ecx
add    %ecx,%eax
mov    %rsp,%rcx
mov    %rcx,-0x38(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x70(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x40(%rbp)
mov    -0x14(%rbp),%edx
add    -0x30(%rbp),%edx
add    -0x28(%rbp),%edx
mov    $0x41,%esi
call   1060 <memset@plt>
mov    -0x70(%rbp),%rsi
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%edx
add    -0x30(%rbp),%edx
add    -0x28(%rbp),%edx
call   1070 <EVP_DigestUpdate@plt>
mov    -0x8(%rbp),%rdi
call   1030 <EVP_MD_CTX_md_data@plt>
mov    (%rax),%rax
mov    %rax,-0x48(%rbp)
mov    -0x20(%rbp),%rdi
call   1040 <EVP_MD_size@plt>
mov    %eax,-0x4c(%rbp)
mov    -0x24(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
mov    %eax,-0x50(%rbp)
movl   $0x0,-0x54(%rbp)
movl   $0x0,-0x58(%rbp)
mov    -0x54(%rbp),%eax
cmp    -0x4c(%rbp),%eax
jge    1323 <sha1_extend+0x183>
movl   $0x0,-0x58(%rbp)
mov    -0x58(%rbp),%eax
cmp    -0x50(%rbp),%eax
jge    1315 <sha1_extend+0x175>
mov    -0x10(%rbp),%rdi
mov    -0x54(%rbp),%eax
add    -0x50(%rbp),%eax
sub    $0x1,%eax
sub    -0x58(%rbp),%eax
shl    $0x1,%eax
cltq
add    %rax,%rdi
mov    $0x2,%esi
mov    $0x10,%edx
call   1050 <strntoul@plt>
mov    %al,%dl
mov    -0x48(%rbp),%rax
mov    -0x54(%rbp),%ecx
add    -0x58(%rbp),%ecx
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x58(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x58(%rbp)
jmp    12c2 <sha1_extend+0x122>
mov    -0x50(%rbp),%eax
add    -0x54(%rbp),%eax
mov    %eax,-0x54(%rbp)
jmp    12af <sha1_extend+0x10f>
mov    -0x30(%rbp),%eax
add    -0x28(%rbp),%eax
shl    $0x1,%eax
add    $0x1,%eax
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   1080 <malloc@plt>
mov    %rax,-0x60(%rbp)
mov    -0x60(%rbp),%rax
movb   $0x38,(%rax)
mov    -0x60(%rbp),%rax
movb   $0x30,0x1(%rax)
movl   $0x1,-0x54(%rbp)
mov    -0x54(%rbp),%eax
mov    -0x30(%rbp),%ecx
add    -0x28(%rbp),%ecx
shl    $0x1,%ecx
cmp    %ecx,%eax
jge    1384 <sha1_extend+0x1e4>
mov    -0x60(%rbp),%rax
movslq -0x54(%rbp),%rcx
movb   $0x30,(%rax,%rcx,1)
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    1356 <sha1_extend+0x1b6>
cmpl   $0x80,-0x24(%rbp)
jne    13c7 <sha1_extend+0x227>
mov    -0x60(%rbp),%rax
mov    -0x30(%rbp),%ecx
shl    $0x1,%ecx
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x78(%rbp)
mov    -0x14(%rbp),%edi
shl    $0x3,%edi
call   10b0 <htole64@plt>
mov    -0x78(%rbp),%rdi
mov    %eax,%edx
lea    0xc43(%rip),%rsi
call   10a0 <sprintf@plt>
jmp    13f8 <sha1_extend+0x258>
mov    -0x60(%rbp),%rax
mov    -0x30(%rbp),%ecx
shl    $0x1,%ecx
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x80(%rbp)
mov    -0x14(%rbp),%edi
shl    $0x3,%edi
call   10b0 <htole64@plt>
mov    -0x80(%rbp),%rdi
mov    %eax,%edx
lea    0xc14(%rip),%rsi
call   10a0 <sprintf@plt>
mov    -0x60(%rbp),%rax
mov    -0x30(%rbp),%ecx
add    -0x28(%rbp),%ecx
shl    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x60(%rbp),%rax
mov    -0x38(%rbp),%rcx
mov    %rcx,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sha1_extend>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %edx,%ebx
mov    %rsi,%r13
mov    %rdi,-0x38(%rbp)
call   1090 <EVP_MD_CTX_md@plt>
mov    %rax,-0x30(%rbp)
mov    %rax,%rdi
call   10c0 <EVP_MD_block_size@plt>
mov    %eax,%ecx
lea    0x7(%rcx),%edi
lea    0xf(%rcx),%r15d
test   %eax,%eax
cmovns %eax,%edi
cmovns %eax,%r15d
sar    $0x3,%edi
mov    %ebx,%eax
cltd
idiv   %ecx
mov    %ecx,%esi
sub    %edi,%esi
mov    %rcx,-0x48(%rbp)
lea    (%rcx,%rcx,1),%eax
sub    %edi,%eax
sub    %edx,%eax
sub    %edx,%esi
cmovle %eax,%esi
mov    %esi,-0x3c(%rbp)
add    %esi,%edi
mov    %rbx,-0x58(%rbp)
mov    %rdi,-0x50(%rbp)
lea    (%rdi,%rbx,1),%r14d
lea    0xf(%r14),%rax
and    $0xfffffffffffffff0,%rax
mov    %rsp,%r12
sub    %rax,%r12
mov    %r12,%rsp
mov    %r12,%rdi
mov    $0x41,%esi
mov    %r14d,%edx
call   1060 <memset@plt>
mov    -0x38(%rbp),%rbx
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %r14d,%edx
call   1070 <EVP_DigestUpdate@plt>
mov    %rbx,%rdi
call   1030 <EVP_MD_CTX_md_data@plt>
mov    (%rax),%rbx
mov    -0x30(%rbp),%rdi
call   1040 <EVP_MD_size@plt>
test   %eax,%eax
jle    12d9 <sha1_extend+0x139>
sar    $0x4,%r15d
movslq %r15d,%rcx
mov    %eax,%eax
mov    %rax,-0x60(%rbp)
mov    %ecx,%r15d
lea    (%rcx,%rcx,1),%eax
mov    %eax,-0x40(%rbp)
lea    (%rcx,%rcx,1),%eax
add    $0xfffffffe,%eax
mov    %eax,-0x30(%rbp)
xor    %eax,%eax
mov    %rcx,-0x68(%rbp)
jmp    129a <sha1_extend+0xfa>
mov    -0x30(%rbp),%eax
add    -0x40(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x68(%rbp),%rcx
add    %rcx,%rbx
mov    -0x38(%rbp),%rax
cmp    -0x60(%rbp),%rax
jge    12d9 <sha1_extend+0x139>
add    %rcx,%rax
mov    %rax,-0x38(%rbp)
cmpl   $0x10,-0x48(%rbp)
jl     1280 <sha1_extend+0xe0>
mov    -0x30(%rbp),%eax
mov    %eax,%r14d
xor    %r12d,%r12d
movslq %r14d,%r14
lea    (%r14,%r13,1),%rdi
mov    $0x2,%esi
mov    $0x10,%edx
call   1050 <strntoul@plt>
mov    %al,(%rbx,%r12,1)
add    $0x1,%r12
add    $0xfffffffe,%r14d
cmp    %r12,%r15
jne    12b0 <sha1_extend+0x110>
jmp    1280 <sha1_extend+0xe0>
movslq -0x50(%rbp),%rbx
lea    (%rbx,%rbx,1),%r15
lea    0x1(%r15),%edi
call   1080 <malloc@plt>
mov    %rax,%r14
movw   $0x3038,(%rax)
test   %ebx,%ebx
jle    1317 <sha1_extend+0x177>
lea    0x1(%r14),%rdi
cmp    $0x3,%r15d
mov    $0x2,%edx
cmovge %r15d,%edx
add    $0xfffffffe,%edx
or     $0x1,%edx
mov    $0x30,%esi
call   1060 <memset@plt>
mov    -0x3c(%rbp),%eax
add    %eax,%eax
cltq
mov    %r14,%rbx
add    %rax,%rbx
mov    -0x58(%rbp),%rdi
shl    $0x3,%edi
call   10b0 <htole64@plt>
cmpl   $0x80,-0x48(%rbp)
lea    0xcc2(%rip),%rcx
lea    0xcc2(%rip),%rsi
cmove  %rcx,%rsi
mov    %rbx,%rdi
mov    %eax,%edx
call   10a0 <sprintf@plt>
movb   $0x0,(%r14,%r15,1)
mov    %r14,%rax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.TYPE_2__ = type { i64 }
@.str = [7 x i8] c"%032lu\00"
@.str.1 = [7 x i8] c"%016lu\00"
define i8* @sha1_extend(i32* %0, i8* %1, i32 %2) {
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i8*
%13 = alloca i64
%14 = alloca i8*
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i8*
store i32* %0, i32** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%20 = load i32*, i32** %4
%21 = call i32* @EVP_MD_CTX_md(i32* %20)
store i32* %21, i32** %7
%22 = load i32*, i32** %7
%23 = call i32 @EVP_MD_block_size(i32* %22)
store i32 %23, i32* %8
%24 = load i32, i32* %8
%25 = sdiv i32 %24, 8
store i32 %25, i32* %9
%26 = load i32, i32* %6
%27 = load i32, i32* %8
%28 = srem i32 %26, %27
store i32 %28, i32* %10
%29 = load i32, i32* %10
%30 = load i32, i32* %8
%31 = load i32, i32* %9
%32 = sub nsw i32 %30, %31
%33 = icmp slt i32 %29, %32
br i1 %33, label %34, label %40
34: ; preds = %3
%35 = load i32, i32* %8
%36 = load i32, i32* %9
%37 = sub nsw i32 %35, %36
%38 = load i32, i32* %10
%39 = sub nsw i32 %37, %38
br label %47
40: ; preds = %3
%41 = load i32, i32* %8
%42 = mul nsw i32 2, %41
%43 = load i32, i32* %9
%44 = sub nsw i32 %42, %43
%45 = load i32, i32* %10
%46 = sub nsw i32 %44, %45
br label %47
47: ; preds = %40, %34
%48 = phi i32 [ %39, %34 ], [ %46, %40 ]
store i32 %48, i32* %11
%49 = load i32, i32* %6
%50 = load i32, i32* %11
%51 = add nsw i32 %49, %50
%52 = load i32, i32* %9
%53 = add nsw i32 %51, %52
%54 = zext i32 %53 to i64
%55 = call i8* @llvm.stacksave()
store i8* %55, i8** %12
%56 = alloca i8, i64 %54
store i64 %54, i64* %13
%57 = load i32, i32* %6
%58 = load i32, i32* %11
%59 = add nsw i32 %57, %58
%60 = load i32, i32* %9
%61 = add nsw i32 %59, %60
%62 = call i32 @memset(i8* %56, i8 signext 65, i32 %61)
%63 = load i32*, i32** %4
%64 = load i32, i32* %6
%65 = load i32, i32* %11
%66 = add nsw i32 %64, %65
%67 = load i32, i32* %9
%68 = add nsw i32 %66, %67
%69 = call i32 @EVP_DigestUpdate(i32* %63, i8* %56, i32 %68)
%70 = load i32*, i32** %4
%71 = call i64 @EVP_MD_CTX_md_data(i32* %70)
%72 = inttoptr i64 %71 to %struct.TYPE_2__*
%73 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %72, i32 0, i32 0
%74 = load i64, i64* %73
%75 = inttoptr i64 %74 to i8*
store i8* %75, i8** %14
%76 = load i32*, i32** %7
%77 = call i32 @EVP_MD_size(i32* %76)
store i32 %77, i32* %15
%78 = load i32, i32* %8
%79 = sdiv i32 %78, 16
store i32 %79, i32* %16
store i32 0, i32* %17
store i32 0, i32* %18
br label %80
80: ; preds = %110, %47
%81 = load i32, i32* %17
%82 = load i32, i32* %15
%83 = icmp slt i32 %81, %82
br i1 %83, label %84, label %114
84: ; preds = %80
store i32 0, i32* %18
br label %85
85: ; preds = %107, %84
%86 = load i32, i32* %18
%87 = load i32, i32* %16
%88 = icmp slt i32 %86, %87
br i1 %88, label %89, label %110
89: ; preds = %85
%90 = load i8*, i8** %5
%91 = load i32, i32* %17
%92 = load i32, i32* %16
%93 = add nsw i32 %91, %92
%94 = sub nsw i32 %93, 1
%95 = load i32, i32* %18
%96 = sub nsw i32 %94, %95
%97 = mul nsw i32 2, %96
%98 = sext i32 %97 to i64
%99 = getelementptr inbounds i8, i8* %90, i64 %98
%100 = call zeroext i8 @strntoul(i8* %99, i32 2, i32 16)
%101 = load i8*, i8** %14
%102 = load i32, i32* %17
%103 = load i32, i32* %18
%104 = add nsw i32 %102, %103
%105 = sext i32 %104 to i64
%106 = getelementptr inbounds i8, i8* %101, i64 %105
store i8 %100, i8* %106
br label %107
107: ; preds = %89
%108 = load i32, i32* %18
%109 = add nsw i32 %108, 1
store i32 %109, i32* %18
br label %85
110: ; preds = %85
%111 = load i32, i32* %16
%112 = load i32, i32* %17
%113 = add nsw i32 %112, %111
store i32 %113, i32* %17
br label %80
114: ; preds = %80
%115 = load i32, i32* %11
%116 = load i32, i32* %9
%117 = add nsw i32 %115, %116
%118 = mul nsw i32 2, %117
%119 = add nsw i32 %118, 1
%120 = sext i32 %119 to i64
%121 = mul i64 %120, 1
%122 = trunc i64 %121 to i32
%123 = call i8* @malloc(i32 %122)
store i8* %123, i8** %19
%124 = load i8*, i8** %19
%125 = getelementptr inbounds i8, i8* %124, i64 0
store i8 56, i8* %125
%126 = load i8*, i8** %19
%127 = getelementptr inbounds i8, i8* %126, i64 1
store i8 48, i8* %127
store i32 1, i32* %17
br label %128
128: ; preds = %140, %114
%129 = load i32, i32* %17
%130 = load i32, i32* %11
%131 = load i32, i32* %9
%132 = add nsw i32 %130, %131
%133 = mul nsw i32 2, %132
%134 = icmp slt i32 %129, %133
br i1 %134, label %135, label %143
135: ; preds = %128
%136 = load i8*, i8** %19
%137 = load i32, i32* %17
%138 = sext i32 %137 to i64
%139 = getelementptr inbounds i8, i8* %136, i64 %138
store i8 48, i8* %139
br label %140
140: ; preds = %135
%141 = load i32, i32* %17
%142 = add nsw i32 %141, 1
store i32 %142, i32* %17
br label %128
143: ; preds = %128
%144 = load i32, i32* %8
%145 = icmp eq i32 %144, 128
br i1 %145, label %146, label %156
146: ; preds = %143
%147 = load i8*, i8** %19
%148 = load i32, i32* %11
%149 = mul nsw i32 2, %148
%150 = sext i32 %149 to i64
%151 = getelementptr inbounds i8, i8* %147, i64 %150
%152 = load i32, i32* %6
%153 = mul nsw i32 8, %152
%154 = call i32 @htole64(i32 %153)
%155 = call i32 @sprintf(i8* %151, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %154)
br label %166
156: ; preds = %143
%157 = load i8*, i8** %19
%158 = load i32, i32* %11
%159 = mul nsw i32 2, %158
%160 = sext i32 %159 to i64
%161 = getelementptr inbounds i8, i8* %157, i64 %160
%162 = load i32, i32* %6
%163 = mul nsw i32 8, %162
%164 = call i32 @htole64(i32 %163)
%165 = call i32 @sprintf(i8* %161, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %164)
br label %166
166: ; preds = %156, %146
%167 = load i8*, i8** %19
%168 = load i32, i32* %11
%169 = load i32, i32* %9
%170 = add nsw i32 %168, %169
%171 = mul nsw i32 2, %170
%172 = sext i32 %171 to i64
%173 = getelementptr inbounds i8, i8* %167, i64 %172
store i8 0, i8* %173
%174 = load i8*, i8** %19
%175 = load i8*, i8** %12
ret i8* %174
}

LLVM IR (-O2):
%struct.TYPE_2__ = type { i64 }
@.str = [7 x i8] c"%032lu\00"
@.str.1 = [7 x i8] c"%016lu\00"
define noalias i8* @sha1_extend(i32* %0, i8* %1, i32 %2) {
%4 = tail call i32* @EVP_MD_CTX_md(i32* %0)
%5 = tail call i32 @EVP_MD_block_size(i32* %4)
%6 = sdiv i32 %5, 8
%7 = srem i32 %2, %5
%8 = sub nsw i32 %5, %6
%9 = icmp sgt i32 %8, %7
%10 = sub nsw i32 %8, %7
%11 = shl nsw i32 %5, 1
%12 = add i32 %6, %7
%13 = sub i32 %11, %12
%14 = select i1 %9, i32 %10, i32 %13
%15 = add i32 %14, %6
%16 = add i32 %15, %2
%17 = zext i32 %16 to i64
%18 = alloca i8, i64 %17
%19 = call i32 @memset(i8* %18, i8 signext 65, i32 %16)
%20 = call i32 @EVP_DigestUpdate(i32* %0, i8* %18, i32 %16)
%21 = call i64 @EVP_MD_CTX_md_data(i32* %0)
%22 = inttoptr i64 %21 to %struct.TYPE_2__*
%23 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %22, i64 0, i32 0
%24 = load i64, i64* %23
%25 = inttoptr i64 %24 to i8*
%26 = call i32 @EVP_MD_size(i32* %4)
%27 = sdiv i32 %5, 16
%28 = icmp sgt i32 %26, 0
br i1 %28, label %29, label %54
29: ; preds = %3
%30 = icmp sgt i32 %5, 15
%31 = sext i32 %27 to i64
%32 = zext i32 %26 to i64
%33 = zext i32 %27 to i64
br label %34
34: ; preds = %29, %52
%35 = phi i64 [ 0, %29 ], [ %36, %52 ]
%36 = add i64 %35, %31
br i1 %30, label %37, label %52
37: ; preds = %34
%38 = trunc i64 %36 to i32
br label %39
39: ; preds = %37, %39
%40 = phi i64 [ 0, %37 ], [ %50, %39 ]
%41 = trunc i64 %40 to i32
%42 = xor i32 %41, -1
%43 = add i32 %38, %42
%44 = shl nsw i32 %43, 1
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds i8, i8* %1, i64 %45
%47 = call zeroext i8 @strntoul(i8* %46, i32 2, i32 16)
%48 = add nsw i64 %40, %35
%49 = getelementptr inbounds i8, i8* %25, i64 %48
store i8 %47, i8* %49
%50 = add nuw nsw i64 %40, 1
%51 = icmp eq i64 %50, %33
br i1 %51, label %52, label %39
52: ; preds = %39, %34
%53 = icmp slt i64 %36, %32
br i1 %53, label %34, label %54
54: ; preds = %52, %3
%55 = shl nsw i32 %15, 1
%56 = or i32 %55, 1
%57 = call i8* @malloc(i32 %56)
store i8 56, i8* %57
%58 = getelementptr i8, i8* %57, i64 1
store i8 48, i8* %58
%59 = icmp sgt i32 %15, 0
br i1 %59, label %60, label %65
60: ; preds = %54
%61 = call i32 @llvm.smax.i32(i32 %55, i32 2)
%62 = add nsw i32 %61, -2
%63 = or i32 %62, 1
%64 = zext i32 %63 to i64
br label %65
65: ; preds = %60, %54
%66 = icmp eq i32 %5, 128
%67 = shl nsw i32 %14, 1
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds i8, i8* %57, i64 %68
%70 = shl nsw i32 %2, 3
%71 = call i32 @htole64(i32 %70)
%72 = select i1 %66, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0)
%73 = call i32 @sprintf(i8* %69, i8* dereferenceable(1) %72, i32 %71)
%74 = sext i32 %55 to i64
%75 = getelementptr inbounds i8, i8* %57, i64 %74
store i8 0, i8* %75
ret i8* %57
}