#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 size_t uint32_t;
struct stat {
  size_t st_size;
};

/* Variables and functions */
char const *MAP_FAILED;
int /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ PROT_READ;
int /*<<< orphan*/ check(int, char *, char const *, int /*<<< orphan*/);
int /*<<< orphan*/ errno;
int fstat(int, struct stat *);
int /*<<< orphan*/ isalpha(char);
int /*<<< orphan*/ isspace(char);
char *mmap(int /*<<< orphan*/, size_t, int /*<<< orphan*/, int /*<<< orphan*/,
           int, int /*<<< orphan*/);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ putchar(char);
int /*<<< orphan*/ strerror(int /*<<< orphan*/);
int main() {
  int fd;
  struct stat s;
  int status;
  size_t size;
  const char *file_name = "me.c";
  const char *mapped;
  uint32_t i;
  fd = open("me.c", O_RDONLY);
  check(fd < 0, "open %s failed: %s", file_name, strerror(errno));
  status = fstat(fd, &s);
  check(status < 0, "stat %s failed: %s", file_name, strerror(errno));
  size = s.st_size;
  mapped = mmap(0, size, PROT_READ, 0, fd, 0);
  check(mapped == MAP_FAILED, "mmap %s failed: %s", file_name, strerror(errno));
  for (i = 0; i < size; i++) {
    char c;
    c = mapped[i];
    if (!isalpha(c) && !isspace(c)) {
      putchar(c);
    }
    if (i % 80 == 79) {
      putchar('\n');
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe6a(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0x2e3f(%rip),%rax
mov    (%rax),%esi
lea    0xe56(%rip),%rdi
call   1070 <open@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
setl   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x6c(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x68(%rbp)
mov    0x2e00(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
mov    -0x6c(%rbp),%edi
mov    -0x68(%rbp),%rdx
mov    %eax,%ecx
lea    0xe1e(%rip),%rsi
call   1080 <check@plt>
mov    -0x8(%rbp),%edi
lea    -0x10(%rbp),%rsi
call   10a0 <fstat@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
setl   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x5c(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    0x2db7(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
mov    -0x5c(%rbp),%edi
mov    -0x58(%rbp),%rdx
mov    %eax,%ecx
lea    0xde8(%rip),%rsi
call   1080 <check@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rsi
mov    0x2db0(%rip),%rax
mov    (%rax),%edx
mov    -0x8(%rbp),%r8d
xor    %r9d,%r9d
mov    %r9d,%edi
mov    %r9d,%ecx
call   1040 <mmap@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    0x2d5d(%rip),%rcx
cmp    (%rcx),%rax
sete   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4c(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    0x2d48(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
mov    -0x4c(%rbp),%edi
mov    -0x48(%rbp),%rdx
mov    %eax,%ecx
lea    0xd8c(%rip),%rsi
call   1080 <check@plt>
movq   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%rax
cmp    -0x20(%rbp),%rax
jae    132d <main+0x1ad>
mov    -0x30(%rbp),%rax
mov    -0x38(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x39(%rbp)
movsbl -0x39(%rbp),%edi
call   1060 <isalpha@plt>
cmp    $0x0,%eax
jne    12f5 <main+0x175>
movsbl -0x39(%rbp),%edi
call   1050 <isspace@plt>
cmp    $0x0,%eax
jne    12f5 <main+0x175>
movsbl -0x39(%rbp),%edi
call   1030 <putchar@plt>
mov    -0x38(%rbp),%rax
mov    $0x50,%ecx
xor    %edx,%edx
div    %rcx
cmp    $0x4f,%rdx
jne    1317 <main+0x197>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    131c <main+0x19c>
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
jmp    12ac <main+0x12c>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    0x2e4e(%rip),%rax
mov    (%rax),%esi
lea    0xe65(%rip),%r15
mov    %r15,%rdi
call   1070 <open@plt>
mov    %eax,%ebx
mov    %eax,%ebp
shr    $0x1f,%ebp
mov    0x2e1f(%rip),%r13
mov    0x0(%r13),%edi
call   1090 <strerror@plt>
lea    0xe44(%rip),%rsi
mov    %ebp,%edi
mov    %r15,%rdx
mov    %eax,%ecx
call   1080 <check@plt>
mov    %rsp,%rsi
mov    %ebx,%edi
call   10a0 <fstat@plt>
mov    %eax,%ebp
shr    $0x1f,%ebp
mov    0x0(%r13),%edi
call   1090 <strerror@plt>
lea    0xe2c(%rip),%rsi
mov    %ebp,%edi
mov    %r15,%rdx
mov    %eax,%ecx
call   1080 <check@plt>
mov    (%rsp),%r14
mov    0x2df5(%rip),%rax
mov    (%rax),%edx
xor    %edi,%edi
mov    %r14,%rsi
xor    %ecx,%ecx
mov    %ebx,%r8d
xor    %r9d,%r9d
call   1040 <mmap@plt>
mov    %rax,%r12
mov    0x2da7(%rip),%rax
xor    %ebx,%ebx
cmp    (%rax),%r12
sete   %bl
mov    0x0(%r13),%edi
call   1090 <strerror@plt>
lea    0xdf2(%rip),%rsi
mov    %ebx,%edi
mov    %r15,%rdx
mov    %eax,%ecx
call   1080 <check@plt>
test   %r14,%r14
je     12bc <main+0x13c>
xor    %ebx,%ebx
movabs $0xcccccccccccccccd,%r15
cc cc cc
jmp    1269 <main+0xe9>
nopl   0x0(%rax,%rax,1)
add    $0x1,%rbx
cmp    %rbx,%r14
je     12bc <main+0x13c>
mov    %rbx,%rax
mul    %r15
shr    $0x6,%rdx
lea    (%rdx,%rdx,4),%rbp
shl    $0x4,%rbp
add    $0x4f,%rbp
movsbl (%r12,%rbx,1),%r13d
mov    %r13d,%edi
call   1060 <isalpha@plt>
test   %eax,%eax
jne    129c <main+0x11c>
mov    %r13d,%edi
call   1050 <isspace@plt>
test   %eax,%eax
je     12ad <main+0x12d>
cmp    %rbx,%rbp
jne    1260 <main+0xe0>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    1260 <main+0xe0>
mov    %r13d,%edi
call   1030 <putchar@plt>
cmp    %rbx,%rbp
jne    1260 <main+0xe0>
jmp    12a1 <main+0x121>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.stat = type { i64 }
@.str = [5 x i8] c"me.c\00"
@O_RDONLY = global i32 0
@.str.1 = [19 x i8] c"open %s failed: %s\00"
@errno = global i32 0
@.str.2 = [19 x i8] c"stat %s failed: %s\00"
@PROT_READ = global i32 0
@MAP_FAILED = global i8* null
@.str.3 = [19 x i8] c"mmap %s failed: %s\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca %struct.stat
%4 = alloca i32
%5 = alloca i64
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i8
store i32 0, i32* %1
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8** %6
%10 = load i32, i32* @O_RDONLY
%11 = call i32 @open(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %10)
store i32 %11, i32* %2
%12 = load i32, i32* %2
%13 = icmp slt i32 %12, 0
%14 = zext i1 %13 to i32
%15 = load i8*, i8** %6
%16 = load i32, i32* @errno
%17 = call i32 @strerror(i32 %16)
%18 = call i32 @check(i32 %14, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8* %15, i32 %17)
%19 = load i32, i32* %2
%20 = call i32 @fstat(i32 %19, %struct.stat* %3)
store i32 %20, i32* %4
%21 = load i32, i32* %4
%22 = icmp slt i32 %21, 0
%23 = zext i1 %22 to i32
%24 = load i8*, i8** %6
%25 = load i32, i32* @errno
%26 = call i32 @strerror(i32 %25)
%27 = call i32 @check(i32 %23, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i8* %24, i32 %26)
%28 = getelementptr inbounds %struct.stat, %struct.stat* %3, i32 0, i32 0
%29 = load i64, i64* %28
store i64 %29, i64* %5
%30 = load i64, i64* %5
%31 = load i32, i32* @PROT_READ
%32 = load i32, i32* %2
%33 = call i8* @mmap(i32 0, i64 %30, i32 %31, i32 0, i32 %32, i32 0)
store i8* %33, i8** %7
%34 = load i8*, i8** %7
%35 = load i8*, i8** @MAP_FAILED
%36 = icmp eq i8* %34, %35
%37 = zext i1 %36 to i32
%38 = load i8*, i8** %6
%39 = load i32, i32* @errno
%40 = call i32 @strerror(i32 %39)
%41 = call i32 @check(i32 %37, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i8* %38, i32 %40)
store i64 0, i64* %8
br label %42
42: ; preds = %68, %0
%43 = load i64, i64* %8
%44 = load i64, i64* %5
%45 = icmp ult i64 %43, %44
br i1 %45, label %46, label %71
46: ; preds = %42
%47 = load i8*, i8** %7
%48 = load i64, i64* %8
%49 = getelementptr inbounds i8, i8* %47, i64 %48
%50 = load i8, i8* %49
store i8 %50, i8* %9
%51 = load i8, i8* %9
%52 = call i32 @isalpha(i8 signext %51)
%53 = icmp ne i32 %52, 0
br i1 %53, label %61, label %54
54: ; preds = %46
%55 = load i8, i8* %9
%56 = call i32 @isspace(i8 signext %55)
%57 = icmp ne i32 %56, 0
br i1 %57, label %61, label %58
58: ; preds = %54
%59 = load i8, i8* %9
%60 = call i32 @putchar(i8 signext %59)
br label %61
61: ; preds = %58, %54, %46
%62 = load i64, i64* %8
%63 = urem i64 %62, 80
%64 = icmp eq i64 %63, 79
br i1 %64, label %65, label %67
65: ; preds = %61
%66 = call i32 @putchar(i8 signext 10)
br label %67
67: ; preds = %65, %61
br label %68
68: ; preds = %67
%69 = load i64, i64* %8
%70 = add i64 %69, 1
store i64 %70, i64* %8
br label %42
71: ; preds = %42
ret i32 0
}

LLVM IR (-O2):
%struct.stat = type { i64 }
@.str = [5 x i8] c"me.c\00"
@O_RDONLY = global i32 0
@.str.1 = [19 x i8] c"open %s failed: %s\00"
@errno = global i32 0
@.str.2 = [19 x i8] c"stat %s failed: %s\00"
@PROT_READ = global i32 0
@MAP_FAILED = global i8* null
@.str.3 = [19 x i8] c"mmap %s failed: %s\00"
define i32 @main() {
%1 = alloca %struct.stat
%2 = bitcast %struct.stat* %1 to i8*
%3 = load i32, i32* @O_RDONLY
%4 = tail call i32 @open(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %3)
%5 = lshr i32 %4, 31
%6 = load i32, i32* @errno
%7 = tail call i32 @strerror(i32 %6)
%8 = tail call i32 @check(i32 %5, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = call i32 @fstat(i32 %4, %struct.stat* %1)
%10 = lshr i32 %9, 31
%11 = load i32, i32* @errno
%12 = tail call i32 @strerror(i32 %11)
%13 = tail call i32 @check(i32 %10, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %12)
%14 = getelementptr inbounds %struct.stat, %struct.stat* %1, i64 0, i32 0
%15 = load i64, i64* %14
%16 = load i32, i32* @PROT_READ
%17 = tail call i8* @mmap(i32 0, i64 %15, i32 %16, i32 0, i32 %4, i32 0)
%18 = load i8*, i8** @MAP_FAILED
%19 = icmp eq i8* %17, %18
%20 = zext i1 %19 to i32
%21 = load i32, i32* @errno
%22 = tail call i32 @strerror(i32 %21)
%23 = tail call i32 @check(i32 %20, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %22)
%24 = icmp eq i64 %15, 0
br i1 %24, label %44, label %25
25: ; preds = %0, %41
%26 = phi i64 [ %42, %41 ], [ 0, %0 ]
%27 = getelementptr inbounds i8, i8* %17, i64 %26
%28 = load i8, i8* %27
%29 = tail call i32 @isalpha(i8 signext %28)
%30 = icmp eq i32 %29, 0
br i1 %30, label %31, label %36
31: ; preds = %25
%32 = tail call i32 @isspace(i8 signext %28)
%33 = icmp eq i32 %32, 0
br i1 %33, label %34, label %36
34: ; preds = %31
%35 = tail call i32 @putchar(i8 signext %28)
br label %36
36: ; preds = %34, %31, %25
%37 = urem i64 %26, 80
%38 = icmp eq i64 %37, 79
br i1 %38, label %39, label %41
39: ; preds = %36
%40 = tail call i32 @putchar(i8 signext 10)
br label %41
41: ; preds = %39, %36
%42 = add nuw i64 %26, 1
%43 = icmp eq i64 %42, %15
br i1 %43, label %44, label %25
44: ; preds = %41, %0
ret i32 0
}