#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);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ feof(int /*<<< orphan*/ *);
unsigned int fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fputc(unsigned int, int /*<<< orphan*/ *);
int main() {
  FILE *fp, *fd;
  if ((fp = fopen(".PASSWDS", "rb")) == NULL)
    exit(1);
  if ((fd = fopen("result", "wb")) == NULL)
    exit(1);
  unsigned c;
  int count = 0;
  while (1) {
    c = fgetc(fp);
    if (feof(fp))
      exit(1);
    count++;
    if ((count - 224) % 452 == 0) {
      c = c | 0x80;
    }
    fputc(c, fd);
  }
  fclose(fp);
  fclose(fd);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rdi
lea    0xe9c(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
jne    118a <main+0x3a>
mov    $0x1,%edi
call   1070 <exit@plt>
lea    0xe7b(%rip),%rdi
lea    0xe7b(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    11b5 <main+0x65>
mov    $0x1,%edi
call   1070 <exit@plt>
movl   $0x0,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <fgetc@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <feof@plt>
cmp    $0x0,%rax
je     11e5 <main+0x95>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
sub    $0xe0,%eax
mov    $0x1c4,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1212 <main+0xc2>
mov    -0x1c(%rbp),%eax
or     $0x80,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%edi
mov    -0x18(%rbp),%rsi
call   1040 <fputc@plt>
jmp    11bc <main+0x6c>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
lea    0xea2(%rip),%rdi
lea    0xea4(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     11f0 <main+0xa0>
mov    %rax,%r15
lea    0xe8f(%rip),%rdi
lea    0xe8f(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     11f0 <main+0xa0>
mov    %rax,%r14
mov    %r15,%rdi
call   1030 <fgetc@plt>
mov    %eax,%ebp
mov    %r15,%rdi
call   1050 <feof@plt>
test   %rax,%rax
jne    11f0 <main+0xa0>
mov    $0xffffff21,%ebx
nopl   (%rax)
imul   $0xfdbc091,%ebx,%eax
add    $0x121fb78,%eax
ror    $0x2,%eax
mov    %ebp,%edi
or     $0x80,%edi
cmp    $0x90fdbd,%eax
cmovae %ebp,%edi
mov    %r14,%rsi
call   1040 <fputc@plt>
mov    %r15,%rdi
call   1030 <fgetc@plt>
mov    %eax,%ebp
mov    %r15,%rdi
call   1050 <feof@plt>
add    $0x1,%ebx
test   %rax,%rax
je     11b0 <main+0x60>
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [9 x i8] c".PASSWDS\00"
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [7 x i8] c"result\00"
@.str.3 = [3 x i8] c"wb\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %6, i32** %2
%7 = icmp eq i32* %6, null
br i1 %7, label %8, label %10
8: ; preds = %0
%9 = call i32 @exit(i32 1)
unreachable
10: ; preds = %0
%11 = call i32* @fopen(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
store i32* %11, i32** %3
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %15
13: ; preds = %10
%14 = call i32 @exit(i32 1)
unreachable
15: ; preds = %10
store i32 0, i32* %5
br label %16
16: ; preds = %15, %34
%17 = load i32*, i32** %2
%18 = call i32 @fgetc(i32* %17)
store i32 %18, i32* %4
%19 = load i32*, i32** %2
%20 = call i64 @feof(i32* %19)
%21 = icmp ne i64 %20, 0
br i1 %21, label %22, label %24
22: ; preds = %16
%23 = call i32 @exit(i32 1)
unreachable
24: ; preds = %16
%25 = load i32, i32* %5
%26 = add nsw i32 %25, 1
store i32 %26, i32* %5
%27 = load i32, i32* %5
%28 = sub nsw i32 %27, 224
%29 = srem i32 %28, 452
%30 = icmp eq i32 %29, 0
br i1 %30, label %31, label %34
31: ; preds = %24
%32 = load i32, i32* %4
%33 = or i32 %32, 128
store i32 %33, i32* %4
br label %34
34: ; preds = %31, %24
%35 = load i32, i32* %4
%36 = load i32*, i32** %3
%37 = call i32 @fputc(i32 %35, i32* %36)
br label %16
}

LLVM IR (-O2):
@.str = [9 x i8] c".PASSWDS\00"
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [7 x i8] c"result\00"
@.str.3 = [3 x i8] c"wb\00"
define i32 @main() {
%1 = tail call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%2 = icmp eq i32* %1, null
br i1 %2, label %3, label %5
3: ; preds = %0
%4 = tail call i32 @exit(i32 1)
unreachable
5: ; preds = %0
%6 = tail call i32* @fopen(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%7 = icmp eq i32* %6, null
br i1 %7, label %12, label %8
8: ; preds = %5
%9 = tail call i32 @fgetc(i32* %1)
%10 = tail call i64 @feof(i32* %1)
%11 = icmp eq i64 %10, 0
br i1 %11, label %16, label %14
12: ; preds = %5
%13 = tail call i32 @exit(i32 1)
unreachable
14: ; preds = %16, %8
%15 = tail call i32 @exit(i32 1)
unreachable
16: ; preds = %8, %16
%17 = phi i32 [ %26, %16 ], [ %9, %8 ]
%18 = phi i32 [ %19, %16 ], [ 0, %8 ]
%19 = add nuw nsw i32 %18, 1
%20 = add nsw i32 %18, -223
%21 = srem i32 %20, 452
%22 = icmp eq i32 %21, 0
%23 = or i32 %17, 128
%24 = select i1 %22, i32 %23, i32 %17
%25 = tail call i32 @fputc(i32 %24, i32* %6)
%26 = tail call i32 @fgetc(i32* %1)
%27 = tail call i64 @feof(i32* %1)
%28 = icmp eq i64 %27, 0
br i1 %28, label %16, label %14
}