#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 **matrix_pointer_alloc(void *, long, long, char, short);
void *vector_alloc(long, char);
void **matrix_all_alloc(long zn, long sn, char type, short indexing) {
  void *a;
  long ges_laenge;
  ges_laenge = zn * sn;
  a = vector_alloc(ges_laenge, type);
  if (a == NULL)
    return NULL;
  return matrix_pointer_alloc(a, zn, sn, type, indexing);
}


x86 assembly (clang, -O0):
<matrix_all_alloc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %cx,%ax
mov    %dl,%cl
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %cl,-0x19(%rbp)
mov    %ax,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
imul   -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
movsbl -0x19(%rbp),%esi
call   1030 <vector_alloc@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1172 <matrix_all_alloc+0x52>
movq   $0x0,-0x8(%rbp)
jmp    1192 <matrix_all_alloc+0x72>
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x19(%rbp),%al
movsbl %al,%ecx
movswl -0x1c(%rbp),%r8d
call   1040 <matrix_pointer_alloc@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<matrix_all_alloc>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %ecx,%r14d
mov    %edx,%ebx
mov    %rsi,%r15
mov    %rdi,%rbp
mov    %rsi,%rdi
imul   %rbp,%rdi
mov    %edx,%esi
call   1030 <vector_alloc@plt>
test   %rax,%rax
je     1164 <matrix_all_alloc+0x44>
movsbl %bl,%ecx
movswl %r14w,%r8d
mov    %rax,%rdi
mov    %rbp,%rsi
mov    %r15,%rdx
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <matrix_pointer_alloc@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i8** @matrix_all_alloc(i64 %0, i64 %1, i8 signext %2, i16 signext %3) {
%5 = alloca i8**
%6 = alloca i64
%7 = alloca i64
%8 = alloca i8
%9 = alloca i16
%10 = alloca i8*
%11 = alloca i64
store i64 %0, i64* %6
store i64 %1, i64* %7
store i8 %2, i8* %8
store i16 %3, i16* %9
%12 = load i64, i64* %6
%13 = load i64, i64* %7
%14 = mul nsw i64 %12, %13
store i64 %14, i64* %11
%15 = load i64, i64* %11
%16 = load i8, i8* %8
%17 = call i8* @vector_alloc(i64 %15, i8 signext %16)
store i8* %17, i8** %10
%18 = load i8*, i8** %10
%19 = icmp eq i8* %18, null
br i1 %19, label %20, label %21
20: ; preds = %4
store i8** null, i8*** %5
br label %28
21: ; preds = %4
%22 = load i8*, i8** %10
%23 = load i64, i64* %6
%24 = load i64, i64* %7
%25 = load i8, i8* %8
%26 = load i16, i16* %9
%27 = call i8** @matrix_pointer_alloc(i8* %22, i64 %23, i64 %24, i8 signext %25, i16 signext %26)
store i8** %27, i8*** %5
br label %28
28: ; preds = %21, %20
%29 = load i8**, i8*** %5
ret i8** %29
}

LLVM IR (-O2):
define i8** @matrix_all_alloc(i64 %0, i64 %1, i8 signext %2, i16 signext %3) {
%5 = mul nsw i64 %1, %0
%6 = tail call i8* @vector_alloc(i64 %5, i8 signext %2)
%7 = icmp eq i8* %6, null
br i1 %7, label %10, label %8
8: ; preds = %4
%9 = tail call i8** @matrix_pointer_alloc(i8* %6, i64 %0, i64 %1, i8 signext %2, i16 signext %3)
br label %10
10: ; preds = %4, %8
%11 = phi i8** [ %9, %8 ], [ null, %4 ]
ret i8** %11
}