#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*/ exit(int);
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 *inputFile, *outputFile;
  char c;
  if ((inputFile = fopen("input", "r")) == NULL) {
    printf("Cannot open input!\n");
    exit(1);
  }
  if ((outputFile = fopen("output", "w")) == NULL) {
    printf("Cannot open output!\n");
    exit(1);
  }
  while ((c = getc(inputFile)) != EOF) {
    if (c >= 'a' && c <= 'z')
      c -= 'a' - 'A';
    putc(c, outputFile);
  }
  fclose(inputFile);
  fclose(outputFile);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe8a(%rip),%rdi
lea    0xe89(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
jne    11a6 <main+0x46>
lea    0xe71(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
lea    0xe6f(%rip),%rdi
lea    0xe6f(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    11dd <main+0x7d>
lea    0xe57(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
jmp    11e2 <main+0x82>
mov    -0x10(%rbp),%rdi
call   1080 <getc@plt>
mov    %al,-0x19(%rbp)
movsbl %al,%eax
mov    0x2df0(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     123b <main+0xdb>
movsbl -0x19(%rbp),%eax
cmp    $0x61,%eax
jl     1227 <main+0xc7>
movsbl -0x19(%rbp),%eax
cmp    $0x7a,%eax
jg     1227 <main+0xc7>
movsbl -0x19(%rbp),%eax
sub    $0x20,%eax
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
mov    -0x18(%rbp),%rsi
movsbl %al,%edi
call   1050 <putc@plt>
jmp    11e2 <main+0x82>
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    0xe94(%rip),%rdi
lea    0xe93(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     11f2 <main+0x92>
mov    %rax,%r14
lea    0xe81(%rip),%rdi
lea    0xe81(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     11fb <main+0x9b>
mov    %rax,%rbx
mov    %r14,%rdi
call   1080 <getc@plt>
mov    0x2e3e(%rip),%r15
cmp    (%r15),%al
je     11da <main+0x7a>
nop
lea    -0x61(%rax),%ecx
lea    -0x20(%rax),%edx
cmp    $0x1a,%cl
movzbl %al,%eax
movzbl %dl,%ecx
cmovae %eax,%ecx
movsbl %cl,%edi
mov    %rbx,%rsi
call   1050 <putc@plt>
mov    %r14,%rdi
call   1080 <getc@plt>
cmp    (%r15),%al
jne    11b0 <main+0x50>
mov    %r14,%rdi
call   1040 <fclose@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret
lea    0xe2c(%rip),%rdi
jmp    1202 <main+0xa2>
lea    0xe0f(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [6 x i8] c"input\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [20 x i8] c"Cannot open input!\0A\00"
@.str.3 = [7 x i8] c"output\00"
@.str.4 = [2 x i8] c"w\00"
@.str.5 = [21 x i8] c"Cannot open output!\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 ([6 x i8], [6 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 = icmp eq i32* %5, null
br i1 %6, label %7, label %10
7: ; preds = %0
%8 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 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.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i32* %11, i32** %3
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %16
13: ; preds = %10
%14 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0))
%15 = call i32 @exit(i32 1)
unreachable
16: ; preds = %10
br label %17
17: ; preds = %37, %16
%18 = load i32*, i32** %2
%19 = call signext i8 @getc(i32* %18)
store i8 %19, i8* %4
%20 = sext i8 %19 to i32
%21 = load i8, i8* @EOF
%22 = sext i8 %21 to i32
%23 = icmp ne i32 %20, %22
br i1 %23, label %24, label %41
24: ; preds = %17
%25 = load i8, i8* %4
%26 = sext i8 %25 to i32
%27 = icmp sge i32 %26, 97
br i1 %27, label %28, label %37
28: ; preds = %24
%29 = load i8, i8* %4
%30 = sext i8 %29 to i32
%31 = icmp sle i32 %30, 122
br i1 %31, label %32, label %37
32: ; preds = %28
%33 = load i8, i8* %4
%34 = sext i8 %33 to i32
%35 = sub nsw i32 %34, 32
%36 = trunc i32 %35 to i8
store i8 %36, i8* %4
br label %37
37: ; preds = %32, %28, %24
%38 = load i8, i8* %4
%39 = load i32*, i32** %3
%40 = call i32 @putc(i8 signext %38, i32* %39)
br label %17
41: ; preds = %17
%42 = load i32*, i32** %2
%43 = call i32 @fclose(i32* %42)
%44 = load i32*, i32** %3
%45 = call i32 @fclose(i32* %44)
ret i32 0
}

LLVM IR (-O2):
@.str = [6 x i8] c"input\00"
@.str.1 = [2 x i8] c"r\00"
@.str.3 = [7 x i8] c"output\00"
@.str.4 = [2 x i8] c"w\00"
@EOF = global i8 0
@str = [20 x i8] c"Cannot open output!\00"
@str.6 = [19 x i8] c"Cannot open input!\00"
define i32 @main() {
%1 = tail call i32* @fopen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 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 ([19 x i8], [19 x i8]* @str.6, i64 0, i64 0))
%5 = tail call i32 @exit(i32 1)
unreachable
6: ; preds = %0
%7 = tail call i32* @fopen(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%8 = icmp eq i32* %7, null
br i1 %8, label %13, label %9
9: ; preds = %6
%10 = tail call signext i8 @getc(i32* %1)
%11 = load i8, i8* @EOF
%12 = icmp eq i8 %10, %11
br i1 %12, label %26, label %16
13: ; preds = %6
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
%15 = tail call i32 @exit(i32 1)
unreachable
16: ; preds = %9, %16
%17 = phi i8 [ %23, %16 ], [ %10, %9 ]
%18 = add i8 %17, -97
%19 = icmp ult i8 %18, 26
%20 = add i8 %17, -32
%21 = select i1 %19, i8 %20, i8 %17
%22 = tail call i32 @putc(i8 signext %21, i32* %7)
%23 = tail call signext i8 @getc(i32* %1)
%24 = load i8, i8* @EOF
%25 = icmp eq i8 %23, %24
br i1 %25, label %26, label %16
26: ; preds = %16, %9
%27 = tail call i32 @fclose(i32* %1)
%28 = tail call i32 @fclose(i32* %7)
ret i32 0
}