#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 hmac_hex(unsigned char *, int /*<<< orphan*/, unsigned char *,
             int /*<<< orphan*/, unsigned char *);
scalar_t__ memcmp(unsigned char *, char *, int);
int /*<<< orphan*/ print_salt(int /*<<< orphan*/, unsigned char *,
                              int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ strlen(char *);
int main(void) {
  char *key[] = {
      "",
      "key",
      "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"
      "\x0b\x0b",
      "Jefe",
      "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
      "\xaa\xaa",
      "\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12"
      "\x13\x14\x15\x16\x17\x18\x19",
      "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
      "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
      "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
      "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
      "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
      "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
      "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
      "\xaa\xaa\xaa\xaa\xaa",
      "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
      "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
      "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
      "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
      "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
      "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
      "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
      "\xaa\xaa\xaa\xaa\xaa"};
  char *salt[] = {
      "",
      "The quick brown fox jumps over the lazy dog",
      "Hi There",
      "what do ya want for nothing?",
      "\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd"
      "\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd"
      "\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd",
      "\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd"
      "\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd"
      "\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd",
      "Test Using Larger Than Block-Size Key - Hash Key First",
      "This is a test using a larger than block-size key and a larger than "
      "block-size data. The key needs to be hashed before being used by the "
      "HMAC algorithm."};
  char *expected[] = {
      "b613679a0814d9ec772f95d778c35fc5ff1697c493715653c6c712144292c5ad",
      "f7bc83f430538424b13298e6aa6fb143ef4d59a14946175997479dbc2d1a3cd8",
      "b0344c61d8db38535ca8afceaf0bf12b881dc200c9833da726e9376c2e32cff7",
      "5bdcc146bf60754e6a042426089575c75a003f089d2739839dec58b964ec3844",
      "773ea91e36800e46854db8ebd09181a72959098b3ef8c122d9635514ced565fe",
      "82558a389a443c0ea4cc819899f2083a85f0faa3e578f8077a2e3ff46729665b",
      "60e431591ee0b67f0d8a26aacbf5b77f8e0bc6213728c5140546040f0ee37f54",
      "9b09ffa71b942fcb27635fbcd5b0e944bfdc63644f0713938a7f51535c3a35e2",
  };
  unsigned char hash[65] = {0x00};
  int ret = 0, i = 0;
  printf("Running test for hmac:\n");
  for (i = 0; i < 8; i++) {
    printf("\nKey:  ");
    if (i == 0 || i == 1 || i == 3) {
      printf("%s", key[i]);
    } else {
      printf("0x");
      print_salt(stdout, (unsigned char *)(key[i]), strlen(key[i]));
    }
    printf("\nSalt: ");
    if (i == 4 || i == 5) {
      printf("0x");
      print_salt(stdout, (unsigned char *)(salt[i]), strlen(salt[i]));
    } else {
      printf("%s", salt[i]);
    }
    printf("\nExp:  %s\n", expected[i]);
    ret = hmac_hex((unsigned char *)(key[i]), strlen(key[i]),
                   (unsigned char *)(salt[i]), strlen(salt[i]), hash);
    if (ret == 0) {
      printf("HMAC: %s\n", hash);
      if (memcmp(hash, expected[i], 64) == 0) {
        printf("Salted Key correct\n");
      } else {
        printf("Salted Key failed!\n");
      }
    } else {
      printf("Got result %u from HMAC instead of 0.\n", ret);
      ret |= (1 << i);
    }
  }
  return ret;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x160,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x50(%rbp),%rdi
lea    0x2bc3(%rip),%rsi
mov    $0x40,%edx
call   1090 <memcpy@plt>
lea    -0x90(%rbp),%rdi
lea    0x2beb(%rip),%rsi
mov    $0x40,%edx
call   1090 <memcpy@plt>
lea    -0xd0(%rbp),%rdi
lea    0x2c13(%rip),%rsi
mov    $0x40,%edx
call   1090 <memcpy@plt>
lea    -0x120(%rbp),%rdi
xor    %esi,%esi
mov    $0x41,%edx
call   1070 <memset@plt>
movl   $0x0,-0x124(%rbp)
movl   $0x0,-0x128(%rbp)
lea    0x1257(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x0,-0x128(%rbp)
cmpl   $0x8,-0x128(%rbp)
jge    14b2 <main+0x342>
lea    0x124a(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
cmpl   $0x0,-0x128(%rbp)
je     1248 <main+0xd8>
cmpl   $0x1,-0x128(%rbp)
je     1248 <main+0xd8>
cmpl   $0x3,-0x128(%rbp)
jne    1267 <main+0xf7>
movslq -0x128(%rbp),%rax
mov    -0x50(%rbp,%rax,8),%rsi
lea    0x1211(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    12bc <main+0x14c>
lea    0x1201(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    0x2d5c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x134(%rbp)
movslq -0x128(%rbp),%rax
mov    -0x50(%rbp,%rax,8),%rax
mov    %rax,-0x130(%rbp)
movslq -0x128(%rbp),%rax
mov    -0x50(%rbp,%rax,8),%rdi
call   1050 <strlen@plt>
mov    -0x134(%rbp),%edi
mov    -0x130(%rbp),%rsi
mov    %eax,%edx
call   1040 <print_salt@plt>
lea    0x11af(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
cmpl   $0x4,-0x128(%rbp)
je     12e4 <main+0x174>
cmpl   $0x5,-0x128(%rbp)
jne    1344 <main+0x1d4>
lea    0x1184(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    0x2cdf(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x144(%rbp)
movslq -0x128(%rbp),%rax
mov    -0x90(%rbp,%rax,8),%rax
ff
mov    %rax,-0x140(%rbp)
movslq -0x128(%rbp),%rax
mov    -0x90(%rbp,%rax,8),%rdi
ff
call   1050 <strlen@plt>
mov    -0x144(%rbp),%edi
mov    -0x140(%rbp),%rsi
mov    %eax,%edx
call   1040 <print_salt@plt>
jmp    1361 <main+0x1f1>
movslq -0x128(%rbp),%rax
mov    -0x90(%rbp,%rax,8),%rsi
ff
lea    0x1112(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movslq -0x128(%rbp),%rax
mov    -0xd0(%rbp,%rax,8),%rsi
ff
lea    0x1103(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movslq -0x128(%rbp),%rax
mov    -0x50(%rbp,%rax,8),%rax
mov    %rax,-0x160(%rbp)
movslq -0x128(%rbp),%rax
mov    -0x50(%rbp,%rax,8),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x154(%rbp)
movslq -0x128(%rbp),%rax
mov    -0x90(%rbp,%rax,8),%rax
ff
mov    %rax,-0x150(%rbp)
movslq -0x128(%rbp),%rax
mov    -0x90(%rbp,%rax,8),%rdi
ff
call   1050 <strlen@plt>
mov    -0x160(%rbp),%rdi
mov    -0x154(%rbp),%esi
mov    -0x150(%rbp),%rdx
mov    %eax,%ecx
lea    -0x120(%rbp),%r8
call   1030 <hmac_hex@plt>
mov    %eax,-0x124(%rbp)
cmpl   $0x0,-0x124(%rbp)
jne    146c <main+0x2fc>
lea    -0x120(%rbp),%rsi
lea    0x1070(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0x120(%rbp),%rdi
movslq -0x128(%rbp),%rax
mov    -0xd0(%rbp,%rax,8),%rsi
ff
mov    $0x40,%edx
call   1080 <memcmp@plt>
cmp    $0x0,%rax
jne    1459 <main+0x2e9>
lea    0x1042(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1467 <main+0x2f7>
lea    0x1043(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1499 <main+0x329>
mov    -0x124(%rbp),%esi
lea    0x103e(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x128(%rbp),%ecx
mov    $0x1,%eax
shl    %cl,%eax
or     -0x124(%rbp),%eax
mov    %eax,-0x124(%rbp)
jmp    149e <main+0x32e>
mov    -0x128(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x128(%rbp)
jmp    1206 <main+0x96>
mov    -0x124(%rbp),%eax
add    $0x160,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
movb   $0x0,0x40(%rsp)
lea    0x130e(%rip),%rdi
call   1040 <puts@plt>
xor    %r13d,%r13d
xor    %ebx,%ebx
jmp    11c7 <main+0x67>
nopl   0x0(%rax)
mov    %eax,%ebp
lea    0x12ce(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1070 <printf@plt>
bts    %ebx,%ebp
add    $0x1,%rbx
add    $0x8,%r13
cmp    $0x8,%rbx
je     133b <main+0x1db>
lea    0x127e(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
cmp    $0x3,%ebx
ja     1200 <main+0xa0>
cmp    $0x2,%ebx
je     1200 <main+0xa0>
lea    0x2b6a(%rip),%rax
mov    0x0(%r13,%rax,1),%r14
lea    0x1262(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
jmp    1237 <main+0xd7>
xchg   %ax,%ax
lea    0x1250(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x2dc3(%rip),%rax
mov    (%rax),%ebp
lea    0x2b32(%rip),%rax
mov    0x0(%r13,%rax,1),%r14
mov    %r14,%rdi
call   1060 <strlen@plt>
mov    %ebp,%edi
mov    %r14,%rsi
mov    %eax,%edx
call   1050 <print_salt@plt>
lea    0x121c(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %ebx,%eax
and    $0x7ffffffe,%eax
cmp    $0x4,%eax
jne    1290 <main+0x130>
lea    0x11ff(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x2d72(%rip),%rax
mov    (%rax),%ebp
lea    0x2b21(%rip),%rax
mov    0x0(%r13,%rax,1),%r15
mov    %r15,%rdi
call   1060 <strlen@plt>
mov    %ebp,%edi
mov    %r15,%rsi
mov    %eax,%edx
call   1050 <print_salt@plt>
jmp    12ad <main+0x14d>
nopw   0x0(%rax,%rax,1)
lea    0x2af9(%rip),%rax
mov    0x0(%r13,%rax,1),%r15
lea    0x11b1(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0x2b1c(%rip),%rax
mov    0x0(%r13,%rax,1),%r12
lea    0x11a2(%rip),%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %r14,%rdi
call   1060 <strlen@plt>
mov    %eax,%ebp
mov    %r15,%rdi
call   1060 <strlen@plt>
mov    %r14,%rdi
mov    %ebp,%esi
mov    %r15,%rdx
mov    %eax,%ecx
mov    %rsp,%r14
mov    %r14,%r8
call   1030 <hmac_hex@plt>
test   %eax,%eax
jne    11a0 <main+0x40>
lea    0x116d(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %r14,%rdi
mov    %r12,%rsi
mov    $0x40,%edx
call   1080 <memcmp@plt>
test   %rax,%rax
je     1328 <main+0x1c8>
lea    0x118f(%rip),%rdi
jmp    132f <main+0x1cf>
lea    0x1199(%rip),%rdi
call   1040 <puts@plt>
xor    %ebp,%ebp
jmp    11b5 <main+0x55>
mov    %ebp,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
@.str.1 = [4 x i8] c"key\00"
@.str.2 = [21 x i8] c"\0B\0B\0B\0B\0B\0B\0B\0B\0B\0B\0B\0B\0B\0B\0B\0B\0B\0B\0B\0B\00"
@.str.3 = [5 x i8] c"Jefe\00"
@.str.4 = [21 x i8] c"\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\00"
@.str.5 = [26 x i8] c"\01\02\03\04\05\06\07\08\09\0A\0B\0C\0D\0E\0F\10\11\12\13\14\15\16\17\18\19\00"
@.str.6 = [132 x i8] c"\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\00"
@__const.main.key = [8 x i8*] [i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([132 x i8], [132 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([132 x i8], [132 x i8]* @.str.6, i32 0, i32 0)]
@.str.7 = [44 x i8] c"The quick brown fox jumps over the lazy dog\00"
@.str.8 = [9 x i8] c"Hi There\00"
@.str.9 = [29 x i8] c"what do ya want for nothing?\00"
@.str.10 = [51 x i8] c"\DD\DD\DD\DD\DD\DD\DD\DD\DD\DD\DD\DD\DD\DD\DD\DD\DD\DD\DD\DD\DD\DD\DD\DD\DD\DD\DD\DD\DD\DD\DD\DD\DD\DD\DD\DD\DD\DD\DD\DD\DD\DD\DD\DD\DD\DD\DD\DD\DD\DD\00"
@.str.11 = [51 x i8] c"\CD\CD\CD\CD\CD\CD\CD\CD\CD\CD\CD\CD\CD\CD\CD\CD\CD\CD\CD\CD\CD\CD\CD\CD\CD\CD\CD\CD\CD\CD\CD\CD\CD\CD\CD\CD\CD\CD\CD\CD\CD\CD\CD\CD\CD\CD\CD\CD\CD\CD\00"
@.str.12 = [55 x i8] c"Test Using Larger Than Block-Size Key - Hash Key First\00"
@.str.13 = [153 x i8] c"This is a test using a larger than block-size key and a larger than block-size data. The key needs to be hashed before being used by the HMAC algorithm.\00"
@__const.main.salt = [8 x i8*] [i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.7, i32 0, i32 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.8, i32 0, i32 0), i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.9, i32 0, i32 0), i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.10, i32 0, i32 0), i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.11, i32 0, i32 0), i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.12, i32 0, i32 0), i8* getelementptr inbounds ([153 x i8], [153 x i8]* @.str.13, i32 0, i32 0)]
@.str.14 = [65 x i8] c"b613679a0814d9ec772f95d778c35fc5ff1697c493715653c6c712144292c5ad\00"
@.str.15 = [65 x i8] c"f7bc83f430538424b13298e6aa6fb143ef4d59a14946175997479dbc2d1a3cd8\00"
@.str.16 = [65 x i8] c"b0344c61d8db38535ca8afceaf0bf12b881dc200c9833da726e9376c2e32cff7\00"
@.str.17 = [65 x i8] c"5bdcc146bf60754e6a042426089575c75a003f089d2739839dec58b964ec3844\00"
@.str.18 = [65 x i8] c"773ea91e36800e46854db8ebd09181a72959098b3ef8c122d9635514ced565fe\00"
@.str.19 = [65 x i8] c"82558a389a443c0ea4cc819899f2083a85f0faa3e578f8077a2e3ff46729665b\00"
@.str.20 = [65 x i8] c"60e431591ee0b67f0d8a26aacbf5b77f8e0bc6213728c5140546040f0ee37f54\00"
@.str.21 = [65 x i8] c"9b09ffa71b942fcb27635fbcd5b0e944bfdc63644f0713938a7f51535c3a35e2\00"
@__const.main.expected = [8 x i8*] [i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.14, i32 0, i32 0), i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.15, i32 0, i32 0), i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.16, i32 0, i32 0), i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.17, i32 0, i32 0), i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.18, i32 0, i32 0), i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.19, i32 0, i32 0), i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.20, i32 0, i32 0), i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.21, i32 0, i32 0)]
@.str.22 = [24 x i8] c"Running test for hmac:\0A\00"
@.str.23 = [8 x i8] c"\0AKey: \00"
@.str.24 = [3 x i8] c"%s\00"
@.str.25 = [3 x i8] c"0x\00"
@stdout = global i32 0
@.str.26 = [8 x i8] c"\0ASalt: \00"
@.str.27 = [11 x i8] c"\0AExp: %s\0A\00"
@.str.28 = [10 x i8] c"HMAC: %s\0A\00"
@.str.29 = [20 x i8] c"Salted Key correct\0A\00"
@.str.30 = [20 x i8] c"Salted Key failed!\0A\00"
@.str.31 = [39 x i8] c"Got result %u from HMAC instead of 0.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [8 x i8*]
%3 = alloca [8 x i8*]
%4 = alloca [8 x i8*]
%5 = alloca [65 x i8]
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
%8 = bitcast [8 x i8*]* %2 to i8*
%9 = bitcast [8 x i8*]* %3 to i8*
%10 = bitcast [8 x i8*]* %4 to i8*
%11 = bitcast [65 x i8]* %5 to i8*
store i32 0, i32* %6
store i32 0, i32* %7
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.22, i64 0, i64 0))
store i32 0, i32* %7
br label %13
13: ; preds = %122, %0
%14 = load i32, i32* %7
%15 = icmp slt i32 %14, 8
br i1 %15, label %16, label %125
16: ; preds = %13
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.23, i64 0, i64 0))
%18 = load i32, i32* %7
%19 = icmp eq i32 %18, 0
br i1 %19, label %26, label %20
20: ; preds = %16
%21 = load i32, i32* %7
%22 = icmp eq i32 %21, 1
br i1 %22, label %26, label %23
23: ; preds = %20
%24 = load i32, i32* %7
%25 = icmp eq i32 %24, 3
br i1 %25, label %26, label %32
26: ; preds = %23, %20, %16
%27 = load i32, i32* %7
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [8 x i8*], [8 x i8*]* %2, i64 0, i64 %28
%30 = load i8*, i8** %29
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.24, i64 0, i64 0), i8* %30)
br label %45
32: ; preds = %23
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.25, i64 0, i64 0))
%34 = load i32, i32* @stdout
%35 = load i32, i32* %7
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [8 x i8*], [8 x i8*]* %2, i64 0, i64 %36
%38 = load i8*, i8** %37
%39 = load i32, i32* %7
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds [8 x i8*], [8 x i8*]* %2, i64 0, i64 %40
%42 = load i8*, i8** %41
%43 = call i32 @strlen(i8* %42)
%44 = call i32 @print_salt(i32 %34, i8* %38, i32 %43)
br label %45
45: ; preds = %32, %26
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.26, i64 0, i64 0))
%47 = load i32, i32* %7
%48 = icmp eq i32 %47, 4
br i1 %48, label %52, label %49
49: ; preds = %45
%50 = load i32, i32* %7
%51 = icmp eq i32 %50, 5
br i1 %51, label %52, label %65
52: ; preds = %49, %45
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.25, i64 0, i64 0))
%54 = load i32, i32* @stdout
%55 = load i32, i32* %7
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds [8 x i8*], [8 x i8*]* %3, i64 0, i64 %56
%58 = load i8*, i8** %57
%59 = load i32, i32* %7
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds [8 x i8*], [8 x i8*]* %3, i64 0, i64 %60
%62 = load i8*, i8** %61
%63 = call i32 @strlen(i8* %62)
%64 = call i32 @print_salt(i32 %54, i8* %58, i32 %63)
br label %71
65: ; preds = %49
%66 = load i32, i32* %7
%67 = sext i32 %66 to i64
%68 = getelementptr inbounds [8 x i8*], [8 x i8*]* %3, i64 0, i64 %67
%69 = load i8*, i8** %68
%70 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.24, i64 0, i64 0), i8* %69)
br label %71
71: ; preds = %65, %52
%72 = load i32, i32* %7
%73 = sext i32 %72 to i64
%74 = getelementptr inbounds [8 x i8*], [8 x i8*]* %4, i64 0, i64 %73
%75 = load i8*, i8** %74
%76 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.27, i64 0, i64 0), i8* %75)
%77 = load i32, i32* %7
%78 = sext i32 %77 to i64
%79 = getelementptr inbounds [8 x i8*], [8 x i8*]* %2, i64 0, i64 %78
%80 = load i8*, i8** %79
%81 = load i32, i32* %7
%82 = sext i32 %81 to i64
%83 = getelementptr inbounds [8 x i8*], [8 x i8*]* %2, i64 0, i64 %82
%84 = load i8*, i8** %83
%85 = call i32 @strlen(i8* %84)
%86 = load i32, i32* %7
%87 = sext i32 %86 to i64
%88 = getelementptr inbounds [8 x i8*], [8 x i8*]* %3, i64 0, i64 %87
%89 = load i8*, i8** %88
%90 = load i32, i32* %7
%91 = sext i32 %90 to i64
%92 = getelementptr inbounds [8 x i8*], [8 x i8*]* %3, i64 0, i64 %91
%93 = load i8*, i8** %92
%94 = call i32 @strlen(i8* %93)
%95 = getelementptr inbounds [65 x i8], [65 x i8]* %5, i64 0, i64 0
%96 = call i32 @hmac_hex(i8* %80, i32 %85, i8* %89, i32 %94, i8* %95)
store i32 %96, i32* %6
%97 = load i32, i32* %6
%98 = icmp eq i32 %97, 0
br i1 %98, label %99, label %114
99: ; preds = %71
%100 = getelementptr inbounds [65 x i8], [65 x i8]* %5, i64 0, i64 0
%101 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.28, i64 0, i64 0), i8* %100)
%102 = getelementptr inbounds [65 x i8], [65 x i8]* %5, i64 0, i64 0
%103 = load i32, i32* %7
%104 = sext i32 %103 to i64
%105 = getelementptr inbounds [8 x i8*], [8 x i8*]* %4, i64 0, i64 %104
%106 = load i8*, i8** %105
%107 = call i64 @memcmp(i8* %102, i8* %106, i32 64)
%108 = icmp eq i64 %107, 0
br i1 %108, label %109, label %111
109: ; preds = %99
%110 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.29, i64 0, i64 0))
br label %113
111: ; preds = %99
%112 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.30, i64 0, i64 0))
br label %113
113: ; preds = %111, %109
br label %121
114: ; preds = %71
%115 = load i32, i32* %6
%116 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.31, i64 0, i64 0), i32 %115)
%117 = load i32, i32* %7
%118 = shl i32 1, %117
%119 = load i32, i32* %6
%120 = or i32 %119, %118
store i32 %120, i32* %6
br label %121
121: ; preds = %114, %113
br label %122
122: ; preds = %121
%123 = load i32, i32* %7
%124 = add nsw i32 %123, 1
store i32 %124, i32* %7
br label %13
125: ; preds = %13
%126 = load i32, i32* %6
ret i32 %126
}

