#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 main03(void) {
  FILE *p = fopen("D:\\temp\\a.txt", "r");
  FILE *p1 = fopen("D:\\temp\\b.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):
<main03>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xea1(%rip),%rdi
lea    0xea8(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x8(%rbp)
lea    0xe9a(%rip),%rdi
lea    0xea1(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    11a2 <main03+0x52>
lea    0xe88(%rip),%rdi
call   1040 <printf@plt>
jmp    11f7 <main03+0xa7>
movb   $0x0,-0x11(%rbp)
mov    -0x8(%rbp),%rdi
call   1070 <getc@plt>
mov    %al,-0x11(%rbp)
movsbl %al,%eax
mov    0x2e2c(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     11e5 <main03+0x95>
movsbl -0x11(%rbp),%eax
add    $0x5,%eax
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
mov    -0x10(%rbp),%rsi
movsbl %al,%edi
call   1050 <putc@plt>
jmp    11a6 <main03+0x56>
mov    -0x8(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main03>:
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 <main03+0x7c>
mov    %rax,%r14
mov    %rbx,%rdi
call   1070 <getc@plt>
mov    0x2e53(%rip),%r15
cmp    (%r15),%al
je     11ba <main03+0x6a>
nopw   0x0(%rax,%rax,1)
add    $0x5,%al
movsbl %al,%edi
mov    %r14,%rsi
call   1050 <putc@plt>
mov    %rbx,%rdi
call   1070 <getc@plt>
cmp    (%r15),%al
jne    11a0 <main03+0x50>
mov    %rbx,%rdi
call   1040 <fclose@plt>
mov    %r14,%rdi
call   1040 <fclose@plt>
jmp    11d8 <main03+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\\a.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [14 x i8] c"D:\\temp\\b.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 @main03() {
%1 = alloca i32*
%2 = alloca i32*
%3 = alloca i8
%4 = 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* %4, i32** %1
%5 = 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* %5, i32** %2
%6 = load i32*, i32** %1
%7 = icmp eq i32* %6, null
br i1 %7, label %8, label %10
8: ; preds = %0
%9 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
br label %31
10: ; preds = %0
store i8 0, i8* %3
br label %11
11: ; preds = %18, %10
%12 = load i32*, i32** %1
%13 = call signext i8 @getc(i32* %12)
store i8 %13, i8* %3
%14 = sext i8 %13 to i32
%15 = load i8, i8* @EOF
%16 = sext i8 %15 to i32
%17 = icmp ne i32 %14, %16
br i1 %17, label %18, label %26
18: ; preds = %11
%19 = load i8, i8* %3
%20 = sext i8 %19 to i32
%21 = add nsw i32 %20, 5
%22 = trunc i32 %21 to i8
store i8 %22, i8* %3
%23 = load i8, i8* %3
%24 = load i32*, i32** %2
%25 = call i32 @putc(i8 signext %23, i32* %24)
br label %11
26: ; preds = %11
%27 = load i32*, i32** %1
%28 = call i32 @fclose(i32* %27)
%29 = load i32*, i32** %2
%30 = call i32 @fclose(i32* %29)
br label %31
31: ; preds = %26, %8
ret i32 0
}

LLVM IR (-O2):
@.str = [14 x i8] c"D:\\temp\\a.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [14 x i8] c"D:\\temp\\b.txt\00"
@.str.3 = [2 x i8] c"w\00"
@EOF = global i8 0
@str = [6 x i8] c"error\00"
define i32 @main03() {
%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
}