#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 */
typedef int /*<<< orphan*/ tmp;
typedef int /*<<< orphan*/ h_i;

/* Variables and functions */
int /*<<< orphan*/ md5_hmac(unsigned char *, int, unsigned char *, int,
                            unsigned char *);
int /*<<< orphan*/ memcpy(unsigned char *, ...);
int /*<<< orphan*/ memset(unsigned char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ sha1_hmac(unsigned char *, int, unsigned char *, int,
                             unsigned char *);
int strlen(char *);
int tls1_prf(unsigned char *secret, int slen, char *label,
             unsigned char *random, int rlen, unsigned char *dstbuf, int dlen) {
  int nb, hs;
  int i, j, k;
  unsigned char *S1, *S2;
  unsigned char tmp[128];
  unsigned char h_i[20];
  if (sizeof(tmp) < 20 + strlen(label) + rlen)
    return (-0x1800);
  hs = (slen + 1) / 2;
  S1 = secret;
  S2 = secret + slen - hs;
  nb = strlen(label);
  memcpy(tmp + 20, label, nb);
  memcpy(tmp + 20 + nb, random, rlen);
  nb += rlen;
  md5_hmac(S1, hs, tmp + 20, nb, 4 + tmp);
  for (i = 0; i < dlen; i += 16) {
    md5_hmac(S1, hs, 4 + tmp, 16 + nb, h_i);
    md5_hmac(S1, hs, 4 + tmp, 16, 4 + tmp);
    k = (i + 16 > dlen) ? dlen % 16 : 16;
    for (j = 0; j < k; j++)
      dstbuf[i + j] = h_i[j];
  }
  sha1_hmac(S2, hs, tmp + 20, nb, tmp);
  for (i = 0; i < dlen; i += 20) {
    sha1_hmac(S2, hs, tmp, 20 + nb, h_i);
    sha1_hmac(S2, hs, tmp, 20, tmp);
    k = (i + 20 > dlen) ? dlen % 20 : 20;
    for (j = 0; j < k; j++)
      dstbuf[i + j] = (unsigned char)(dstbuf[i + j] ^ h_i[j]);
  }
  memset(tmp, 0, sizeof(tmp));
  memset(h_i, 0, sizeof(h_i));
  return (0);
}


x86 assembly (clang, -O0):
<tls1_prf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x110,%rsp
mov    0x10(%rbp),%eax
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8d,-0x2c(%rbp)
mov    %r9,-0x38(%rbp)
mov    -0x20(%rbp),%rdi
call   1040 <strlen@plt>
add    $0x14,%eax
add    -0x2c(%rbp),%eax
movslq %eax,%rcx
mov    $0x80,%eax
cmp    %rcx,%rax
jae    11a1 <tls1_prf+0x51>
movl   $0xffffe800,-0x4(%rbp)
jmp    1476 <tls1_prf+0x326>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x40(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
add    %rcx,%rax
movslq -0x40(%rbp),%rdx
xor    %ecx,%ecx
sub    %rdx,%rcx
add    %rcx,%rax
mov    %rax,-0x60(%rbp)
mov    -0x20(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x3c(%rbp)
lea    -0xe0(%rbp),%rdi
add    $0x14,%rdi
mov    -0x20(%rbp),%rsi
mov    -0x3c(%rbp),%edx
xor    %eax,%eax
call   1060 <memcpy@plt>
lea    -0xe0(%rbp),%rdi
add    $0x14,%rdi
movslq -0x3c(%rbp),%rax
add    %rax,%rdi
mov    -0x28(%rbp),%rsi
mov    -0x2c(%rbp),%edx
xor    %eax,%eax
call   1060 <memcpy@plt>
mov    -0x2c(%rbp),%eax
add    -0x3c(%rbp),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x58(%rbp),%rdi
mov    -0x40(%rbp),%esi
lea    -0xe0(%rbp),%rdx
add    $0x14,%rdx
mov    -0x3c(%rbp),%ecx
lea    -0xe0(%rbp),%r8
add    $0x4,%r8
call   1030 <md5_hmac@plt>
movl   $0x0,-0x44(%rbp)
mov    -0x44(%rbp),%eax
cmp    0x10(%rbp),%eax
jge    1333 <tls1_prf+0x1e3>
mov    -0x58(%rbp),%rdi
mov    -0x40(%rbp),%esi
lea    -0xe0(%rbp),%rdx
add    $0x4,%rdx
mov    -0x3c(%rbp),%ecx
add    $0x10,%ecx
lea    -0x100(%rbp),%r8
call   1030 <md5_hmac@plt>
mov    -0x58(%rbp),%rdi
mov    -0x40(%rbp),%esi
lea    -0xe0(%rbp),%rdx
add    $0x4,%rdx
lea    -0xe0(%rbp),%r8
add    $0x4,%r8
mov    $0x10,%ecx
call   1030 <md5_hmac@plt>
mov    -0x44(%rbp),%eax
add    $0x10,%eax
cmp    0x10(%rbp),%eax
jle    12cb <tls1_prf+0x17b>
mov    0x10(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
mov    %edx,-0x104(%rbp)
jmp    12db <tls1_prf+0x18b>
mov    $0x10,%eax
mov    %eax,-0x104(%rbp)
jmp    12db <tls1_prf+0x18b>
mov    -0x104(%rbp),%eax
mov    %eax,-0x4c(%rbp)
movl   $0x0,-0x48(%rbp)
mov    -0x48(%rbp),%eax
cmp    -0x4c(%rbp),%eax
jge    1320 <tls1_prf+0x1d0>
movslq -0x48(%rbp),%rax
mov    -0x100(%rbp,%rax,1),%dl
mov    -0x38(%rbp),%rax
mov    -0x44(%rbp),%ecx
add    -0x48(%rbp),%ecx
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x48(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x48(%rbp)
jmp    12eb <tls1_prf+0x19b>
jmp    1325 <tls1_prf+0x1d5>
mov    -0x44(%rbp),%eax
add    $0x10,%eax
mov    %eax,-0x44(%rbp)
jmp    124f <tls1_prf+0xff>
mov    -0x60(%rbp),%rdi
mov    -0x40(%rbp),%esi
lea    -0xe0(%rbp),%rdx
add    $0x14,%rdx
mov    -0x3c(%rbp),%ecx
lea    -0xe0(%rbp),%r8
call   1070 <sha1_hmac@plt>
movl   $0x0,-0x44(%rbp)
mov    -0x44(%rbp),%eax
cmp    0x10(%rbp),%eax
jge    1449 <tls1_prf+0x2f9>
mov    -0x60(%rbp),%rdi
mov    -0x40(%rbp),%esi
lea    -0xe0(%rbp),%rdx
mov    -0x3c(%rbp),%ecx
add    $0x14,%ecx
lea    -0x100(%rbp),%r8
call   1070 <sha1_hmac@plt>
mov    -0x60(%rbp),%rdi
mov    -0x40(%rbp),%esi
lea    -0xe0(%rbp),%rdx
lea    -0xe0(%rbp),%r8
mov    $0x14,%ecx
call   1070 <sha1_hmac@plt>
mov    -0x44(%rbp),%eax
add    $0x14,%eax
cmp    0x10(%rbp),%eax
jle    13cb <tls1_prf+0x27b>
mov    0x10(%rbp),%eax
mov    $0x14,%ecx
cltd
idiv   %ecx
mov    %edx,-0x108(%rbp)
jmp    13db <tls1_prf+0x28b>
mov    $0x14,%eax
mov    %eax,-0x108(%rbp)
jmp    13db <tls1_prf+0x28b>
mov    -0x108(%rbp),%eax
mov    %eax,-0x4c(%rbp)
movl   $0x0,-0x48(%rbp)
mov    -0x48(%rbp),%eax
cmp    -0x4c(%rbp),%eax
jge    1436 <tls1_prf+0x2e6>
mov    -0x38(%rbp),%rax
mov    -0x44(%rbp),%ecx
add    -0x48(%rbp),%ecx
movslq %ecx,%rcx
movzbl (%rax,%rcx,1),%eax
movslq -0x48(%rbp),%rcx
movzbl -0x100(%rbp,%rcx,1),%ecx
ff
xor    %ecx,%eax
mov    %al,%dl
mov    -0x38(%rbp),%rax
mov    -0x44(%rbp),%ecx
add    -0x48(%rbp),%ecx
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x48(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x48(%rbp)
jmp    13eb <tls1_prf+0x29b>
jmp    143b <tls1_prf+0x2eb>
mov    -0x44(%rbp),%eax
add    $0x14,%eax
mov    %eax,-0x44(%rbp)
jmp    135b <tls1_prf+0x20b>
lea    -0xe0(%rbp),%rdi
xor    %esi,%esi
mov    $0x80,%edx
call   1050 <memset@plt>
lea    -0x100(%rbp),%rdi
xor    %esi,%esi
mov    $0x14,%edx
call   1050 <memset@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x110,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tls1_prf>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xd8,%rsp
mov    %r9,0x20(%rsp)
mov    %r8d,%r13d
mov    %rcx,%r12
mov    %rdx,%r14
mov    %esi,%r15d
mov    %rdi,%rbx
mov    %rdx,%rdi
call   1040 <strlen@plt>
add    %r13d,%eax
add    $0x14,%eax
mov    $0xffffe800,%ebp
cmp    $0x80,%eax
ja     1441 <tls1_prf+0x2f1>
lea    0x1(%r15),%eax
shr    $0x1f,%eax
mov    %r12,0x8(%rsp)
lea    (%r15,%rax,1),%r12d
add    $0x1,%r12d
sar    %r12d
mov    %r12d,%eax
neg    %eax
movslq %r15d,%rcx
add    %rbx,%rcx
cltq
add    %rcx,%rax
mov    %rax,0x18(%rsp)
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    %eax,%r15d
lea    0x64(%rsp),%rdi
mov    %r14,%rsi
mov    %rdi,%r14
mov    %eax,%edx
xor    %eax,%eax
call   1060 <memcpy@plt>
movslq %r15d,%rbp
lea    (%rsp,%rbp,1),%rdi
add    $0x64,%rdi
mov    0x8(%rsp),%rsi
mov    %r13d,%edx
xor    %eax,%eax
call   1060 <memcpy@plt>
add    %r13d,%ebp
lea    0x54(%rsp),%r13
mov    %rbx,%rdi
mov    %r12d,%esi
mov    %r14,%rdx
mov    %ebp,%ecx
mov    %r13,%r8
call   1030 <md5_hmac@plt>
mov    0x110(%rsp),%eax
test   %eax,%eax
jle    1406 <tls1_prf+0x2b6>
mov    %r12d,0x8(%rsp)
mov    %rbp,0x10(%rsp)
lea    0x10(%rbp),%ecx
mov    %ecx,0x4(%rsp)
mov    %eax,%ecx
and    $0xf,%ecx
mov    %ecx,0x2c(%rsp)
xor    %r15d,%r15d
lea    0x30(%rsp),%r12
mov    %eax,%ebp
mov    0x8(%rsp),%r14d
jmp    1259 <tls1_prf+0x109>
nopl   (%rax)
add    $0x10,%r15
cmp    %ebp,%r15d
jge    12b4 <tls1_prf+0x164>
mov    %rbx,%rdi
mov    %r14d,%esi
mov    %r13,%rdx
mov    0x4(%rsp),%ecx
mov    %r12,%r8
call   1030 <md5_hmac@plt>
mov    %rbx,%rdi
mov    %r14d,%esi
mov    %r13,%rdx
mov    $0x10,%ecx
mov    %r13,%r8
call   1030 <md5_hmac@plt>
lea    0x10(%r15),%eax
cmp    %ebp,%eax
mov    $0x10,%eax
cmovg  0x2c(%rsp),%eax
test   %eax,%eax
je     1250 <tls1_prf+0x100>
mov    0x20(%rsp),%rcx
lea    (%rcx,%r15,1),%rdi
mov    %eax,%edx
mov    %r12,%rsi
call   1060 <memcpy@plt>
mov    0x110(%rsp),%ebp
jmp    1250 <tls1_prf+0x100>
lea    0x50(%rsp),%r8
mov    0x18(%rsp),%r14
mov    %r14,%rdi
mov    0x8(%rsp),%esi
lea    0x64(%rsp),%rdx
mov    0x10(%rsp),%rcx
call   1070 <sha1_hmac@plt>
test   %ebp,%ebp
jle    141d <tls1_prf+0x2cd>
mov    0x10(%rsp),%rax
add    $0x14,%eax
mov    %rax,0x10(%rsp)
xor    %r8d,%r8d
lea    0x50(%rsp),%r15
mov    %ebp,%ecx
mov    $0xcccccccd,%edx
imul   %rcx,%rdx
shr    $0x24,%rdx
shl    $0x2,%edx
lea    (%rdx,%rdx,4),%ecx
sub    %ecx,%ebp
mov    %ebp,0x4(%rsp)
mov    0x20(%rsp),%rbx
mov    0x8(%rsp),%r13d
jmp    132d <tls1_prf+0x1dd>
nopl   0x0(%rax,%rax,1)
add    $0x14,%rbx
cmp    %r9d,%r8d
jge    141d <tls1_prf+0x2cd>
mov    %r8,%r12
mov    %r14,%rdi
mov    %r13d,%esi
mov    %r15,%rdx
mov    0x10(%rsp),%rcx
lea    0x30(%rsp),%r8
call   1070 <sha1_hmac@plt>
mov    $0x14,%ebp
mov    %r14,%rdi
mov    %r13d,%esi
mov    %r15,%rdx
mov    $0x14,%ecx
mov    %r15,%r8
call   1070 <sha1_hmac@plt>
mov    0x110(%rsp),%r9d
lea    0x14(%r12),%r8
cmp    %r9d,%r8d
jle    1379 <tls1_prf+0x229>
mov    0x4(%rsp),%ebp
test   %ebp,%ebp
mov    0x18(%rsp),%r14
je     1320 <tls1_prf+0x1d0>
mov    %ebp,%ecx
cmp    $0x8,%ebp
jae    1390 <tls1_prf+0x240>
xor    %edx,%edx
jmp    13f0 <tls1_prf+0x2a0>
nopl   (%rax)
cmp    $0x10,%ebp
jae    13bc <tls1_prf+0x26c>
xor    %edx,%edx
mov    %rdx,%rsi
mov    %ecx,%edx
and    $0x18,%edx
nop
mov    0x30(%rsp,%rsi,1),%rdi
xor    %rdi,(%rbx,%rsi,1)
add    $0x8,%rsi
cmp    %rsi,%rdx
jne    13a0 <tls1_prf+0x250>
cmp    %rcx,%rdx
jne    13f0 <tls1_prf+0x2a0>
jmp    1320 <tls1_prf+0x1d0>
mov    %ecx,%edx
and    $0x10,%edx
mov    0x20(%rsp),%rax
movups (%rax,%r12,1),%xmm0
xorps  0x30(%rsp),%xmm0
movups %xmm0,(%rax,%r12,1)
cmp    %rcx,%rdx
je     1320 <tls1_prf+0x1d0>
test   $0x8,%cl
jne    1397 <tls1_prf+0x247>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movzbl 0x30(%rsp,%rdx,1),%eax
xor    %al,(%rbx,%rdx,1)
add    $0x1,%rdx
cmp    %rdx,%rcx
jne    13f0 <tls1_prf+0x2a0>
jmp    1320 <tls1_prf+0x1d0>
lea    0x50(%rsp),%r8
mov    0x18(%rsp),%rdi
mov    %r12d,%esi
mov    %r14,%rdx
mov    %ebp,%ecx
call   1070 <sha1_hmac@plt>
lea    0x50(%rsp),%rdi
xor    %ebp,%ebp
xor    %esi,%esi
mov    $0x80,%edx
call   1050 <memset@plt>
lea    0x30(%rsp),%rdi
xor    %esi,%esi
mov    $0x14,%edx
call   1050 <memset@plt>
mov    %ebp,%eax
add    $0xd8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @tls1_prf(i8* %0, i32 %1, i8* %2, i8* %3, i32 %4, i8* nocapture %5, i32 %6) {
%8 = alloca [128 x i8]
%9 = alloca [20 x i8]
%10 = getelementptr inbounds [20 x i8], [20 x i8]* %9, i64 0, i64 0
%11 = getelementptr inbounds [128 x i8], [128 x i8]* %8, i64 0, i64 0
%12 = getelementptr inbounds [20 x i8], [20 x i8]* %9, i64 0, i64 0
%13 = tail call i32 @strlen(i8* %2)
%14 = add i32 %4, 20
%15 = add i32 %14, %13
%16 = icmp ugt i32 %15, 128
br i1 %16, label %124, label %17
17: ; preds = %7
%18 = add nsw i32 %1, 1
%19 = sdiv i32 %18, 2
%20 = sext i32 %1 to i64
%21 = getelementptr inbounds i8, i8* %0, i64 %20
%22 = sub nsw i32 0, %19
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8, i8* %21, i64 %23
%25 = tail call i32 @strlen(i8* %2)
%26 = getelementptr inbounds [128 x i8], [128 x i8]* %8, i64 0, i64 20
%27 = call i32 (i8*, ...) @memcpy(i8* %26, i8* %2, i32 %25)
%28 = sext i32 %25 to i64
%29 = getelementptr inbounds i8, i8* %26, i64 %28
%30 = call i32 (i8*, ...) @memcpy(i8* %29, i8* %3, i32 %4)
%31 = add nsw i32 %25, %4
%32 = getelementptr inbounds [128 x i8], [128 x i8]* %8, i64 0, i64 4
%33 = call i32 @md5_hmac(i8* %0, i32 %19, i8* %26, i32 %31, i8* %32)
%34 = icmp sgt i32 %6, 0
br i1 %34, label %37, label %35
35: ; preds = %17
%36 = call i32 @sha1_hmac(i8* %24, i32 %19, i8* %26, i32 %31, i8* %11)
br label %121
37: ; preds = %17
%38 = add nsw i32 %31, 16
%39 = and i32 %6, 15
br label %43
40: ; preds = %52, %43
%41 = icmp slt i32 %48, %6
%42 = add i64 %44, 1
br i1 %41, label %43, label %56
43: ; preds = %37, %40
%44 = phi i64 [ 0, %37 ], [ %42, %40 ]
%45 = phi i32 [ 0, %37 ], [ %48, %40 ]
%46 = call i32 @md5_hmac(i8* %0, i32 %19, i8* %32, i32 %38, i8* %12)
%47 = call i32 @md5_hmac(i8* %0, i32 %19, i8* %32, i32 16, i8* %32)
%48 = add nuw nsw i32 %45, 16
%49 = icmp sgt i32 %48, %6
%50 = select i1 %49, i32 %39, i32 16
%51 = icmp eq i32 %50, 0
br i1 %51, label %40, label %52
52: ; preds = %43
%53 = shl i64 %44, 4
%54 = getelementptr i8, i8* %5, i64 %53
%55 = zext i32 %50 to i64
br label %40
56: ; preds = %40
%57 = call i32 @sha1_hmac(i8* %24, i32 %19, i8* %26, i32 %31, i8* %11)
br i1 %34, label %58, label %121
58: ; preds = %56
%59 = add nsw i32 %31, 20
%60 = urem i32 %6, 20
%61 = bitcast [20 x i8]* %9 to <16 x i8>*
br label %64
62: ; preds = %111, %78, %107, %64
%63 = icmp slt i32 %69, %6
br i1 %63, label %64, label %121
64: ; preds = %58, %62
%65 = phi i64 [ 0, %58 ], [ %68, %62 ]
%66 = call i32 @sha1_hmac(i8* %24, i32 %19, i8* %11, i32 %59, i8* %12)
%67 = call i32 @sha1_hmac(i8* %24, i32 %19, i8* %11, i32 20, i8* %11)
%68 = add nuw i64 %65, 20
%69 = trunc i64 %68 to i32
%70 = icmp sgt i32 %69, %6
%71 = select i1 %70, i32 %60, i32 20
%72 = icmp eq i32 %71, 0
br i1 %72, label %62, label %73
73: ; preds = %64
%74 = zext i32 %71 to i64
%75 = icmp ult i32 %71, 8
br i1 %75, label %109, label %76
76: ; preds = %73
%77 = icmp ult i32 %71, 16
br i1 %77, label %90, label %78
78: ; preds = %76
%79 = and i64 %74, 16
%80 = getelementptr inbounds i8, i8* %5, i64 %65
%81 = bitcast i8* %80 to <16 x i8>*
%82 = load <16 x i8>, <16 x i8>* %81
%83 = load <16 x i8>, <16 x i8>* %61
%84 = xor <16 x i8> %83, %82
%85 = bitcast i8* %80 to <16 x i8>*
store <16 x i8> %84, <16 x i8>* %85
%86 = icmp eq i64 %79, %74
br i1 %86, label %62, label %87
87: ; preds = %78
%88 = and i64 %74, 8
%89 = icmp eq i64 %88, 0
br i1 %89, label %109, label %90
90: ; preds = %76, %87
%91 = phi i64 [ %79, %87 ], [ 0, %76 ]
%92 = zext i32 %71 to i64
%93 = and i64 %92, 24
br label %94
94: ; preds = %94, %90
%95 = phi i64 [ %91, %90 ], [ %105, %94 ]
%96 = add nuw nsw i64 %95, %65
%97 = getelementptr inbounds i8, i8* %5, i64 %96
%98 = bitcast i8* %97 to <8 x i8>*
%99 = load <8 x i8>, <8 x i8>* %98
%100 = getelementptr inbounds [20 x i8], [20 x i8]* %9, i64 0, i64 %95
%101 = bitcast i8* %100 to <8 x i8>*
%102 = load <8 x i8>, <8 x i8>* %101
%103 = xor <8 x i8> %102, %99
%104 = bitcast i8* %97 to <8 x i8>*
store <8 x i8> %103, <8 x i8>* %104
%105 = add nuw i64 %95, 8
%106 = icmp eq i64 %105, %93
br i1 %106, label %107, label %94
107: ; preds = %94
%108 = icmp eq i64 %93, %92
br i1 %108, label %62, label %109
109: ; preds = %73, %87, %107
%110 = phi i64 [ 0, %73 ], [ %79, %87 ], [ %93, %107 ]
br label %111
111: ; preds = %109, %111
%112 = phi i64 [ %119, %111 ], [ %110, %109 ]
%113 = add nuw nsw i64 %112, %65
%114 = getelementptr inbounds i8, i8* %5, i64 %113
%115 = load i8, i8* %114
%116 = getelementptr inbounds [20 x i8], [20 x i8]* %9, i64 0, i64 %112
%117 = load i8, i8* %116
%118 = xor i8 %117, %115
store i8 %118, i8* %114
%119 = add nuw nsw i64 %112, 1
%120 = icmp eq i64 %119, %74
br i1 %120, label %62, label %111
121: ; preds = %62, %35, %56
%122 = call i32 @memset(i8* %11, i32 0, i32 128)
%123 = call i32 @memset(i8* %12, i32 0, i32 20)
br label %124
124: ; preds = %7, %121
%125 = phi i32 [ 0, %121 ], [ -6144, %7 ]
ret i32 %125
}