#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*/ printf(char *, ...);
int multiplyMatrices(int **mat1, int **mat2, int m1, int n1, int m2, int n2) {
  int i, j, k = 0, res;
  printf("\nResult of multiplication:\n");
  for (i = 0; i < m1; i++) {
    for (j = 0; j < n2; j++) {
      res = 0;
      for (k = 0; k < n1; k++) {
        res = mat1[i][k] * mat2[k][j];
      }
      printf("%d ", res);
    }
    printf("\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<multiplyMatrices>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    %r8d,-0x1c(%rbp)
mov    %r9d,-0x20(%rbp)
movl   $0x0,-0x2c(%rbp)
lea    0xec4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11f6 <multiplyMatrices+0xe6>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    11da <multiplyMatrices+0xca>
movl   $0x0,-0x30(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    11bb <multiplyMatrices+0xab>
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    -0x10(%rbp),%rcx
movslq -0x2c(%rbp),%rdx
mov    (%rcx,%rdx,8),%rcx
movslq -0x28(%rbp),%rdx
imul   (%rcx,%rdx,4),%eax
mov    %eax,-0x30(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1177 <multiplyMatrices+0x67>
mov    -0x30(%rbp),%esi
lea    0xe57(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    115d <multiplyMatrices+0x4d>
lea    0xe39(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    114a <multiplyMatrices+0x3a>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<multiplyMatrices>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r9d,0x4(%rsp)
mov    %ecx,%ebx
mov    %edx,%r12d
mov    %rsi,0x10(%rsp)
mov    %rdi,%r13
lea    0xead(%rip),%rdi
call   1040 <puts@plt>
test   %r12d,%r12d
jle    11e5 <multiplyMatrices+0xb5>
lea    -0x1(%rbx),%ebp
mov    %r12d,%eax
mov    %rax,0x8(%rsp)
mov    0x4(%rsp),%r14d
xor    %r15d,%r15d
jmp    1195 <multiplyMatrices+0x65>
nopw   0x0(%rax,%rax,1)
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%r15
cmp    0x8(%rsp),%r15
je     11e5 <multiplyMatrices+0xb5>
cmpl   $0x0,0x4(%rsp)
jle    1180 <multiplyMatrices+0x50>
xor    %r12d,%r12d
jmp    11dd <multiplyMatrices+0xad>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    0x0(%r13,%r15,8),%rax
mov    0x10(%rsp),%rcx
mov    (%rcx,%rbp,8),%rcx
mov    (%rcx,%r12,4),%esi
imul   (%rax,%rbp,4),%esi
lea    0xe33(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%r12
cmp    %r12,%r14
je     1180 <multiplyMatrices+0x50>
test   %ebx,%ebx
jg     11b0 <multiplyMatrices+0x80>
xor    %esi,%esi
jmp    11c6 <multiplyMatrices+0x96>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [28 x i8] c"\0AResult of multiplication:\0A\00"
@.str.1 = [4 x i8] c"%d \00"
@.str.2 = [2 x i8] c"\0A\00"
define i32 @multiplyMatrices(i32** %0, i32** %1, i32 %2, i32 %3, i32 %4, i32 %5) {
%7 = alloca i32**
%8 = alloca i32**
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
store i32** %0, i32*** %7
store i32** %1, i32*** %8
store i32 %2, i32* %9
store i32 %3, i32* %10
store i32 %4, i32* %11
store i32 %5, i32* %12
store i32 0, i32* %15
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %13
br label %18
18: ; preds = %63, %6
%19 = load i32, i32* %13
%20 = load i32, i32* %9
%21 = icmp slt i32 %19, %20
br i1 %21, label %22, label %66
22: ; preds = %18
store i32 0, i32* %14
br label %23
23: ; preds = %58, %22
%24 = load i32, i32* %14
%25 = load i32, i32* %12
%26 = icmp slt i32 %24, %25
br i1 %26, label %27, label %61
27: ; preds = %23
store i32 0, i32* %16
store i32 0, i32* %15
br label %28
28: ; preds = %52, %27
%29 = load i32, i32* %15
%30 = load i32, i32* %10
%31 = icmp slt i32 %29, %30
br i1 %31, label %32, label %55
32: ; preds = %28
%33 = load i32**, i32*** %7
%34 = load i32, i32* %13
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i32*, i32** %33, i64 %35
%37 = load i32*, i32** %36
%38 = load i32, i32* %15
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i32, i32* %37, i64 %39
%41 = load i32, i32* %40
%42 = load i32**, i32*** %8
%43 = load i32, i32* %15
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds i32*, i32** %42, i64 %44
%46 = load i32*, i32** %45
%47 = load i32, i32* %14
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds i32, i32* %46, i64 %48
%50 = load i32, i32* %49
%51 = mul nsw i32 %41, %50
store i32 %51, i32* %16
br label %52
52: ; preds = %32
%53 = load i32, i32* %15
%54 = add nsw i32 %53, 1
store i32 %54, i32* %15
br label %28
55: ; preds = %28
%56 = load i32, i32* %16
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %56)
br label %58
58: ; preds = %55
%59 = load i32, i32* %14
%60 = add nsw i32 %59, 1
store i32 %60, i32* %14
br label %23
61: ; preds = %23
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %63
63: ; preds = %61
%64 = load i32, i32* %13
%65 = add nsw i32 %64, 1
store i32 %65, i32* %13
br label %18
66: ; preds = %18
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [4 x i8] c"%d \00"
@str = [27 x i8] c"\0AResult of multiplication:\00"
define i32 @multiplyMatrices(i32** nocapture %0, i32** nocapture %1, i32 %2, i32 %3, i32 %4, i32 %5) {
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str, i64 0, i64 0))
%8 = icmp sgt i32 %2, 0
br i1 %8, label %9, label %40
9: ; preds = %6
%10 = icmp sgt i32 %5, 0
%11 = icmp sgt i32 %3, 0
%12 = add i32 %3, -1
%13 = zext i32 %2 to i64
%14 = zext i32 %5 to i64
%15 = zext i32 %12 to i64
%16 = getelementptr inbounds i32*, i32** %1, i64 %15
br label %17
17: ; preds = %9, %36
%18 = phi i64 [ 0, %9 ], [ %38, %36 ]
br i1 %10, label %19, label %36
19: ; preds = %17
%20 = getelementptr inbounds i32*, i32** %0, i64 %18
br label %21
21: ; preds = %19, %31
%22 = phi i64 [ 0, %19 ], [ %34, %31 ]
br i1 %11, label %23, label %31
23: ; preds = %21
%24 = load i32*, i32** %20
%25 = getelementptr inbounds i32, i32* %24, i64 %15
%26 = load i32, i32* %25
%27 = load i32*, i32** %16
%28 = getelementptr inbounds i32, i32* %27, i64 %22
%29 = load i32, i32* %28
%30 = mul nsw i32 %29, %26
br label %31
31: ; preds = %23, %21
%32 = phi i32 [ %30, %23 ], [ 0, %21 ]
%33 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %32)
%34 = add nuw nsw i64 %22, 1
%35 = icmp eq i64 %34, %14
br i1 %35, label %36, label %21
36: ; preds = %31, %17
%37 = tail call i32 @putchar(i32 10)
%38 = add nuw nsw i64 %18, 1
%39 = icmp eq i64 %38, %13
br i1 %39, label %40, label %17
40: ; preds = %36, %6
ret i32 0
}