#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*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fputc(int, int /*<<< orphan*/ *);
int main(void) {
  int i;
  FILE *fp;
  fp = fopen("./.testbytes", "w");
  if (!fp) {
    return -1;
  }
  for (i = 0; i < 255; i++) {
    fputc(i, fp);
  }
  fclose(fp);
  fp = fopen("./.testbits", "w");
  if (!fp) {
    return -1;
  }
  fputc(0xFF, fp);
  fputc(0xFF, fp);
  fputc(0xFF, fp);
  fputc(0xFF, fp);
  fputc(0x00, fp);
  fputc(0x00, fp);
  fputc(0x00, fp);
  fputc(0x00, fp);
  fputc(0xFF, fp);
  fputc(0xFF, fp);
  fputc(0xFF, fp);
  fputc(0xFF, fp);
  fputc(0x00, fp);
  fputc(0x00, fp);
  fputc(0x00, fp);
  fputc(0x00, fp);
  fputc(0xFF, fp);
  fputc(0xFF, fp);
  fputc(0xFF, fp);
  fputc(0xFF, fp);
  fputc(0x00, fp);
  fputc(0x00, fp);
  fputc(0x00, fp);
  fputc(0x00, fp);
  fputc(0xFF, fp);
  fputc(0xFF, fp);
  fputc(0xFF, fp);
  fputc(0xFF, fp);
  fputc(0x00, fp);
  fputc(0x00, fp);
  fputc(0x00, fp);
  fputc(0x00, fp);
  fclose(fp);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
lea    0xec0(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    116d <main+0x3d>
movl   $0xffffffff,-0x4(%rbp)
jmp    136b <main+0x23b>
movl   $0x0,-0x8(%rbp)
cmpl   $0xff,-0x8(%rbp)
jge    119b <main+0x6b>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1040 <fputc@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1174 <main+0x44>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
lea    0xe64(%rip),%rdi
lea    0xe5b(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11d2 <main+0xa2>
movl   $0xffffffff,-0x4(%rbp)
jmp    136b <main+0x23b>
mov    -0x10(%rbp),%rsi
mov    $0xff,%edi
call   1040 <fputc@plt>
mov    -0x10(%rbp),%rsi
mov    $0xff,%edi
call   1040 <fputc@plt>
mov    -0x10(%rbp),%rsi
mov    $0xff,%edi
call   1040 <fputc@plt>
mov    -0x10(%rbp),%rsi
mov    $0xff,%edi
call   1040 <fputc@plt>
mov    -0x10(%rbp),%rsi
xor    %edi,%edi
call   1040 <fputc@plt>
mov    -0x10(%rbp),%rsi
xor    %edi,%edi
call   1040 <fputc@plt>
mov    -0x10(%rbp),%rsi
xor    %edi,%edi
call   1040 <fputc@plt>
mov    -0x10(%rbp),%rsi
xor    %edi,%edi
call   1040 <fputc@plt>
mov    -0x10(%rbp),%rsi
mov    $0xff,%edi
call   1040 <fputc@plt>
mov    -0x10(%rbp),%rsi
mov    $0xff,%edi
call   1040 <fputc@plt>
mov    -0x10(%rbp),%rsi
mov    $0xff,%edi
call   1040 <fputc@plt>
mov    -0x10(%rbp),%rsi
mov    $0xff,%edi
call   1040 <fputc@plt>
mov    -0x10(%rbp),%rsi
xor    %edi,%edi
call   1040 <fputc@plt>
mov    -0x10(%rbp),%rsi
xor    %edi,%edi
call   1040 <fputc@plt>
mov    -0x10(%rbp),%rsi
xor    %edi,%edi
call   1040 <fputc@plt>
mov    -0x10(%rbp),%rsi
xor    %edi,%edi
call   1040 <fputc@plt>
mov    -0x10(%rbp),%rsi
mov    $0xff,%edi
call   1040 <fputc@plt>
mov    -0x10(%rbp),%rsi
mov    $0xff,%edi
call   1040 <fputc@plt>
mov    -0x10(%rbp),%rsi
mov    $0xff,%edi
call   1040 <fputc@plt>
mov    -0x10(%rbp),%rsi
mov    $0xff,%edi
call   1040 <fputc@plt>
mov    -0x10(%rbp),%rsi
xor    %edi,%edi
call   1040 <fputc@plt>
mov    -0x10(%rbp),%rsi
xor    %edi,%edi
call   1040 <fputc@plt>
mov    -0x10(%rbp),%rsi
xor    %edi,%edi
call   1040 <fputc@plt>
mov    -0x10(%rbp),%rsi
xor    %edi,%edi
call   1040 <fputc@plt>
mov    -0x10(%rbp),%rsi
mov    $0xff,%edi
call   1040 <fputc@plt>
mov    -0x10(%rbp),%rsi
mov    $0xff,%edi
call   1040 <fputc@plt>
mov    -0x10(%rbp),%rsi
mov    $0xff,%edi
call   1040 <fputc@plt>
mov    -0x10(%rbp),%rsi
mov    $0xff,%edi
call   1040 <fputc@plt>
mov    -0x10(%rbp),%rsi
xor    %edi,%edi
call   1040 <fputc@plt>
mov    -0x10(%rbp),%rsi
xor    %edi,%edi
call   1040 <fputc@plt>
mov    -0x10(%rbp),%rsi
xor    %edi,%edi
call   1040 <fputc@plt>
mov    -0x10(%rbp),%rsi
xor    %edi,%edi
call   1040 <fputc@plt>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
lea    0xec5(%rip),%rdi
lea    0xecb(%rip),%rsi
call   1050 <fopen@plt>
mov    $0xffffffff,%r14d
test   %rax,%rax
je     1317 <main+0x1e7>
mov    %rax,%rbx
xor    %ebp,%ebp
nopl   0x0(%rax,%rax,1)
mov    %ebp,%edi
mov    %rbx,%rsi
call   1040 <fputc@plt>
add    $0x1,%ebp
cmp    $0xff,%ebp
jne    1160 <main+0x30>
mov    %rbx,%rdi
call   1030 <fclose@plt>
lea    0xe8b(%rip),%rdi
lea    0xe82(%rip),%rsi
call   1050 <fopen@plt>
test   %rax,%rax
je     1317 <main+0x1e7>
mov    %rax,%rbx
mov    $0xff,%edi
mov    %rax,%rsi
call   1040 <fputc@plt>
mov    $0xff,%edi
mov    %rbx,%rsi
call   1040 <fputc@plt>
mov    $0xff,%edi
mov    %rbx,%rsi
call   1040 <fputc@plt>
mov    $0xff,%edi
mov    %rbx,%rsi
call   1040 <fputc@plt>
xor    %r14d,%r14d
xor    %edi,%edi
mov    %rbx,%rsi
call   1040 <fputc@plt>
xor    %edi,%edi
mov    %rbx,%rsi
call   1040 <fputc@plt>
xor    %edi,%edi
mov    %rbx,%rsi
call   1040 <fputc@plt>
xor    %edi,%edi
mov    %rbx,%rsi
call   1040 <fputc@plt>
mov    $0xff,%edi
mov    %rbx,%rsi
call   1040 <fputc@plt>
mov    $0xff,%edi
mov    %rbx,%rsi
call   1040 <fputc@plt>
mov    $0xff,%edi
mov    %rbx,%rsi
call   1040 <fputc@plt>
mov    $0xff,%edi
mov    %rbx,%rsi
call   1040 <fputc@plt>
xor    %edi,%edi
mov    %rbx,%rsi
call   1040 <fputc@plt>
xor    %edi,%edi
mov    %rbx,%rsi
call   1040 <fputc@plt>
xor    %edi,%edi
mov    %rbx,%rsi
call   1040 <fputc@plt>
xor    %edi,%edi
mov    %rbx,%rsi
call   1040 <fputc@plt>
mov    $0xff,%edi
mov    %rbx,%rsi
call   1040 <fputc@plt>
mov    $0xff,%edi
mov    %rbx,%rsi
call   1040 <fputc@plt>
mov    $0xff,%edi
mov    %rbx,%rsi
call   1040 <fputc@plt>
mov    $0xff,%edi
mov    %rbx,%rsi
call   1040 <fputc@plt>
xor    %edi,%edi
mov    %rbx,%rsi
call   1040 <fputc@plt>
xor    %edi,%edi
mov    %rbx,%rsi
call   1040 <fputc@plt>
xor    %edi,%edi
mov    %rbx,%rsi
call   1040 <fputc@plt>
xor    %edi,%edi
mov    %rbx,%rsi
call   1040 <fputc@plt>
mov    $0xff,%edi
mov    %rbx,%rsi
call   1040 <fputc@plt>
mov    $0xff,%edi
mov    %rbx,%rsi
call   1040 <fputc@plt>
mov    $0xff,%edi
mov    %rbx,%rsi
call   1040 <fputc@plt>
mov    $0xff,%edi
mov    %rbx,%rsi
call   1040 <fputc@plt>
xor    %edi,%edi
mov    %rbx,%rsi
call   1040 <fputc@plt>
xor    %edi,%edi
mov    %rbx,%rsi
call   1040 <fputc@plt>
xor    %edi,%edi
mov    %rbx,%rsi
call   1040 <fputc@plt>
xor    %edi,%edi
mov    %rbx,%rsi
call   1040 <fputc@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
mov    %r14d,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [13 x i8] c"./.testbytes\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [12 x i8] c"./.testbits\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32*
store i32 0, i32* %1
%4 = call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %4, i32** %3
%5 = load i32*, i32** %3
%6 = icmp ne i32* %5, null
br i1 %6, label %8, label %7
7: ; preds = %0
store i32 -1, i32* %1
br label %93
8: ; preds = %0
store i32 0, i32* %2
br label %9
9: ; preds = %16, %8
%10 = load i32, i32* %2
%11 = icmp slt i32 %10, 255
br i1 %11, label %12, label %19
12: ; preds = %9
%13 = load i32, i32* %2
%14 = load i32*, i32** %3
%15 = call i32 @fputc(i32 %13, i32* %14)
br label %16
16: ; preds = %12
%17 = load i32, i32* %2
%18 = add nsw i32 %17, 1
store i32 %18, i32* %2
br label %9
19: ; preds = %9
%20 = load i32*, i32** %3
%21 = call i32 @fclose(i32* %20)
%22 = call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %22, i32** %3
%23 = load i32*, i32** %3
%24 = icmp ne i32* %23, null
br i1 %24, label %26, label %25
25: ; preds = %19
store i32 -1, i32* %1
br label %93
26: ; preds = %19
%27 = load i32*, i32** %3
%28 = call i32 @fputc(i32 255, i32* %27)
%29 = load i32*, i32** %3
%30 = call i32 @fputc(i32 255, i32* %29)
%31 = load i32*, i32** %3
%32 = call i32 @fputc(i32 255, i32* %31)
%33 = load i32*, i32** %3
%34 = call i32 @fputc(i32 255, i32* %33)
%35 = load i32*, i32** %3
%36 = call i32 @fputc(i32 0, i32* %35)
%37 = load i32*, i32** %3
%38 = call i32 @fputc(i32 0, i32* %37)
%39 = load i32*, i32** %3
%40 = call i32 @fputc(i32 0, i32* %39)
%41 = load i32*, i32** %3
%42 = call i32 @fputc(i32 0, i32* %41)
%43 = load i32*, i32** %3
%44 = call i32 @fputc(i32 255, i32* %43)
%45 = load i32*, i32** %3
%46 = call i32 @fputc(i32 255, i32* %45)
%47 = load i32*, i32** %3
%48 = call i32 @fputc(i32 255, i32* %47)
%49 = load i32*, i32** %3
%50 = call i32 @fputc(i32 255, i32* %49)
%51 = load i32*, i32** %3
%52 = call i32 @fputc(i32 0, i32* %51)
%53 = load i32*, i32** %3
%54 = call i32 @fputc(i32 0, i32* %53)
%55 = load i32*, i32** %3
%56 = call i32 @fputc(i32 0, i32* %55)
%57 = load i32*, i32** %3
%58 = call i32 @fputc(i32 0, i32* %57)
%59 = load i32*, i32** %3
%60 = call i32 @fputc(i32 255, i32* %59)
%61 = load i32*, i32** %3
%62 = call i32 @fputc(i32 255, i32* %61)
%63 = load i32*, i32** %3
%64 = call i32 @fputc(i32 255, i32* %63)
%65 = load i32*, i32** %3
%66 = call i32 @fputc(i32 255, i32* %65)
%67 = load i32*, i32** %3
%68 = call i32 @fputc(i32 0, i32* %67)
%69 = load i32*, i32** %3
%70 = call i32 @fputc(i32 0, i32* %69)
%71 = load i32*, i32** %3
%72 = call i32 @fputc(i32 0, i32* %71)
%73 = load i32*, i32** %3
%74 = call i32 @fputc(i32 0, i32* %73)
%75 = load i32*, i32** %3
%76 = call i32 @fputc(i32 255, i32* %75)
%77 = load i32*, i32** %3
%78 = call i32 @fputc(i32 255, i32* %77)
%79 = load i32*, i32** %3
%80 = call i32 @fputc(i32 255, i32* %79)
%81 = load i32*, i32** %3
%82 = call i32 @fputc(i32 255, i32* %81)
%83 = load i32*, i32** %3
%84 = call i32 @fputc(i32 0, i32* %83)
%85 = load i32*, i32** %3
%86 = call i32 @fputc(i32 0, i32* %85)
%87 = load i32*, i32** %3
%88 = call i32 @fputc(i32 0, i32* %87)
%89 = load i32*, i32** %3
%90 = call i32 @fputc(i32 0, i32* %89)
%91 = load i32*, i32** %3
%92 = call i32 @fclose(i32* %91)
br label %93
93: ; preds = %26, %25, %7
%94 = load i32, i32* %1
ret i32 %94
}

LLVM IR (-O2):
@.str = [13 x i8] c"./.testbytes\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [12 x i8] c"./.testbits\00"
define i32 @main() {
%1 = tail call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%2 = icmp eq i32* %1, null
br i1 %2, label %46, label %3
3: ; preds = %0, %3
%4 = phi i32 [ %6, %3 ], [ 0, %0 ]
%5 = tail call i32 @fputc(i32 %4, i32* %1)
%6 = add nuw nsw i32 %4, 1
%7 = icmp eq i32 %6, 255
br i1 %7, label %8, label %3
8: ; preds = %3
%9 = tail call i32 @fclose(i32* %1)
%10 = tail call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%11 = icmp eq i32* %10, null
br i1 %11, label %46, label %12
12: ; preds = %8
%13 = tail call i32 @fputc(i32 255, i32* %10)
%14 = tail call i32 @fputc(i32 255, i32* %10)
%15 = tail call i32 @fputc(i32 255, i32* %10)
%16 = tail call i32 @fputc(i32 255, i32* %10)
%17 = tail call i32 @fputc(i32 0, i32* %10)
%18 = tail call i32 @fputc(i32 0, i32* %10)
%19 = tail call i32 @fputc(i32 0, i32* %10)
%20 = tail call i32 @fputc(i32 0, i32* %10)
%21 = tail call i32 @fputc(i32 255, i32* %10)
%22 = tail call i32 @fputc(i32 255, i32* %10)
%23 = tail call i32 @fputc(i32 255, i32* %10)
%24 = tail call i32 @fputc(i32 255, i32* %10)
%25 = tail call i32 @fputc(i32 0, i32* %10)
%26 = tail call i32 @fputc(i32 0, i32* %10)
%27 = tail call i32 @fputc(i32 0, i32* %10)
%28 = tail call i32 @fputc(i32 0, i32* %10)
%29 = tail call i32 @fputc(i32 255, i32* %10)
%30 = tail call i32 @fputc(i32 255, i32* %10)
%31 = tail call i32 @fputc(i32 255, i32* %10)
%32 = tail call i32 @fputc(i32 255, i32* %10)
%33 = tail call i32 @fputc(i32 0, i32* %10)
%34 = tail call i32 @fputc(i32 0, i32* %10)
%35 = tail call i32 @fputc(i32 0, i32* %10)
%36 = tail call i32 @fputc(i32 0, i32* %10)
%37 = tail call i32 @fputc(i32 255, i32* %10)
%38 = tail call i32 @fputc(i32 255, i32* %10)
%39 = tail call i32 @fputc(i32 255, i32* %10)
%40 = tail call i32 @fputc(i32 255, i32* %10)
%41 = tail call i32 @fputc(i32 0, i32* %10)
%42 = tail call i32 @fputc(i32 0, i32* %10)
%43 = tail call i32 @fputc(i32 0, i32* %10)
%44 = tail call i32 @fputc(i32 0, i32* %10)
%45 = tail call i32 @fclose(i32* %10)
br label %46
46: ; preds = %8, %0, %12
%47 = phi i32 [ 0, %12 ], [ -1, %0 ], [ -1, %8 ]
ret i32 %47
}