#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*/ free(void **);
void **matrix_pointer_alloc(void *, long, long, char, short);
void *vector_realloc(void *, long, long, char);
void **matrix_realloc_zeilen(void **m, long zn_alt, long zn_neu, long sn,
                             char type, short indexing) {
  void **m_neu;
  void *a;
  long ges_laenge_alt;
  long ges_laenge_neu;
  a = m[0];
  ges_laenge_alt = zn_alt * sn;
  ges_laenge_neu = zn_neu * sn;
  a = vector_realloc(a, ges_laenge_alt, ges_laenge_neu, type);
  if (a == NULL)
    return NULL;
  free(m);
  m_neu = matrix_pointer_alloc(a, zn_neu, sn, type, indexing);
  return m_neu;
}


x86 assembly (clang, -O0):
<matrix_realloc_zeilen>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %r8d,-0x6c(%rbp)
mov    %rcx,%rax
mov    -0x6c(%rbp),%ecx
mov    %rax,-0x68(%rbp)
mov    %rdx,%rax
mov    -0x68(%rbp),%rdx
mov    %rax,-0x60(%rbp)
mov    %rsi,%rax
mov    -0x60(%rbp),%rsi
mov    %rax,-0x58(%rbp)
mov    %rdi,%r8
mov    -0x58(%rbp),%rdi
mov    %r9w,%ax
mov    %r8,-0x10(%rbp)
mov    %rdi,-0x18(%rbp)
mov    %rsi,-0x20(%rbp)
mov    %rdx,-0x28(%rbp)
mov    %cl,-0x29(%rbp)
mov    %ax,-0x2c(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x40(%rbp)
mov    -0x18(%rbp),%rax
imul   -0x28(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x20(%rbp),%rax
imul   -0x28(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x40(%rbp),%rdi
mov    -0x48(%rbp),%rsi
mov    -0x50(%rbp),%rdx
movsbl -0x29(%rbp),%ecx
call   1050 <vector_realloc@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
jne    11d4 <matrix_realloc_zeilen+0xa4>
movq   $0x0,-0x8(%rbp)
jmp    1205 <matrix_realloc_zeilen+0xd5>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
mov    -0x40(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
mov    -0x29(%rbp),%al
movsbl %al,%ecx
movswl -0x2c(%rbp),%r8d
call   1040 <matrix_pointer_alloc@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<matrix_realloc_zeilen>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r9d,%r14d
mov    %r8d,%r12d
mov    %rcx,%rbx
mov    %rdx,%r15
mov    %rdi,%r13
mov    (%rdi),%rdi
imul   %rcx,%rsi
mov    %rcx,%rdx
imul   %r15,%rdx
mov    %r8d,%ecx
call   1050 <vector_realloc@plt>
test   %rax,%rax
je     1194 <matrix_realloc_zeilen+0x64>
mov    %rax,%rbp
mov    %r13,%rdi
call   1030 <free@plt>
movsbl %r12b,%ecx
movswl %r14w,%r8d
mov    %rbp,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <matrix_pointer_alloc@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i8** @matrix_realloc_zeilen(i8** %0, i64 %1, i64 %2, i64 %3, i8 signext %4, i16 signext %5) {
%7 = alloca i8**
%8 = alloca i8**
%9 = alloca i64
%10 = alloca i64
%11 = alloca i64
%12 = alloca i8
%13 = alloca i16
%14 = alloca i8**
%15 = alloca i8*
%16 = alloca i64
%17 = alloca i64
store i8** %0, i8*** %8
store i64 %1, i64* %9
store i64 %2, i64* %10
store i64 %3, i64* %11
store i8 %4, i8* %12
store i16 %5, i16* %13
%18 = load i8**, i8*** %8
%19 = getelementptr inbounds i8*, i8** %18, i64 0
%20 = load i8*, i8** %19
store i8* %20, i8** %15
%21 = load i64, i64* %9
%22 = load i64, i64* %11
%23 = mul nsw i64 %21, %22
store i64 %23, i64* %16
%24 = load i64, i64* %10
%25 = load i64, i64* %11
%26 = mul nsw i64 %24, %25
store i64 %26, i64* %17
%27 = load i8*, i8** %15
%28 = load i64, i64* %16
%29 = load i64, i64* %17
%30 = load i8, i8* %12
%31 = call i8* @vector_realloc(i8* %27, i64 %28, i64 %29, i8 signext %30)
store i8* %31, i8** %15
%32 = load i8*, i8** %15
%33 = icmp eq i8* %32, null
br i1 %33, label %34, label %35
34: ; preds = %6
store i8** null, i8*** %7
br label %45
35: ; preds = %6
%36 = load i8**, i8*** %8
%37 = call i32 @free(i8** %36)
%38 = load i8*, i8** %15
%39 = load i64, i64* %10
%40 = load i64, i64* %11
%41 = load i8, i8* %12
%42 = load i16, i16* %13
%43 = call i8** @matrix_pointer_alloc(i8* %38, i64 %39, i64 %40, i8 signext %41, i16 signext %42)
store i8** %43, i8*** %14
%44 = load i8**, i8*** %14
store i8** %44, i8*** %7
br label %45
45: ; preds = %35, %34
%46 = load i8**, i8*** %7
ret i8** %46
}

LLVM IR (-O2):
define i8** @matrix_realloc_zeilen(i8** nocapture %0, i64 %1, i64 %2, i64 %3, i8 signext %4, i16 signext %5) {
%7 = load i8*, i8** %0
%8 = mul nsw i64 %3, %1
%9 = mul nsw i64 %3, %2
%10 = tail call i8* @vector_realloc(i8* %7, i64 %8, i64 %9, i8 signext %4)
%11 = icmp eq i8* %10, null
br i1 %11, label %15, label %12
12: ; preds = %6
%13 = tail call i32 @free(i8** %0)
%14 = tail call i8** @matrix_pointer_alloc(i8* %10, i64 %2, i64 %3, i8 signext %4, i16 signext %5)
br label %15
15: ; preds = %6, %12
%16 = phi i8** [ %14, %12 ], [ null, %6 ]
ret i8** %16
}