#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*/ fprintf(int /*<<< orphan*/ *, char *, float const, ...);
int /*<<< orphan*/ fputc(char, int /*<<< orphan*/ *);
void write_bg(FILE *fp, const int m, const int n, const float *lp) {
  fprintf(fp, "%i %i\n", m, n);
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < n; j++) {
      fprintf(fp,
              "%.2"
              "f",
              lp[i * n + j]);
      fputc(j < n - 1 ? ' ' : '\n', fp);
    }
  }
}


x86 assembly (clang, -O0):
<write_bg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
cvtsi2ssl -0xc(%rbp),%xmm0
mov    -0x10(%rbp),%edx
lea    0xeb7(%rip),%rsi
mov    $0x1,%al
call   1040 <fprintf@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11e3 <write_bg+0xc3>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11d0 <write_bg+0xb0>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
imul   -0x10(%rbp),%ecx
add    -0x20(%rbp),%ecx
movslq %ecx,%rcx
movss  (%rax,%rcx,4),%xmm0
lea    0xe70(%rip),%rsi
mov    $0x1,%al
call   1040 <fprintf@plt>
mov    -0x20(%rbp),%edx
mov    -0x10(%rbp),%esi
sub    $0x1,%esi
mov    $0xa,%eax
mov    $0x20,%ecx
cmp    %esi,%edx
cmovl  %ecx,%eax
mov    -0x8(%rbp),%rsi
movsbl %al,%edi
call   1030 <fputc@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    116a <write_bg+0x4a>
jmp    11d5 <write_bg+0xb5>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1157 <write_bg+0x37>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write_bg>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rcx,%r15
mov    %esi,%r12d
mov    %rdi,%rbx
cvtsi2ss %esi,%xmm0
lea    0xebe(%rip),%rsi
mov    %rdx,0x8(%rsp)
mov    $0x1,%al
call   1040 <fprintf@plt>
test   %r12d,%r12d
jle    11f6 <write_bg+0xd6>
mov    0x8(%rsp),%rcx
lea    -0x1(%rcx),%eax
movslq %eax,%rbp
movslq %ecx,%rax
mov    %r12d,%edx
mov    %rdx,0x10(%rsp)
mov    %ecx,%r14d
shl    $0x2,%rax
mov    %rax,0x18(%rsp)
xor    %eax,%eax
lea    0xe85(%rip),%r13
jmp    11a5 <write_bg+0x85>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    0x20(%rsp),%rax
add    $0x1,%rax
add    0x18(%rsp),%r15
cmp    0x10(%rsp),%rax
je     11f6 <write_bg+0xd6>
mov    %rax,0x20(%rsp)
cmpl   $0x0,0x8(%rsp)
jle    1190 <write_bg+0x70>
xor    %r12d,%r12d
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movss  (%r15,%r12,4),%xmm0
mov    %rbx,%rdi
mov    %r13,%rsi
mov    $0x1,%al
call   1040 <fprintf@plt>
cmp    %rbp,%r12
mov    $0xa,%edi
mov    $0x20,%eax
cmovl  %eax,%edi
mov    %rbx,%rsi
call   1030 <fputc@plt>
add    $0x1,%r12
cmp    %r12,%r14
jne    11c0 <write_bg+0xa0>
jmp    1190 <write_bg+0x70>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"%i %i\0A\00"
@.str.1 = [5 x i8] c"%.2f\00"
define void @write_bg(i32* %0, i32 %1, i32 %2, float* %3) {
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32
%8 = alloca float*
%9 = alloca i32
%10 = alloca i32
store i32* %0, i32** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store float* %3, float** %8
%11 = load i32*, i32** %5
%12 = load i32, i32* %6
%13 = sitofp i32 %12 to float
%14 = load i32, i32* %7
%15 = call i32 (i32*, i8*, float, ...) @fprintf(i32* %11, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), float %13, i32 %14)
store i32 0, i32* %9
br label %16
16: ; preds = %50, %4
%17 = load i32, i32* %9
%18 = load i32, i32* %6
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %53
20: ; preds = %16
store i32 0, i32* %10
br label %21
21: ; preds = %46, %20
%22 = load i32, i32* %10
%23 = load i32, i32* %7
%24 = icmp slt i32 %22, %23
br i1 %24, label %25, label %49
25: ; preds = %21
%26 = load i32*, i32** %5
%27 = load float*, float** %8
%28 = load i32, i32* %9
%29 = load i32, i32* %7
%30 = mul nsw i32 %28, %29
%31 = load i32, i32* %10
%32 = add nsw i32 %30, %31
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds float, float* %27, i64 %33
%35 = load float, float* %34
%36 = call i32 (i32*, i8*, float, ...) @fprintf(i32* %26, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), float %35)
%37 = load i32, i32* %10
%38 = load i32, i32* %7
%39 = sub nsw i32 %38, 1
%40 = icmp slt i32 %37, %39
%41 = zext i1 %40 to i64
%42 = select i1 %40, i32 32, i32 10
%43 = trunc i32 %42 to i8
%44 = load i32*, i32** %5
%45 = call i32 @fputc(i8 signext %43, i32* %44)
br label %46
46: ; preds = %25
%47 = load i32, i32* %10
%48 = add nsw i32 %47, 1
store i32 %48, i32* %10
br label %21
49: ; preds = %21
br label %50
50: ; preds = %49
%51 = load i32, i32* %9
%52 = add nsw i32 %51, 1
store i32 %52, i32* %9
br label %16
53: ; preds = %16
ret void
}

LLVM IR (-O2):
@.str = [7 x i8] c"%i %i\0A\00"
@.str.1 = [5 x i8] c"%.2f\00"
define void @write_bg(i32* nocapture %0, i32 %1, i32 %2, float* nocapture %3) {
%5 = sitofp i32 %1 to float
%6 = tail call i32 (i32*, i8*, float, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), float %5, i32 %2)
%7 = icmp sgt i32 %1, 0
br i1 %7, label %8, label %19
8: ; preds = %4
%9 = icmp sgt i32 %2, 0
%10 = add nsw i32 %2, -1
%11 = sext i32 %10 to i64
%12 = sext i32 %2 to i64
%13 = zext i32 %1 to i64
%14 = zext i32 %2 to i64
br label %15
15: ; preds = %8, %20
%16 = phi i64 [ 0, %8 ], [ %21, %20 ]
br i1 %9, label %17, label %20
17: ; preds = %15
%18 = mul nsw i64 %16, %12
br label %23
19: ; preds = %20, %4
ret void
20: ; preds = %23, %15
%21 = add nuw nsw i64 %16, 1
%22 = icmp eq i64 %21, %13
br i1 %22, label %19, label %15
23: ; preds = %17, %23
%24 = phi i64 [ 0, %17 ], [ %32, %23 ]
%25 = add nsw i64 %24, %18
%26 = getelementptr inbounds float, float* %3, i64 %25
%27 = load float, float* %26
%28 = tail call i32 (i32*, i8*, float, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), float %27)
%29 = icmp slt i64 %24, %11
%30 = select i1 %29, i8 32, i8 10
%31 = tail call i32 @fputc(i8 signext %30, i32* %0)
%32 = add nuw nsw i64 %24, 1
%33 = icmp eq i64 %32, %14
br i1 %33, label %20, label %23
}