#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*/ v;
typedef int /*<<< orphan*/ q;

/* Variables and functions */
void LOG_wrk(char *, int);
int /*<<< orphan*/ memcpy(char *, char *, int);
int min_i(int, int);
int /*<<< orphan*/ sprintf(char *, char *, int);
int /*<<< orphan*/ write(int, char *, int);
void qstat_dump(const double *v, int n) {
  int i, j, k, n7 = (n + 6) / 7;
  if (n7 < 1)
    return LOG_wrk("BUG: qstat_dump: n=%d", n);
  char buf[82 * n7 + 20], *q = buf;
  q += sprintf(q, "Q_^_Sc%d", n);
  for (i = j = 0; i < n7; i++) {
    memcpy(q, "\nQ_^<", 5);
    q += 5;
    for (k = min_i(n, j + 7); j < k; j++)
      enc11(q, v[j]), q += 11;
  }
  q[0] = '!';
  q[1] = 10;
  write(1, buf, q + 2 - buf);
}


x86 assembly (clang, -O0):
<qstat_dump>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0x6,%eax
mov    $0x7,%ecx
cltd
idiv   %ecx
mov    %eax,-0x1c(%rbp)
cmpl   $0x1,-0x1c(%rbp)
jge    119e <qstat_dump+0x3e>
mov    -0xc(%rbp),%esi
lea    0xe6c(%rip),%rdi
call   1040 <LOG_wrk@plt>
jmp    12c1 <qstat_dump+0x161>
mov    -0x1c(%rbp),%eax
imul   $0x52,%eax,%eax
add    $0x14,%eax
mov    %eax,%ecx
mov    %rsp,%rax
mov    %rax,-0x28(%rbp)
mov    %rcx,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rax
sub    %rdx,%rax
mov    %rax,-0x40(%rbp)
mov    %rax,%rsp
mov    %rcx,-0x30(%rbp)
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0xc(%rbp),%edx
lea    0xe38(%rip),%rsi
call   1080 <sprintf@plt>
mov    %eax,%ecx
mov    -0x38(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x38(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1290 <qstat_dump+0x130>
mov    -0x38(%rbp),%rdi
lea    0xe07(%rip),%rsi
mov    $0x5,%edx
call   1050 <memcpy@plt>
mov    -0x38(%rbp),%rax
add    $0x5,%rax
mov    %rax,-0x38(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x14(%rbp),%esi
add    $0x7,%esi
call   1060 <min_i@plt>
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    127d <qstat_dump+0x11d>
mov    -0x38(%rbp),%rdi
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    $0x1,%al
call   1070 <enc11@plt>
mov    -0x38(%rbp),%rax
add    $0xb,%rax
mov    %rax,-0x38(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    123f <qstat_dump+0xdf>
jmp    1282 <qstat_dump+0x122>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1201 <qstat_dump+0xa1>
mov    -0x40(%rbp),%rsi
mov    -0x38(%rbp),%rax
movb   $0x21,(%rax)
mov    -0x38(%rbp),%rax
movb   $0xa,0x1(%rax)
mov    -0x38(%rbp),%rax
add    $0x2,%rax
sub    %rsi,%rax
mov    %eax,%edx
mov    $0x1,%edi
call   1030 <write@plt>
mov    -0x28(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<qstat_dump>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %esi,%ecx
mov    %rdi,-0x50(%rbp)
test   %esi,%esi
jle    12c1 <qstat_dump+0x161>
mov    %rsp,-0x48(%rbp)
lea    0x6(%rcx),%eax
cltq
imul   $0xffffffff92492493,%rax,%rax
shr    $0x20,%rax
lea    (%rax,%rcx,1),%r14d
add    $0x6,%r14d
mov    %r14d,%eax
shr    $0x1f,%eax
sar    $0x2,%r14d
add    %eax,%r14d
imul   $0x52,%r14d,%eax
add    $0x14,%eax
mov    %rsp,%r12
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r12
mov    %r12,%rsp
lea    0xe4f(%rip),%rsi
mov    %r12,%rdi
mov    %rcx,-0x58(%rbp)
mov    %ecx,%edx
call   1080 <sprintf@plt>
movslq %eax,%rbx
mov    %r12,-0x40(%rbp)
add    %r12,%rbx
cmp    $0x2,%r14d
mov    $0x1,%r12d
cmovge %r14d,%r12d
xor    %r13d,%r13d
lea    0xe28(%rip),%r14
xor    %eax,%eax
mov    %rax,-0x38(%rbp)
mov    %r12d,-0x2c(%rbp)
jmp    1219 <qstat_dump+0xb9>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%r13d
cmp    %r12d,%r13d
je     1294 <qstat_dump+0x134>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x5,%edx
call   1050 <memcpy@plt>
add    $0x5,%rbx
mov    -0x38(%rbp),%r15
lea    0x7(%r15),%esi
mov    -0x58(%rbp),%rdi
call   1060 <min_i@plt>
cmp    %eax,%r15d
jge    1210 <qstat_dump+0xb0>
movslq %r15d,%rsi
mov    -0x50(%rbp),%rcx
lea    (%rcx,%rsi,8),%r14
mov    %eax,-0x30(%rbp)
mov    %eax,%r12d
sub    %r15d,%r12d
xor    %r15d,%r15d
nopw   0x0(%rax,%rax,1)
movsd  (%r14,%r15,8),%xmm0
mov    %rbx,%rdi
mov    $0x1,%al
call   1070 <enc11@plt>
add    $0xb,%rbx
add    $0x1,%r15
cmp    %r15d,%r12d
jne    1260 <qstat_dump+0x100>
mov    -0x30(%rbp),%eax
mov    %rax,-0x38(%rbp)
mov    -0x2c(%rbp),%r12d
lea    0xd90(%rip),%r14
jmp    1210 <qstat_dump+0xb0>
movw   $0xa21,(%rbx)
mov    -0x40(%rbp),%rsi
sub    %esi,%ebx
add    $0x2,%ebx
mov    $0x1,%edi
mov    %ebx,%edx
call   1030 <write@plt>
mov    -0x48(%rbp),%rsp
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xd38(%rip),%rdi
mov    %ecx,%esi
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <LOG_wrk@plt>

LLVM IR (-O0):
@.str = [22 x i8] c"BUG: qstat_dump: n=%d\00"
@.str.1 = [9 x i8] c"Q_^_Sc%d\00"
@.str.2 = [6 x i8] c"\0AQ_^<\00"
define void @qstat_dump(double* %0, i32 %1) {
%3 = alloca double*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i64
%11 = alloca i8*
store double* %0, double** %3
store i32 %1, i32* %4
%12 = load i32, i32* %4
%13 = add nsw i32 %12, 6
%14 = sdiv i32 %13, 7
store i32 %14, i32* %8
%15 = load i32, i32* %8
%16 = icmp slt i32 %15, 1
br i1 %16, label %17, label %19
17: ; preds = %2
%18 = load i32, i32* %4
br label %79
19: ; preds = %2
%20 = load i32, i32* %8
%21 = mul nsw i32 82, %20
%22 = add nsw i32 %21, 20
%23 = zext i32 %22 to i64
%24 = call i8* @llvm.stacksave()
store i8* %24, i8** %9
%25 = alloca i8, i64 %23
store i64 %23, i64* %10
store i8* %25, i8** %11
%26 = load i8*, i8** %11
%27 = load i32, i32* %4
%28 = call i32 @sprintf(i8* %26, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %27)
%29 = load i8*, i8** %11
%30 = sext i32 %28 to i64
%31 = getelementptr inbounds i8, i8* %29, i64 %30
store i8* %31, i8** %11
store i32 0, i32* %6
store i32 0, i32* %5
br label %32
32: ; preds = %63, %19
%33 = load i32, i32* %5
%34 = load i32, i32* %8
%35 = icmp slt i32 %33, %34
br i1 %35, label %36, label %66
36: ; preds = %32
%37 = load i8*, i8** %11
%38 = call i32 @memcpy(i8* %37, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 5)
%39 = load i8*, i8** %11
%40 = getelementptr inbounds i8, i8* %39, i64 5
store i8* %40, i8** %11
%41 = load i32, i32* %4
%42 = load i32, i32* %6
%43 = add nsw i32 %42, 7
%44 = call i32 @min_i(i32 %41, i32 %43)
store i32 %44, i32* %7
br label %45
45: ; preds = %59, %36
%46 = load i32, i32* %6
%47 = load i32, i32* %7
%48 = icmp slt i32 %46, %47
br i1 %48, label %49, label %62
49: ; preds = %45
%50 = load i8*, i8** %11
%51 = load double*, double** %3
%52 = load i32, i32* %6
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds double, double* %51, i64 %53
%55 = load double, double* %54
%56 = call i32 (i8*, double, ...) bitcast (i32 (...)* @enc11 to i32 (i8*, double, ...)*)(i8* %50, double %55)
%57 = load i8*, i8** %11
%58 = getelementptr inbounds i8, i8* %57, i64 11
store i8* %58, i8** %11
br label %59
59: ; preds = %49
%60 = load i32, i32* %6
%61 = add nsw i32 %60, 1
store i32 %61, i32* %6
br label %45
62: ; preds = %45
br label %63
63: ; preds = %62
%64 = load i32, i32* %5
%65 = add nsw i32 %64, 1
store i32 %65, i32* %5
br label %32
66: ; preds = %32
%67 = load i8*, i8** %11
%68 = getelementptr inbounds i8, i8* %67, i64 0
store i8 33, i8* %68
%69 = load i8*, i8** %11
%70 = getelementptr inbounds i8, i8* %69, i64 1
store i8 10, i8* %70
%71 = load i8*, i8** %11
%72 = getelementptr inbounds i8, i8* %71, i64 2
%73 = ptrtoint i8* %72 to i64
%74 = ptrtoint i8* %25 to i64
%75 = sub i64 %73, %74
%76 = trunc i64 %75 to i32
%77 = call i32 @write(i32 1, i8* %25, i32 %76)
%78 = load i8*, i8** %9
br label %79
79: ; preds = %66, %17
ret void
}

LLVM IR (-O2):
@.str = [22 x i8] c"BUG: qstat_dump: n=%d\00"
@.str.1 = [9 x i8] c"Q_^_Sc%d\00"
@.str.2 = [6 x i8] c"\0AQ_^<\00"
define void @qstat_dump(double* nocapture %0, i32 %1) {
%3 = add nsw i32 %1, 6
%4 = sdiv i32 %3, 7
%5 = icmp slt i32 %1, 1
br i1 %5, label %6, label %7
6: ; preds = %2
tail call void @LOG_wrk(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %1)
br label %51
7: ; preds = %2
%8 = mul nsw i32 %4, 82
%9 = add nsw i32 %8, 20
%10 = zext i32 %9 to i64
%11 = tail call i8* @llvm.stacksave()
%12 = alloca i8, i64 %10
%13 = call i32 @sprintf(i8* %12, i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %1)
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i8, i8* %12, i64 %14
%16 = call i32 @llvm.smax.i32(i32 %4, i32 1)
br label %17
17: ; preds = %7, %38
%18 = phi i8* [ %40, %38 ], [ %15, %7 ]
%19 = phi i32 [ %41, %38 ], [ 0, %7 ]
%20 = phi i32 [ %39, %38 ], [ 0, %7 ]
%21 = call i32 @memcpy(i8* %18, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 5)
%22 = getelementptr inbounds i8, i8* %18, i64 5
%23 = add nsw i32 %20, 7
%24 = call i32 @min_i(i32 %1, i32 %23)
%25 = icmp slt i32 %20, %24
br i1 %25, label %26, label %38
26: ; preds = %17
%27 = sext i32 %20 to i64
br label %28
28: ; preds = %26, %28
%29 = phi i64 [ %27, %26 ], [ %35, %28 ]
%30 = phi i8* [ %22, %26 ], [ %34, %28 ]
%31 = getelementptr inbounds double, double* %0, i64 %29
%32 = load double, double* %31
%33 = call i32 (i8*, double, ...) bitcast (i32 (...)* @enc11 to i32 (i8*, double, ...)*)(i8* %30, double %32)
%34 = getelementptr inbounds i8, i8* %30, i64 11
%35 = add nsw i64 %29, 1
%36 = trunc i64 %35 to i32
%37 = icmp eq i32 %24, %36
br i1 %37, label %38, label %28
38: ; preds = %28, %17
%39 = phi i32 [ %20, %17 ], [ %24, %28 ]
%40 = phi i8* [ %22, %17 ], [ %34, %28 ]
%41 = add nuw nsw i32 %19, 1
%42 = icmp eq i32 %41, %16
br i1 %42, label %43, label %17
43: ; preds = %38
store i8 33, i8* %40
%44 = getelementptr inbounds i8, i8* %40, i64 1
store i8 10, i8* %44
%45 = getelementptr inbounds i8, i8* %40, i64 2
%46 = ptrtoint i8* %45 to i64
%47 = ptrtoint i8* %12 to i64
%48 = sub i64 %46, %47
%49 = trunc i64 %48 to i32
%50 = call i32 @write(i32 1, i8* %12, i32 %49)
br label %51
51: ; preds = %43, %6
ret void
}