#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 */
char EOF;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
char getc(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ putc(char, int /*<<< orphan*/ *);
int main(void) {
  FILE *p = fopen("D:\\temp\\b.txt", "r");
  FILE *p1 = fopen("D:\\temp\\c.txt", "w");
  if (p == NULL) {
    printf("error\n");
  } else {
    char c = 0;
    while ((c = getc(p)) != EOF) {
      c -= 5;
      putc(c, p1);
    }
    fclose(p);
    fclose(p1);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rdi
lea    0xea1(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x10(%rbp)
lea    0xe93(%rip),%rdi
lea    0xe9a(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11a9 <main+0x59>
lea    0xe81(%rip),%rdi
call   1040 <printf@plt>
jmp    11fe <main+0xae>
movb   $0x0,-0x19(%rbp)
mov    -0x10(%rbp),%rdi
call   1070 <getc@plt>
mov    %al,-0x19(%rbp)
movsbl %al,%eax
mov    0x2e25(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     11ec <main+0x9c>
movsbl -0x19(%rbp),%eax
sub    $0x5,%eax
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
mov    -0x18(%rbp),%rsi
movsbl %al,%edi
call   1050 <putc@plt>
jmp    11ad <main+0x5d>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
lea    0xea4(%rip),%rdi
lea    0xebf(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%rbx
lea    0xe9c(%rip),%rdi
lea    0xea3(%rip),%rsi
call   1060 <fopen@plt>
test   %rbx,%rbx
je     11cc <main+0x7c>
mov    %rax,%r14
mov    %rbx,%rdi
call   1070 <getc@plt>
mov    0x2e53(%rip),%r15
cmp    (%r15),%al
je     11ba <main+0x6a>
nopw   0x0(%rax,%rax,1)
add    $0xfb,%al
movsbl %al,%edi
mov    %r14,%rsi
call   1050 <putc@plt>
mov    %rbx,%rdi
call   1070 <getc@plt>
cmp    (%r15),%al
jne    11a0 <main+0x50>
mov    %rbx,%rdi
call   1040 <fclose@plt>
mov    %r14,%rdi
call   1040 <fclose@plt>
jmp    11d8 <main+0x88>
lea    0xe4b(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [14 x i8] c"D:\\temp\\b.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [14 x i8] c"D:\\temp\\c.txt\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [7 x i8] c"error\0A\00"
@EOF = global i8 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32*
%4 = alloca i8
store i32 0, i32* %1
%5 = call i32* @fopen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %5, i32** %2
%6 = call i32* @fopen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %6, i32** %3
%7 = load i32*, i32** %2
%8 = icmp eq i32* %7, null
br i1 %8, label %9, label %11
9: ; preds = %0
%10 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
br label %32
11: ; preds = %0
store i8 0, i8* %4
br label %12
12: ; preds = %19, %11
%13 = load i32*, i32** %2
%14 = call signext i8 @getc(i32* %13)
store i8 %14, i8* %4
%15 = sext i8 %14 to i32
%16 = load i8, i8* @EOF
%17 = sext i8 %16 to i32
%18 = icmp ne i32 %15, %17
br i1 %18, label %19, label %27
19: ; preds = %12
%20 = load i8, i8* %4
%21 = sext i8 %20 to i32
%22 = sub nsw i32 %21, 5
%23 = trunc i32 %22 to i8
store i8 %23, i8* %4
%24 = load i8, i8* %4
%25 = load i32*, i32** %3
%26 = call i32 @putc(i8 signext %24, i32* %25)
br label %12
27: ; preds = %12
%28 = load i32*, i32** %2
%29 = call i32 @fclose(i32* %28)
%30 = load i32*, i32** %3
%31 = call i32 @fclose(i32* %30)
br label %32
32: ; preds = %27, %9
ret i32 0
}

LLVM IR (-O2):
@.str = [14 x i8] c"D:\\temp\\b.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [14 x i8] c"D:\\temp\\c.txt\00"
@.str.3 = [2 x i8] c"w\00"
@EOF = global i8 0
@str = [6 x i8] c"error\00"
define i32 @main() {
%1 = tail call i32* @fopen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%2 = tail call i32* @fopen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%3 = icmp eq i32* %1, null
br i1 %3, label %8, label %4
4: ; preds = %0
%5 = tail call signext i8 @getc(i32* %1)
%6 = load i8, i8* @EOF
%7 = icmp eq i8 %5, %6
br i1 %7, label %17, label %10
8: ; preds = %0
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str, i64 0, i64 0))
br label %20
10: ; preds = %4, %10
%11 = phi i8 [ %14, %10 ], [ %5, %4 ]
%12 = add i8 %11, -5
%13 = tail call i32 @putc(i8 signext %12, i32* %2)
%14 = tail call signext i8 @getc(i32* %1)
%15 = load i8, i8* @EOF
%16 = icmp eq i8 %14, %15
br i1 %16, label %17, label %10
17: ; preds = %10, %4
%18 = tail call i32 @fclose(i32* %1)
%19 = tail call i32 @fclose(i32* %2)
br label %20
20: ; preds = %17, %8
ret i32 0
}