#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*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fputc(int /*<<< orphan*/, int /*<<< orphan*/ *);
int fread(char *, int, int, int /*<<< orphan*/ *);
scalar_t__ isalpha(char);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ tolower(char);
int main(int argc, char **argv) {
  if (argc < 3) {
    printf("Not enough arguments!\n", "r");
    printf("Usage: %s [infile] [outfile]", argv[0]);
    exit(1);
  }
  FILE *fin = fopen(argv[1], "rb");
  FILE *fout = fopen(argv[2], "wb");
  char buffer[4096];
  int sz;
  register int i;
  while ((sz = fread(buffer, 1, 4096, fin)) != 0) {
    i = 0;
    for (; i < sz; i++) {
      if (isalpha(buffer[i])) {
        fputc(tolower(buffer[i]), fout);
      }
    }
  }
  fclose(fin);
  fclose(fout);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1030,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    11d3 <main+0x53>
lea    0xe56(%rip),%rdi
lea    0xe66(%rip),%rsi
call   1050 <printf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe55(%rip),%rdi
call   1050 <printf@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe54(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe3f(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x20(%rbp)
lea    -0x1020(%rbp),%rdi
mov    -0x18(%rbp),%rcx
mov    $0x1,%esi
mov    $0x1000,%edx
call   1030 <fread@plt>
mov    %eax,-0x1024(%rbp)
cmp    $0x0,%eax
je     12a3 <main+0x123>
movl   $0x0,-0x1028(%rbp)
mov    -0x1028(%rbp),%eax
cmp    -0x1024(%rbp),%eax
jge    129e <main+0x11e>
movslq -0x1028(%rbp),%rax
movsbl -0x1020(%rbp,%rax,1),%edi
ff
call   1080 <isalpha@plt>
cmp    $0x0,%rax
je     1285 <main+0x105>
movslq -0x1028(%rbp),%rax
movsbl -0x1020(%rbp,%rax,1),%edi
ff
call   1070 <tolower@plt>
mov    %eax,%edi
mov    -0x20(%rbp),%rsi
call   1060 <fputc@plt>
jmp    128a <main+0x10a>
mov    -0x1028(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1028(%rbp)
jmp    1236 <main+0xb6>
jmp    1203 <main+0x83>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x4(%rbp),%eax
add    $0x1030,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1008,%rsp
mov    %rsi,%rbx
cmp    $0x2,%edi
jle    1270 <main+0xf0>
mov    0x8(%rbx),%rdi
lea    0xe8e(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,%r14
mov    0x10(%rbx),%rdi
lea    0xe7e(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,%r12
mov    %rsp,%rdi
mov    $0x1,%esi
mov    $0x1000,%edx
mov    %r14,%rcx
call   1030 <fread@plt>
test   %eax,%eax
je     124c <main+0xcc>
mov    %rsp,%r15
jmp    1209 <main+0x89>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    $0x1,%esi
mov    $0x1000,%edx
mov    %r14,%rcx
call   1030 <fread@plt>
test   %eax,%eax
je     124c <main+0xcc>
test   %eax,%eax
jle    11f0 <main+0x70>
mov    %eax,%r13d
xor    %ebx,%ebx
jmp    1229 <main+0xa9>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%rbx
cmp    %rbx,%r13
je     11f0 <main+0x70>
movsbl (%rsp,%rbx,1),%ebp
mov    %ebp,%edi
call   1080 <isalpha@plt>
test   %rax,%rax
je     1220 <main+0xa0>
mov    %ebp,%edi
call   1070 <tolower@plt>
mov    %eax,%edi
mov    %r12,%rsi
call   1060 <fputc@plt>
jmp    1220 <main+0xa0>
mov    %r14,%rdi
call   1040 <fclose@plt>
mov    %r12,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x1008,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xd89(%rip),%rdi
lea    0xd99(%rip),%rsi
call   1050 <printf@plt>
mov    (%rbx),%rsi
lea    0xd8c(%rip),%rdi
call   1050 <printf@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@.str = [23 x i8] c"Not enough arguments!\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [29 x i8] c"Usage: %s [infile] [outfile]\00"
@.str.3 = [3 x i8] c"rb\00"
@.str.4 = [3 x i8] c"wb\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca [4096 x i8]
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i32, i32* %4
%12 = icmp slt i32 %11, 3
br i1 %12, label %13, label %20
13: ; preds = %2
%14 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 0
%17 = load i8*, i8** %16
%18 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i8* %17)
%19 = call i32 @exit(i32 1)
unreachable
20: ; preds = %2
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 1
%23 = load i8*, i8** %22
%24 = call i32* @fopen(i8* %23, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
store i32* %24, i32** %6
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 2
%27 = load i8*, i8** %26
%28 = call i32* @fopen(i8* %27, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
store i32* %28, i32** %7
br label %29
29: ; preds = %58, %20
%30 = getelementptr inbounds [4096 x i8], [4096 x i8]* %8, i64 0, i64 0
%31 = load i32*, i32** %6
%32 = call i32 @fread(i8* %30, i32 1, i32 4096, i32* %31)
store i32 %32, i32* %9
%33 = icmp ne i32 %32, 0
br i1 %33, label %34, label %59
34: ; preds = %29
store i32 0, i32* %10
br label %35
35: ; preds = %55, %34
%36 = load i32, i32* %10
%37 = load i32, i32* %9
%38 = icmp slt i32 %36, %37
br i1 %38, label %39, label %58
39: ; preds = %35
%40 = load i32, i32* %10
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds [4096 x i8], [4096 x i8]* %8, i64 0, i64 %41
%43 = load i8, i8* %42
%44 = call i64 @isalpha(i8 signext %43)
%45 = icmp ne i64 %44, 0
br i1 %45, label %46, label %54
46: ; preds = %39
%47 = load i32, i32* %10
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds [4096 x i8], [4096 x i8]* %8, i64 0, i64 %48
%50 = load i8, i8* %49
%51 = call i32 @tolower(i8 signext %50)
%52 = load i32*, i32** %7
%53 = call i32 @fputc(i32 %51, i32* %52)
br label %54
54: ; preds = %46, %39
br label %55
55: ; preds = %54
%56 = load i32, i32* %10
%57 = add nsw i32 %56, 1
store i32 %57, i32* %10
br label %35
58: ; preds = %35
br label %29
59: ; preds = %29
%60 = load i32*, i32** %6
%61 = call i32 @fclose(i32* %60)
%62 = load i32*, i32** %7
%63 = call i32 @fclose(i32* %62)
%64 = load i32, i32* %3
ret i32 %64
}

LLVM IR (-O2):
@.str = [23 x i8] c"Not enough arguments!\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [29 x i8] c"Usage: %s [infile] [outfile]\00"
@.str.3 = [3 x i8] c"rb\00"
@.str.4 = [3 x i8] c"wb\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [4096 x i8]
%4 = icmp slt i32 %0, 3
br i1 %4, label %5, label %10
5: ; preds = %2
%6 = tail call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%7 = load i8*, i8** %1
%8 = tail call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i8* %7)
%9 = tail call i32 @exit(i32 1)
unreachable
10: ; preds = %2
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = tail call i32* @fopen(i8* %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%14 = getelementptr inbounds i8*, i8** %1, i64 2
%15 = load i8*, i8** %14
%16 = tail call i32* @fopen(i8* %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%17 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 0
%18 = call i32 @fread(i8* %17, i32 1, i32 4096, i32* %13)
%19 = icmp eq i32 %18, 0
br i1 %19, label %40, label %23
20: ; preds = %37, %23
%21 = call i32 @fread(i8* %17, i32 1, i32 4096, i32* %13)
%22 = icmp eq i32 %21, 0
br i1 %22, label %40, label %23
23: ; preds = %10, %20
%24 = phi i32 [ %21, %20 ], [ %18, %10 ]
%25 = icmp sgt i32 %24, 0
br i1 %25, label %26, label %20
26: ; preds = %23
%27 = zext i32 %24 to i64
br label %28
28: ; preds = %26, %37
%29 = phi i64 [ 0, %26 ], [ %38, %37 ]
%30 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 %29
%31 = load i8, i8* %30
%32 = tail call i64 @isalpha(i8 signext %31)
%33 = icmp eq i64 %32, 0
br i1 %33, label %37, label %34
34: ; preds = %28
%35 = tail call i32 @tolower(i8 signext %31)
%36 = tail call i32 @fputc(i32 %35, i32* %16)
br label %37
37: ; preds = %28, %34
%38 = add nuw nsw i64 %29, 1
%39 = icmp eq i64 %38, %27
br i1 %39, label %20, label %28
40: ; preds = %20, %10
%41 = tail call i32 @fclose(i32* %13)
%42 = tail call i32 @fclose(i32* %16)
ret i32 0
}