#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 */
scalar_t__ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ stdout;
int frmatprintf(const char *name, unsigned int size1, unsigned int stride1,
                unsigned int size2, unsigned int stride2, const float *m) {
  unsigned int i, j;
  int ret = 0;
  fprintf(stdout, "%s = [", name);
  for (i = 0; i < size1; i++) {
    for (j = 0; j < size2; j++)
      ret += fprintf(stdout, " %g", m[i * stride1 + j * stride2]);
    if (i + 1 < size1)
      ret += fprintf(stdout, " ; ...\n    ");
  }
  ret += fprintf(stdout, " ];\n");
  return ret;
}


x86 assembly (clang, -O0):
<frmatprintf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    %r8d,-0x18(%rbp)
mov    %r9,-0x20(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    0x2ea5(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xeb8(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0xc(%rbp),%eax
jae    120c <frmatprintf+0xfc>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x14(%rbp),%eax
jae    11c6 <frmatprintf+0xb6>
mov    0x2e64(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rax
mov    -0x24(%rbp),%ecx
imul   -0x10(%rbp),%ecx
mov    -0x28(%rbp),%edx
imul   -0x18(%rbp),%edx
add    %edx,%ecx
mov    %ecx,%ecx
movss  (%rax,%rcx,4),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe63(%rip),%rsi
mov    $0x1,%al
call   1030 <fprintf@plt>
mov    %rax,%rcx
movslq -0x2c(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x2c(%rbp)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1169 <frmatprintf+0x59>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
cmp    -0xc(%rbp),%eax
jae    11f9 <frmatprintf+0xe9>
mov    0x2e04(%rip),%rax
mov    (%rax),%edi
lea    0xe26(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    %rax,%rcx
movslq -0x2c(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x2c(%rbp)
jmp    11fe <frmatprintf+0xee>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1156 <frmatprintf+0x46>
mov    0x2dcd(%rip),%rax
mov    (%rax),%edi
lea    0xdfb(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    %rax,%rcx
movslq -0x2c(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<frmatprintf>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %r9,%rbx
mov    %r8d,%ebp
mov    %ecx,0xc(%rsp)
mov    %edx,0x18(%rsp)
mov    %esi,%r12d
mov    %rdi,%rdx
mov    0x2ea7(%rip),%r14
mov    (%r14),%edi
lea    0xebd(%rip),%rsi
xor    %r15d,%r15d
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    %r14,%rax
test   %r12d,%r12d
je     1209 <frmatprintf+0xf9>
mov    0xc(%rsp),%ecx
mov    %rcx,0x20(%rsp)
xor    %ecx,%ecx
xor    %r15d,%r15d
mov    %rax,%r13
mov    %r12d,0x14(%rsp)
xor    %r12d,%r12d
jmp    118d <frmatprintf+0x7d>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    0x10(%rsp),%ecx
add    0x18(%rsp),%ecx
cmp    %r14d,%r12d
je     1209 <frmatprintf+0xf9>
cmpl   $0x0,0xc(%rsp)
mov    %ecx,0x10(%rsp)
mov    %r12d,0x1c(%rsp)
je     11db <frmatprintf+0xcb>
mov    0x20(%rsp),%r12
mov    %ecx,%r14d
cs nopw 0x0(%rax,%rax,1)
nop
mov    (%rax),%edi
mov    %r14d,%eax
movss  (%rbx,%rax,4),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe42(%rip),%rsi
mov    $0x1,%al
call   1030 <fprintf@plt>
add    %eax,%r15d
mov    %r13,%rax
add    %ebp,%r14d
add    $0xffffffffffffffff,%r12
jne    11b0 <frmatprintf+0xa0>
mov    0x1c(%rsp),%r12d
add    $0x1,%r12d
mov    0x14(%rsp),%r14d
cmp    %r14d,%r12d
jae    1180 <frmatprintf+0x70>
mov    (%rax),%edi
lea    0xe14(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
add    %eax,%r15d
mov    %r13,%rax
jmp    1180 <frmatprintf+0x70>
mov    (%rax),%edi
lea    0xe05(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
add    %r15d,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@stdout = global i32 0
@.str = [7 x i8] c"%s = [\00"
@.str.1 = [4 x i8] c" %g\00"
@.str.2 = [12 x i8] c" ; ...\0A \00"
@.str.3 = [5 x i8] c" ];\0A\00"
define i32 @frmatprintf(i8* %0, i32 %1, i32 %2, i32 %3, i32 %4, float* nocapture %5) {
%7 = load i32, i32* @stdout
%8 = tail call i64 (i32, i8*, ...) @fprintf(i32 %7, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %0)
%9 = icmp eq i32 %1, 0
br i1 %9, label %46, label %10
10: ; preds = %6
%11 = icmp eq i32 %3, 0
%12 = zext i32 %3 to i64
br label %13
13: ; preds = %10, %43
%14 = phi i32 [ 0, %10 ], [ %44, %43 ]
%15 = phi i32 [ 0, %10 ], [ %36, %43 ]
br i1 %11, label %34, label %16
16: ; preds = %13
%17 = mul i32 %15, %2
br label %18
18: ; preds = %16, %18
%19 = phi i64 [ 0, %16 ], [ %32, %18 ]
%20 = phi i32 [ %14, %16 ], [ %31, %18 ]
%21 = load i32, i32* @stdout
%22 = trunc i64 %19 to i32
%23 = mul i32 %22, %4
%24 = add i32 %23, %17
%25 = zext i32 %24 to i64
%26 = getelementptr inbounds float, float* %5, i64 %25
%27 = load float, float* %26
%28 = fpext float %27 to double
%29 = tail call i64 (i32, i8*, ...) @fprintf(i32 %21, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double %28)
%30 = trunc i64 %29 to i32
%31 = add i32 %20, %30
%32 = add nuw nsw i64 %19, 1
%33 = icmp eq i64 %32, %12
br i1 %33, label %34, label %18
34: ; preds = %18, %13
%35 = phi i32 [ %14, %13 ], [ %31, %18 ]
%36 = add nuw i32 %15, 1
%37 = icmp ult i32 %36, %1
br i1 %37, label %38, label %43
38: ; preds = %34
%39 = load i32, i32* @stdout
%40 = tail call i64 (i32, i8*, ...) @fprintf(i32 %39, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%41 = trunc i64 %40 to i32
%42 = add i32 %35, %41
br label %43
43: ; preds = %34, %38
%44 = phi i32 [ %42, %38 ], [ %35, %34 ]
%45 = icmp eq i32 %36, %1
br i1 %45, label %46, label %13
46: ; preds = %43, %6
%47 = phi i32 [ 0, %6 ], [ %44, %43 ]
%48 = load i32, i32* @stdout
%49 = tail call i64 (i32, i8*, ...) @fprintf(i32 %48, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%50 = trunc i64 %49 to i32
%51 = add i32 %47, %50
ret i32 %51
}