#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*/ exit(int);
scalar_t__ fclose(int /*<<< orphan*/ *);
scalar_t__ ferror(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ stderr;
void debug_output_predicate(const char *filename,
                            bool (*predicate)(unsigned int)) {
  FILE *stream;
  unsigned int ch;
  stream = fopen(filename, "w");
  if (stream == NULL) {
    fprintf(stderr, "cannot open '%s' for writing\n", filename);
    exit(1);
  }
  for (ch = 0; ch < 0x110000; ch++)
    if (predicate(ch)) {
      unsigned int first = ch;
      unsigned int last;
      while (ch + 1 < 0x110000 && predicate(ch + 1))
        ch++;
      last = ch;
      if (first < last)
        fprintf(stream, "0x%04X..0x%04X\n", first, last);
      else
        fprintf(stream, "0x%04X\n", ch);
    }
  if (ferror(stream) || fclose(stream)) {
    fprintf(stderr, "error writing to '%s'\n", filename);
    exit(1);
  }
}


x86 assembly (clang, -O0):
<debug_output_predicate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe95(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11a4 <debug_output_predicate+0x54>
mov    0x2e5a(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xe6f(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x110000,-0x1c(%rbp)
jae    127a <debug_output_predicate+0x12a>
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%edi
call   *%rax
cmp    $0x0,%eax
je     1267 <debug_output_predicate+0x117>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%ecx
add    $0x1,%ecx
xor    %eax,%eax
cmp    $0x110000,%ecx
mov    %al,-0x25(%rbp)
jae    11fc <debug_output_predicate+0xac>
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%edi
add    $0x1,%edi
call   *%rax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x25(%rbp)
mov    -0x25(%rbp),%al
test   $0x1,%al
jne    120c <debug_output_predicate+0xbc>
jmp    121a <debug_output_predicate+0xca>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11d0 <debug_output_predicate+0x80>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x24(%rbp),%eax
jae    124b <debug_output_predicate+0xfb>
mov    -0x18(%rbp),%rax
mov    %eax,%edi
mov    -0x20(%rbp),%edx
mov    -0x24(%rbp),%ecx
lea    0xde1(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
jmp    1262 <debug_output_predicate+0x112>
mov    -0x18(%rbp),%rax
mov    %eax,%edi
mov    -0x1c(%rbp),%edx
lea    0xdcd(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
jmp    1267 <debug_output_predicate+0x117>
jmp    126c <debug_output_predicate+0x11c>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11ab <debug_output_predicate+0x5b>
mov    -0x18(%rbp),%rdi
call   1030 <ferror@plt>
cmp    $0x0,%rax
jne    12a0 <debug_output_predicate+0x150>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
cmp    $0x0,%rax
je     12c5 <debug_output_predicate+0x175>
mov    0x2d39(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xd7c(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<debug_output_predicate>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rbx
lea    0xe9b(%rip),%rsi
mov    %rdi,(%rsp)
call   1060 <fopen@plt>
test   %rax,%rax
je     1251 <debug_output_predicate+0x101>
mov    %rax,%r15
xor    %ebp,%ebp
jmp    1194 <debug_output_predicate+0x44>
xchg   %ax,%ax
mov    %ebp,%r13d
lea    0x1(%r13),%ebp
cmp    $0x10ffff,%r13d
jae    1216 <debug_output_predicate+0xc6>
mov    %ebp,%edi
call   *%rbx
test   %eax,%eax
je     1180 <debug_output_predicate+0x30>
cmp    $0x110000,%ebp
mov    $0x10ffff,%r13d
cmovae %ebp,%r13d
mov    %r13d,%r12d
neg    %r12d
lea    0x1(%rbp),%r14d
cs nopw 0x0(%rax,%rax,1)
lea    (%r12,%r14,1),%eax
cmp    $0x1,%eax
je     11dd <debug_output_predicate+0x8d>
mov    %r14d,%edi
call   *%rbx
add    $0x1,%r14d
test   %eax,%eax
jne    11c0 <debug_output_predicate+0x70>
add    $0xfffffffe,%r14d
mov    %r14d,%r13d
mov    %r15d,%edi
cmp    %r13d,%ebp
jae    1200 <debug_output_predicate+0xb0>
lea    0xe34(%rip),%rsi
mov    %ebp,%edx
mov    %r13d,%ecx
xor    %eax,%eax
call   1050 <fprintf@plt>
jmp    1183 <debug_output_predicate+0x33>
nopw   0x0(%rax,%rax,1)
lea    0xe21(%rip),%rsi
mov    %r13d,%edx
xor    %eax,%eax
call   1050 <fprintf@plt>
jmp    1183 <debug_output_predicate+0x33>
mov    %r15,%rdi
call   1030 <ferror@plt>
test   %rax,%rax
jne    123f <debug_output_predicate+0xef>
mov    %r15,%rdi
call   1040 <fclose@plt>
test   %rax,%rax
jne    123f <debug_output_predicate+0xef>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2d9a(%rip),%rax
mov    (%rax),%edi
lea    0xde1(%rip),%rsi
jmp    1261 <debug_output_predicate+0x111>
mov    0x2d88(%rip),%rax
mov    (%rax),%edi
lea    0xda1(%rip),%rsi
mov    (%rsp),%rdx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"w\00"
@stderr = global i32 0
@.str.1 = [30 x i8] c"cannot open '%s' for writing\0A\00"
@.str.2 = [16 x i8] c"0x%04X..0x%04X\0A\00"
@.str.3 = [8 x i8] c"0x%04X\0A\00"
@.str.4 = [23 x i8] c"error writing to '%s'\0A\00"
define void @debug_output_predicate(i8* %0, i32 (i32)* %1) {
%3 = alloca i8*
%4 = alloca i32 (i32)*
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %3
store i32 (i32)* %1, i32 (i32)** %4
%9 = load i8*, i8** %3
%10 = call i32* @fopen(i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %10, i32** %5
%11 = load i32*, i32** %5
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %18
13: ; preds = %2
%14 = load i32, i32* @stderr
%15 = load i8*, i8** %3
%16 = call i32 (i32, i8*, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* %15)
%17 = call i32 @exit(i32 1)
unreachable
18: ; preds = %2
store i32 0, i32* %6
br label %19
19: ; preds = %62, %18
%20 = load i32, i32* %6
%21 = icmp ult i32 %20, 1114112
br i1 %21, label %22, label %65
22: ; preds = %19
%23 = load i32 (i32)*, i32 (i32)** %4
%24 = load i32, i32* %6
%25 = call i32 %23(i32 %24)
%26 = icmp ne i32 %25, 0
br i1 %26, label %27, label %61
27: ; preds = %22
%28 = load i32, i32* %6
store i32 %28, i32* %7
br label %29
29: ; preds = %41, %27
%30 = load i32, i32* %6
%31 = add i32 %30, 1
%32 = icmp ult i32 %31, 1114112
br i1 %32, label %33, label %39
33: ; preds = %29
%34 = load i32 (i32)*, i32 (i32)** %4
%35 = load i32, i32* %6
%36 = add i32 %35, 1
%37 = call i32 %34(i32 %36)
%38 = icmp ne i32 %37, 0
br label %39
39: ; preds = %33, %29
%40 = phi i1 [ false, %29 ], [ %38, %33 ]
br i1 %40, label %41, label %44
41: ; preds = %39
%42 = load i32, i32* %6
%43 = add i32 %42, 1
store i32 %43, i32* %6
br label %29
44: ; preds = %39
%45 = load i32, i32* %6
store i32 %45, i32* %8
%46 = load i32, i32* %7
%47 = load i32, i32* %8
%48 = icmp ult i32 %46, %47
br i1 %48, label %49, label %55
49: ; preds = %44
%50 = load i32*, i32** %5
%51 = ptrtoint i32* %50 to i32
%52 = load i32, i32* %7
%53 = load i32, i32* %8
%54 = call i32 (i32, i8*, ...) @fprintf(i32 %51, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i32 %52, i32 %53)
br label %60
55: ; preds = %44
%56 = load i32*, i32** %5
%57 = ptrtoint i32* %56 to i32
%58 = load i32, i32* %6
%59 = call i32 (i32, i8*, ...) @fprintf(i32 %57, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 %58)
br label %60
60: ; preds = %55, %49
br label %61
61: ; preds = %60, %22
br label %62
62: ; preds = %61
%63 = load i32, i32* %6
%64 = add i32 %63, 1
store i32 %64, i32* %6
br label %19
65: ; preds = %19
%66 = load i32*, i32** %5
%67 = call i64 @ferror(i32* %66)
%68 = icmp ne i64 %67, 0
br i1 %68, label %73, label %69
69: ; preds = %65
%70 = load i32*, i32** %5
%71 = call i64 @fclose(i32* %70)
%72 = icmp ne i64 %71, 0
br i1 %72, label %73, label %78
73: ; preds = %69, %65
%74 = load i32, i32* @stderr
%75 = load i8*, i8** %3
%76 = call i32 (i32, i8*, ...) @fprintf(i32 %74, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i8* %75)
%77 = call i32 @exit(i32 1)
unreachable
78: ; preds = %69
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"w\00"
@stderr = global i32 0
@.str.1 = [30 x i8] c"cannot open '%s' for writing\0A\00"
@.str.2 = [16 x i8] c"0x%04X..0x%04X\0A\00"
@.str.3 = [8 x i8] c"0x%04X\0A\00"
@.str.4 = [23 x i8] c"error writing to '%s'\0A\00"
define void @debug_output_predicate(i8* %0, i32 (i32)* nocapture %1) {
%3 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i32* %3, null
br i1 %4, label %8, label %5
5: ; preds = %2
%6 = ptrtoint i32* %3 to i64
%7 = trunc i64 %6 to i32
br label %12
8: ; preds = %2
%9 = load i32, i32* @stderr
%10 = tail call i32 (i32, i8*, ...) @fprintf(i32 %9, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%11 = tail call i32 @exit(i32 1)
unreachable
12: ; preds = %5, %32
%13 = phi i32 [ 0, %5 ], [ %34, %32 ]
%14 = tail call i32 %1(i32 %13)
%15 = icmp eq i32 %14, 0
br i1 %15, label %32, label %16
16: ; preds = %12
%17 = call i32 @llvm.umax.i32(i32 %13, i32 1114111)
br label %18
18: ; preds = %16, %22
%19 = phi i32 [ %20, %22 ], [ %13, %16 ]
%20 = add i32 %19, 1
%21 = icmp eq i32 %19, %17
br i1 %21, label %25, label %22
22: ; preds = %18
%23 = tail call i32 %1(i32 %20)
%24 = icmp eq i32 %23, 0
br i1 %24, label %25, label %18
25: ; preds = %18, %22
%26 = phi i32 [ %17, %18 ], [ %19, %22 ]
%27 = icmp ult i32 %13, %26
br i1 %27, label %28, label %30
28: ; preds = %25
%29 = tail call i32 (i32, i8*, ...) @fprintf(i32 %7, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i32 %13, i32 %26)
br label %32
30: ; preds = %25
%31 = tail call i32 (i32, i8*, ...) @fprintf(i32 %7, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 %26)
br label %32
32: ; preds = %28, %30, %12
%33 = phi i32 [ %13, %12 ], [ %26, %30 ], [ %26, %28 ]
%34 = add nuw nsw i32 %33, 1
%35 = icmp ult i32 %33, 1114111
br i1 %35, label %12, label %36
36: ; preds = %32
%37 = tail call i64 @ferror(i32* %3)
%38 = icmp eq i64 %37, 0
br i1 %38, label %39, label %42
39: ; preds = %36
%40 = tail call i64 @fclose(i32* %3)
%41 = icmp eq i64 %40, 0
br i1 %41, label %46, label %42
42: ; preds = %39, %36
%43 = load i32, i32* @stderr
%44 = tail call i32 (i32, i8*, ...) @fprintf(i32 %43, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i8* %0)
%45 = tail call i32 @exit(i32 1)
unreachable
46: ; preds = %39
ret void
}