#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*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ getMatrixValues(double *, int *);
int /*<<< orphan*/ getSizeForArray(int, int *);
int /*<<< orphan*/ getchar();
int /*<<< orphan*/ matrixmultiplication(double *, int *, double *, int *,
                                        double *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ printmatrix(double *, int *);
int /*<<< orphan*/ stdin;
int main(void) {
  int sizearr1[2], sizearr2[2];
  do {
    getSizeForArray(1, sizearr1);
    getSizeForArray(2, sizearr2);
    if (sizearr1[1] != sizearr2[0])
      printf("Spalten der ersten Matrix muessen gleich den Zeilen der 2. "
             "Matrix sein!\n");
  } while (sizearr1[1] != sizearr2[0]);
  double matrix1[sizearr1[0] * sizearr1[1]], matrix2[sizearr2[0] * sizearr2[1]],
      result[sizearr1[0] * sizearr2[1]];
  printf("Eingabe der 1. Matrix\n");
  getMatrixValues(matrix1, sizearr1);
  printf("Eingabe der 2. Matrix\n");
  getMatrixValues(matrix2, sizearr2);
  printf("1. Matrix\n");
  printmatrix(matrix1, sizearr1);
  printf("2. Matrix\n");
  printmatrix(matrix2, sizearr2);
  matrixmultiplication(matrix1, sizearr1, matrix2, sizearr2, result);
  int sizeresult[2] = {sizearr1[0], sizearr2[1]};
  printf("Ergebnismatrix\n");
  printmatrix(result, sizeresult);
  fflush(stdin);
  getchar();
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0xc(%rbp),%rsi
mov    $0x1,%edi
call   1080 <getSizeForArray@plt>
lea    -0x14(%rbp),%rsi
mov    $0x2,%edi
call   1080 <getSizeForArray@plt>
mov    -0x8(%rbp),%eax
cmp    -0x14(%rbp),%eax
je     11b3 <main+0x43>
lea    0xe52(%rip),%rdi
call   1050 <printf@plt>
jmp    11b8 <main+0x48>
mov    -0x8(%rbp),%eax
cmp    -0x14(%rbp),%eax
jne    117f <main+0xf>
mov    -0xc(%rbp),%eax
mov    -0x8(%rbp),%ecx
imul   %ecx,%eax
mov    %rsp,%rcx
mov    %rcx,-0x20(%rbp)
lea    0xf(,%rax,8),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x58(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x28(%rbp)
mov    -0x14(%rbp),%eax
mov    -0x10(%rbp),%ecx
imul   %ecx,%eax
lea    0xf(,%rax,8),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x50(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x30(%rbp)
mov    -0xc(%rbp),%eax
mov    -0x10(%rbp),%ecx
imul   %ecx,%eax
lea    0xf(,%rax,8),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x48(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x38(%rbp)
lea    0xe05(%rip),%rdi
call   1050 <printf@plt>
mov    -0x58(%rbp),%rdi
lea    -0xc(%rbp),%rsi
call   1030 <getMatrixValues@plt>
lea    0xe03(%rip),%rdi
call   1050 <printf@plt>
mov    -0x50(%rbp),%rdi
lea    -0x14(%rbp),%rsi
call   1030 <getMatrixValues@plt>
lea    0xddf(%rip),%rdi
call   1050 <printf@plt>
mov    -0x58(%rbp),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <printmatrix@plt>
lea    0xddd(%rip),%rdi
call   1050 <printf@plt>
mov    -0x50(%rbp),%rdi
lea    -0x14(%rbp),%rsi
call   1040 <printmatrix@plt>
mov    -0x58(%rbp),%rdi
mov    -0x50(%rbp),%rdx
mov    -0x48(%rbp),%r8
lea    -0xc(%rbp),%rsi
lea    -0x14(%rbp),%rcx
call   1060 <matrixmultiplication@plt>
mov    -0xc(%rbp),%eax
mov    %eax,-0x40(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x3c(%rbp)
lea    0xdaa(%rip),%rdi
call   1050 <printf@plt>
mov    -0x48(%rbp),%rdi
lea    -0x40(%rbp),%rsi
call   1040 <printmatrix@plt>
mov    0x2d02(%rip),%rax
mov    (%rax),%edi
call   1090 <fflush@plt>
mov    $0x0,%al
call   1070 <getchar@plt>
mov    -0x20(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
lea    -0x38(%rbp),%r14
lea    -0x30(%rbp),%rbx
lea    0xeab(%rip),%r15
mov    $0x1,%edi
mov    %r14,%rsi
call   1080 <getSizeForArray@plt>
mov    $0x2,%edi
mov    %rbx,%rsi
call   1080 <getSizeForArray@plt>
mov    -0x34(%rbp),%eax
cmp    -0x30(%rbp),%eax
je     11c2 <main+0x52>
mov    %r15,%rdi
call   1030 <puts@plt>
mov    -0x30(%rbp),%eax
cmp    %eax,-0x34(%rbp)
jne    1190 <main+0x20>
mov    %rsp,-0x48(%rbp)
imul   -0x38(%rbp),%eax
mov    %rsp,%r15
lea    0xf(,%rax,8),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r15
mov    %r15,%rsp
mov    -0x2c(%rbp),%eax
mov    -0x30(%rbp),%ecx
imul   %eax,%ecx
mov    %rsp,%rbx
lea    0xf(,%rcx,8),%rcx
and    $0xfffffffffffffff0,%rcx
sub    %rcx,%rbx
mov    %rbx,%rsp
imul   -0x38(%rbp),%eax
mov    %rsp,%r14
lea    0xf(,%rax,8),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r14
mov    %r14,%rsp
lea    0xde3(%rip),%rdi
call   1030 <puts@plt>
lea    -0x38(%rbp),%r12
mov    %r15,%rdi
mov    %r12,%rsi
call   1040 <getMatrixValues@plt>
lea    0xdde(%rip),%rdi
call   1030 <puts@plt>
lea    -0x30(%rbp),%r13
mov    %rbx,%rdi
mov    %r13,%rsi
call   1040 <getMatrixValues@plt>
lea    0xdb9(%rip),%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1050 <printmatrix@plt>
lea    0xdb8(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   1050 <printmatrix@plt>
mov    %r15,%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
mov    %r13,%rcx
mov    %r14,%r8
call   1060 <matrixmultiplication@plt>
mov    -0x38(%rbp),%eax
mov    %eax,-0x40(%rbp)
mov    -0x2c(%rbp),%eax
mov    %eax,-0x3c(%rbp)
lea    0xd8b(%rip),%rdi
call   1030 <puts@plt>
lea    -0x40(%rbp),%rsi
mov    %r14,%rdi
call   1050 <printmatrix@plt>
mov    0x2d2f(%rip),%rax
mov    (%rax),%edi
call   1090 <fflush@plt>
xor    %eax,%eax
call   1070 <getchar@plt>
mov    -0x48(%rbp),%rsp
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [73 x i8] c"Spalten der ersten Matrix muessen gleich den Zeilen der 2. Matrix sein!\0A\00"
@.str.1 = [23 x i8] c"Eingabe der 1. Matrix\0A\00"
@.str.2 = [23 x i8] c"Eingabe der 2. Matrix\0A\00"
@.str.3 = [11 x i8] c"1. Matrix\0A\00"
@.str.4 = [11 x i8] c"2. Matrix\0A\00"
@.str.5 = [16 x i8] c"Ergebnismatrix\0A\00"
@stdin = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca [2 x i32]
%3 = alloca [2 x i32]
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i64
%7 = alloca i64
%8 = alloca [2 x i32]
store i32 0, i32* %1
br label %9
9: ; preds = %22, %0
%10 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 0
%11 = call i32 @getSizeForArray(i32 1, i32* %10)
%12 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 0
%13 = call i32 @getSizeForArray(i32 2, i32* %12)
%14 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 1
%15 = load i32, i32* %14
%16 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 0
%17 = load i32, i32* %16
%18 = icmp ne i32 %15, %17
br i1 %18, label %19, label %21
19: ; preds = %9
%20 = call i32 @printf(i8* getelementptr inbounds ([73 x i8], [73 x i8]* @.str, i64 0, i64 0))
br label %21
21: ; preds = %19, %9
br label %22
22: ; preds = %21
%23 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 1
%24 = load i32, i32* %23
%25 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 0
%26 = load i32, i32* %25
%27 = icmp ne i32 %24, %26
br i1 %27, label %9, label %28
28: ; preds = %22
%29 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 0
%30 = load i32, i32* %29
%31 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 1
%32 = load i32, i32* %31
%33 = mul nsw i32 %30, %32
%34 = zext i32 %33 to i64
%35 = call i8* @llvm.stacksave()
store i8* %35, i8** %4
%36 = alloca double, i64 %34
store i64 %34, i64* %5
%37 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 0
%38 = load i32, i32* %37
%39 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 1
%40 = load i32, i32* %39
%41 = mul nsw i32 %38, %40
%42 = zext i32 %41 to i64
%43 = alloca double, i64 %42
store i64 %42, i64* %6
%44 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 0
%45 = load i32, i32* %44
%46 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 1
%47 = load i32, i32* %46
%48 = mul nsw i32 %45, %47
%49 = zext i32 %48 to i64
%50 = alloca double, i64 %49
store i64 %49, i64* %7
%51 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
%52 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 0
%53 = call i32 @getMatrixValues(double* %36, i32* %52)
%54 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
%55 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 0
%56 = call i32 @getMatrixValues(double* %43, i32* %55)
%57 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0))
%58 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 0
%59 = call i32 @printmatrix(double* %36, i32* %58)
%60 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
%61 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 0
%62 = call i32 @printmatrix(double* %43, i32* %61)
%63 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 0
%64 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 0
%65 = call i32 @matrixmultiplication(double* %36, i32* %63, double* %43, i32* %64, double* %50)
%66 = getelementptr inbounds [2 x i32], [2 x i32]* %8, i64 0, i64 0
%67 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 0
%68 = load i32, i32* %67
store i32 %68, i32* %66
%69 = getelementptr inbounds i32, i32* %66, i64 1
%70 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 1
%71 = load i32, i32* %70
store i32 %71, i32* %69
%72 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0))
%73 = getelementptr inbounds [2 x i32], [2 x i32]* %8, i64 0, i64 0
%74 = call i32 @printmatrix(double* %50, i32* %73)
%75 = load i32, i32* @stdin
%76 = call i32 @fflush(i32 %75)
%77 = call i32 (...) @getchar()
%78 = load i8*, i8** %4
%79 = load i32, i32* %1
ret i32 %79
}

LLVM IR (-O2):
@stdin = global i32 0
@str = [22 x i8] c"Eingabe der 1. Matrix\00"
@str.6 = [22 x i8] c"Eingabe der 2. Matrix\00"
@str.7 = [10 x i8] c"1. Matrix\00"
@str.8 = [10 x i8] c"2. Matrix\00"
@str.9 = [15 x i8] c"Ergebnismatrix\00"
@str.10 = [72 x i8] c"Spalten der ersten Matrix muessen gleich den Zeilen der 2. Matrix sein!\00"
define i32 @main() {
%1 = alloca [2 x i32]
%2 = alloca [2 x i32]
%3 = alloca [2 x i32]
%4 = bitcast [2 x i32]* %1 to i8*
%5 = bitcast [2 x i32]* %2 to i8*
%6 = getelementptr inbounds [2 x i32], [2 x i32]* %1, i64 0, i64 0
%7 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 0
%8 = getelementptr inbounds [2 x i32], [2 x i32]* %1, i64 0, i64 1
br label %9
9: ; preds = %15, %0
%10 = call i32 @getSizeForArray(i32 1, i32* %6)
%11 = call i32 @getSizeForArray(i32 2, i32* %7)
%12 = load i32, i32* %8
%13 = load i32, i32* %7
%14 = icmp eq i32 %12, %13
br i1 %14, label %20, label %15
15: ; preds = %9
%16 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([72 x i8], [72 x i8]* @str.10, i64 0, i64 0))
%17 = load i32, i32* %8
%18 = load i32, i32* %7
%19 = icmp eq i32 %17, %18
br i1 %19, label %20, label %9
20: ; preds = %9, %15
%21 = phi i32 [ %18, %15 ], [ %12, %9 ]
%22 = load i32, i32* %6
%23 = mul nsw i32 %22, %21
%24 = zext i32 %23 to i64
%25 = call i8* @llvm.stacksave()
%26 = alloca double, i64 %24
%27 = load i32, i32* %7
%28 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 1
%29 = load i32, i32* %28
%30 = mul nsw i32 %29, %27
%31 = zext i32 %30 to i64
%32 = alloca double, i64 %31
%33 = load i32, i32* %6
%34 = mul nsw i32 %33, %29
%35 = zext i32 %34 to i64
%36 = alloca double, i64 %35
%37 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
%38 = call i32 @getMatrixValues(double* %26, i32* %6)
%39 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.6, i64 0, i64 0))
%40 = call i32 @getMatrixValues(double* %32, i32* %7)
%41 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str.7, i64 0, i64 0))
%42 = call i32 @printmatrix(double* %26, i32* %6)
%43 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str.8, i64 0, i64 0))
%44 = call i32 @printmatrix(double* %32, i32* %7)
%45 = call i32 @matrixmultiplication(double* %26, i32* %6, double* %32, i32* %7, double* %36)
%46 = bitcast [2 x i32]* %3 to i8*
%47 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 0
%48 = load i32, i32* %6
store i32 %48, i32* %47
%49 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 1
%50 = load i32, i32* %28
store i32 %50, i32* %49
%51 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.9, i64 0, i64 0))
%52 = call i32 @printmatrix(double* %36, i32* %47)
%53 = load i32, i32* @stdin
%54 = call i32 @fflush(i32 %53)
%55 = call i32 (...) @getchar()
ret i32 0
}