#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*/ buf;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int errno;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int fread(char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fwrite(char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ isalpha(char);
int /*<<< orphan*/ stdout;
int wordonly(const char *srcfile, const char *dstfile) {
  FILE *fsrc = fopen(srcfile, "rb");
  FILE *fdst = fopen(dstfile, "wb");
  if (NULL == fsrc || NULL == fdst) {
    fprintf(stdout, "open i/o file failed!!\n");
    return errno;
  }
  char buf[1024] = {0};
  int rd = 0;
  while ((rd = fread(buf, 1, sizeof(buf), fsrc)) != 0) {
    const char *end = buf + rd;
    char *psz = buf;
    while (psz != end) {
      if (*psz > 32 && !isalpha(*psz)) {
        *psz = ' ';
      }
      ++psz;
    }
    fwrite(buf, 1, rd, fdst);
  }
  fclose(fsrc);
  fclose(fdst);
}


x86 assembly (clang, -O0):
<wordonly>:
push   %rbp
mov    %rsp,%rbp
sub    $0x450,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe72(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe61(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x28(%rbp)
xor    %eax,%eax
cmp    -0x20(%rbp),%rax
je     11c3 <wordonly+0x53>
xor    %eax,%eax
cmp    -0x28(%rbp),%rax
jne    11e9 <wordonly+0x79>
mov    0x2e0e(%rip),%rax
mov    (%rax),%edi
lea    0xe33(%rip),%rsi
call   1060 <fprintf@plt>
mov    0x2e01(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    12e7 <wordonly+0x177>
lea    -0x430(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1050 <memset@plt>
movl   $0x0,-0x434(%rbp)
lea    -0x430(%rbp),%rdi
mov    -0x20(%rbp),%rcx
mov    $0x1,%esi
mov    $0x400,%edx
call   1030 <fread@plt>
mov    %eax,-0x434(%rbp)
cmp    $0x0,%eax
je     12d5 <wordonly+0x165>
lea    -0x430(%rbp),%rax
movslq -0x434(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x440(%rbp)
lea    -0x430(%rbp),%rax
mov    %rax,-0x448(%rbp)
mov    -0x448(%rbp),%rax
cmp    -0x440(%rbp),%rax
je     12b5 <wordonly+0x145>
mov    -0x448(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
jle    129e <wordonly+0x12e>
mov    -0x448(%rbp),%rax
movsbl (%rax),%edi
call   1070 <isalpha@plt>
cmp    $0x0,%eax
jne    129e <wordonly+0x12e>
mov    -0x448(%rbp),%rax
movb   $0x20,(%rax)
mov    -0x448(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x448(%rbp)
jmp    1255 <wordonly+0xe5>
lea    -0x430(%rbp),%rdi
mov    -0x434(%rbp),%edx
mov    -0x28(%rbp),%rcx
mov    $0x1,%esi
call   1090 <fwrite@plt>
jmp    1206 <wordonly+0x96>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x28(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x4(%rbp),%eax
add    $0x450,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<wordonly>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x408,%rsp
mov    %rsi,%rbx
lea    0xe75(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%r15
lea    0xe69(%rip),%rsi
mov    %rbx,%rdi
call   1080 <fopen@plt>
test   %r15,%r15
je     1253 <wordonly+0xe3>
mov    %rax,%r14
test   %rax,%rax
je     1253 <wordonly+0xe3>
mov    %rsp,%rbx
mov    $0x400,%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1050 <memset@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x400,%edx
mov    %r15,%rcx
call   1030 <fread@plt>
test   %eax,%eax
je     1273 <wordonly+0x103>
mov    %eax,%r13d
mov    %rsp,%r12
jmp    121f <wordonly+0xaf>
xchg   %ax,%ax
mov    %r12,%rdi
mov    $0x1,%esi
mov    %r13d,%edx
mov    %r14,%rcx
call   1090 <fwrite@plt>
mov    %r12,%rdi
mov    $0x1,%esi
mov    $0x400,%edx
mov    %r15,%rcx
call   1030 <fread@plt>
mov    %eax,%r13d
test   %eax,%eax
je     1273 <wordonly+0x103>
movslq %r13d,%rbx
xor    %ebp,%ebp
jmp    1239 <wordonly+0xc9>
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%rbp
cmp    %rbp,%rbx
je     11f0 <wordonly+0x80>
movzbl (%rsp,%rbp,1),%eax
cmp    $0x21,%al
jl     1230 <wordonly+0xc0>
movsbl %al,%edi
call   1070 <isalpha@plt>
test   %eax,%eax
jne    1230 <wordonly+0xc0>
movb   $0x20,(%rsp,%rbp,1)
jmp    1230 <wordonly+0xc0>
mov    0x2d7e(%rip),%rax
mov    (%rax),%edi
lea    0xda3(%rip),%rsi
call   1060 <fprintf@plt>
mov    0x2d71(%rip),%rax
mov    (%rax),%eax
jmp    1283 <wordonly+0x113>
mov    %r15,%rdi
call   1040 <fclose@plt>
mov    %r14,%rdi
call   1040 <fclose@plt>
add    $0x408,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"rb\00"
@.str.1 = [3 x i8] c"wb\00"
@stdout = global i32 0
@.str.2 = [24 x i8] c"open i/o file failed!!\0A\00"
@errno = global i32 0
define i32 @wordonly(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca [1024 x i8]
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
%12 = load i8*, i8** %4
%13 = call i32* @fopen(i8* %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %13, i32** %6
%14 = load i8*, i8** %5
%15 = call i32* @fopen(i8* %14, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %15, i32** %7
%16 = load i32*, i32** %6
%17 = icmp eq i32* null, %16
br i1 %17, label %21, label %18
18: ; preds = %2
%19 = load i32*, i32** %7
%20 = icmp eq i32* null, %19
br i1 %20, label %21, label %25
21: ; preds = %18, %2
%22 = load i32, i32* @stdout
%23 = call i32 @fprintf(i32 %22, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%24 = load i32, i32* @errno
store i32 %24, i32* %3
br label %67
25: ; preds = %18
%26 = bitcast [1024 x i8]* %8 to i8*
store i32 0, i32* %9
br label %27
27: ; preds = %57, %25
%28 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%29 = load i32*, i32** %6
%30 = call i32 @fread(i8* %28, i32 1, i32 1024, i32* %29)
store i32 %30, i32* %9
%31 = icmp ne i32 %30, 0
br i1 %31, label %32, label %62
32: ; preds = %27
%33 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%34 = load i32, i32* %9
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i8, i8* %33, i64 %35
store i8* %36, i8** %10
%37 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
store i8* %37, i8** %11
br label %38
38: ; preds = %54, %32
%39 = load i8*, i8** %11
%40 = load i8*, i8** %10
%41 = icmp ne i8* %39, %40
br i1 %41, label %42, label %57
42: ; preds = %38
%43 = load i8*, i8** %11
%44 = load i8, i8* %43
%45 = sext i8 %44 to i32
%46 = icmp sgt i32 %45, 32
br i1 %46, label %47, label %54
47: ; preds = %42
%48 = load i8*, i8** %11
%49 = load i8, i8* %48
%50 = call i32 @isalpha(i8 signext %49)
%51 = icmp ne i32 %50, 0
br i1 %51, label %54, label %52
52: ; preds = %47
%53 = load i8*, i8** %11
store i8 32, i8* %53
br label %54
54: ; preds = %52, %47, %42
%55 = load i8*, i8** %11
%56 = getelementptr inbounds i8, i8* %55, i32 1
store i8* %56, i8** %11
br label %38
57: ; preds = %38
%58 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%59 = load i32, i32* %9
%60 = load i32*, i32** %7
%61 = call i32 @fwrite(i8* %58, i32 1, i32 %59, i32* %60)
br label %27
62: ; preds = %27
%63 = load i32*, i32** %6
%64 = call i32 @fclose(i32* %63)
%65 = load i32*, i32** %7
%66 = call i32 @fclose(i32* %65)
br label %67
67: ; preds = %62, %21
%68 = load i32, i32* %3
ret i32 %68
}

LLVM IR (-O2):
@.str = [3 x i8] c"rb\00"
@.str.1 = [3 x i8] c"wb\00"
@stdout = global i32 0
@.str.2 = [24 x i8] c"open i/o file failed!!\0A\00"
@errno = global i32 0
define i32 @wordonly(i8* nocapture %0, i8* nocapture %1) {
%3 = alloca [1024 x i8]
%4 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%5 = tail call i32* @fopen(i8* %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%6 = icmp eq i32* %4, null
%7 = icmp eq i32* %5, null
%8 = or i1 %6, %7
br i1 %8, label %9, label %13
9: ; preds = %2
%10 = load i32, i32* @stdout
%11 = tail call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%12 = load i32, i32* @errno
br label %39
13: ; preds = %2
%14 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%15 = call i32 @fread(i8* %14, i32 1, i32 1024, i32* %4)
%16 = icmp eq i32 %15, 0
br i1 %16, label %36, label %17
17: ; preds = %13, %32
%18 = phi i32 [ %34, %32 ], [ %15, %13 ]
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 %19
br label %21
21: ; preds = %17, %29
%22 = phi i8* [ %30, %29 ], [ %14, %17 ]
%23 = load i8, i8* %22
%24 = icmp sgt i8 %23, 32
br i1 %24, label %25, label %29
25: ; preds = %21
%26 = call i32 @isalpha(i8 signext %23)
%27 = icmp eq i32 %26, 0
br i1 %27, label %28, label %29
28: ; preds = %25
store i8 32, i8* %22
br label %29
29: ; preds = %28, %25, %21
%30 = getelementptr inbounds i8, i8* %22, i64 1
%31 = icmp eq i8* %30, %20
br i1 %31, label %32, label %21
32: ; preds = %29
%33 = call i32 @fwrite(i8* %14, i32 1, i32 %18, i32* %5)
%34 = call i32 @fread(i8* %14, i32 1, i32 1024, i32* %4)
%35 = icmp eq i32 %34, 0
br i1 %35, label %36, label %17
36: ; preds = %32, %13
%37 = call i32 @fclose(i32* %4)
%38 = call i32 @fclose(i32* %5)
br label %39
39: ; preds = %36, %9
%40 = phi i32 [ %12, %9 ], [ undef, %36 ]
ret i32 %40
}