#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 */
struct stat {
  int st_size;
  int /*<<< orphan*/ st_mode;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
scalar_t__ S_ISDIR(int /*<<< orphan*/);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char *, int, int, int);
int fread(char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ free(char *);
scalar_t__ malloc(int);
int /*<<< orphan*/ perror(char *);
int stat(char *, struct stat *);
scalar_t__ strcmp(char *, char *);
int strlen(char *);
int system(char *);
int unlink(char *);
int main(void) {
  FILE *in, *out;
  FILE *fp;
  struct stat statbuf;
  char file_name[128];
  char *buf;
  int n, len;
  char *p;
  int file_size = 0;
  int letter, number, blank;
  if (system("ls > temp") == -1) {
    perror("fail to exec command");
    exit(1);
  }
  fp = fopen("temp", "rb");
  if (fp == NULL) {
    perror("fail to open");
    exit(1);
  }
  out = fopen("res", "wb");
  if (out == NULL) {
    perror("fail to open");
    exit(1);
  }
  while (fgets(file_name, 128, fp) != NULL) {
    len = strlen(file_name);
    if (strcmp(&file_name[len - 4], "txt\n") != 0)
      continue;
    file_name[len - 1] = '\0';
    if (stat(file_name, &statbuf) == -1) {
      perror("fail to get stat");
      exit(1);
    }
    if (S_ISDIR(statbuf.st_mode))
      continue;
    if ((file_size = statbuf.st_size) > 1024)
      file_size = 1024;
    file_size++;
    buf = (char *)malloc(sizeof(char) * file_size);
    in = fopen(file_name, "rb");
    if (in == NULL) {
      perror("fail to open");
      exit(1);
    }
    letter = 0;
    number = 0;
    blank = 0;
    while ((n = fread(buf, sizeof(char), file_size - 1, in)) > 0) {
      buf[n] = '\0';
      p = buf;
      while (*p != '\0') {
        if (('a' <= *p && *p <= 'z') || ('A' <= *p && *p <= 'Z'))
          letter++;
        if (*p == ' ')
          blank++;
        if ('0' <= *p && *p <= '9')
          number++;
        p++;
      }
    }
    if (n == -1) {
      perror("fail to read");
      exit(1);
    }
    fprintf(out,
            "%s, he sum of letter is : %d\nthe sum of number is : %d\nthe sum "
            "of blank is : %d\n",
            file_name, letter, number, blank);
    fclose(in);
    free(buf);
  }
  fclose(fp);
  fclose(out);
  if (unlink("temp") == -1) {
    perror("fail to unlink");
    exit(1);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xe0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xcc(%rbp)
lea    0xded(%rip),%rdi
call   1080 <system@plt>
cmp    $0xffffffff,%eax
jne    1237 <main+0x47>
lea    0xde2(%rip),%rdi
call   1100 <perror@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
lea    0xdc7(%rip),%rdi
lea    0xdda(%rip),%rsi
call   10f0 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    126f <main+0x7f>
lea    0xdc2(%rip),%rdi
call   1100 <perror@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
lea    0xdb9(%rip),%rdi
lea    0xdb6(%rip),%rsi
call   10f0 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    12a7 <main+0xb7>
lea    0xd8a(%rip),%rdi
call   1100 <perror@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
jmp    12ac <main+0xbc>
lea    -0xb0(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    $0x80,%esi
call   10a0 <fgets@plt>
cmp    $0x0,%rax
je     15a4 <main+0x3b4>
lea    -0xb0(%rbp),%rdi
call   1070 <strlen@plt>
mov    %eax,-0xc0(%rbp)
mov    -0xc0(%rbp),%eax
sub    $0x4,%eax
cltq
lea    -0xb0(%rbp),%rdi
add    %rax,%rdi
lea    0xd3d(%rip),%rsi
call   10b0 <strcmp@plt>
cmp    $0x0,%rax
je     130d <main+0x11d>
jmp    12ac <main+0xbc>
mov    -0xc0(%rbp),%eax
sub    $0x1,%eax
cltq
movb   $0x0,-0xb0(%rbp,%rax,1)
lea    -0xb0(%rbp),%rdi
lea    -0x28(%rbp),%rsi
call   10d0 <stat@plt>
cmp    $0xffffffff,%eax
jne    134f <main+0x15f>
lea    0xcfb(%rip),%rdi
call   1100 <perror@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
mov    -0x24(%rbp),%edi
call   1090 <S_ISDIR@plt>
cmp    $0x0,%rax
je     1366 <main+0x176>
jmp    12ac <main+0xbc>
mov    -0x28(%rbp),%eax
mov    %eax,-0xcc(%rbp)
cmp    $0x400,%eax
jle    1384 <main+0x194>
movl   $0x400,-0xcc(%rbp)
mov    -0xcc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xcc(%rbp)
movslq -0xcc(%rbp),%rax
shl    $0x0,%rax
mov    %eax,%edi
call   10e0 <malloc@plt>
mov    %rax,-0xb8(%rbp)
lea    -0xb0(%rbp),%rdi
lea    0xc65(%rip),%rsi
call   10f0 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    13e4 <main+0x1f4>
lea    0xc4d(%rip),%rdi
call   1100 <perror@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
movl   $0x0,-0xd0(%rbp)
movl   $0x0,-0xd4(%rbp)
movl   $0x0,-0xd8(%rbp)
mov    -0xb8(%rbp),%rdi
mov    -0xcc(%rbp),%edx
sub    $0x1,%edx
mov    -0x10(%rbp),%rcx
mov    $0x1,%esi
call   1050 <fread@plt>
mov    %eax,-0xbc(%rbp)
cmp    $0x0,%eax
jle    153c <main+0x34c>
mov    -0xb8(%rbp),%rax
movslq -0xbc(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0xb8(%rbp),%rax
mov    %rax,-0xc8(%rbp)
mov    -0xc8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1537 <main+0x347>
mov    -0xc8(%rbp),%rax
movsbl (%rax),%ecx
mov    $0x61,%eax
cmp    %ecx,%eax
jg     148c <main+0x29c>
mov    -0xc8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x7a,%eax
jle    14b6 <main+0x2c6>
mov    -0xc8(%rbp),%rax
movsbl (%rax),%ecx
mov    $0x41,%eax
cmp    %ecx,%eax
jg     14c5 <main+0x2d5>
mov    -0xc8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5a,%eax
jg     14c5 <main+0x2d5>
mov    -0xd0(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xd0(%rbp)
mov    -0xc8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
jne    14e7 <main+0x2f7>
mov    -0xd8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xd8(%rbp)
mov    -0xc8(%rbp),%rax
movsbl (%rax),%ecx
mov    $0x30,%eax
cmp    %ecx,%eax
jg     1520 <main+0x330>
mov    -0xc8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x39,%eax
jg     1520 <main+0x330>
mov    -0xd4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xd4(%rbp)
mov    -0xc8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0xc8(%rbp)
jmp    144f <main+0x25f>
jmp    1402 <main+0x212>
cmpl   $0xffffffff,-0xbc(%rbp)
jne    155f <main+0x36f>
lea    0xafc(%rip),%rdi
call   1100 <perror@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
mov    -0x18(%rbp),%rdi
lea    -0xb0(%rbp),%rdx
mov    -0xd0(%rbp),%ecx
mov    -0xd4(%rbp),%r8d
mov    -0xd8(%rbp),%r9d
lea    0xad4(%rip),%rsi
call   10c0 <fprintf@plt>
mov    -0x10(%rbp),%rdi
call   1060 <fclose@plt>
mov    -0xb8(%rbp),%rdi
call   1030 <free@plt>
jmp    12ac <main+0xbc>
mov    -0x20(%rbp),%rdi
call   1060 <fclose@plt>
mov    -0x18(%rbp),%rdi
call   1060 <fclose@plt>
lea    0xa48(%rip),%rdi
call   1040 <unlink@plt>
cmp    $0xffffffff,%eax
jne    15e1 <main+0x3f1>
lea    0xad8(%rip),%rdi
call   1100 <perror@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
xor    %eax,%eax
add    $0xe0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xa8,%rsp
lea    0xdf8(%rip),%rdi
call   1080 <system@plt>
cmp    $0xffffffff,%eax
je     145f <main+0x26f>
lea    0xde8(%rip),%rdi
lea    0xdfb(%rip),%rsi
call   10f0 <fopen@plt>
test   %rax,%rax
je     144d <main+0x25d>
mov    %rax,%r15
lea    0xdf3(%rip),%rdi
lea    0xdf0(%rip),%rsi
call   10f0 <fopen@plt>
mov    %rax,0x8(%rsp)
test   %rax,%rax
je     144d <main+0x25d>
lea    0x20(%rsp),%r12
mov    %r12,%rdi
mov    $0x80,%esi
mov    %r15,%rdx
call   10a0 <fgets@plt>
test   %rax,%rax
je     140d <main+0x21d>
lea    0xdbb(%rip),%rbp
mov    %rsp,%r14
mov    %r15,0x10(%rsp)
jmp    12f9 <main+0x109>
xor    %r15d,%r15d
xor    %ebx,%ebx
xor    %r12d,%r12d
cmp    $0xffffffff,%eax
je     1456 <main+0x266>
mov    0x8(%rsp),%rdi
lea    0xdb7(%rip),%rsi
lea    0x20(%rsp),%rdx
mov    %r15d,%ecx
mov    %ebx,%r8d
mov    %r12d,%r9d
mov    %rdx,%r12
call   10c0 <fprintf@plt>
mov    %r13,%rdi
call   1060 <fclose@plt>
mov    %rbp,%rdi
call   1030 <free@plt>
mov    0x10(%rsp),%r15
lea    0xd62(%rip),%rbp
mov    %rsp,%r14
nopw   0x0(%rax,%rax,1)
mov    %r12,%rdi
mov    $0x80,%esi
mov    %r15,%rdx
call   10a0 <fgets@plt>
test   %rax,%rax
je     140d <main+0x21d>
mov    %r12,%rdi
call   1070 <strlen@plt>
movslq %eax,%rbx
lea    (%rbx,%r12,1),%rdi
add    $0xfffffffffffffffc,%rdi
mov    %rbp,%rsi
call   10b0 <strcmp@plt>
test   %rax,%rax
jne    12e0 <main+0xf0>
movb   $0x0,-0x1(%rbx,%r12,1)
mov    %r12,%rdi
mov    %r14,%rsi
call   10d0 <stat@plt>
cmp    $0xffffffff,%eax
je     1444 <main+0x254>
mov    0x4(%rsp),%edi
call   1090 <S_ISDIR@plt>
test   %rax,%rax
jne    12e0 <main+0xf0>
mov    (%rsp),%r14d
cmp    $0x400,%r14d
mov    $0x400,%eax
cmovge %eax,%r14d
lea    0x1(%r14),%edi
call   10e0 <malloc@plt>
mov    %rax,%rbp
mov    %r12,%rdi
lea    0xcb4(%rip),%rsi
call   10f0 <fopen@plt>
test   %rax,%rax
je     144d <main+0x25d>
mov    %rax,%r13
mov    %rbp,%rdi
mov    $0x1,%esi
mov    %r14d,%edx
mov    %rax,%rcx
call   1050 <fread@plt>
test   %eax,%eax
jle    1285 <main+0x95>
mov    %rbp,%rcx
add    $0x1,%rcx
mov    %rcx,0x18(%rsp)
xor    %r12d,%r12d
xor    %ebx,%ebx
xor    %r15d,%r15d
jmp    13cb <main+0x1db>
nopl   (%rax)
mov    %rbp,%rdi
mov    $0x1,%esi
mov    %r14d,%edx
mov    %r13,%rcx
call   1050 <fread@plt>
test   %eax,%eax
jle    128d <main+0x9d>
mov    %eax,%eax
movb   $0x0,0x0(%rbp,%rax,1)
mov    0x0(%rbp),%al
test   %al,%al
je     13b0 <main+0x1c0>
mov    0x18(%rsp),%rcx
xchg   %ax,%ax
mov    %eax,%edx
and    $0xdf,%dl
add    $0xbf,%dl
cmp    $0x1a,%dl
adc    $0x0,%r15d
xor    %edx,%edx
cmp    $0x20,%al
sete   %dl
add    %edx,%r12d
add    $0xd0,%al
cmp    $0xa,%al
adc    $0x0,%ebx
movzbl (%rcx),%eax
add    $0x1,%rcx
test   %al,%al
jne    13e0 <main+0x1f0>
jmp    13b0 <main+0x1c0>
mov    %r15,%rdi
call   1060 <fclose@plt>
mov    0x8(%rsp),%rdi
call   1060 <fclose@plt>
lea    0xbdf(%rip),%rdi
call   1040 <unlink@plt>
cmp    $0xffffffff,%eax
je     1468 <main+0x278>
xor    %eax,%eax
add    $0xa8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xbf0(%rip),%rdi
jmp    146f <main+0x27f>
lea    0xbce(%rip),%rdi
jmp    146f <main+0x27f>
lea    0xbef(%rip),%rdi
jmp    146f <main+0x27f>
lea    0xba4(%rip),%rdi
jmp    146f <main+0x27f>
lea    0xc3b(%rip),%rdi
call   1100 <perror@plt>
mov    $0x1,%edi
call   1110 <exit@plt>

LLVM IR (-O0):
%struct.stat = type { i32, i32 }
@.str = [10 x i8] c"ls > temp\00"
@.str.1 = [21 x i8] c"fail to exec command\00"
@.str.2 = [5 x i8] c"temp\00"
@.str.3 = [3 x i8] c"rb\00"
@.str.4 = [13 x i8] c"fail to open\00"
@.str.5 = [4 x i8] c"res\00"
@.str.6 = [3 x i8] c"wb\00"
@.str.7 = [5 x i8] c"txt\0A\00"
@.str.8 = [17 x i8] c"fail to get stat\00"
@.str.9 = [13 x i8] c"fail to read\00"
@.str.10 = [81 x i8] c"%s, he sum of letter is : %d\0Athe sum of number is : %d\0Athe sum of blank is : %d\0A\00"
@.str.11 = [15 x i8] c"fail to unlink\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca %struct.stat
%6 = alloca [128 x i8]
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %11
%15 = call i32 @system(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%16 = icmp eq i32 %15, -1
br i1 %16, label %17, label %20
17: ; preds = %0
%18 = call i32 @perror(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
%19 = call i32 @exit(i32 1)
unreachable
20: ; preds = %0
%21 = call i32* @fopen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
store i32* %21, i32** %4
%22 = load i32*, i32** %4
%23 = icmp eq i32* %22, null
br i1 %23, label %24, label %27
24: ; preds = %20
%25 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
%26 = call i32 @exit(i32 1)
unreachable
27: ; preds = %20
%28 = call i32* @fopen(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
store i32* %28, i32** %3
%29 = load i32*, i32** %3
%30 = icmp eq i32* %29, null
br i1 %30, label %31, label %34
31: ; preds = %27
%32 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
%33 = call i32 @exit(i32 1)
unreachable
34: ; preds = %27
br label %35
35: ; preds = %161, %66, %49, %34
%36 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%37 = load i32*, i32** %4
%38 = call i32* @fgets(i8* %36, i32 128, i32* %37)
%39 = icmp ne i32* %38, null
br i1 %39, label %40, label %172
40: ; preds = %35
%41 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%42 = call i32 @strlen(i8* %41)
store i32 %42, i32* %9
%43 = load i32, i32* %9
%44 = sub nsw i32 %43, 4
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 %45
%47 = call i64 @strcmp(i8* %46, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
%48 = icmp ne i64 %47, 0
br i1 %48, label %49, label %50
49: ; preds = %40
br label %35
50: ; preds = %40
%51 = load i32, i32* %9
%52 = sub nsw i32 %51, 1
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 %53
store i8 0, i8* %54
%55 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%56 = call i32 @stat(i8* %55, %struct.stat* %5)
%57 = icmp eq i32 %56, -1
br i1 %57, label %58, label %61
58: ; preds = %50
%59 = call i32 @perror(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.8, i64 0, i64 0))
%60 = call i32 @exit(i32 1)
unreachable
61: ; preds = %50
%62 = getelementptr inbounds %struct.stat, %struct.stat* %5, i32 0, i32 1
%63 = load i32, i32* %62
%64 = call i64 @S_ISDIR(i32 %63)
%65 = icmp ne i64 %64, 0
br i1 %65, label %66, label %67
66: ; preds = %61
br label %35
67: ; preds = %61
%68 = getelementptr inbounds %struct.stat, %struct.stat* %5, i32 0, i32 0
%69 = load i32, i32* %68
store i32 %69, i32* %11
%70 = icmp sgt i32 %69, 1024
br i1 %70, label %71, label %72
71: ; preds = %67
store i32 1024, i32* %11
br label %72
72: ; preds = %71, %67
%73 = load i32, i32* %11
%74 = add nsw i32 %73, 1
store i32 %74, i32* %11
%75 = load i32, i32* %11
%76 = sext i32 %75 to i64
%77 = mul i64 1, %76
%78 = trunc i64 %77 to i32
%79 = call i64 @malloc(i32 %78)
%80 = inttoptr i64 %79 to i8*
store i8* %80, i8** %7
%81 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%82 = call i32* @fopen(i8* %81, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
store i32* %82, i32** %2
%83 = load i32*, i32** %2
%84 = icmp eq i32* %83, null
br i1 %84, label %85, label %88
85: ; preds = %72
%86 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
%87 = call i32 @exit(i32 1)
unreachable
88: ; preds = %72
store i32 0, i32* %12
store i32 0, i32* %13
store i32 0, i32* %14
br label %89
89: ; preds = %154, %88
%90 = load i8*, i8** %7
%91 = load i32, i32* %11
%92 = sub nsw i32 %91, 1
%93 = load i32*, i32** %2
%94 = call i32 @fread(i8* %90, i32 1, i32 %92, i32* %93)
store i32 %94, i32* %8
%95 = icmp sgt i32 %94, 0
br i1 %95, label %96, label %155
96: ; preds = %89
%97 = load i8*, i8** %7
%98 = load i32, i32* %8
%99 = sext i32 %98 to i64
%100 = getelementptr inbounds i8, i8* %97, i64 %99
store i8 0, i8* %100
%101 = load i8*, i8** %7
store i8* %101, i8** %10
br label %102
102: ; preds = %151, %96
%103 = load i8*, i8** %10
%104 = load i8, i8* %103
%105 = sext i8 %104 to i32
%106 = icmp ne i32 %105, 0
br i1 %106, label %107, label %154
107: ; preds = %102
%108 = load i8*, i8** %10
%109 = load i8, i8* %108
%110 = sext i8 %109 to i32
%111 = icmp sle i32 97, %110
br i1 %111, label %112, label %117
112: ; preds = %107
%113 = load i8*, i8** %10
%114 = load i8, i8* %113
%115 = sext i8 %114 to i32
%116 = icmp sle i32 %115, 122
br i1 %116, label %127, label %117
117: ; preds = %112, %107
%118 = load i8*, i8** %10
%119 = load i8, i8* %118
%120 = sext i8 %119 to i32
%121 = icmp sle i32 65, %120
br i1 %121, label %122, label %130
122: ; preds = %117
%123 = load i8*, i8** %10
%124 = load i8, i8* %123
%125 = sext i8 %124 to i32
%126 = icmp sle i32 %125, 90
br i1 %126, label %127, label %130
127: ; preds = %122, %112
%128 = load i32, i32* %12
%129 = add nsw i32 %128, 1
store i32 %129, i32* %12
br label %130
130: ; preds = %127, %122, %117
%131 = load i8*, i8** %10
%132 = load i8, i8* %131
%133 = sext i8 %132 to i32
%134 = icmp eq i32 %133, 32
br i1 %134, label %135, label %138
135: ; preds = %130
%136 = load i32, i32* %14
%137 = add nsw i32 %136, 1
store i32 %137, i32* %14
br label %138
138: ; preds = %135, %130
%139 = load i8*, i8** %10
%140 = load i8, i8* %139
%141 = sext i8 %140 to i32
%142 = icmp sle i32 48, %141
br i1 %142, label %143, label %151
143: ; preds = %138
%144 = load i8*, i8** %10
%145 = load i8, i8* %144
%146 = sext i8 %145 to i32
%147 = icmp sle i32 %146, 57
br i1 %147, label %148, label %151
148: ; preds = %143
%149 = load i32, i32* %13
%150 = add nsw i32 %149, 1
store i32 %150, i32* %13
br label %151
151: ; preds = %148, %143, %138
%152 = load i8*, i8** %10
%153 = getelementptr inbounds i8, i8* %152, i32 1
store i8* %153, i8** %10
br label %102
154: ; preds = %102
br label %89
155: ; preds = %89
%156 = load i32, i32* %8
%157 = icmp eq i32 %156, -1
br i1 %157, label %158, label %161
158: ; preds = %155
%159 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.9, i64 0, i64 0))
%160 = call i32 @exit(i32 1)
unreachable
161: ; preds = %155
%162 = load i32*, i32** %3
%163 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%164 = load i32, i32* %12
%165 = load i32, i32* %13
%166 = load i32, i32* %14
%167 = call i32 @fprintf(i32* %162, i8* getelementptr inbounds ([81 x i8], [81 x i8]* @.str.10, i64 0, i64 0), i8* %163, i32 %164, i32 %165, i32 %166)
%168 = load i32*, i32** %2
%169 = call i32 @fclose(i32* %168)
%170 = load i8*, i8** %7
%171 = call i32 @free(i8* %170)
br label %35
172: ; preds = %35
%173 = load i32*, i32** %4
%174 = call i32 @fclose(i32* %173)
%175 = load i32*, i32** %3
%176 = call i32 @fclose(i32* %175)
%177 = call i32 @unlink(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%178 = icmp eq i32 %177, -1
br i1 %178, label %179, label %182
179: ; preds = %172
%180 = call i32 @perror(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.11, i64 0, i64 0))
%181 = call i32 @exit(i32 1)
unreachable
182: ; preds = %172
ret i32 0
}

LLVM IR (-O2):
%struct.stat = type { i32, i32 }
@.str = [10 x i8] c"ls > temp\00"
@.str.1 = [21 x i8] c"fail to exec command\00"
@.str.2 = [5 x i8] c"temp\00"
@.str.3 = [3 x i8] c"rb\00"
@.str.4 = [13 x i8] c"fail to open\00"
@.str.5 = [4 x i8] c"res\00"
@.str.6 = [3 x i8] c"wb\00"
@.str.7 = [5 x i8] c"txt\0A\00"
@.str.8 = [17 x i8] c"fail to get stat\00"
@.str.9 = [13 x i8] c"fail to read\00"
@.str.10 = [81 x i8] c"%s, he sum of letter is : %d\0Athe sum of number is : %d\0Athe sum of blank is : %d\0A\00"
@.str.11 = [15 x i8] c"fail to unlink\00"
define i32 @main() {
%1 = alloca %struct.stat
%2 = alloca [128 x i8]
%3 = bitcast %struct.stat* %1 to i8*
%4 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%5 = tail call i32 @system(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i32 %5, -1
br i1 %6, label %7, label %10
7: ; preds = %0
%8 = tail call i32 @perror(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
%9 = tail call i32 @exit(i32 1)
unreachable
10: ; preds = %0
%11 = tail call i32* @fopen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %16
13: ; preds = %10
%14 = tail call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
%15 = tail call i32 @exit(i32 1)
unreachable
16: ; preds = %10
%17 = tail call i32* @fopen(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%18 = icmp eq i32* %17, null
br i1 %18, label %25, label %19
19: ; preds = %16
%20 = call i32* @fgets(i8* %4, i32 128, i32* %11)
%21 = icmp eq i32* %20, null
br i1 %21, label %115, label %22
22: ; preds = %19
%23 = getelementptr inbounds %struct.stat, %struct.stat* %1, i64 0, i32 1
%24 = getelementptr inbounds %struct.stat, %struct.stat* %1, i64 0, i32 0
br label %28
25: ; preds = %16
%26 = tail call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
%27 = tail call i32 @exit(i32 1)
unreachable
28: ; preds = %22, %112
%29 = call i32 @strlen(i8* %4)
%30 = add nsw i32 %29, -4
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 %31
%33 = call i64 @strcmp(i8* %32, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
%34 = icmp eq i64 %33, 0
br i1 %34, label %35, label %112
35: ; preds = %28
%36 = add nsw i32 %29, -1
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 %37
store i8 0, i8* %38
%39 = call i32 @stat(i8* %4, %struct.stat* %1)
%40 = icmp eq i32 %39, -1
br i1 %40, label %41, label %44
41: ; preds = %35
%42 = call i32 @perror(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.8, i64 0, i64 0))
%43 = call i32 @exit(i32 1)
unreachable
44: ; preds = %35
%45 = load i32, i32* %23
%46 = call i64 @S_ISDIR(i32 %45)
%47 = icmp eq i64 %46, 0
br i1 %47, label %48, label %112
48: ; preds = %44
%49 = load i32, i32* %24
%50 = icmp slt i32 %49, 1024
%51 = select i1 %50, i32 %49, i32 1024
%52 = add nsw i32 %51, 1
%53 = call i64 @malloc(i32 %52)
%54 = inttoptr i64 %53 to i8*
%55 = call i32* @fopen(i8* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%56 = icmp eq i32* %55, null
br i1 %56, label %60, label %57
57: ; preds = %48
%58 = call i32 @fread(i8* %54, i32 1, i32 %51, i32* %55)
%59 = icmp sgt i32 %58, 0
br i1 %59, label %69, label %99
60: ; preds = %48
%61 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
%62 = call i32 @exit(i32 1)
unreachable
63: ; preds = %78, %69
%64 = phi i32 [ %73, %69 ], [ %88, %78 ]
%65 = phi i32 [ %72, %69 ], [ %95, %78 ]
%66 = phi i32 [ %71, %69 ], [ %91, %78 ]
%67 = call i32 @fread(i8* %54, i32 1, i32 %51, i32* %55)
%68 = icmp sgt i32 %67, 0
br i1 %68, label %69, label %99
69: ; preds = %57, %63
%70 = phi i32 [ %67, %63 ], [ %58, %57 ]
%71 = phi i32 [ %66, %63 ], [ 0, %57 ]
%72 = phi i32 [ %65, %63 ], [ 0, %57 ]
%73 = phi i32 [ %64, %63 ], [ 0, %57 ]
%74 = zext i32 %70 to i64
%75 = getelementptr inbounds i8, i8* %54, i64 %74
store i8 0, i8* %75
%76 = load i8, i8* %54
%77 = icmp eq i8 %76, 0
br i1 %77, label %63, label %78
78: ; preds = %69, %78
%79 = phi i8 [ %97, %78 ], [ %76, %69 ]
%80 = phi i32 [ %91, %78 ], [ %71, %69 ]
%81 = phi i32 [ %95, %78 ], [ %72, %69 ]
%82 = phi i32 [ %88, %78 ], [ %73, %69 ]
%83 = phi i8* [ %96, %78 ], [ %54, %69 ]
%84 = and i8 %79, -33
%85 = add i8 %84, -65
%86 = icmp ult i8 %85, 26
%87 = zext i1 %86 to i32
%88 = add nsw i32 %82, %87
%89 = icmp eq i8 %79, 32
%90 = zext i1 %89 to i32
%91 = add nsw i32 %80, %90
%92 = add i8 %79, -48
%93 = icmp ult i8 %92, 10
%94 = zext i1 %93 to i32
%95 = add nsw i32 %81, %94
%96 = getelementptr inbounds i8, i8* %83, i64 1
%97 = load i8, i8* %96
%98 = icmp eq i8 %97, 0
br i1 %98, label %63, label %78
99: ; preds = %63, %57
%100 = phi i32 [ 0, %57 ], [ %64, %63 ]
%101 = phi i32 [ 0, %57 ], [ %65, %63 ]
%102 = phi i32 [ 0, %57 ], [ %66, %63 ]
%103 = phi i32 [ %58, %57 ], [ %67, %63 ]
%104 = icmp eq i32 %103, -1
br i1 %104, label %105, label %108
105: ; preds = %99
%106 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.9, i64 0, i64 0))
%107 = call i32 @exit(i32 1)
unreachable
108: ; preds = %99
%109 = call i32 @fprintf(i32* %17, i8* getelementptr inbounds ([81 x i8], [81 x i8]* @.str.10, i64 0, i64 0), i8* %4, i32 %100, i32 %101, i32 %102)
%110 = call i32 @fclose(i32* %55)
%111 = call i32 @free(i8* %54)
br label %112
112: ; preds = %108, %28, %44
%113 = call i32* @fgets(i8* %4, i32 128, i32* %11)
%114 = icmp eq i32* %113, null
br i1 %114, label %115, label %28
115: ; preds = %112, %19
%116 = call i32 @fclose(i32* %11)
%117 = call i32 @fclose(i32* %17)
%118 = call i32 @unlink(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%119 = icmp eq i32 %118, -1
br i1 %119, label %120, label %123
120: ; preds = %115
%121 = call i32 @perror(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.11, i64 0, i64 0))
%122 = call i32 @exit(i32 1)
unreachable
123: ; preds = %115
ret i32 0
}