#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 */
void *malloc(int);
int /*<<< orphan*/ sensors_fatal_error(char *, char *);
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("sensors_malloc_array", "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),%edi
shl    $0x4,%edi
call   1040 <malloc@plt>
mov    %rax,%rcx
mov    -0x28(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x28(%rbp),%rax
cmpq   $0x0,(%rax)
jne    1175 <sensors_malloc_array+0x55>
lea    0xe97(%rip),%rdi
lea    0xea5(%rip),%rsi
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
mov    %ecx,%edi
call   1040 <malloc@plt>
mov    %rax,(%rbx)
test   %rax,%rax
jne    1153 <sensors_malloc_array+0x33>
lea    0xeb9(%rip),%rdi
lea    0xec7(%rip),%rsi
call   1030 <sensors_fatal_error@plt>
movl   $0x10,(%r14)
movl   $0x0,(%r15)
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [21 x i8] c"sensors_malloc_array\00"
@.str.1 = [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 = call i8* @malloc(i32 %13)
%15 = load i8**, i8*** %9
store i8* %14, i8** %15
%16 = load i8**, i8*** %9
%17 = load i8*, i8** %16
%18 = icmp ne i8* %17, null
br i1 %18, label %21, label %19
19: ; preds = %4
%20 = call i32 @sensors_fatal_error(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
br label %21
21: ; preds = %19, %4
%22 = load i32*, i32** %7
store i32 16, i32* %22
%23 = load i32*, i32** %6
store i32 0, i32* %23
ret void
}

LLVM IR (-O2):
@.str = [21 x i8] c"sensors_malloc_array\00"
@.str.1 = [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 = tail call i8* @malloc(i32 %6)
store i8* %7, i8** %5
%8 = icmp eq i8* %7, null
br i1 %8, label %9, label %11
9: ; preds = %4
%10 = tail call i32 @sensors_fatal_error(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
br label %11
11: ; preds = %9, %4
store i32 16, i32* %2
store i32 0, i32* %1
ret void
}