#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*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *);
int /*<<< orphan*/ print_sdense2mm(int /*<<< orphan*/ *, char const *, int, int,
                                   float const *);
int /*<<< orphan*/ stderr;
void fprint_sdense2mm(const char *fname, const char *name, int m, int n,
                      const float *A) {
  FILE *f = fopen(fname, "w");
  if (f == NULL) {
    fprintf(stderr, "err: cannot open %s for writing\n", fname);
  }
  print_sdense2mm(f, name, m, n, A);
  fclose(f);
}


x86 assembly (clang, -O0):
<fprint_sdense2mm>:
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    %r8,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe9b(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1192 <fprint_sdense2mm+0x52>
mov    0x2e60(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xe75(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
mov    -0x20(%rbp),%r8
call   1040 <print_sdense2mm@plt>
mov    -0x28(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fprint_sdense2mm>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8,%r14
mov    %ecx,%r15d
mov    %edx,%r12d
mov    %rsi,%r13
mov    %rdi,%rbp
lea    0xe9f(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1186 <fprint_sdense2mm+0x46>
mov    0x2e6b(%rip),%rax
mov    (%rax),%edi
lea    0xe84(%rip),%rsi
mov    %rbp,%rdx
call   1050 <fprintf@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
mov    %r12d,%edx
mov    %r15d,%ecx
mov    %r14,%r8
call   1040 <print_sdense2mm@plt>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <fclose@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"w\00"
@stderr = global i32 0
@.str.1 = [33 x i8] c"err: cannot open %s for writing\0A\00"
define void @fprint_sdense2mm(i8* %0, i8* %1, i32 %2, i32 %3, float* %4) {
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca float*
%11 = alloca i32*
store i8* %0, i8** %6
store i8* %1, i8** %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store float* %4, float** %10
%12 = load i8*, i8** %6
%13 = call i32* @fopen(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %13, i32** %11
%14 = load i32*, i32** %11
%15 = icmp eq i32* %14, null
br i1 %15, label %16, label %20
16: ; preds = %5
%17 = load i32, i32* @stderr
%18 = load i8*, i8** %6
%19 = call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i8* %18)
br label %20
20: ; preds = %16, %5
%21 = load i32*, i32** %11
%22 = load i8*, i8** %7
%23 = load i32, i32* %8
%24 = load i32, i32* %9
%25 = load float*, float** %10
%26 = call i32 @print_sdense2mm(i32* %21, i8* %22, i32 %23, i32 %24, float* %25)
%27 = load i32*, i32** %11
%28 = call i32 @fclose(i32* %27)
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"w\00"
@stderr = global i32 0
@.str.1 = [33 x i8] c"err: cannot open %s for writing\0A\00"
define void @fprint_sdense2mm(i8* %0, i8* %1, i32 %2, i32 %3, float* %4) {
%6 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i32* %6, null
br i1 %7, label %8, label %11
8: ; preds = %5
%9 = load i32, i32* @stderr
%10 = tail call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i8* %0)
br label %11
11: ; preds = %8, %5
%12 = tail call i32 @print_sdense2mm(i32* %6, i8* %1, i32 %2, i32 %3, float* %4)
%13 = tail call i32 @fclose(i32* %6)
ret void
}