#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 EOF;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ fputc(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ isAlpha(int);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  FILE *fin, *fout;
  int ch;
  if (argc != 3) {
    fprintf(stderr, "uso: toupper nomefile1 nomefile2\n");
    return 0;
  }
  fin = fopen(argv[1], "r");
  fout = fopen(argv[2], "w");
  while ((ch = fgetc(fin)) != EOF) {
    if (ch == '.') {
      do {
        fputc(ch, fout);
        ch = fgetc(fin);
      } while (!isAlpha(ch) && ch != EOF);
      if (ch >= 'a' && ch <= 'z')
        ch += 'A' - 'a';
    }
    if (ch != EOF)
      fputc(ch, fout);
  }
  fclose(fin);
  fclose(fout);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     11a1 <main+0x41>
mov    0x2e51(%rip),%rax
mov    (%rax),%edi
lea    0xe70(%rip),%rsi
call   1060 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    129f <main+0x13f>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe72(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe5c(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <fgetc@plt>
mov    %eax,-0x24(%rbp)
mov    0x2e04(%rip),%rcx
cmp    (%rcx),%eax
je     128d <main+0x12d>
cmpl   $0x2e,-0x24(%rbp)
jne    126a <main+0x10a>
jmp    11fb <main+0x9b>
mov    -0x24(%rbp),%edi
mov    -0x20(%rbp),%rsi
call   1050 <fputc@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fgetc@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%edi
call   1070 <isAlpha@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x25(%rbp)
jne    123d <main+0xdd>
mov    -0x24(%rbp),%eax
mov    0x2db3(%rip),%rcx
cmp    (%rcx),%eax
setne  %al
mov    %al,-0x25(%rbp)
mov    -0x25(%rbp),%al
test   $0x1,%al
jne    11fb <main+0x9b>
cmpl   $0x61,-0x24(%rbp)
jl     1265 <main+0x105>
cmpl   $0x7a,-0x24(%rbp)
jg     1265 <main+0x105>
mov    -0x24(%rbp),%eax
add    $0xffffffe0,%eax
mov    %eax,-0x24(%rbp)
jmp    126a <main+0x10a>
mov    -0x24(%rbp),%eax
mov    0x2d74(%rip),%rcx
cmp    (%rcx),%eax
je     1288 <main+0x128>
mov    -0x24(%rbp),%edi
mov    -0x20(%rbp),%rsi
call   1050 <fputc@plt>
jmp    11d1 <main+0x71>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
cmp    $0x3,%edi
jne    1213 <main+0xb3>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
lea    0xea3(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%r14
mov    0x10(%rbx),%rdi
lea    0xe92(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%r15
mov    %r14,%rdi
call   1040 <fgetc@plt>
mov    0x2e3f(%rip),%r12
jmp    11b8 <main+0x58>
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1040 <fgetc@plt>
mov    (%r12),%ecx
cmp    %ecx,%eax
je     122a <main+0xca>
cmp    $0x2e,%eax
jne    1203 <main+0xa3>
mov    $0x2e,%ebx
nopw   0x0(%rax,%rax,1)
mov    %ebx,%edi
mov    %r15,%rsi
call   1050 <fputc@plt>
mov    %r14,%rdi
call   1040 <fgetc@plt>
mov    %eax,%ebx
mov    %eax,%edi
call   1070 <isAlpha@plt>
mov    (%r12),%ecx
test   %eax,%eax
jne    11f7 <main+0x97>
cmp    %ecx,%ebx
jne    11d0 <main+0x70>
lea    -0x61(%rbx),%edx
lea    -0x20(%rbx),%eax
cmp    $0x1a,%edx
cmovae %ebx,%eax
cmp    %ecx,%eax
je     11b0 <main+0x50>
mov    %eax,%edi
mov    %r15,%rsi
call   1050 <fputc@plt>
jmp    11b0 <main+0x50>
mov    0x2dbe(%rip),%rax
mov    (%rax),%edi
lea    0xddd(%rip),%rsi
call   1060 <fprintf@plt>
jmp    123a <main+0xda>
mov    %r14,%rdi
call   1030 <fclose@plt>
mov    %r15,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [34 x i8] c"uso: toupper nomefile1 nomefile2\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [2 x i8] c"w\00"
@EOF = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp ne i32 %9, 3
br i1 %10, label %11, label %14
11: ; preds = %2
%12 = load i32, i32* @stderr
%13 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %3
br label %72
14: ; preds = %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = call i32* @fopen(i8* %17, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %18, i32** %6
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 2
%21 = load i8*, i8** %20
%22 = call i32* @fopen(i8* %21, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %22, i32** %7
br label %23
23: ; preds = %66, %14
%24 = load i32*, i32** %6
%25 = call i32 @fgetc(i32* %24)
store i32 %25, i32* %8
%26 = load i32, i32* @EOF
%27 = icmp ne i32 %25, %26
br i1 %27, label %28, label %67
28: ; preds = %23
%29 = load i32, i32* %8
%30 = icmp eq i32 %29, 46
br i1 %30, label %31, label %58
31: ; preds = %28
br label %32
32: ; preds = %46, %31
%33 = load i32, i32* %8
%34 = load i32*, i32** %7
%35 = call i32 @fputc(i32 %33, i32* %34)
%36 = load i32*, i32** %6
%37 = call i32 @fgetc(i32* %36)
store i32 %37, i32* %8
br label %38
38: ; preds = %32
%39 = load i32, i32* %8
%40 = call i32 @isAlpha(i32 %39)
%41 = icmp ne i32 %40, 0
br i1 %41, label %46, label %42
42: ; preds = %38
%43 = load i32, i32* %8
%44 = load i32, i32* @EOF
%45 = icmp ne i32 %43, %44
br label %46
46: ; preds = %42, %38
%47 = phi i1 [ false, %38 ], [ %45, %42 ]
br i1 %47, label %32, label %48
48: ; preds = %46
%49 = load i32, i32* %8
%50 = icmp sge i32 %49, 97
br i1 %50, label %51, label %57
51: ; preds = %48
%52 = load i32, i32* %8
%53 = icmp sle i32 %52, 122
br i1 %53, label %54, label %57
54: ; preds = %51
%55 = load i32, i32* %8
%56 = add nsw i32 %55, -32
store i32 %56, i32* %8
br label %57
57: ; preds = %54, %51, %48
br label %58
58: ; preds = %57, %28
%59 = load i32, i32* %8
%60 = load i32, i32* @EOF
%61 = icmp ne i32 %59, %60
br i1 %61, label %62, label %66
62: ; preds = %58
%63 = load i32, i32* %8
%64 = load i32*, i32** %7
%65 = call i32 @fputc(i32 %63, i32* %64)
br label %66
66: ; preds = %62, %58
br label %23
67: ; preds = %23
%68 = load i32*, i32** %6
%69 = call i32 @fclose(i32* %68)
%70 = load i32*, i32** %7
%71 = call i32 @fclose(i32* %70)
br label %72
72: ; preds = %67, %11
%73 = load i32, i32* %3
ret i32 %73
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [34 x i8] c"uso: toupper nomefile1 nomefile2\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [2 x i8] c"w\00"
@EOF = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 3
br i1 %3, label %7, label %4
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
br label %48
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = tail call i32* @fopen(i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%11 = getelementptr inbounds i8*, i8** %1, i64 2
%12 = load i8*, i8** %11
%13 = tail call i32* @fopen(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%14 = tail call i32 @fgetc(i32* %10)
%15 = load i32, i32* @EOF
%16 = icmp eq i32 %14, %15
br i1 %16, label %45, label %17
17: ; preds = %7, %41
%18 = phi i32 [ %43, %41 ], [ %15, %7 ]
%19 = phi i32 [ %42, %41 ], [ %14, %7 ]
%20 = icmp eq i32 %19, 46
br i1 %20, label %21, label %35
21: ; preds = %17, %21
%22 = phi i32 [ %24, %21 ], [ 46, %17 ]
%23 = tail call i32 @fputc(i32 %22, i32* %13)
%24 = tail call i32 @fgetc(i32* %10)
%25 = tail call i32 @isAlpha(i32 %24)
%26 = icmp eq i32 %25, 0
%27 = load i32, i32* @EOF
%28 = icmp ne i32 %24, %27
%29 = select i1 %26, i1 %28, i1 false
br i1 %29, label %21, label %30
30: ; preds = %21
%31 = add i32 %24, -97
%32 = icmp ult i32 %31, 26
%33 = add nsw i32 %24, -32
%34 = select i1 %32, i32 %33, i32 %24
br label %35
35: ; preds = %30, %17
%36 = phi i32 [ %18, %17 ], [ %27, %30 ]
%37 = phi i32 [ %19, %17 ], [ %34, %30 ]
%38 = icmp eq i32 %37, %36
br i1 %38, label %41, label %39
39: ; preds = %35
%40 = tail call i32 @fputc(i32 %37, i32* %13)
br label %41
41: ; preds = %39, %35
%42 = tail call i32 @fgetc(i32* %10)
%43 = load i32, i32* @EOF
%44 = icmp eq i32 %42, %43
br i1 %44, label %45, label %17
45: ; preds = %41, %7
%46 = tail call i32 @fclose(i32* %10)
%47 = tail call i32 @fclose(i32* %13)
br label %48
48: ; preds = %45, %4
ret i32 0
}