#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*/ assert(int /*<<< orphan*/);
int /*<<< orphan*/ clc_init_key(unsigned char *, unsigned char const *,
                                int const);
int /*<<< orphan*/ memset(unsigned char *, int /*<<< orphan*/, short const);
void clc_init_key_base(unsigned char *key, const unsigned char *data,
                       const int data_len, const short key_len) {
  assert(data_len > 0 && data_len <= key_len &&
         "FAIL: data length incorrect !");
  clc_init_key(key, data, data_len);
  if (data_len < key_len) {
    memset(key + data_len, 0, key_len - data_len);
  }
}


x86 assembly (clang, -O0):
<clc_init_key_base>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %cx,%ax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ax,-0x16(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0x14(%rbp)
mov    %al,-0x17(%rbp)
jle    1177 <clc_init_key_base+0x47>
mov    -0x14(%rbp),%ecx
movswl -0x16(%rbp),%edx
xor    %eax,%eax
cmp    %edx,%ecx
mov    %al,-0x17(%rbp)
jg     1177 <clc_init_key_base+0x47>
mov    $0x1,%al
mov    %al,-0x17(%rbp)
jmp    1177 <clc_init_key_base+0x47>
mov    -0x17(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1030 <clc_init_key@plt>
mov    -0x14(%rbp),%eax
movswl -0x16(%rbp),%ecx
cmp    %ecx,%eax
jge    11bf <clc_init_key_base+0x8f>
mov    -0x8(%rbp),%rdi
movslq -0x14(%rbp),%rax
add    %rax,%rdi
movswl -0x16(%rbp),%eax
sub    -0x14(%rbp),%eax
movswl %ax,%edx
xor    %esi,%esi
call   1040 <memset@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<clc_init_key_base>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %ecx,%ebx
mov    %edx,%ebp
mov    %rsi,%r15
mov    %rdi,%r14
test   %edx,%edx
setg   %al
cmp    %edx,%ecx
setge  %cl
and    %al,%cl
movzbl %cl,%edi
call   1050 <assert@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %ebp,%edx
call   1030 <clc_init_key@plt>
cmp    %ebp,%ebx
jle    1185 <clc_init_key_base+0x55>
movslq %ebp,%rax
add    %rax,%r14
sub    %ebp,%ebx
movswl %bx,%edx
mov    %r14,%rdi
xor    %esi,%esi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <memset@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [30 x i8] c"FAIL: data length incorrect !\00"
define void @clc_init_key_base(i8* %0, i8* %1, i32 %2, i16 signext %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i16
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
store i16 %3, i16* %8
%9 = load i32, i32* %7
%10 = icmp sgt i32 %9, 0
br i1 %10, label %11, label %17
11: ; preds = %4
%12 = load i32, i32* %7
%13 = load i16, i16* %8
%14 = sext i16 %13 to i32
%15 = icmp sle i32 %12, %14
br i1 %15, label %16, label %17
16: ; preds = %11
br label %17
17: ; preds = %16, %11, %4
%18 = phi i1 [ false, %11 ], [ false, %4 ], [ true, %16 ]
%19 = zext i1 %18 to i32
%20 = call i32 @assert(i32 %19)
%21 = load i8*, i8** %5
%22 = load i8*, i8** %6
%23 = load i32, i32* %7
%24 = call i32 @clc_init_key(i8* %21, i8* %22, i32 %23)
%25 = load i32, i32* %7
%26 = load i16, i16* %8
%27 = sext i16 %26 to i32
%28 = icmp slt i32 %25, %27
br i1 %28, label %29, label %40
29: ; preds = %17
%30 = load i8*, i8** %5
%31 = load i32, i32* %7
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i8, i8* %30, i64 %32
%34 = load i16, i16* %8
%35 = sext i16 %34 to i32
%36 = load i32, i32* %7
%37 = sub nsw i32 %35, %36
%38 = trunc i32 %37 to i16
%39 = call i32 @memset(i8* %33, i32 0, i16 signext %38)
br label %40
40: ; preds = %29, %17
ret void
}

LLVM IR (-O2):
define void @clc_init_key_base(i8* %0, i8* %1, i32 %2, i16 signext %3) {
%5 = icmp sgt i32 %2, 0
%6 = sext i16 %3 to i32
%7 = icmp sge i32 %6, %2
%8 = and i1 %5, %7
%9 = zext i1 %8 to i32
%10 = tail call i32 @assert(i32 %9)
%11 = tail call i32 @clc_init_key(i8* %0, i8* %1, i32 %2)
%12 = icmp sgt i32 %6, %2
br i1 %12, label %13, label %19
13: ; preds = %4
%14 = sext i32 %2 to i64
%15 = getelementptr inbounds i8, i8* %0, i64 %14
%16 = trunc i32 %2 to i16
%17 = sub i16 %3, %16
%18 = tail call i32 @memset(i8* %15, i32 0, i16 signext %17)
br label %19
19: ; preds = %13, %4
ret void
}