#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 */
unsigned int atoi(char *);
int /*<<< orphan*/ multiplica(int **, int **, int **, unsigned int);
int /*<<< orphan*/ print_matriu(int **);
int rand();
int main(int argc, char *argv[]) {
  int A[4][4], B[4][4],
      C[4][4] = {{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}};
  unsigned int n_iter = 10000000, i, j;
  for (i = 0; i < 4; i++) {
    for (j = 0; j < 4; j++) {
      A[i][j] = rand();
      B[i][j] = rand();
    }
  }
  if (argc > 1) {
    n_iter = atoi(argv[1]);
  }
  multiplica(A, B, C, n_iter);
  print_matriu(C);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xe0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0xd0(%rbp),%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1030 <memset@plt>
movl   $0x989680,-0xd4(%rbp)
movl   $0x0,-0xd8(%rbp)
cmpl   $0x4,-0xd8(%rbp)
jae    122e <main+0xde>
movl   $0x0,-0xdc(%rbp)
cmpl   $0x4,-0xdc(%rbp)
jae    1215 <main+0xc5>
mov    $0x0,%al
call   1070 <rand@plt>
mov    %eax,%edx
mov    -0xd8(%rbp),%eax
mov    %eax,%ecx
lea    -0x50(%rbp),%rax
shl    $0x4,%rcx
add    %rcx,%rax
mov    -0xdc(%rbp),%ecx
mov    %edx,(%rax,%rcx,4)
mov    $0x0,%al
call   1070 <rand@plt>
mov    %eax,%edx
mov    -0xd8(%rbp),%eax
mov    %eax,%ecx
lea    -0x90(%rbp),%rax
shl    $0x4,%rcx
add    %rcx,%rax
mov    -0xdc(%rbp),%ecx
mov    %edx,(%rax,%rcx,4)
mov    -0xdc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xdc(%rbp)
jmp    11a7 <main+0x57>
jmp    121a <main+0xca>
mov    -0xd8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xd8(%rbp)
jmp    1190 <main+0x40>
cmpl   $0x1,-0x8(%rbp)
jle    124b <main+0xfb>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1060 <atoi@plt>
mov    %eax,-0xd4(%rbp)
lea    -0x50(%rbp),%rdi
lea    -0x90(%rbp),%rsi
lea    -0xd0(%rbp),%rdx
mov    -0xd4(%rbp),%ecx
call   1050 <multiplica@plt>
lea    -0xd0(%rbp),%rdi
call   1040 <print_matriu@plt>
xor    %eax,%eax
add    $0xe0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0xc8,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
xorps  %xmm0,%xmm0
movaps %xmm0,0xb0(%rsp)
movaps %xmm0,0xa0(%rsp)
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0x80(%rsp)
xor    %eax,%eax
call   1060 <rand@plt>
mov    %eax,0x40(%rsp)
xor    %eax,%eax
call   1060 <rand@plt>
mov    %eax,(%rsp)
xor    %eax,%eax
call   1060 <rand@plt>
mov    %eax,0x44(%rsp)
xor    %eax,%eax
call   1060 <rand@plt>
mov    %eax,0x4(%rsp)
xor    %eax,%eax
call   1060 <rand@plt>
mov    %eax,0x48(%rsp)
xor    %eax,%eax
call   1060 <rand@plt>
mov    %eax,0x8(%rsp)
xor    %eax,%eax
call   1060 <rand@plt>
mov    %eax,0x4c(%rsp)
xor    %eax,%eax
call   1060 <rand@plt>
mov    %eax,0xc(%rsp)
xor    %eax,%eax
call   1060 <rand@plt>
mov    %eax,0x50(%rsp)
xor    %eax,%eax
call   1060 <rand@plt>
mov    %eax,0x10(%rsp)
xor    %eax,%eax
call   1060 <rand@plt>
mov    %eax,0x54(%rsp)
xor    %eax,%eax
call   1060 <rand@plt>
mov    %eax,0x14(%rsp)
xor    %eax,%eax
call   1060 <rand@plt>
mov    %eax,0x58(%rsp)
xor    %eax,%eax
call   1060 <rand@plt>
mov    %eax,0x18(%rsp)
xor    %eax,%eax
call   1060 <rand@plt>
mov    %eax,0x5c(%rsp)
xor    %eax,%eax
call   1060 <rand@plt>
mov    %eax,0x1c(%rsp)
xor    %eax,%eax
call   1060 <rand@plt>
mov    %eax,0x60(%rsp)
xor    %eax,%eax
call   1060 <rand@plt>
mov    %eax,0x20(%rsp)
xor    %eax,%eax
call   1060 <rand@plt>
mov    %eax,0x64(%rsp)
xor    %eax,%eax
call   1060 <rand@plt>
mov    %eax,0x24(%rsp)
xor    %eax,%eax
call   1060 <rand@plt>
mov    %eax,0x68(%rsp)
xor    %eax,%eax
call   1060 <rand@plt>
mov    %eax,0x28(%rsp)
xor    %eax,%eax
call   1060 <rand@plt>
mov    %eax,0x6c(%rsp)
xor    %eax,%eax
call   1060 <rand@plt>
mov    %eax,0x2c(%rsp)
xor    %eax,%eax
call   1060 <rand@plt>
mov    %eax,0x70(%rsp)
xor    %eax,%eax
call   1060 <rand@plt>
mov    %eax,0x30(%rsp)
xor    %eax,%eax
call   1060 <rand@plt>
mov    %eax,0x74(%rsp)
xor    %eax,%eax
call   1060 <rand@plt>
mov    %eax,0x34(%rsp)
xor    %eax,%eax
call   1060 <rand@plt>
mov    %eax,0x78(%rsp)
xor    %eax,%eax
call   1060 <rand@plt>
mov    %eax,0x38(%rsp)
xor    %eax,%eax
call   1060 <rand@plt>
mov    %eax,0x7c(%rsp)
xor    %eax,%eax
call   1060 <rand@plt>
mov    %eax,0x3c(%rsp)
mov    $0x989680,%ecx
cmp    $0x2,%ebp
jl     12e5 <main+0x1a5>
mov    0x8(%rbx),%rdi
call   1050 <atoi@plt>
mov    %eax,%ecx
lea    0x40(%rsp),%rdi
mov    %rsp,%rsi
lea    0x80(%rsp),%rbx
mov    %rbx,%rdx
call   1040 <multiplica@plt>
mov    %rbx,%rdi
call   1030 <print_matriu@plt>
xor    %eax,%eax
add    $0xc8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [4 x [4 x i32]]
%7 = alloca [4 x [4 x i32]]
%8 = alloca [4 x [4 x i32]]
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = bitcast [4 x [4 x i32]]* %8 to i8*
store i32 10000000, i32* %9
store i32 0, i32* %10
br label %13
13: ; preds = %39, %2
%14 = load i32, i32* %10
%15 = icmp ult i32 %14, 4
br i1 %15, label %16, label %42
16: ; preds = %13
store i32 0, i32* %11
br label %17
17: ; preds = %35, %16
%18 = load i32, i32* %11
%19 = icmp ult i32 %18, 4
br i1 %19, label %20, label %38
20: ; preds = %17
%21 = call i32 (...) @rand()
%22 = load i32, i32* %10
%23 = zext i32 %22 to i64
%24 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %6, i64 0, i64 %23
%25 = load i32, i32* %11
%26 = zext i32 %25 to i64
%27 = getelementptr inbounds [4 x i32], [4 x i32]* %24, i64 0, i64 %26
store i32 %21, i32* %27
%28 = call i32 (...) @rand()
%29 = load i32, i32* %10
%30 = zext i32 %29 to i64
%31 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %7, i64 0, i64 %30
%32 = load i32, i32* %11
%33 = zext i32 %32 to i64
%34 = getelementptr inbounds [4 x i32], [4 x i32]* %31, i64 0, i64 %33
store i32 %28, i32* %34
br label %35
35: ; preds = %20
%36 = load i32, i32* %11
%37 = add i32 %36, 1
store i32 %37, i32* %11
br label %17
38: ; preds = %17
br label %39
39: ; preds = %38
%40 = load i32, i32* %10
%41 = add i32 %40, 1
store i32 %41, i32* %10
br label %13
42: ; preds = %13
%43 = load i32, i32* %4
%44 = icmp sgt i32 %43, 1
br i1 %44, label %45, label %50
45: ; preds = %42
%46 = load i8**, i8*** %5
%47 = getelementptr inbounds i8*, i8** %46, i64 1
%48 = load i8*, i8** %47
%49 = call i32 @atoi(i8* %48)
store i32 %49, i32* %9
br label %50
50: ; preds = %45, %42
%51 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %6, i64 0, i64 0
%52 = bitcast [4 x i32]* %51 to i32**
%53 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %7, i64 0, i64 0
%54 = bitcast [4 x i32]* %53 to i32**
%55 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %8, i64 0, i64 0
%56 = bitcast [4 x i32]* %55 to i32**
%57 = load i32, i32* %9
%58 = call i32 @multiplica(i32** %52, i32** %54, i32** %56, i32 %57)
%59 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %8, i64 0, i64 0
%60 = bitcast [4 x i32]* %59 to i32**
%61 = call i32 @print_matriu(i32** %60)
ret i32 0
}