LLVM IR (-O2):
@.str = [1 x i8] zeroinitializer
@.str.1 = [4 x i8] c"key\00"
@.str.2 = [21 x i8] c"\0B\0B\0B\0B\0B\0B\0B\0B\0B\0B\0B\0B\0B\0B\0B\0B\0B\0B\0B\0B\00"
@.str.3 = [5 x i8] c"Jefe\00"
@.str.4 = [21 x i8] c"\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\00"
@.str.5 = [26 x i8] c"\01\02\03\04\05\06\07\08\09\0A\0B\0C\0D\0E\0F\10\11\12\13\14\15\16\17\18\19\00"
@.str.6 = [132 x i8] c"\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\00"
@__const.main.key = [8 x i8*] [i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([132 x i8], [132 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([132 x i8], [132 x i8]* @.str.6, i32 0, i32 0)]
@.str.7 = [44 x i8] c"The quick brown fox jumps over the lazy dog\00"
@.str.8 = [9 x i8] c"Hi There\00"
@.str.9 = [29 x i8] c"what do ya want for nothing?\00"
@.str.10 = [51 x i8] c"\DD\DD\DD\DD\DD\DD\DD\DD\DD\DD\DD\DD\DD\DD\DD\DD\DD\DD\DD\DD\DD\DD\DD\DD\DD\DD\DD\DD\DD\DD\DD\DD\DD\DD\DD\DD\DD\DD\DD\DD\DD\DD\DD\DD\DD\DD\DD\DD\DD\DD\00"
@.str.11 = [51 x i8] c"\CD\CD\CD\CD\CD\CD\CD\CD\CD\CD\CD\CD\CD\CD\CD\CD\CD\CD\CD\CD\CD\CD\CD\CD\CD\CD\CD\CD\CD\CD\CD\CD\CD\CD\CD\CD\CD\CD\CD\CD\CD\CD\CD\CD\CD\CD\CD\CD\CD\CD\00"
@.str.12 = [55 x i8] c"Test Using Larger Than Block-Size Key - Hash Key First\00"
@.str.13 = [153 x i8] c"This is a test using a larger than block-size key and a larger than block-size data. The key needs to be hashed before being used by the HMAC algorithm.\00"
@__const.main.salt = [8 x i8*] [i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.7, i32 0, i32 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.8, i32 0, i32 0), i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.9, i32 0, i32 0), i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.10, i32 0, i32 0), i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.11, i32 0, i32 0), i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.12, i32 0, i32 0), i8* getelementptr inbounds ([153 x i8], [153 x i8]* @.str.13, i32 0, i32 0)]
@.str.14 = [65 x i8] c"b613679a0814d9ec772f95d778c35fc5ff1697c493715653c6c712144292c5ad\00"
@.str.15 = [65 x i8] c"f7bc83f430538424b13298e6aa6fb143ef4d59a14946175997479dbc2d1a3cd8\00"
@.str.16 = [65 x i8] c"b0344c61d8db38535ca8afceaf0bf12b881dc200c9833da726e9376c2e32cff7\00"
@.str.17 = [65 x i8] c"5bdcc146bf60754e6a042426089575c75a003f089d2739839dec58b964ec3844\00"
@.str.18 = [65 x i8] c"773ea91e36800e46854db8ebd09181a72959098b3ef8c122d9635514ced565fe\00"
@.str.19 = [65 x i8] c"82558a389a443c0ea4cc819899f2083a85f0faa3e578f8077a2e3ff46729665b\00"
@.str.20 = [65 x i8] c"60e431591ee0b67f0d8a26aacbf5b77f8e0bc6213728c5140546040f0ee37f54\00"
@.str.21 = [65 x i8] c"9b09ffa71b942fcb27635fbcd5b0e944bfdc63644f0713938a7f51535c3a35e2\00"
@__const.main.expected = [8 x i8*] [i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.14, i32 0, i32 0), i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.15, i32 0, i32 0), i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.16, i32 0, i32 0), i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.17, i32 0, i32 0), i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.18, i32 0, i32 0), i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.19, i32 0, i32 0), i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.20, i32 0, i32 0), i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.21, i32 0, i32 0)]
@.str.23 = [8 x i8] c"\0AKey: \00"
@.str.24 = [3 x i8] c"%s\00"
@.str.25 = [3 x i8] c"0x\00"
@stdout = global i32 0
@.str.26 = [8 x i8] c"\0ASalt: \00"
@.str.27 = [11 x i8] c"\0AExp: %s\0A\00"
@.str.28 = [10 x i8] c"HMAC: %s\0A\00"
@.str.31 = [39 x i8] c"Got result %u from HMAC instead of 0.\0A\00"
@str = [23 x i8] c"Running test for hmac:\00"
@str.32 = [19 x i8] c"Salted Key failed!\00"
@str.33 = [19 x i8] c"Salted Key correct\00"
define i32 @main() {
%1 = alloca [65 x i8]
%2 = getelementptr inbounds [65 x i8], [65 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0))
br label %4
4: ; preds = %0, %56
%5 = phi i64 [ 0, %0 ], [ %58, %56 ]
%6 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.23, i64 0, i64 0))
%7 = trunc i64 %5 to i32
switch i32 %7, label %12 [
i32 3, label %8
i32 1, label %8
i32 0, label %8
]
8: ; preds = %4, %4, %4
%9 = getelementptr inbounds [8 x i8*], [8 x i8*]* @__const.main.key, i64 0, i64 %5
%10 = load i8*, i8** %9
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.24, i64 0, i64 0), i8* %10)
br label %19
12: ; preds = %4
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.25, i64 0, i64 0))
%14 = load i32, i32* @stdout
%15 = getelementptr inbounds [8 x i8*], [8 x i8*]* @__const.main.key, i64 0, i64 %5
%16 = load i8*, i8** %15
%17 = call i32 @strlen(i8* %16)
%18 = call i32 @print_salt(i32 %14, i8* %16, i32 %17)
br label %19
19: ; preds = %12, %8
%20 = phi i8* [ %16, %12 ], [ %10, %8 ]
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.26, i64 0, i64 0))
%22 = and i32 %7, 2147483646
%23 = icmp eq i32 %22, 4
br i1 %23, label %24, label %31
24: ; preds = %19
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.25, i64 0, i64 0))
%26 = load i32, i32* @stdout
%27 = getelementptr inbounds [8 x i8*], [8 x i8*]* @__const.main.salt, i64 0, i64 %5
%28 = load i8*, i8** %27
%29 = call i32 @strlen(i8* %28)
%30 = call i32 @print_salt(i32 %26, i8* %28, i32 %29)
br label %35
31: ; preds = %19
%32 = getelementptr inbounds [8 x i8*], [8 x i8*]* @__const.main.salt, i64 0, i64 %5
%33 = load i8*, i8** %32
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.24, i64 0, i64 0), i8* %33)
br label %35
35: ; preds = %31, %24
%36 = phi i8* [ %33, %31 ], [ %28, %24 ]
%37 = getelementptr inbounds [8 x i8*], [8 x i8*]* @__const.main.expected, i64 0, i64 %5
%38 = load i8*, i8** %37
%39 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.27, i64 0, i64 0), i8* %38)
%40 = call i32 @strlen(i8* %20)
%41 = call i32 @strlen(i8* %36)
%42 = call i32 @hmac_hex(i8* %20, i32 %40, i8* %36, i32 %41, i8* %2)
%43 = icmp eq i32 %42, 0
br i1 %43, label %44, label %52
44: ; preds = %35
%45 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.28, i64 0, i64 0), i8* %2)
%46 = call i64 @memcmp(i8* %2, i8* %38, i32 64)
%47 = icmp eq i64 %46, 0
br i1 %47, label %48, label %50
48: ; preds = %44
%49 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.33, i64 0, i64 0))
br label %56
50: ; preds = %44
%51 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.32, i64 0, i64 0))
br label %56
52: ; preds = %35
%53 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.31, i64 0, i64 0), i32 %42)
%54 = shl nuw nsw i32 1, %7
%55 = or i32 %42, %54
br label %56
56: ; preds = %52, %50, %48
%57 = phi i32 [ 0, %48 ], [ 0, %50 ], [ %55, %52 ]
%58 = add nuw nsw i64 %5, 1
%59 = icmp eq i64 %58, 8
br i1 %59, label %60, label %4
60: ; preds = %56
ret i32 %57
}