#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_matrix(unsigned int **, int);
int /*<<< orphan*/ initialize_matrix(unsigned int **, int);
unsigned int **malloc_matrix(int);
int /*<<< orphan*/ multiply_matrix(unsigned int **, unsigned int **,
                                   unsigned int **, int);
int /*<<< orphan*/ reset_matrix(unsigned int **, int);
int /*<<< orphan*/ srand(unsigned int);
scalar_t__ time(int /*<<< orphan*/ *);
void do_foo(int SIZE) {
  unsigned int **first;
  unsigned int **second;
  unsigned int **multiply;
  unsigned int seed;
  seed = (unsigned)time(NULL);
  srand(seed);
  first = malloc_matrix(SIZE);
  initialize_matrix(first, SIZE);
  second = malloc_matrix(SIZE);
  initialize_matrix(second, SIZE);
  multiply = malloc_matrix(SIZE);
  reset_matrix(multiply, SIZE);
  multiply_matrix(multiply, first, second, SIZE);
  free_matrix(first, SIZE);
  free_matrix(second, SIZE);
  free_matrix(multiply, SIZE);
}


x86 assembly (clang, -O0):
<do_foo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1070 <time@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%edi
call   1060 <srand@plt>
mov    -0x4(%rbp),%edi
call   1050 <malloc_matrix@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x4(%rbp),%esi
call   1090 <initialize_matrix@plt>
mov    -0x4(%rbp),%edi
call   1050 <malloc_matrix@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x4(%rbp),%esi
call   1090 <initialize_matrix@plt>
mov    -0x4(%rbp),%edi
call   1050 <malloc_matrix@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x4(%rbp),%esi
call   1080 <reset_matrix@plt>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x4(%rbp),%ecx
call   1040 <multiply_matrix@plt>
mov    -0x10(%rbp),%rdi
mov    -0x4(%rbp),%esi
call   1030 <free_matrix@plt>
mov    -0x18(%rbp),%rdi
mov    -0x4(%rbp),%esi
call   1030 <free_matrix@plt>
mov    -0x20(%rbp),%rdi
mov    -0x4(%rbp),%esi
call   1030 <free_matrix@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<do_foo>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %edi,%ebx
xor    %edi,%edi
call   1070 <time@plt>
mov    %eax,%edi
call   1060 <srand@plt>
mov    %ebx,%edi
call   1050 <malloc_matrix@plt>
mov    %rax,%r14
mov    %rax,%rdi
mov    %ebx,%esi
call   1090 <initialize_matrix@plt>
mov    %ebx,%edi
call   1050 <malloc_matrix@plt>
mov    %rax,%r15
mov    %rax,%rdi
mov    %ebx,%esi
call   1090 <initialize_matrix@plt>
mov    %ebx,%edi
call   1050 <malloc_matrix@plt>
mov    %rax,%r12
mov    %rax,%rdi
mov    %ebx,%esi
call   1080 <reset_matrix@plt>
mov    %r12,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
mov    %ebx,%ecx
call   1040 <multiply_matrix@plt>
mov    %r14,%rdi
mov    %ebx,%esi
call   1030 <free_matrix@plt>
mov    %r15,%rdi
mov    %ebx,%esi
call   1030 <free_matrix@plt>
mov    %r12,%rdi
mov    %ebx,%esi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1030 <free_matrix@plt>

LLVM IR (-O0):
define void @do_foo(i32 %0) {
%2 = alloca i32
%3 = alloca i32**
%4 = alloca i32**
%5 = alloca i32**
%6 = alloca i32
store i32 %0, i32* %2
%7 = call i64 @time(i32* null)
%8 = trunc i64 %7 to i32
store i32 %8, i32* %6
%9 = load i32, i32* %6
%10 = call i32 @srand(i32 %9)
%11 = load i32, i32* %2
%12 = call i32** @malloc_matrix(i32 %11)
store i32** %12, i32*** %3
%13 = load i32**, i32*** %3
%14 = load i32, i32* %2
%15 = call i32 @initialize_matrix(i32** %13, i32 %14)
%16 = load i32, i32* %2
%17 = call i32** @malloc_matrix(i32 %16)
store i32** %17, i32*** %4
%18 = load i32**, i32*** %4
%19 = load i32, i32* %2
%20 = call i32 @initialize_matrix(i32** %18, i32 %19)
%21 = load i32, i32* %2
%22 = call i32** @malloc_matrix(i32 %21)
store i32** %22, i32*** %5
%23 = load i32**, i32*** %5
%24 = load i32, i32* %2
%25 = call i32 @reset_matrix(i32** %23, i32 %24)
%26 = load i32**, i32*** %5
%27 = load i32**, i32*** %3
%28 = load i32**, i32*** %4
%29 = load i32, i32* %2
%30 = call i32 @multiply_matrix(i32** %26, i32** %27, i32** %28, i32 %29)
%31 = load i32**, i32*** %3
%32 = load i32, i32* %2
%33 = call i32 @free_matrix(i32** %31, i32 %32)
%34 = load i32**, i32*** %4
%35 = load i32, i32* %2
%36 = call i32 @free_matrix(i32** %34, i32 %35)
%37 = load i32**, i32*** %5
%38 = load i32, i32* %2
%39 = call i32 @free_matrix(i32** %37, i32 %38)
ret void
}

LLVM IR (-O2):
define void @do_foo(i32 %0) {
%2 = tail call i64 @time(i32* null)
%3 = trunc i64 %2 to i32
%4 = tail call i32 @srand(i32 %3)
%5 = tail call i32** @malloc_matrix(i32 %0)
%6 = tail call i32 @initialize_matrix(i32** %5, i32 %0)
%7 = tail call i32** @malloc_matrix(i32 %0)
%8 = tail call i32 @initialize_matrix(i32** %7, i32 %0)
%9 = tail call i32** @malloc_matrix(i32 %0)
%10 = tail call i32 @reset_matrix(i32** %9, i32 %0)
%11 = tail call i32 @multiply_matrix(i32** %9, i32** %5, i32** %7, i32 %0)
%12 = tail call i32 @free_matrix(i32** %5, i32 %0)
%13 = tail call i32 @free_matrix(i32** %7, i32 %0)
%14 = tail call i32 @free_matrix(i32** %9, i32 %0)
ret void
}