#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 unsigned char uint8_t;
typedef int /*<<< orphan*/ k_pad;

/* Variables and functions */
int /*<<< orphan*/ memcpy(unsigned char *, unsigned char *, size_t);
int /*<<< orphan*/ memset(unsigned char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ sha1_vector(int, unsigned char const **, size_t *,
                               unsigned char *);
void hmac_sha1_vector(const uint8_t *key, size_t key_len, size_t num_elem,
                      const uint8_t *addr[], const size_t *len, uint8_t *mac) {
  unsigned char k_pad[64];
  unsigned char tk[20];
  int i;
  const uint8_t *_addr[6];
  size_t _len[6];
  if (num_elem > 5) {
    return;
  }
  if (key_len > 64) {
    sha1_vector(1, &key, &key_len, tk);
    key = tk;
    key_len = 20;
  }
  memset(k_pad, 0, sizeof(k_pad));
  memcpy((uint8_t *)k_pad, (uint8_t *)key, key_len);
  for (i = 0; i < 64; i++)
    k_pad[i] ^= 0x36;
  _addr[0] = k_pad;
  _len[0] = 64;
  for (i = 0; i < num_elem; i++) {
    _addr[i + 1] = addr[i];
    _len[i + 1] = len[i];
  }
  sha1_vector(1 + num_elem, _addr, _len, mac);
  memset(k_pad, 0, sizeof(k_pad));
  memcpy((uint8_t *)k_pad, (uint8_t *)key, key_len);
  for (i = 0; i < 64; i++)
    k_pad[i] ^= 0x5c;
  _addr[0] = k_pad;
  _len[0] = 64;
  _addr[1] = mac;
  _len[1] = 20;
  sha1_vector(2, _addr, _len, mac);
}


x86 assembly (clang, -O0):
<hmac_sha1_vector>:
push   %rbp
mov    %rsp,%rbp
sub    $0x100,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
cmpq   $0x5,-0x18(%rbp)
jbe    1163 <hmac_sha1_vector+0x33>
jmp    134a <hmac_sha1_vector+0x21a>
cmpq   $0x40,-0x10(%rbp)
jbe    119a <hmac_sha1_vector+0x6a>
lea    -0x90(%rbp),%rcx
mov    $0x1,%edi
lea    -0x8(%rbp),%rsi
lea    -0x10(%rbp),%rdx
call   1030 <sha1_vector@plt>
lea    -0x90(%rbp),%rax
mov    %rax,-0x8(%rbp)
movq   $0x14,-0x10(%rbp)
lea    -0x70(%rbp),%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1040 <memset@plt>
lea    -0x70(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
call   1050 <memcpy@plt>
movl   $0x0,-0x94(%rbp)
cmpl   $0x40,-0x94(%rbp)
jge    11f9 <hmac_sha1_vector+0xc9>
movslq -0x94(%rbp),%rax
movzbl -0x70(%rbp,%rax,1),%ecx
xor    $0x36,%ecx
mov    %cl,-0x70(%rbp,%rax,1)
mov    -0x94(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x94(%rbp)
jmp    11c5 <hmac_sha1_vector+0x95>
lea    -0x70(%rbp),%rax
mov    %rax,-0xd0(%rbp)
movq   $0x40,-0x100(%rbp)
movl   $0x0,-0x94(%rbp)
movslq -0x94(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    1282 <hmac_sha1_vector+0x152>
mov    -0x20(%rbp),%rax
movslq -0x94(%rbp),%rcx
mov    (%rax,%rcx,8),%rcx
mov    -0x94(%rbp),%eax
add    $0x1,%eax
cltq
mov    %rcx,-0xd0(%rbp,%rax,8)
ff
mov    -0x28(%rbp),%rax
movslq -0x94(%rbp),%rcx
mov    (%rax,%rcx,8),%rcx
mov    -0x94(%rbp),%eax
add    $0x1,%eax
cltq
mov    %rcx,-0x100(%rbp,%rax,8)
ff
mov    -0x94(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x94(%rbp)
jmp    1219 <hmac_sha1_vector+0xe9>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %eax,%edi
lea    -0xd0(%rbp),%rsi
lea    -0x100(%rbp),%rdx
mov    -0x30(%rbp),%rcx
call   1030 <sha1_vector@plt>
lea    -0x70(%rbp),%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1040 <memset@plt>
lea    -0x70(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
call   1050 <memcpy@plt>
movl   $0x0,-0x94(%rbp)
cmpl   $0x40,-0x94(%rbp)
jge    1302 <hmac_sha1_vector+0x1d2>
movslq -0x94(%rbp),%rax
movzbl -0x70(%rbp,%rax,1),%ecx
xor    $0x5c,%ecx
mov    %cl,-0x70(%rbp,%rax,1)
mov    -0x94(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x94(%rbp)
jmp    12ce <hmac_sha1_vector+0x19e>
lea    -0x70(%rbp),%rax
mov    %rax,-0xd0(%rbp)
movq   $0x40,-0x100(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0xc8(%rbp)
movq   $0x14,-0xf8(%rbp)
lea    -0xd0(%rbp),%rsi
lea    -0x100(%rbp),%rdx
mov    -0x30(%rbp),%rcx
mov    $0x2,%edi
call   1030 <sha1_vector@plt>
add    $0x100,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hmac_sha1_vector>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xc8,%rsp
mov    %rdi,0x8(%rsp)
mov    %rsi,(%rsp)
cmp    $0x5,%rdx
ja     12d2 <hmac_sha1_vector+0x1a2>
mov    %r9,%r15
mov    %r8,%r12
mov    %rcx,%r13
mov    %rdx,%rbx
cmp    $0x41,%rsi
jb     1190 <hmac_sha1_vector+0x60>
lea    0x8(%rsp),%rsi
mov    %rsp,%rdx
lea    0xb0(%rsp),%r14
mov    $0x1,%edi
mov    %r14,%rcx
call   1030 <sha1_vector@plt>
mov    %r14,0x8(%rsp)
movq   $0x14,(%rsp)
lea    0x10(%rsp),%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1040 <memset@plt>
mov    0x8(%rsp),%rsi
mov    (%rsp),%rdx
mov    %r14,%rdi
call   1050 <memcpy@plt>
movaps 0xe44(%rip),%xmm0
movaps 0x10(%rsp),%xmm1
xorps  %xmm0,%xmm1
movaps %xmm1,0x10(%rsp)
movaps 0x20(%rsp),%xmm1
xorps  %xmm0,%xmm1
movaps %xmm1,0x20(%rsp)
movaps 0x30(%rsp),%xmm1
xorps  %xmm0,%xmm1
movaps %xmm1,0x30(%rsp)
xorps  0x40(%rsp),%xmm0
movaps %xmm0,0x40(%rsp)
mov    %r14,0x50(%rsp)
movq   $0x40,0x80(%rsp)
test   %rbx,%rbx
je     122e <hmac_sha1_vector+0xfe>
lea    0x58(%rsp),%rdi
lea    0x0(,%rbx,8),%rbp
mov    %r13,%rsi
mov    %rbp,%rdx
call   1050 <memcpy@plt>
lea    0x88(%rsp),%rdi
mov    %r12,%rsi
mov    %rbp,%rdx
call   1050 <memcpy@plt>
add    $0x1,%ebx
lea    0x50(%rsp),%r12
lea    0x80(%rsp),%r13
mov    %ebx,%edi
mov    %r12,%rsi
mov    %r13,%rdx
mov    %r15,%rcx
call   1030 <sha1_vector@plt>
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1040 <memset@plt>
mov    0x8(%rsp),%rsi
mov    (%rsp),%rdx
mov    %r14,%rdi
call   1050 <memcpy@plt>
movaps 0xd9b(%rip),%xmm0
movaps 0x10(%rsp),%xmm1
xorps  %xmm0,%xmm1
movaps %xmm1,0x10(%rsp)
movaps 0x20(%rsp),%xmm1
xorps  %xmm0,%xmm1
movaps %xmm1,0x20(%rsp)
movaps 0x30(%rsp),%xmm1
xorps  %xmm0,%xmm1
movaps %xmm1,0x30(%rsp)
xorps  0x40(%rsp),%xmm0
movaps %xmm0,0x40(%rsp)
mov    %r14,0x50(%rsp)
mov    %r15,0x58(%rsp)
movaps 0xd69(%rip),%xmm0
movaps %xmm0,0x80(%rsp)
mov    $0x2,%edi
mov    %r12,%rsi
mov    %r13,%rdx
mov    %r15,%rcx
call   1030 <sha1_vector@plt>
add    $0xc8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @hmac_sha1_vector(i8* %0, i64 %1, i64 %2, i8** nocapture %3, i64* nocapture %4, i8* %5) {
%7 = bitcast i8** %3 to i8*
%8 = bitcast i64* %4 to i8*
%9 = alloca i8*
%10 = alloca i64
%11 = alloca [64 x i8]
%12 = alloca [20 x i8]
%13 = alloca [6 x i8*]
%14 = alloca [6 x i64]
store i8* %0, i8** %9
store i64 %1, i64* %10
%15 = getelementptr inbounds [64 x i8], [64 x i8]* %11, i64 0, i64 0
%16 = getelementptr inbounds [20 x i8], [20 x i8]* %12, i64 0, i64 0
%17 = bitcast [6 x i8*]* %13 to i8*
%18 = bitcast [6 x i64]* %14 to i8*
%19 = icmp ugt i64 %2, 5
br i1 %19, label %87, label %20
20: ; preds = %6
%21 = icmp ugt i64 %1, 64
br i1 %21, label %22, label %24
22: ; preds = %20
%23 = call i32 @sha1_vector(i32 1, i8** %9, i64* %10, i8* %16)
store i8* %16, i8** %9
store i64 20, i64* %10
br label %24
24: ; preds = %22, %20
%25 = call i32 @memset(i8* %15, i32 0, i32 64)
%26 = load i8*, i8** %9
%27 = load i64, i64* %10
%28 = call i32 @memcpy(i8* %15, i8* %26, i64 %27)
%29 = bitcast [64 x i8]* %11 to <16 x i8>*
%30 = load <16 x i8>, <16 x i8>* %29
%31 = xor <16 x i8> %30, <i8 54, i8 54, i8 54, i8 54, i8 54, i8 54, i8 54, i8 54, i8 54, i8 54, i8 54, i8 54, i8 54, i8 54, i8 54, i8 54>
%32 = bitcast [64 x i8]* %11 to <16 x i8>*
store <16 x i8> %31, <16 x i8>* %32
%33 = getelementptr inbounds [64 x i8], [64 x i8]* %11, i64 0, i64 16
%34 = bitcast i8* %33 to <16 x i8>*
%35 = load <16 x i8>, <16 x i8>* %34
%36 = xor <16 x i8> %35, <i8 54, i8 54, i8 54, i8 54, i8 54, i8 54, i8 54, i8 54, i8 54, i8 54, i8 54, i8 54, i8 54, i8 54, i8 54, i8 54>
%37 = bitcast i8* %33 to <16 x i8>*
store <16 x i8> %36, <16 x i8>* %37
%38 = getelementptr inbounds [64 x i8], [64 x i8]* %11, i64 0, i64 32
%39 = bitcast i8* %38 to <16 x i8>*
%40 = load <16 x i8>, <16 x i8>* %39
%41 = xor <16 x i8> %40, <i8 54, i8 54, i8 54, i8 54, i8 54, i8 54, i8 54, i8 54, i8 54, i8 54, i8 54, i8 54, i8 54, i8 54, i8 54, i8 54>
%42 = bitcast i8* %38 to <16 x i8>*
store <16 x i8> %41, <16 x i8>* %42
%43 = getelementptr inbounds [64 x i8], [64 x i8]* %11, i64 0, i64 48
%44 = bitcast i8* %43 to <16 x i8>*
%45 = load <16 x i8>, <16 x i8>* %44
%46 = xor <16 x i8> %45, <i8 54, i8 54, i8 54, i8 54, i8 54, i8 54, i8 54, i8 54, i8 54, i8 54, i8 54, i8 54, i8 54, i8 54, i8 54, i8 54>
%47 = bitcast i8* %43 to <16 x i8>*
store <16 x i8> %46, <16 x i8>* %47
%48 = getelementptr inbounds [6 x i8*], [6 x i8*]* %13, i64 0, i64 0
store i8* %15, i8** %48
%49 = getelementptr inbounds [6 x i64], [6 x i64]* %14, i64 0, i64 0
store i64 64, i64* %49
%50 = icmp eq i64 %2, 0
br i1 %50, label %57, label %51
51: ; preds = %24
%52 = getelementptr inbounds [6 x i8*], [6 x i8*]* %13, i64 0, i64 1
%53 = bitcast i8** %52 to i8*
%54 = shl nuw i64 %2, 3
%55 = getelementptr inbounds [6 x i64], [6 x i64]* %14, i64 0, i64 1
%56 = bitcast i64* %55 to i8*
br label %57
57: ; preds = %51, %24
%58 = trunc i64 %2 to i32
%59 = add i32 %58, 1
%60 = call i32 @sha1_vector(i32 %59, i8** %48, i64* %49, i8* %5)
%61 = call i32 @memset(i8* %15, i32 0, i32 64)
%62 = load i8*, i8** %9
%63 = load i64, i64* %10
%64 = call i32 @memcpy(i8* %15, i8* %62, i64 %63)
%65 = bitcast [64 x i8]* %11 to <16 x i8>*
%66 = load <16 x i8>, <16 x i8>* %65
%67 = xor <16 x i8> %66, <i8 92, i8 92, i8 92, i8 92, i8 92, i8 92, i8 92, i8 92, i8 92, i8 92, i8 92, i8 92, i8 92, i8 92, i8 92, i8 92>
%68 = bitcast [64 x i8]* %11 to <16 x i8>*
store <16 x i8> %67, <16 x i8>* %68
%69 = getelementptr inbounds [64 x i8], [64 x i8]* %11, i64 0, i64 16
%70 = bitcast i8* %69 to <16 x i8>*
%71 = load <16 x i8>, <16 x i8>* %70
%72 = xor <16 x i8> %71, <i8 92, i8 92, i8 92, i8 92, i8 92, i8 92, i8 92, i8 92, i8 92, i8 92, i8 92, i8 92, i8 92, i8 92, i8 92, i8 92>
%73 = bitcast i8* %69 to <16 x i8>*
store <16 x i8> %72, <16 x i8>* %73
%74 = getelementptr inbounds [64 x i8], [64 x i8]* %11, i64 0, i64 32
%75 = bitcast i8* %74 to <16 x i8>*
%76 = load <16 x i8>, <16 x i8>* %75
%77 = xor <16 x i8> %76, <i8 92, i8 92, i8 92, i8 92, i8 92, i8 92, i8 92, i8 92, i8 92, i8 92, i8 92, i8 92, i8 92, i8 92, i8 92, i8 92>
%78 = bitcast i8* %74 to <16 x i8>*
store <16 x i8> %77, <16 x i8>* %78
%79 = getelementptr inbounds [64 x i8], [64 x i8]* %11, i64 0, i64 48
%80 = bitcast i8* %79 to <16 x i8>*
%81 = load <16 x i8>, <16 x i8>* %80
%82 = xor <16 x i8> %81, <i8 92, i8 92, i8 92, i8 92, i8 92, i8 92, i8 92, i8 92, i8 92, i8 92, i8 92, i8 92, i8 92, i8 92, i8 92, i8 92>
%83 = bitcast i8* %79 to <16 x i8>*
store <16 x i8> %82, <16 x i8>* %83
store i8* %15, i8** %48
%84 = getelementptr inbounds [6 x i8*], [6 x i8*]* %13, i64 0, i64 1
store i8* %5, i8** %84
%85 = bitcast [6 x i64]* %14 to <2 x i64>*
store <2 x i64> <i64 64, i64 20>, <2 x i64>* %85
%86 = call i32 @sha1_vector(i32 2, i8** %48, i64* %49, i8* %5)
br label %87
87: ; preds = %6, %57
ret void
}