LLVM IR (-O2):
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [4 x [4 x i32]]
%4 = alloca [4 x [4 x i32]]
%5 = alloca [4 x [4 x i32]]
%6 = bitcast [4 x [4 x i32]]* %3 to i8*
%7 = bitcast [4 x [4 x i32]]* %4 to i8*
%8 = bitcast [4 x [4 x i32]]* %5 to i8*
%9 = tail call i32 (...) @rand()
%10 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %3, i64 0, i64 0, i64 0
store i32 %9, i32* %10
%11 = tail call i32 (...) @rand()
%12 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %4, i64 0, i64 0, i64 0
store i32 %11, i32* %12
%13 = tail call i32 (...) @rand()
%14 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %3, i64 0, i64 0, i64 1
store i32 %13, i32* %14
%15 = tail call i32 (...) @rand()
%16 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %4, i64 0, i64 0, i64 1
store i32 %15, i32* %16
%17 = tail call i32 (...) @rand()
%18 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %3, i64 0, i64 0, i64 2
store i32 %17, i32* %18
%19 = tail call i32 (...) @rand()
%20 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %4, i64 0, i64 0, i64 2
store i32 %19, i32* %20
%21 = tail call i32 (...) @rand()
%22 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %3, i64 0, i64 0, i64 3
store i32 %21, i32* %22
%23 = tail call i32 (...) @rand()
%24 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %4, i64 0, i64 0, i64 3
store i32 %23, i32* %24
%25 = tail call i32 (...) @rand()
%26 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %3, i64 0, i64 1, i64 0
store i32 %25, i32* %26
%27 = tail call i32 (...) @rand()
%28 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %4, i64 0, i64 1, i64 0
store i32 %27, i32* %28
%29 = tail call i32 (...) @rand()
%30 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %3, i64 0, i64 1, i64 1
store i32 %29, i32* %30
%31 = tail call i32 (...) @rand()
%32 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %4, i64 0, i64 1, i64 1
store i32 %31, i32* %32
%33 = tail call i32 (...) @rand()
%34 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %3, i64 0, i64 1, i64 2
store i32 %33, i32* %34
%35 = tail call i32 (...) @rand()
%36 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %4, i64 0, i64 1, i64 2
store i32 %35, i32* %36
%37 = tail call i32 (...) @rand()
%38 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %3, i64 0, i64 1, i64 3
store i32 %37, i32* %38
%39 = tail call i32 (...) @rand()
%40 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %4, i64 0, i64 1, i64 3
store i32 %39, i32* %40
%41 = tail call i32 (...) @rand()
%42 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %3, i64 0, i64 2, i64 0
store i32 %41, i32* %42
%43 = tail call i32 (...) @rand()
%44 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %4, i64 0, i64 2, i64 0
store i32 %43, i32* %44
%45 = tail call i32 (...) @rand()
%46 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %3, i64 0, i64 2, i64 1
store i32 %45, i32* %46
%47 = tail call i32 (...) @rand()
%48 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %4, i64 0, i64 2, i64 1
store i32 %47, i32* %48
%49 = tail call i32 (...) @rand()
%50 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %3, i64 0, i64 2, i64 2
store i32 %49, i32* %50
%51 = tail call i32 (...) @rand()
%52 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %4, i64 0, i64 2, i64 2
store i32 %51, i32* %52
%53 = tail call i32 (...) @rand()
%54 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %3, i64 0, i64 2, i64 3
store i32 %53, i32* %54
%55 = tail call i32 (...) @rand()
%56 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %4, i64 0, i64 2, i64 3
store i32 %55, i32* %56
%57 = tail call i32 (...) @rand()
%58 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %3, i64 0, i64 3, i64 0
store i32 %57, i32* %58
%59 = tail call i32 (...) @rand()
%60 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %4, i64 0, i64 3, i64 0
store i32 %59, i32* %60
%61 = tail call i32 (...) @rand()
%62 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %3, i64 0, i64 3, i64 1
store i32 %61, i32* %62
%63 = tail call i32 (...) @rand()
%64 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %4, i64 0, i64 3, i64 1
store i32 %63, i32* %64
%65 = tail call i32 (...) @rand()
%66 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %3, i64 0, i64 3, i64 2
store i32 %65, i32* %66
%67 = tail call i32 (...) @rand()
%68 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %4, i64 0, i64 3, i64 2
store i32 %67, i32* %68
%69 = tail call i32 (...) @rand()
%70 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %3, i64 0, i64 3, i64 3
store i32 %69, i32* %70
%71 = tail call i32 (...) @rand()
%72 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %4, i64 0, i64 3, i64 3
store i32 %71, i32* %72
%73 = icmp sgt i32 %0, 1
br i1 %73, label %74, label %78
74: ; preds = %2
%75 = getelementptr inbounds i8*, i8** %1, i64 1
%76 = load i8*, i8** %75
%77 = tail call i32 @atoi(i8* %76)
br label %78
78: ; preds = %74, %2
%79 = phi i32 [ %77, %74 ], [ 10000000, %2 ]
%80 = bitcast [4 x [4 x i32]]* %3 to i32**
%81 = bitcast [4 x [4 x i32]]* %4 to i32**
%82 = bitcast [4 x [4 x i32]]* %5 to i32**
%83 = call i32 @multiplica(i32** %80, i32** %81, i32** %82, i32 %79)
%84 = call i32 @print_matriu(i32** %82)
ret i32 0
}