#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 /*<<< orphan*/ EINVAL;
int _calculate_k_rakp_hmac(int, int, void const *, unsigned int, void *,
                           unsigned int, void const *, unsigned int);
int /*<<< orphan*/ errno;
int _calculate_k_rakp_hmac_sha1(const void *sik_key, unsigned int sik_key_len,
                                void *k, unsigned int k_len,
                                const void *constant,
                                unsigned int constant_len) {
  if (!sik_key || !sik_key_len || !k || !k_len || !constant || !constant_len ||
      (constant_len < 20)) {
    do {
      errno = (EINVAL);
      ;
    } while (0);
    return (-1);
  }
  return (_calculate_k_rakp_hmac(0x00, 20, sik_key, sik_key_len, k, k_len,
                                 constant, constant_len));
}


x86 assembly (clang, -O0):
<_calculate_k_rakp_hmac_sha1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
mov    %r8,-0x30(%rbp)
mov    %r9d,-0x34(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1177 <_calculate_k_rakp_hmac_sha1+0x67>
cmpl   $0x0,-0x14(%rbp)
je     1177 <_calculate_k_rakp_hmac_sha1+0x67>
cmpq   $0x0,-0x20(%rbp)
je     1177 <_calculate_k_rakp_hmac_sha1+0x67>
cmpl   $0x0,-0x24(%rbp)
je     1177 <_calculate_k_rakp_hmac_sha1+0x67>
cmpq   $0x0,-0x30(%rbp)
je     1177 <_calculate_k_rakp_hmac_sha1+0x67>
cmpl   $0x0,-0x34(%rbp)
je     1177 <_calculate_k_rakp_hmac_sha1+0x67>
cmpl   $0x14,-0x34(%rbp)
jae    119a <_calculate_k_rakp_hmac_sha1+0x8a>
jmp    117c <_calculate_k_rakp_hmac_sha1+0x6c>
mov    0x2e55(%rip),%rax
mov    (%rax),%ecx
mov    0x2e54(%rip),%rax
mov    %ecx,(%rax)
movl   $0xffffffff,-0x4(%rbp)
jmp    11c7 <_calculate_k_rakp_hmac_sha1+0xb7>
mov    -0x10(%rbp),%rdx
mov    -0x14(%rbp),%ecx
mov    -0x20(%rbp),%r8
mov    -0x24(%rbp),%r9d
mov    -0x30(%rbp),%r10
mov    -0x34(%rbp),%eax
xor    %edi,%edi
mov    $0x14,%esi
mov    %r10,(%rsp)
mov    %eax,0x8(%rsp)
call   1030 <_calculate_k_rakp_hmac@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_calculate_k_rakp_hmac_sha1>:
push   %rax
test   %rdi,%rdi
je     1155 <_calculate_k_rakp_hmac_sha1+0x45>
mov    %r9d,%r10d
mov    %ecx,%r9d
mov    %esi,%ecx
test   %esi,%esi
je     1155 <_calculate_k_rakp_hmac_sha1+0x45>
mov    %r8,%rax
mov    %rdx,%r8
test   %rdx,%rdx
je     1155 <_calculate_k_rakp_hmac_sha1+0x45>
test   %r9d,%r9d
je     1155 <_calculate_k_rakp_hmac_sha1+0x45>
test   %rax,%rax
je     1155 <_calculate_k_rakp_hmac_sha1+0x45>
cmp    $0x13,%r10d
jbe    1155 <_calculate_k_rakp_hmac_sha1+0x45>
mov    %rdi,%rdx
xor    %edi,%edi
mov    $0x14,%esi
push   %r10
push   %rax
call   1030 <_calculate_k_rakp_hmac@plt>
add    $0x10,%rsp
pop    %rcx
ret
mov    0x2e7c(%rip),%rax
mov    (%rax),%eax
mov    0x2e7b(%rip),%rcx
mov    %eax,(%rcx)
mov    $0xffffffff,%eax
pop    %rcx
ret

LLVM IR (-O0):
@EINVAL = global i32 0
@errno = global i32 0
define i32 @_calculate_k_rakp_hmac_sha1(i8* %0, i32 %1, i8* %2, i32 %3, i8* %4, i32 %5) {
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i32
%12 = alloca i8*
%13 = alloca i32
store i8* %0, i8** %8
store i32 %1, i32* %9
store i8* %2, i8** %10
store i32 %3, i32* %11
store i8* %4, i8** %12
store i32 %5, i32* %13
%14 = load i8*, i8** %8
%15 = icmp ne i8* %14, null
br i1 %15, label %16, label %34
16: ; preds = %6
%17 = load i32, i32* %9
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %34
19: ; preds = %16
%20 = load i8*, i8** %10
%21 = icmp ne i8* %20, null
br i1 %21, label %22, label %34
22: ; preds = %19
%23 = load i32, i32* %11
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %34
25: ; preds = %22
%26 = load i8*, i8** %12
%27 = icmp ne i8* %26, null
br i1 %27, label %28, label %34
28: ; preds = %25
%29 = load i32, i32* %13
%30 = icmp ne i32 %29, 0
br i1 %30, label %31, label %34
31: ; preds = %28
%32 = load i32, i32* %13
%33 = icmp ult i32 %32, 20
br i1 %33, label %34, label %38
34: ; preds = %31, %28, %25, %22, %19, %16, %6
br label %35
35: ; preds = %34
%36 = load i32, i32* @EINVAL
store i32 %36, i32* @errno
br label %37
37: ; preds = %35
store i32 -1, i32* %7
br label %46
38: ; preds = %31
%39 = load i8*, i8** %8
%40 = load i32, i32* %9
%41 = load i8*, i8** %10
%42 = load i32, i32* %11
%43 = load i8*, i8** %12
%44 = load i32, i32* %13
%45 = call i32 @_calculate_k_rakp_hmac(i32 0, i32 20, i8* %39, i32 %40, i8* %41, i32 %42, i8* %43, i32 %44)
store i32 %45, i32* %7
br label %46
46: ; preds = %38, %37
%47 = load i32, i32* %7
ret i32 %47
}

LLVM IR (-O2):
@EINVAL = global i32 0
@errno = global i32 0
define i32 @_calculate_k_rakp_hmac_sha1(i8* %0, i32 %1, i8* %2, i32 %3, i8* %4, i32 %5) {
%7 = icmp ne i8* %0, null
%8 = icmp ne i32 %1, 0
%9 = and i1 %7, %8
%10 = icmp ne i8* %2, null
%11 = and i1 %9, %10
%12 = icmp ne i32 %3, 0
%13 = and i1 %11, %12
%14 = icmp ne i8* %4, null
%15 = and i1 %13, %14
%16 = icmp ugt i32 %5, 19
%17 = and i1 %15, %16
br i1 %17, label %20, label %18
18: ; preds = %6
%19 = load i32, i32* @EINVAL
store i32 %19, i32* @errno
br label %22
20: ; preds = %6
%21 = tail call i32 @_calculate_k_rakp_hmac(i32 0, i32 20, i8* %0, i32 %1, i8* %2, i32 %3, i8* %4, i32 %5)
br label %22
22: ; preds = %20, %18
%23 = phi i32 [ -1, %18 ], [ %21, %20 ]
ret i32 %23
}