void sensors_malloc_array(void *list, int *num_el, int *max_el, int el_size) {
  void **my_list = (void **)list;
  *my_list = malloc(el_size * 16);
  if (!*my_list)
    sensors_fatal_error(__func__, "Allocating new elements");
  *max_el = 16;
  *num_el = 0;
}


x86 assembly (clang, -O0):
<sensors_malloc_array>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x1c(%rbp),%eax
shl    $0x4,%eax
movslq %eax,%rdi
call   1040 <malloc@plt>
mov    %rax,%rcx
mov    -0x28(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x28(%rbp),%rax
cmpq   $0x0,(%rax)
jne    117a <sensors_malloc_array+0x5a>
lea    0xe94(%rip),%rdi
lea    0xea2(%rip),%rsi
mov    $0x0,%al
call   1030 <sensors_fatal_error@plt>
mov    -0x18(%rbp),%rax
movl   $0x10,(%rax)
mov    -0x10(%rbp),%rax
movl   $0x0,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sensors_malloc_array>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
shl    $0x4,%ecx
movslq %ecx,%rdi
call   1040 <malloc@plt>
mov    %rax,(%rbx)
test   %rax,%rax
jne    1156 <sensors_malloc_array+0x36>
lea    0xeb8(%rip),%rdi
lea    0xec6(%rip),%rsi
xor    %eax,%eax
call   1030 <sensors_fatal_error@plt>
movl   $0x10,(%r14)
movl   $0x0,(%r15)
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__func__.sensors_malloc_array = [21 x i8] c"sensors_malloc_array\00"
@.str = [24 x i8] c"Allocating new elements\00"
define void @sensors_malloc_array(i8* %0, i32* %1, i32* %2, i32 %3) {
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i8**
store i8* %0, i8** %5
store i32* %1, i32** %6
store i32* %2, i32** %7
store i32 %3, i32* %8
%10 = load i8*, i8** %5
%11 = bitcast i8* %10 to i8**
store i8** %11, i8*** %9
%12 = load i32, i32* %8
%13 = mul nsw i32 %12, 16
%14 = sext i32 %13 to i64
%15 = call i8* @malloc(i64 %14)
%16 = load i8**, i8*** %9
store i8* %15, i8** %16
%17 = load i8**, i8*** %9
%18 = load i8*, i8** %17
%19 = icmp ne i8* %18, null
br i1 %19, label %22, label %20
20: ; preds = %4
%21 = call i32 (i8*, i8*, ...) bitcast (i32 (...)* @sensors_fatal_error to i32 (i8*, i8*, ...)*)(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @__func__.sensors_malloc_array, i64 0, i64 0), i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
br label %22
22: ; preds = %20, %4
%23 = load i32*, i32** %7
store i32 16, i32* %23
%24 = load i32*, i32** %6
store i32 0, i32* %24
ret void
}

LLVM IR (-O2):
@__func__.sensors_malloc_array = [21 x i8] c"sensors_malloc_array\00"
@.str = [24 x i8] c"Allocating new elements\00"
define void @sensors_malloc_array(i8* nocapture writeonly %0, i32* nocapture writeonly %1, i32* nocapture writeonly %2, i32 %3) {
%5 = bitcast i8* %0 to i8**
%6 = shl nsw i32 %3, 4
%7 = sext i32 %6 to i64
%8 = tail call i8* @malloc(i64 %7)
store i8* %8, i8** %5
%9 = icmp eq i8* %8, null
br i1 %9, label %10, label %12
10: ; preds = %4
%11 = tail call i32 (i8*, i8*, ...) bitcast (i32 (...)* @sensors_fatal_error to i32 (i8*, i8*, ...)*)(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @__func__.sensors_malloc_array, i64 0, i64 0), i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
br label %12
12: ; preds = %10, %4
store i32 16, i32* %2
store i32 0, i32* %1
ret void
}