#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*/ SEEK_SET;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fputc(char, int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, long, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ putchar(char);
main() {
  FILE *f, *f1;
  int i;
  char c;
  if ((f = fopen("/dos/file1", "w+")) == NULL) {
    printf("couldn't open file1\n");
    exit(-1);
  }
  if ((f1 = fopen("/dos/file2", "w+")) == NULL) {
    printf("couldn't open file2\n");
    exit(-1);
  }
  for (i = 0; i < 26; i++) {
    fseek(f, (long)i, SEEK_SET);
    fputc('a' + i, f);
    fseek(f, (long)(26 - i - 1), SEEK_SET);
    fputc('A' + i, f);
    fseek(f1, (long)(26 - i - 1), SEEK_SET);
    fputc('a' + i, f1);
    fseek(f1, (long)i, SEEK_SET);
    fputc('A' + i, f1);
  }
  putchar('\n');
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe8a(%rip),%rdi
lea    0xe8e(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
jne    11a6 <main+0x46>
lea    0xe77(%rip),%rdi
call   1040 <printf@plt>
mov    $0xffffffff,%edi
call   1080 <exit@plt>
lea    0xe76(%rip),%rdi
lea    0xe57(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    11dd <main+0x7d>
lea    0xe60(%rip),%rdi
call   1040 <printf@plt>
mov    $0xffffffff,%edi
call   1080 <exit@plt>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x1a,-0x1c(%rbp)
jge    12b0 <main+0x150>
mov    -0x10(%rbp),%rdi
movslq -0x1c(%rbp),%rsi
mov    0x2de3(%rip),%rax
mov    (%rax),%edx
call   1060 <fseek@plt>
mov    -0x1c(%rbp),%eax
add    $0x61,%eax
mov    -0x10(%rbp),%rsi
movsbl %al,%edi
call   1050 <fputc@plt>
mov    -0x10(%rbp),%rdi
mov    $0x1a,%eax
sub    -0x1c(%rbp),%eax
sub    $0x1,%eax
movslq %eax,%rsi
mov    0x2db1(%rip),%rax
mov    (%rax),%edx
call   1060 <fseek@plt>
mov    -0x1c(%rbp),%eax
add    $0x41,%eax
mov    -0x10(%rbp),%rsi
movsbl %al,%edi
call   1050 <fputc@plt>
mov    -0x18(%rbp),%rdi
mov    $0x1a,%eax
sub    -0x1c(%rbp),%eax
sub    $0x1,%eax
movslq %eax,%rsi
mov    0x2d7f(%rip),%rax
mov    (%rax),%edx
call   1060 <fseek@plt>
mov    -0x1c(%rbp),%eax
add    $0x61,%eax
mov    -0x18(%rbp),%rsi
movsbl %al,%edi
call   1050 <fputc@plt>
mov    -0x18(%rbp),%rdi
movslq -0x1c(%rbp),%rsi
mov    0x2d57(%rip),%rax
mov    (%rax),%edx
call   1060 <fseek@plt>
mov    -0x1c(%rbp),%eax
add    $0x41,%eax
mov    -0x18(%rbp),%rsi
movsbl %al,%edi
call   1050 <fputc@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11e4 <main+0x84>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xe8e(%rip),%rdi
lea    0xe92(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     1273 <main+0x113>
mov    %rax,%r15
lea    0xe7d(%rip),%rdi
lea    0xe73(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     127c <main+0x11c>
mov    %rax,%rbp
mov    $0x19,%r12d
xor    %ebx,%ebx
mov    %r15,(%rsp)
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rbp,%r15
mov    0x2e16(%rip),%r14
mov    (%r14),%edx
mov    (%rsp),%rbp
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1060 <fseek@plt>
lea    0x61(%rbx),%eax
movsbl %al,%r13d
mov    %r13d,%edi
mov    %rbp,%rsi
call   1050 <fputc@plt>
mov    (%r14),%edx
mov    %rbp,%rdi
mov    %r12,%rsi
call   1060 <fseek@plt>
lea    0x41(%rbx),%eax
movsbl %al,%r14d
mov    %r14d,%edi
mov    %rbp,%rsi
call   1050 <fputc@plt>
mov    0x2dcb(%rip),%rbp
mov    0x0(%rbp),%edx
mov    %r15,%rdi
mov    %r12,%rsi
call   1060 <fseek@plt>
mov    %r13d,%edi
mov    %r15,%rsi
call   1050 <fputc@plt>
mov    0x0(%rbp),%edx
mov    %r15,%rbp
mov    %r15,%rdi
mov    %rbx,%rsi
call   1060 <fseek@plt>
mov    %r14d,%edi
mov    %r15,%rsi
call   1050 <fputc@plt>
add    $0x1,%rbx
add    $0xffffffffffffffff,%r12
jb     11c0 <main+0x60>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xdb3(%rip),%rdi
jmp    1283 <main+0x123>
lea    0xd96(%rip),%rdi
call   1040 <puts@plt>
mov    $0xffffffff,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [11 x i8] c"/dos/file1\00"
@.str.1 = [3 x i8] c"w+\00"
@.str.2 = [21 x i8] c"couldn't open file1\0A\00"
@.str.3 = [11 x i8] c"/dos/file2\00"
@.str.4 = [21 x i8] c"couldn't open file2\0A\00"
@SEEK_SET = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i8
store i32 0, i32* %1
%6 = call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 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 %11
8: ; preds = %0
%9 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 @exit(i32 -1)
unreachable
11: ; preds = %0
%12 = call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %12, i32** %3
%13 = icmp eq i32* %12, null
br i1 %13, label %14, label %17
14: ; preds = %11
%15 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0))
%16 = call i32 @exit(i32 -1)
unreachable
17: ; preds = %11
store i32 0, i32* %4
br label %18
18: ; preds = %66, %17
%19 = load i32, i32* %4
%20 = icmp slt i32 %19, 26
br i1 %20, label %21, label %69
21: ; preds = %18
%22 = load i32*, i32** %2
%23 = load i32, i32* %4
%24 = sext i32 %23 to i64
%25 = load i32, i32* @SEEK_SET
%26 = call i32 @fseek(i32* %22, i64 %24, i32 %25)
%27 = load i32, i32* %4
%28 = add nsw i32 97, %27
%29 = trunc i32 %28 to i8
%30 = load i32*, i32** %2
%31 = call i32 @fputc(i8 signext %29, i32* %30)
%32 = load i32*, i32** %2
%33 = load i32, i32* %4
%34 = sub nsw i32 26, %33
%35 = sub nsw i32 %34, 1
%36 = sext i32 %35 to i64
%37 = load i32, i32* @SEEK_SET
%38 = call i32 @fseek(i32* %32, i64 %36, i32 %37)
%39 = load i32, i32* %4
%40 = add nsw i32 65, %39
%41 = trunc i32 %40 to i8
%42 = load i32*, i32** %2
%43 = call i32 @fputc(i8 signext %41, i32* %42)
%44 = load i32*, i32** %3
%45 = load i32, i32* %4
%46 = sub nsw i32 26, %45
%47 = sub nsw i32 %46, 1
%48 = sext i32 %47 to i64
%49 = load i32, i32* @SEEK_SET
%50 = call i32 @fseek(i32* %44, i64 %48, i32 %49)
%51 = load i32, i32* %4
%52 = add nsw i32 97, %51
%53 = trunc i32 %52 to i8
%54 = load i32*, i32** %3
%55 = call i32 @fputc(i8 signext %53, i32* %54)
%56 = load i32*, i32** %3
%57 = load i32, i32* %4
%58 = sext i32 %57 to i64
%59 = load i32, i32* @SEEK_SET
%60 = call i32 @fseek(i32* %56, i64 %58, i32 %59)
%61 = load i32, i32* %4
%62 = add nsw i32 65, %61
%63 = trunc i32 %62 to i8
%64 = load i32*, i32** %3
%65 = call i32 @fputc(i8 signext %63, i32* %64)
br label %66
66: ; preds = %21
%67 = load i32, i32* %4
%68 = add nsw i32 %67, 1
store i32 %68, i32* %4
br label %18
69: ; preds = %18
%70 = call i32 @putchar(i8 signext 10)
%71 = load i32, i32* %1
ret i32 %71
}

LLVM IR (-O2):
@.str = [11 x i8] c"/dos/file1\00"
@.str.1 = [3 x i8] c"w+\00"
@.str.3 = [11 x i8] c"/dos/file2\00"
@SEEK_SET = global i32 0
@str = [20 x i8] c"couldn't open file2\00"
@str.5 = [20 x i8] c"couldn't open file1\00"
define i32 @main() {
%1 = tail call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 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 %6
3: ; preds = %0
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.5, i64 0, i64 0))
%5 = tail call i32 @exit(i32 -1)
unreachable
6: ; preds = %0
%7 = tail call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%8 = icmp eq i32* %7, null
br i1 %8, label %9, label %12
9: ; preds = %6
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
%11 = tail call i32 @exit(i32 -1)
unreachable
12: ; preds = %6, %12
%13 = phi i64 [ %30, %12 ], [ 0, %6 ]
%14 = load i32, i32* @SEEK_SET
%15 = tail call i32 @fseek(i32* %1, i64 %13, i32 %14)
%16 = trunc i64 %13 to i8
%17 = add nuw nsw i8 %16, 97
%18 = tail call i32 @fputc(i8 signext %17, i32* %1)
%19 = sub nuw nsw i64 25, %13
%20 = load i32, i32* @SEEK_SET
%21 = tail call i32 @fseek(i32* %1, i64 %19, i32 %20)
%22 = add nuw nsw i8 %16, 65
%23 = tail call i32 @fputc(i8 signext %22, i32* %1)
%24 = load i32, i32* @SEEK_SET
%25 = tail call i32 @fseek(i32* %7, i64 %19, i32 %24)
%26 = tail call i32 @fputc(i8 signext %17, i32* %7)
%27 = load i32, i32* @SEEK_SET
%28 = tail call i32 @fseek(i32* %7, i64 %13, i32 %27)
%29 = tail call i32 @fputc(i8 signext %22, i32* %7)
%30 = add nuw nsw i64 %13, 1
%31 = icmp eq i64 %30, 26
br i1 %31, label %32, label %12
32: ; preds = %12
%33 = tail call i32 @putchar(i8 signext 10)
ret i32 0
}