#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 *, ...);
void write_lpsolve(FILE *fp, const int m, const int n, const float *lp) {
  for (int j = 1; j < n; j++)
    if (lp[j] != 0)
      fprintf(fp,
              "%+.2"
              "f"
              " x%d ",
              lp[j], j);
  fprintf(fp, ";\n");
  for (int i = 1; i < m; i++) {
    for (int j = 1; j < n; j++) {
      float a = lp[i * n + j];
      if (a != 0)
        fprintf(fp,
                "%+.2"
                "f"
                " x%d ",
                a, j);
    }
    fprintf(fp,
            "<= "
            "%+.2"
            "f"
            " ;\n",
            lp[i * n]);
  }
}


x86 assembly (clang, -O0):
<write_lpsolve>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
movl   $0x1,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    1196 <write_lpsolve+0x86>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    115d <write_lpsolve+0x4d>
jp     115d <write_lpsolve+0x4d>
jmp    1183 <write_lpsolve+0x73>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
cvtss2sd %xmm0,%xmm0
mov    -0x1c(%rbp),%edx
lea    0xe84(%rip),%rsi
mov    $0x1,%al
call   1030 <fprintf@plt>
jmp    1188 <write_lpsolve+0x78>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    112d <write_lpsolve+0x1d>
mov    -0x8(%rbp),%rdi
lea    0xe73(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
movl   $0x1,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    126d <write_lpsolve+0x15d>
movl   $0x1,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    1236 <write_lpsolve+0x126>
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%ecx
imul   -0x10(%rbp),%ecx
add    -0x24(%rbp),%ecx
movslq %ecx,%rcx
movss  (%rax,%rcx,4),%xmm0
movss  %xmm0,-0x28(%rbp)
movss  -0x28(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    1205 <write_lpsolve+0xf5>
jp     1205 <write_lpsolve+0xf5>
jmp    1223 <write_lpsolve+0x113>
mov    -0x8(%rbp),%rdi
movss  -0x28(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
mov    -0x24(%rbp),%edx
lea    0xde4(%rip),%rsi
mov    $0x1,%al
call   1030 <fprintf@plt>
jmp    1228 <write_lpsolve+0x118>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11c2 <write_lpsolve+0xb2>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%ecx
imul   -0x10(%rbp),%ecx
movslq %ecx,%rcx
movss  (%rax,%rcx,4),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xdb3(%rip),%rsi
mov    $0x1,%al
call   1030 <fprintf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11af <write_lpsolve+0x9f>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write_lpsolve>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rcx,0x8(%rsp)
mov    %esi,%r15d
mov    %rdi,%rbp
mov    %edx,%r12d
mov    %edx,0x4(%rsp)
cmp    $0x2,%edx
jl     1193 <write_lpsolve+0x73>
mov    $0x1,%ebx
lea    0xeb3(%rip),%r13
jmp    1169 <write_lpsolve+0x49>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%rbx
cmp    %rbx,%r12
je     1193 <write_lpsolve+0x73>
mov    0x8(%rsp),%rax
movss  (%rax,%rbx,4),%xmm0
ucomiss 0xe86(%rip),%xmm0
jne    117e <write_lpsolve+0x5e>
jnp    1160 <write_lpsolve+0x40>
cvtss2sd %xmm0,%xmm0
mov    %rbp,%rdi
mov    %r13,%rsi
mov    %ebx,%edx
mov    $0x1,%al
call   1030 <fprintf@plt>
jmp    1160 <write_lpsolve+0x40>
lea    0xe7e(%rip),%rdi
mov    $0x1,%r14d
mov    $0x2,%esi
mov    $0x1,%edx
mov    %rbp,%rcx
call   1040 <fwrite@plt>
cmp    $0x2,%r15d
jl     1273 <write_lpsolve+0x153>
movslq 0x4(%rsp),%rcx
mov    %r15d,%eax
mov    %rax,0x18(%rsp)
mov    0x8(%rsp),%rax
lea    (%rax,%rcx,4),%r15
mov    %rcx,0x20(%rsp)
lea    0x0(,%rcx,4),%rax
mov    %rax,0x10(%rsp)
jmp    1220 <write_lpsolve+0x100>
cs nopw 0x0(%rax,%rax,1)
mov    0x8(%rsp),%rax
movss  (%rax,%r13,4),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %rbp,%rdi
lea    0xe06(%rip),%rsi
mov    $0x1,%al
call   1030 <fprintf@plt>
add    $0x1,%r14
add    0x10(%rsp),%r15
cmp    0x18(%rsp),%r14
je     1273 <write_lpsolve+0x153>
mov    %r14,%r13
imul   0x20(%rsp),%r13
cmpl   $0x2,0x4(%rsp)
jl     11f0 <write_lpsolve+0xd0>
mov    $0x1,%ebx
jmp    1249 <write_lpsolve+0x129>
nopw   0x0(%rax,%rax,1)
add    $0x1,%rbx
cmp    %rbx,%r12
je     11f0 <write_lpsolve+0xd0>
movss  (%r15,%rbx,4),%xmm0
ucomiss 0xdaa(%rip),%xmm0
jne    125a <write_lpsolve+0x13a>
jnp    1240 <write_lpsolve+0x120>
cvtss2sd %xmm0,%xmm0
mov    %rbp,%rdi
lea    0xd9c(%rip),%rsi
mov    %ebx,%edx
mov    $0x1,%al
call   1030 <fprintf@plt>
jmp    1240 <write_lpsolve+0x120>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [11 x i8] c"%+.2f x%d \00"
@.str.1 = [3 x i8] c";\0A\00"
@.str.2 = [12 x i8] c"<= %+.2f ;\0A\00"
define void @write_lpsolve(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
%11 = alloca i32
%12 = alloca float
store i32* %0, i32** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store float* %3, float** %8
store i32 1, i32* %9
br label %13
13: ; preds = %35, %4
%14 = load i32, i32* %9
%15 = load i32, i32* %7
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %38
17: ; preds = %13
%18 = load float*, float** %8
%19 = load i32, i32* %9
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds float, float* %18, i64 %20
%22 = load float, float* %21
%23 = fcmp une float %22, 0.000000e+00
br i1 %23, label %24, label %34
24: ; preds = %17
%25 = load i32*, i32** %5
%26 = load float*, float** %8
%27 = load i32, i32* %9
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds float, float* %26, i64 %28
%30 = load float, float* %29
%31 = fpext float %30 to double
%32 = load i32, i32* %9
%33 = call i32 (i32*, i8*, ...) @fprintf(i32* %25, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), double %31, i32 %32)
br label %34
34: ; preds = %24, %17
br label %35
35: ; preds = %34
%36 = load i32, i32* %9
%37 = add nsw i32 %36, 1
store i32 %37, i32* %9
br label %13
38: ; preds = %13
%39 = load i32*, i32** %5
%40 = call i32 (i32*, i8*, ...) @fprintf(i32* %39, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %10
br label %41
41: ; preds = %83, %38
%42 = load i32, i32* %10
%43 = load i32, i32* %6
%44 = icmp slt i32 %42, %43
br i1 %44, label %45, label %86
45: ; preds = %41
store i32 1, i32* %11
br label %46
46: ; preds = %69, %45
%47 = load i32, i32* %11
%48 = load i32, i32* %7
%49 = icmp slt i32 %47, %48
br i1 %49, label %50, label %72
50: ; preds = %46
%51 = load float*, float** %8
%52 = load i32, i32* %10
%53 = load i32, i32* %7
%54 = mul nsw i32 %52, %53
%55 = load i32, i32* %11
%56 = add nsw i32 %54, %55
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds float, float* %51, i64 %57
%59 = load float, float* %58
store float %59, float* %12
%60 = load float, float* %12
%61 = fcmp une float %60, 0.000000e+00
br i1 %61, label %62, label %68
62: ; preds = %50
%63 = load i32*, i32** %5
%64 = load float, float* %12
%65 = fpext float %64 to double
%66 = load i32, i32* %11
%67 = call i32 (i32*, i8*, ...) @fprintf(i32* %63, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), double %65, i32 %66)
br label %68
68: ; preds = %62, %50
br label %69
69: ; preds = %68
%70 = load i32, i32* %11
%71 = add nsw i32 %70, 1
store i32 %71, i32* %11
br label %46
72: ; preds = %46
%73 = load i32*, i32** %5
%74 = load float*, float** %8
%75 = load i32, i32* %10
%76 = load i32, i32* %7
%77 = mul nsw i32 %75, %76
%78 = sext i32 %77 to i64
%79 = getelementptr inbounds float, float* %74, i64 %78
%80 = load float, float* %79
%81 = fpext float %80 to double
%82 = call i32 (i32*, i8*, ...) @fprintf(i32* %73, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), double %81)
br label %83
83: ; preds = %72
%84 = load i32, i32* %10
%85 = add nsw i32 %84, 1
store i32 %85, i32* %10
br label %41
86: ; preds = %41
ret void
}

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