#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 */
typedef int /*<<< orphan*/ out;
typedef int /*<<< orphan*/ in1;
typedef int /*<<< orphan*/ in0;

/* Variables and functions */
int /*<<< orphan*/ snprintf(char *, int, char *, int);
int /*<<< orphan*/ write_matrix(int *, char *, int);
void write_data(int *input_matrixes[2], int **output_matrix, int matrix_size) {
  char in0[32];
  char in1[32];
  char out[32];
  snprintf(in0, sizeof(in0), "matrixmul_in0_%06d.dat", matrix_size);
  snprintf(in1, sizeof(in1), "matrixmul_in1_%06d.dat", matrix_size);
  snprintf(out, sizeof(out), "matrixmul_out_%06d.dat", matrix_size);
  write_matrix(input_matrixes[0], in0, matrix_size);
  write_matrix(input_matrixes[1], in1, matrix_size);
  write_matrix(*output_matrix, out, matrix_size);
}


x86 assembly (clang, -O0):
<write_data>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
lea    -0x40(%rbp),%rdi
mov    -0x14(%rbp),%ecx
mov    $0x20,%esi
lea    0xeb7(%rip),%rdx
call   1040 <snprintf@plt>
lea    -0x60(%rbp),%rdi
mov    -0x14(%rbp),%ecx
mov    $0x20,%esi
lea    0xeb6(%rip),%rdx
call   1040 <snprintf@plt>
lea    -0x80(%rbp),%rdi
mov    -0x14(%rbp),%ecx
mov    $0x20,%esi
lea    0xeb5(%rip),%rdx
call   1040 <snprintf@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
lea    -0x40(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1030 <write_matrix@plt>
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x60(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1030 <write_matrix@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    -0x80(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1030 <write_matrix@plt>
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write_data>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
mov    %edx,%ebx
mov    %rsi,%r14
mov    %rdi,%r15
lea    0xec3(%rip),%rdx
lea    0x40(%rsp),%r12
mov    %r12,%rdi
mov    $0x20,%esi
mov    %ebx,%ecx
call   1040 <snprintf@plt>
lea    0xebf(%rip),%rdx
lea    0x20(%rsp),%r13
mov    %r13,%rdi
mov    $0x20,%esi
mov    %ebx,%ecx
call   1040 <snprintf@plt>
lea    0xebb(%rip),%rdx
mov    %rsp,%rbp
mov    %rbp,%rdi
mov    $0x20,%esi
mov    %ebx,%ecx
call   1040 <snprintf@plt>
mov    (%r15),%rdi
mov    %r12,%rsi
mov    %ebx,%edx
call   1030 <write_matrix@plt>
mov    0x8(%r15),%rdi
mov    %r13,%rsi
mov    %ebx,%edx
call   1030 <write_matrix@plt>
mov    (%r14),%rdi
mov    %rbp,%rsi
mov    %ebx,%edx
call   1030 <write_matrix@plt>
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [23 x i8] c"matrixmul_in0_%06d.dat\00"
@.str.1 = [23 x i8] c"matrixmul_in1_%06d.dat\00"
@.str.2 = [23 x i8] c"matrixmul_out_%06d.dat\00"
define void @write_data(i32** %0, i32** %1, i32 %2) {
%4 = alloca i32**
%5 = alloca i32**
%6 = alloca i32
%7 = alloca [32 x i8]
%8 = alloca [32 x i8]
%9 = alloca [32 x i8]
store i32** %0, i32*** %4
store i32** %1, i32*** %5
store i32 %2, i32* %6
%10 = getelementptr inbounds [32 x i8], [32 x i8]* %7, i64 0, i64 0
%11 = load i32, i32* %6
%12 = call i32 @snprintf(i8* %10, i32 32, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %11)
%13 = getelementptr inbounds [32 x i8], [32 x i8]* %8, i64 0, i64 0
%14 = load i32, i32* %6
%15 = call i32 @snprintf(i8* %13, i32 32, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 %14)
%16 = getelementptr inbounds [32 x i8], [32 x i8]* %9, i64 0, i64 0
%17 = load i32, i32* %6
%18 = call i32 @snprintf(i8* %16, i32 32, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i32 %17)
%19 = load i32**, i32*** %4
%20 = getelementptr inbounds i32*, i32** %19, i64 0
%21 = load i32*, i32** %20
%22 = getelementptr inbounds [32 x i8], [32 x i8]* %7, i64 0, i64 0
%23 = load i32, i32* %6
%24 = call i32 @write_matrix(i32* %21, i8* %22, i32 %23)
%25 = load i32**, i32*** %4
%26 = getelementptr inbounds i32*, i32** %25, i64 1
%27 = load i32*, i32** %26
%28 = getelementptr inbounds [32 x i8], [32 x i8]* %8, i64 0, i64 0
%29 = load i32, i32* %6
%30 = call i32 @write_matrix(i32* %27, i8* %28, i32 %29)
%31 = load i32**, i32*** %5
%32 = load i32*, i32** %31
%33 = getelementptr inbounds [32 x i8], [32 x i8]* %9, i64 0, i64 0
%34 = load i32, i32* %6
%35 = call i32 @write_matrix(i32* %32, i8* %33, i32 %34)
ret void
}

LLVM IR (-O2):
@.str = [23 x i8] c"matrixmul_in0_%06d.dat\00"
@.str.1 = [23 x i8] c"matrixmul_in1_%06d.dat\00"
@.str.2 = [23 x i8] c"matrixmul_out_%06d.dat\00"
define void @write_data(i32** nocapture %0, i32** nocapture %1, i32 %2) {
%4 = alloca [32 x i8]
%5 = alloca [32 x i8]
%6 = alloca [32 x i8]
%7 = getelementptr inbounds [32 x i8], [32 x i8]* %4, i64 0, i64 0
%8 = getelementptr inbounds [32 x i8], [32 x i8]* %5, i64 0, i64 0
%9 = getelementptr inbounds [32 x i8], [32 x i8]* %6, i64 0, i64 0
%10 = call i32 @snprintf(i8* %7, i32 32, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %2)
%11 = call i32 @snprintf(i8* %8, i32 32, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 %2)
%12 = call i32 @snprintf(i8* %9, i32 32, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i32 %2)
%13 = load i32*, i32** %0
%14 = call i32 @write_matrix(i32* %13, i8* %7, i32 %2)
%15 = getelementptr inbounds i32*, i32** %0, i64 1
%16 = load i32*, i32** %15
%17 = call i32 @write_matrix(i32* %16, i8* %8, i32 %2)
%18 = load i32*, i32** %1
%19 = call i32 @write_matrix(i32* %18, i8* %9, i32 %2)
ret void
}