#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*/ formats;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fputc(char const, int /*<<< orphan*/ *);
int /*<<< orphan*/ mpfr_fprintf(int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ round_str(int /*<<< orphan*/ *, char const *, int, int, int,
                             int);
void round_for_all(FILE *fout, const char *s) {
  static const struct fmt {
    int prec;
    int emin;
    int emax;
    bool ibm_ld;
  } formats[] = {
      {24, -148, 128, false},     {53, -1073, 1024, false},
      {64, -16444, 16384, false}, {64, -16445, 16384, false},
      {106, -1073, 1024, true},   {113, -16493, 16384, false},
  };
  mpfr_fprintf(fout, "  TEST (\"");
  const char *p;
  for (p = s; *p; p++) {
    fputc(*p, fout);
    if ((p - s) % 60 == 59 && p[1])
      mpfr_fprintf(fout, "\"\n\t\"");
  }
  mpfr_fprintf(fout, "\",\n");
  int i;
  int n_formats = sizeof(formats) / sizeof(formats[0]);
  for (i = 0; i < n_formats; i++) {
    round_str(fout, s, formats[i].prec, formats[i].emin, formats[i].emax,
              formats[i].ibm_ld);
    if (i < n_formats - 1)
      mpfr_fprintf(fout, ",\n");
  }
  mpfr_fprintf(fout, "),\n");
}


x86 assembly (clang, -O0):
<round_for_all>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xf15(%rip),%rsi
call   1030 <mpfr_fprintf@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmpb   $0x0,(%rax)
je     11cd <round_for_all+0x9d>
mov    -0x18(%rbp),%rax
mov    (%rax),%al
mov    -0x8(%rbp),%rsi
movsbl %al,%edi
call   1040 <fputc@plt>
mov    -0x18(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    %rcx,%rax
mov    $0x3c,%ecx
cqto
idiv   %rcx
cmp    $0x3b,%rdx
jne    11b7 <round_for_all+0x87>
mov    -0x18(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x0,%eax
je     11b7 <round_for_all+0x87>
mov    -0x8(%rbp),%rdi
lea    0xeb8(%rip),%rsi
call   1030 <mpfr_fprintf@plt>
jmp    11bc <round_for_all+0x8c>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1158 <round_for_all+0x28>
mov    -0x8(%rbp),%rdi
lea    0xe97(%rip),%rsi
call   1030 <mpfr_fprintf@plt>
movl   $0x6,-0x20(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    128d <round_for_all+0x15d>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
movslq -0x1c(%rbp),%rcx
lea    0xdf6(%rip),%rax
shl    $0x4,%rcx
add    %rcx,%rax
mov    (%rax),%edx
movslq -0x1c(%rbp),%rcx
lea    0xde2(%rip),%rax
shl    $0x4,%rcx
add    %rcx,%rax
mov    0x4(%rax),%ecx
movslq -0x1c(%rbp),%r8
lea    0xdcd(%rip),%rax
shl    $0x4,%r8
add    %r8,%rax
mov    0x8(%rax),%r8d
movslq -0x1c(%rbp),%r9
lea    0xdb7(%rip),%rax
shl    $0x4,%r9
add    %r9,%rax
mov    0xc(%rax),%r9d
call   1050 <round_str@plt>
mov    -0x1c(%rbp),%eax
mov    -0x20(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    127a <round_for_all+0x14a>
mov    -0x8(%rbp),%rdi
lea    0xdfb(%rip),%rsi
call   1030 <mpfr_fprintf@plt>
jmp    127f <round_for_all+0x14f>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11eb <round_for_all+0xbb>
mov    -0x8(%rbp),%rdi
lea    0xddb(%rip),%rsi
call   1030 <mpfr_fprintf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<round_for_all>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r12
lea    0xeba(%rip),%rsi
call   1030 <mpfr_fprintf@plt>
mov    (%r14),%al
test   %al,%al
je     11c5 <round_for_all+0x95>
xor    %ebx,%ebx
movabs $0x8888888888888889,%r13
88 88 88
lea    0xea5(%rip),%r15
jmp    117e <round_for_all+0x4e>
nopw   0x0(%rax,%rax,1)
movzbl 0x1(%r14,%rbx,1),%eax
add    $0x1,%rbx
test   %al,%al
je     11c5 <round_for_all+0x95>
movsbl %al,%edi
mov    %r12,%rsi
call   1040 <fputc@plt>
mov    %rbx,%rax
imul   %r13
add    %rbx,%rdx
mov    %rdx,%rax
shr    $0x3f,%rax
sar    $0x5,%rdx
add    %rax,%rdx
imul   $0x3c,%rdx,%rax
mov    %rbx,%rcx
sub    %rax,%rcx
cmp    $0x3b,%rcx
jne    1170 <round_for_all+0x40>
cmpb   $0x0,0x1(%r14,%rbx,1)
je     1170 <round_for_all+0x40>
mov    %r12,%rdi
mov    %r15,%rsi
call   1030 <mpfr_fprintf@plt>
jmp    1170 <round_for_all+0x40>
lea    0xe43(%rip),%rsi
mov    %r12,%rdi
call   1030 <mpfr_fprintf@plt>
mov    %r12,%rdi
mov    %r14,%rsi
mov    $0x18,%edx
mov    $0xffffff6c,%ecx
mov    $0x80,%r8d
xor    %r9d,%r9d
call   1050 <round_str@plt>
lea    0xe17(%rip),%r15
mov    %r12,%rdi
mov    %r15,%rsi
call   1030 <mpfr_fprintf@plt>
mov    %r12,%rdi
mov    %r14,%rsi
mov    $0x35,%edx
mov    $0xfffffbcf,%ecx
mov    $0x400,%r8d
xor    %r9d,%r9d
call   1050 <round_str@plt>
mov    %r12,%rdi
mov    %r15,%rsi
call   1030 <mpfr_fprintf@plt>
mov    %r12,%rdi
mov    %r14,%rsi
mov    $0x40,%edx
mov    $0xffffbfc4,%ecx
mov    $0x4000,%r8d
xor    %r9d,%r9d
call   1050 <round_str@plt>
mov    %r12,%rdi
mov    %r15,%rsi
call   1030 <mpfr_fprintf@plt>
mov    %r12,%rdi
mov    %r14,%rsi
mov    $0x40,%edx
mov    $0xffffbfc3,%ecx
mov    $0x4000,%r8d
xor    %r9d,%r9d
call   1050 <round_str@plt>
mov    %r12,%rdi
mov    %r15,%rsi
call   1030 <mpfr_fprintf@plt>
mov    %r12,%rdi
mov    %r14,%rsi
mov    $0x6a,%edx
mov    $0xfffffbcf,%ecx
mov    $0x400,%r8d
mov    $0x1,%r9d
call   1050 <round_str@plt>
mov    %r12,%rdi
mov    %r15,%rsi
call   1030 <mpfr_fprintf@plt>
mov    %r12,%rdi
mov    %r14,%rsi
mov    $0x71,%edx
mov    $0xffffbf93,%ecx
mov    $0x4000,%r8d
xor    %r9d,%r9d
call   1050 <round_str@plt>
lea    0xd43(%rip),%rsi
mov    %r12,%rdi
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    1030 <mpfr_fprintf@plt>

LLVM IR (-O0):
%struct.fmt = type { i32, i32, i32, i32 }
@round_for_all.formats = internal constant [6 x %struct.fmt] [%struct.fmt { i32 24, i32 -148, i32 128, i32 0 }, %struct.fmt { i32 53, i32 -1073, i32 1024, i32 0 }, %struct.fmt { i32 64, i32 -16444, i32 16384, i32 0 }, %struct.fmt { i32 64, i32 -16445, i32 16384, i32 0 }, %struct.fmt { i32 106, i32 -1073, i32 1024, i32 1 }, %struct.fmt { i32 113, i32 -16493, i32 16384, i32 0 }]
@.str = [10 x i8] c" TEST (\22\00"
@.str.1 = [5 x i8] c"\22\0A\09\22\00"
@.str.2 = [4 x i8] c"\22,\0A\00"
@.str.3 = [3 x i8] c",\0A\00"
@.str.4 = [4 x i8] c"),\0A\00"
define void @round_for_all(i32* %0, i8* %1) {
%3 = alloca i32*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
store i32* %0, i32** %3
store i8* %1, i8** %4
%8 = load i32*, i32** %3
%9 = call i32 @mpfr_fprintf(i32* %8, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%10 = load i8*, i8** %4
store i8* %10, i8** %5
br label %11
11: ; preds = %37, %2
%12 = load i8*, i8** %5
%13 = load i8, i8* %12
%14 = icmp ne i8 %13, 0
br i1 %14, label %15, label %40
15: ; preds = %11
%16 = load i8*, i8** %5
%17 = load i8, i8* %16
%18 = load i32*, i32** %3
%19 = call i32 @fputc(i8 signext %17, i32* %18)
%20 = load i8*, i8** %5
%21 = load i8*, i8** %4
%22 = ptrtoint i8* %20 to i64
%23 = ptrtoint i8* %21 to i64
%24 = sub i64 %22, %23
%25 = srem i64 %24, 60
%26 = icmp eq i64 %25, 59
br i1 %26, label %27, label %36
27: ; preds = %15
%28 = load i8*, i8** %5
%29 = getelementptr inbounds i8, i8* %28, i64 1
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = icmp ne i32 %31, 0
br i1 %32, label %33, label %36
33: ; preds = %27
%34 = load i32*, i32** %3
%35 = call i32 @mpfr_fprintf(i32* %34, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
br label %36
36: ; preds = %33, %27, %15
br label %37
37: ; preds = %36
%38 = load i8*, i8** %5
%39 = getelementptr inbounds i8, i8* %38, i32 1
store i8* %39, i8** %5
br label %11
40: ; preds = %11
%41 = load i32*, i32** %3
%42 = call i32 @mpfr_fprintf(i32* %41, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
store i32 6, i32* %7
store i32 0, i32* %6
br label %43
43: ; preds = %79, %40
%44 = load i32, i32* %6
%45 = load i32, i32* %7
%46 = icmp slt i32 %44, %45
br i1 %46, label %47, label %82
47: ; preds = %43
%48 = load i32*, i32** %3
%49 = load i8*, i8** %4
%50 = load i32, i32* %6
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds [6 x %struct.fmt], [6 x %struct.fmt]* @round_for_all.formats, i64 0, i64 %51
%53 = getelementptr inbounds %struct.fmt, %struct.fmt* %52, i32 0, i32 0
%54 = load i32, i32* %53
%55 = load i32, i32* %6
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds [6 x %struct.fmt], [6 x %struct.fmt]* @round_for_all.formats, i64 0, i64 %56
%58 = getelementptr inbounds %struct.fmt, %struct.fmt* %57, i32 0, i32 1
%59 = load i32, i32* %58
%60 = load i32, i32* %6
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds [6 x %struct.fmt], [6 x %struct.fmt]* @round_for_all.formats, i64 0, i64 %61
%63 = getelementptr inbounds %struct.fmt, %struct.fmt* %62, i32 0, i32 2
%64 = load i32, i32* %63
%65 = load i32, i32* %6
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds [6 x %struct.fmt], [6 x %struct.fmt]* @round_for_all.formats, i64 0, i64 %66
%68 = getelementptr inbounds %struct.fmt, %struct.fmt* %67, i32 0, i32 3
%69 = load i32, i32* %68
%70 = call i32 @round_str(i32* %48, i8* %49, i32 %54, i32 %59, i32 %64, i32 %69)
%71 = load i32, i32* %6
%72 = load i32, i32* %7
%73 = sub nsw i32 %72, 1
%74 = icmp slt i32 %71, %73
br i1 %74, label %75, label %78
75: ; preds = %47
%76 = load i32*, i32** %3
%77 = call i32 @mpfr_fprintf(i32* %76, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
br label %78
78: ; preds = %75, %47
br label %79
79: ; preds = %78
%80 = load i32, i32* %6
%81 = add nsw i32 %80, 1
store i32 %81, i32* %6
br label %43
82: ; preds = %43
%83 = load i32*, i32** %3
%84 = call i32 @mpfr_fprintf(i32* %83, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [10 x i8] c" TEST (\22\00"
@.str.1 = [5 x i8] c"\22\0A\09\22\00"
@.str.2 = [4 x i8] c"\22,\0A\00"
@.str.3 = [3 x i8] c",\0A\00"
@.str.4 = [4 x i8] c"),\0A\00"
define void @round_for_all(i32* %0, i8* %1) {
%3 = tail call i32 @mpfr_fprintf(i32* %0, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%4 = load i8, i8* %1
%5 = icmp eq i8 %4, 0
br i1 %5, label %26, label %6
6: ; preds = %2
%7 = ptrtoint i8* %1 to i64
br label %8
8: ; preds = %6, %22
%9 = phi i8 [ %4, %6 ], [ %24, %22 ]
%10 = phi i8* [ %1, %6 ], [ %23, %22 ]
%11 = tail call i32 @fputc(i8 signext %9, i32* %0)
%12 = ptrtoint i8* %10 to i64
%13 = sub i64 %12, %7
%14 = srem i64 %13, 60
%15 = icmp eq i64 %14, 59
br i1 %15, label %16, label %22
16: ; preds = %8
%17 = getelementptr inbounds i8, i8* %10, i64 1
%18 = load i8, i8* %17
%19 = icmp eq i8 %18, 0
br i1 %19, label %22, label %20
20: ; preds = %16
%21 = tail call i32 @mpfr_fprintf(i32* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
br label %22
22: ; preds = %8, %16, %20
%23 = getelementptr inbounds i8, i8* %10, i64 1
%24 = load i8, i8* %23
%25 = icmp eq i8 %24, 0
br i1 %25, label %26, label %8
26: ; preds = %22, %2
%27 = tail call i32 @mpfr_fprintf(i32* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%28 = tail call i32 @round_str(i32* %0, i8* %1, i32 24, i32 -148, i32 128, i32 0)
%29 = tail call i32 @mpfr_fprintf(i32* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%30 = tail call i32 @round_str(i32* %0, i8* %1, i32 53, i32 -1073, i32 1024, i32 0)
%31 = tail call i32 @mpfr_fprintf(i32* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%32 = tail call i32 @round_str(i32* %0, i8* %1, i32 64, i32 -16444, i32 16384, i32 0)
%33 = tail call i32 @mpfr_fprintf(i32* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%34 = tail call i32 @round_str(i32* %0, i8* %1, i32 64, i32 -16445, i32 16384, i32 0)
%35 = tail call i32 @mpfr_fprintf(i32* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%36 = tail call i32 @round_str(i32* %0, i8* %1, i32 106, i32 -1073, i32 1024, i32 1)
%37 = tail call i32 @mpfr_fprintf(i32* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%38 = tail call i32 @round_str(i32* %0, i8* %1, i32 113, i32 -16493, i32 16384, i32 0)
%39 = tail call i32 @mpfr_fprintf(i32* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
ret void
}