#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 fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ putc(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ rewind(int /*<<< orphan*/ *);
int main(int argc, char *argv[]) {
  FILE *fp;
  if (argc == 2) {
    fp = fopen(argv[1], "rb+");
  } else {
    printf("-- Error: Please indicate file! One argument only!!!");
    return (1);
  }
  if (NULL == fp) {
    printf("Error opening the file\n");
    return (1);
  };
  int c = fgetc(fp);
  c ^= 'D';
  rewind(fp);
  putc(c, fp);
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jne    118d <main+0x3d>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe81(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x18(%rbp)
jmp    11a5 <main+0x55>
lea    0xe70(%rip),%rdi
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11fa <main+0xaa>
xor    %eax,%eax
cmp    -0x18(%rbp),%rax
jne    11c9 <main+0x79>
lea    0xe81(%rip),%rdi
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11fa <main+0xaa>
mov    -0x18(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
xor    $0x44,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <rewind@plt>
mov    -0x1c(%rbp),%edi
mov    -0x18(%rbp),%rsi
call   1060 <putc@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
cmp    $0x2,%edi
jne    11a3 <main+0x43>
mov    0x8(%rsi),%rdi
lea    0xe8d(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     11b1 <main+0x51>
mov    %rax,%rbx
mov    %rax,%rdi
call   1060 <fgetc@plt>
mov    %eax,%ebp
xor    $0x44,%ebp
mov    %rbx,%rdi
call   1050 <rewind@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
call   1070 <putc@plt>
xor    %eax,%eax
jmp    11c2 <main+0x62>
lea    0xe5a(%rip),%rdi
call   1040 <printf@plt>
jmp    11bd <main+0x5d>
lea    0xe81(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"rb+\00"
@.str.1 = [53 x i8] c"-- Error: Please indicate file! One argument only!!!\00"
@.str.2 = [24 x i8] c"Error opening the file\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp eq i32 %8, 2
br i1 %9, label %10, label %15
10: ; preds = %2
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 1
%13 = load i8*, i8** %12
%14 = call i32* @fopen(i8* %13, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
store i32* %14, i32** %6
br label %17
15: ; preds = %2
%16 = call i32 @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %3
br label %32
17: ; preds = %10
%18 = load i32*, i32** %6
%19 = icmp eq i32* null, %18
br i1 %19, label %20, label %22
20: ; preds = %17
%21 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %3
br label %32
22: ; preds = %17
%23 = load i32*, i32** %6
%24 = call i32 @fgetc(i32* %23)
store i32 %24, i32* %7
%25 = load i32, i32* %7
%26 = xor i32 %25, 68
store i32 %26, i32* %7
%27 = load i32*, i32** %6
%28 = call i32 @rewind(i32* %27)
%29 = load i32, i32* %7
%30 = load i32*, i32** %6
%31 = call i32 @putc(i32 %29, i32* %30)
store i32 0, i32* %3
br label %32
32: ; preds = %22, %20, %15
%33 = load i32, i32* %3
ret i32 %33
}

LLVM IR (-O2):
@.str = [4 x i8] c"rb+\00"
@.str.1 = [53 x i8] c"-- Error: Please indicate file! One argument only!!!\00"
@str = [23 x i8] c"Error opening the file\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %4, label %9
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i32* @fopen(i8* %6, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i32* %7, null
br i1 %8, label %11, label %13
9: ; preds = %2
%10 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @.str.1, i64 0, i64 0))
br label %18
11: ; preds = %4
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0))
br label %18
13: ; preds = %4
%14 = tail call i32 @fgetc(i32* %7)
%15 = xor i32 %14, 68
%16 = tail call i32 @rewind(i32* %7)
%17 = tail call i32 @putc(i32 %15, i32* %7)
br label %18
18: ; preds = %13, %11, %9
%19 = phi i32 [ 1, %11 ], [ 0, %13 ], [ 1, %9 ]
ret i32 %19
}