void init_keypack(unsigned char *key_p, unsigned char *key) {
  memset(key_p, 0, 400 + 2);
  unsigned char pad = 0x01;
  unsigned char keypack_sizeInBytes = ((strlen(key)) + 2);
  key_p[0] = keypack_sizeInBytes;
  write_data_to_pointer_on_offset(key_p, key, 1, (strlen(key)));
  write_data_to_pointer_on_offset(key_p, &pad, 1 + (strlen(key)), 1);
}


x86 assembly (clang, -O0):
<init_keypack>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
xor    %esi,%esi
mov    $0x192,%edx
call   1040 <memset@plt>
movb   $0x1,-0x11(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
add    $0x2,%rax
mov    %al,-0x12(%rbp)
mov    -0x12(%rbp),%cl
mov    -0x8(%rbp),%rax
mov    %cl,(%rax)
mov    -0x8(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    %rax,%rcx
mov    $0x1,%edx
mov    $0x0,%al
call   1050 <write_data_to_pointer_on_offset@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x20(%rbp),%rdi
mov    %rax,%rdx
add    $0x1,%rdx
lea    -0x11(%rbp),%rsi
mov    $0x1,%ecx
mov    $0x0,%al
call   1050 <write_data_to_pointer_on_offset@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<init_keypack>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
mov    $0x192,%edx
xor    %esi,%esi
call   1040 <memset@plt>
movb   $0x1,0x7(%rsp)
mov    %rbx,%rdi
call   1030 <strlen@plt>
add    $0x2,%al
mov    %al,(%r14)
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0x1,%edx
mov    %rax,%rcx
xor    %eax,%eax
call   1050 <write_data_to_pointer_on_offset@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
lea    0x1(%rax),%rdx
lea    0x7(%rsp),%rsi
mov    %r14,%rdi
mov    $0x1,%ecx
xor    %eax,%eax
call   1050 <write_data_to_pointer_on_offset@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @init_keypack(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8
%6 = alloca i8
store i8* %0, i8** %3
store i8* %1, i8** %4
%7 = load i8*, i8** %3
store i8 1, i8* %5
%8 = load i8*, i8** %4
%9 = call i64 @strlen(i8* %8)
%10 = add i64 %9, 2
%11 = trunc i64 %10 to i8
store i8 %11, i8* %6
%12 = load i8, i8* %6
%13 = load i8*, i8** %3
%14 = getelementptr inbounds i8, i8* %13, i64 0
store i8 %12, i8* %14
%15 = load i8*, i8** %3
%16 = load i8*, i8** %4
%17 = load i8*, i8** %4
%18 = call i64 @strlen(i8* %17)
%19 = call i32 (i8*, i8*, i32, i64, ...) bitcast (i32 (...)* @write_data_to_pointer_on_offset to i32 (i8*, i8*, i32, i64, ...)*)(i8* %15, i8* %16, i32 1, i64 %18)
%20 = load i8*, i8** %3
%21 = load i8*, i8** %4
%22 = call i64 @strlen(i8* %21)
%23 = add i64 1, %22
%24 = call i32 (i8*, i8*, i64, i32, ...) bitcast (i32 (...)* @write_data_to_pointer_on_offset to i32 (i8*, i8*, i64, i32, ...)*)(i8* %20, i8* %5, i64 %23, i32 1)
ret void
}

LLVM IR (-O2):
define void @init_keypack(i8* %0, i8* %1) {
%3 = alloca i8
tail call void @llvm.memset.p0i8.i64(i8* align 1 dereferenceable(402) %0, i8 0, i64 402, i1 false)
store i8 1, i8* %3
%4 = tail call i64 @strlen(i8* dereferenceable(1) %1)
%5 = trunc i64 %4 to i8
%6 = add i8 %5, 2
store i8 %6, i8* %0
%7 = tail call i64 @strlen(i8* dereferenceable(1) %1)
%8 = tail call i32 (i8*, i8*, i32, i64, ...) bitcast (i32 (...)* @write_data_to_pointer_on_offset to i32 (i8*, i8*, i32, i64, ...)*)(i8* %0, i8* %1, i32 1, i64 %7)
%9 = tail call i64 @strlen(i8* dereferenceable(1) %1)
%10 = add i64 %9, 1
%11 = call i32 (i8*, i8*, i64, i32, ...) bitcast (i32 (...)* @write_data_to_pointer_on_offset to i32 (i8*, i8*, i64, i32, ...)*)(i8* %0, i8* %3, i64 %10, i32 1)
ret void
}