#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 passwd {
  char *pw_name;
};
typedef int /*<<< orphan*/ buf;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int BUFSIZ;
char *_PATH_MAILDIR;
int /*<<< orphan*/ errx(int, char *, ...);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
char *getenv(char *);
int getopt(int, char **, char *);
struct passwd *getpwuid(int /*<<< orphan*/);
int /*<<< orphan*/ getuid();
scalar_t__ match(char *, char *);
void *optarg;
scalar_t__ optind;
int /*<<< orphan*/ printf(char *, char *, ...);
int /*<<< orphan*/ snprintf(char *, int, char *, char *, char const *);
int /*<<< orphan*/ *stdin;
scalar_t__ strcmp(char const *, char *);
int /*<<< orphan*/ strncmp(char *, char *, int);
char tolower(char);
int /*<<< orphan*/ usage();
int main(int argc, char **argv) {
  FILE *mbox;
  struct passwd *pwd;
  int ch, count, newline;
  const char *file;
  char *sender, *p;
  char buf[BUFSIZ];
  file = sender = NULL;
  count = -1;
  while ((ch = getopt(argc, argv, "cf:s:")) != -1)
    switch (ch) {
    case 'c':
      count = 0;
      break;
    case 'f':
      file = optarg;
      break;
    case 's':
      sender = optarg;
      for (p = sender; *p; ++p)
        *p = tolower(*p);
      break;
    case '?':
    default:
      usage();
    }
  argc -= optind;
  argv += optind;
  if (file == NULL) {
    if (argc) {
      (void)snprintf(buf, sizeof(buf), "%s/%s", _PATH_MAILDIR, *argv);
      file = buf;
    } else {
      if (!(file = getenv("MAIL"))) {
        if (!(pwd = getpwuid(getuid())))
          errx(1, "no password file entry for you");
        file = pwd->pw_name;
        (void)snprintf(buf, sizeof(buf), "%s/%s", _PATH_MAILDIR, file);
        file = buf;
      }
    }
  }
  if (strcmp(file, "-") == 0) {
    mbox = stdin;
  } else if ((mbox = fopen(file, "r")) == NULL) {
    errx(1, "can't read %s", file);
  }
  for (newline = 1; fgets(buf, sizeof(buf), mbox);) {
    if (*buf == '\n') {
      newline = 1;
      continue;
    }
    if (newline && !strncmp(buf, "From ", 5) &&
        (!sender || match(buf + 5, sender))) {
      if (count != -1)
        count++;
      else
        printf("%s", buf);
    }
    newline = 0;
  }
  if (count != -1)
    printf("There %s %d message%s in your incoming mailbox.\n",
           count == 1 ? "is" : "are", count, count == 1 ? "" : "s");
  fclose(mbox);
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2dab(%rip),%rax
mov    (%rax),%eax
mov    %rax,-0x68(%rbp)
mov    %rsp,%rcx
mov    %rcx,-0x50(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x60(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x58(%rbp)
movq   $0x0,-0x40(%rbp)
movq   $0x0,-0x38(%rbp)
movl   $0xffffffff,-0x28(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xd95(%rip),%rdx
call   1110 <getopt@plt>
mov    %eax,-0x24(%rbp)
cmp    $0xffffffff,%eax
je     1340 <main+0x140>
mov    -0x24(%rbp),%eax
mov    %eax,-0x6c(%rbp)
sub    $0x3f,%eax
je     132f <main+0x12f>
jmp    1290 <main+0x90>
mov    -0x6c(%rbp),%eax
sub    $0x63,%eax
je     12c3 <main+0xc3>
jmp    12a1 <main+0xa1>
mov    -0x6c(%rbp),%eax
sub    $0x66,%eax
je     12cf <main+0xcf>
jmp    12b2 <main+0xb2>
mov    -0x6c(%rbp),%eax
sub    $0x73,%eax
je     12e2 <main+0xe2>
jmp    1334 <main+0x134>
movl   $0x0,-0x28(%rbp)
jmp    133b <main+0x13b>
mov    0x2d22(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x38(%rbp)
jmp    133b <main+0x13b>
mov    0x2d0f(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rax
cmpb   $0x0,(%rax)
je     132a <main+0x12a>
mov    -0x48(%rbp),%rax
movsbl (%rax),%edi
call   10d0 <tolower@plt>
mov    %al,%cl
mov    -0x48(%rbp),%rax
mov    %cl,(%rax)
mov    -0x48(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x48(%rbp)
jmp    12f8 <main+0xf8>
jmp    133b <main+0x13b>
jmp    1334 <main+0x134>
mov    $0x0,%al
call   10f0 <usage@plt>
jmp    125d <main+0x5d>
mov    0x2c91(%rip),%rax
mov    (%rax),%rcx
movslq -0x8(%rbp),%rax
sub    %rcx,%rax
mov    %eax,-0x8(%rbp)
mov    0x2c7d(%rip),%rax
mov    (%rax),%rax
shl    $0x3,%rax
add    -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    143d <main+0x23d>
cmpl   $0x0,-0x8(%rbp)
je     13b3 <main+0x1b3>
mov    -0x60(%rbp),%rdi
mov    -0x68(%rbp),%rax
mov    %eax,%esi
mov    0x2c30(%rip),%rax
mov    (%rax),%rcx
mov    -0x10(%rbp),%rax
mov    (%rax),%r8
lea    0xc65(%rip),%rdx
call   10a0 <snprintf@plt>
mov    -0x60(%rbp),%rax
mov    %rax,-0x38(%rbp)
jmp    1438 <main+0x238>
lea    0xc52(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x38(%rbp)
cmp    $0x0,%rax
jne    1433 <main+0x233>
mov    $0x0,%al
call   1070 <getuid@plt>
mov    %eax,%edi
call   1060 <getpwuid@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    13fc <main+0x1fc>
mov    $0x1,%edi
lea    0xc1c(%rip),%rsi
mov    $0x0,%al
call   1080 <errx@plt>
mov    -0x60(%rbp),%rdi
mov    -0x68(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    (%rcx),%rcx
mov    %rcx,-0x38(%rbp)
mov    %eax,%esi
mov    0x2ba8(%rip),%rax
mov    (%rax),%rcx
mov    -0x38(%rbp),%r8
lea    0xbe0(%rip),%rdx
call   10a0 <snprintf@plt>
mov    -0x60(%rbp),%rax
mov    %rax,-0x38(%rbp)
jmp    1438 <main+0x238>
jmp    143d <main+0x23d>
mov    -0x38(%rbp),%rdi
lea    0xbe8(%rip),%rsi
call   10c0 <strcmp@plt>
cmp    $0x0,%rax
jne    146a <main+0x26a>
mov    0x2b82(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
jmp    14a4 <main+0x2a4>
mov    -0x38(%rbp),%rdi
lea    0xbbd(%rip),%rsi
call   1100 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    149f <main+0x29f>
mov    -0x38(%rbp),%rdx
mov    $0x1,%edi
lea    0xb9c(%rip),%rsi
mov    $0x0,%al
call   1080 <errx@plt>
jmp    14a4 <main+0x2a4>
movl   $0x1,-0x2c(%rbp)
mov    -0x60(%rbp),%rdi
mov    -0x68(%rbp),%rax
mov    %eax,%esi
mov    -0x18(%rbp),%rdx
call   10b0 <fgets@plt>
cmp    $0x0,%rax
je     156d <main+0x36d>
mov    -0x60(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
jne    14e4 <main+0x2e4>
movl   $0x1,-0x2c(%rbp)
jmp    14ab <main+0x2ab>
cmpl   $0x0,-0x2c(%rbp)
je     1561 <main+0x361>
mov    -0x60(%rbp),%rdi
lea    0xb49(%rip),%rsi
mov    $0x5,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%eax
jne    1561 <main+0x361>
cmpq   $0x0,-0x40(%rbp)
je     1532 <main+0x332>
mov    -0x60(%rbp),%rdi
add    $0x5,%rdi
mov    -0x40(%rbp),%rsi
call   10e0 <match@plt>
cmp    $0x0,%rax
je     1561 <main+0x361>
cmpl   $0xffffffff,-0x28(%rbp)
je     154a <main+0x34a>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    155c <main+0x35c>
mov    -0x60(%rbp),%rsi
lea    0xaea(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
jmp    1561 <main+0x361>
movl   $0x0,-0x2c(%rbp)
jmp    14ab <main+0x2ab>
cmpl   $0xffffffff,-0x28(%rbp)
je     15b8 <main+0x3b8>
mov    -0x28(%rbp),%ecx
lea    0xafb(%rip),%rsi
lea    0xaf1(%rip),%rax
cmp    $0x1,%ecx
cmove  %rax,%rsi
mov    -0x28(%rbp),%edx
mov    -0x28(%rbp),%edi
lea    0xaa4(%rip),%rcx
lea    0xad5(%rip),%rax
cmp    $0x1,%edi
cmove  %rax,%rcx
lea    0xa97(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1050 <fclose@plt>
xor    %edi,%edi
call   1120 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rsi,%rbx
mov    %edi,%r14d
mov    0x2daa(%rip),%rax
mov    (%rax),%r15d
mov    %rsp,%r13
mov    %r15,%rax
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r13
mov    %r13,%rsp
movl   $0xffffffff,-0x2c(%rbp)
lea    0xdbd(%rip),%r12
xor    %eax,%eax
mov    %rax,-0x38(%rbp)
xor    %eax,%eax
mov    %rax,-0x40(%rbp)
mov    %r15,-0x48(%rbp)
jmp    1275 <main+0x75>
cs nopw 0x0(%rax,%rax,1)
nop
cmp    $0x63,%eax
je     12a2 <main+0xa2>
cmp    $0xffffffff,%eax
je     12ee <main+0xee>
xor    %eax,%eax
call   10f0 <usage@plt>
mov    %r14d,%edi
mov    %rbx,%rsi
mov    %r12,%rdx
call   1110 <getopt@plt>
cmp    $0x65,%eax
jle    1260 <main+0x60>
cmp    $0x73,%eax
je     12ab <main+0xab>
cmp    $0x66,%eax
jne    126e <main+0x6e>
mov    0x2d5f(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x38(%rbp)
jmp    1275 <main+0x75>
movl   $0x0,-0x2c(%rbp)
jmp    1275 <main+0x75>
mov    0x2d46(%rip),%rax
mov    (%rax),%rcx
mov    %rcx,%rax
mov    %rcx,-0x40(%rbp)
mov    (%rcx),%al
test   %al,%al
je     1275 <main+0x75>
mov    -0x40(%rbp),%rcx
lea    0x1(%rcx),%r15
nopw   0x0(%rax,%rax,1)
movsbl %al,%edi
call   10d0 <tolower@plt>
mov    %al,-0x1(%r15)
movzbl (%r15),%eax
add    $0x1,%r15
test   %al,%al
jne    12d0 <main+0xd0>
mov    -0x48(%rbp),%r15
jmp    1275 <main+0x75>
mov    -0x38(%rbp),%r12
test   %r12,%r12
jne    136b <main+0x16b>
mov    0x2cda(%rip),%rax
mov    (%rax),%rax
cmp    %r14d,%eax
jne    1345 <main+0x145>
lea    0xcff(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,%r12
test   %rax,%rax
jne    136b <main+0x16b>
xor    %eax,%eax
call   1070 <getuid@plt>
mov    %eax,%edi
call   1060 <getpwuid@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1349 <main+0x149>
lea    0xcda(%rip),%rsi
mov    $0x1,%edi
xor    %eax,%eax
call   1080 <errx@plt>
jmp    1349 <main+0x149>
lea    (%rbx,%rax,8),%rbx
mov    0x2c70(%rip),%rax
mov    (%rax),%rcx
mov    (%rbx),%r8
lea    0xca9(%rip),%rdx
mov    %r13,%rdi
mov    %r15d,%esi
call   10a0 <snprintf@plt>
mov    %r13,%r12
lea    0xcbe(%rip),%rsi
mov    %r12,%rdi
call   10c0 <strcmp@plt>
test   %rax,%rax
jne    138b <main+0x18b>
mov    0x2c5a(%rip),%rax
mov    (%rax),%rbx
jmp    13ba <main+0x1ba>
lea    0xca0(%rip),%rsi
mov    %r12,%rdi
call   1100 <fopen@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    13ba <main+0x1ba>
lea    0xc8b(%rip),%rsi
xor    %ebx,%ebx
mov    $0x1,%edi
mov    %r12,%rdx
xor    %eax,%eax
call   1080 <errx@plt>
lea    0x5(%r13),%rax
mov    %rax,-0x38(%rbp)
xor    %r14d,%r14d
jmp    13e0 <main+0x1e0>
mov    -0x2c(%rbp),%eax
cmp    $0xffffffff,%eax
je     143c <main+0x23c>
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
mov    $0x1,%r14b
nopl   0x0(%rax,%rax,1)
mov    %r14d,%r12d
mov    %r13,%rdi
mov    %r15d,%esi
mov    %rbx,%rdx
call   10b0 <fgets@plt>
test   %rax,%rax
je     1459 <main+0x259>
xor    %r14d,%r14d
cmpb   $0xa,0x0(%r13)
je     13e0 <main+0x1e0>
mov    $0x1,%r14b
test   $0x1,%r12b
jne    13e0 <main+0x1e0>
mov    %r13,%rdi
lea    0xc2f(%rip),%rsi
mov    $0x5,%edx
call   1040 <strncmp@plt>
test   %eax,%eax
jne    13e0 <main+0x1e0>
cmpq   $0x0,-0x40(%rbp)
je     13c7 <main+0x1c7>
mov    -0x38(%rbp),%rdi
mov    -0x40(%rbp),%rsi
call   10e0 <match@plt>
test   %rax,%rax
je     13e0 <main+0x1e0>
jmp    13c7 <main+0x1c7>
lea    0xbfc(%rip),%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1090 <printf@plt>
mov    $0x1,%r14b
movl   $0xffffffff,-0x2c(%rbp)
jmp    13e0 <main+0x1e0>
mov    -0x2c(%rbp),%edx
cmp    $0xffffffff,%edx
je     1496 <main+0x296>
cmp    $0x1,%edx
lea    0xc0e(%rip),%rax
lea    0xc0a(%rip),%rsi
cmove  %rax,%rsi
lea    0xbfb(%rip),%rax
lea    0xbbc(%rip),%rcx
cmove  %rax,%rcx
lea    0xbb9(%rip),%rdi
xor    %eax,%eax
call   1090 <printf@plt>
mov    %rbx,%rdi
call   1050 <fclose@plt>
xor    %edi,%edi
call   1120 <exit@plt>

LLVM IR (-O0):
%struct.passwd = type { i8* }
@BUFSIZ = global i32 0
@.str = [6 x i8] c"cf:s:\00"
@optarg = global i8* null
@optind = global i64 0
@.str.1 = [6 x i8] c"%s/%s\00"
@_PATH_MAILDIR = global i8* null
@.str.2 = [5 x i8] c"MAIL\00"
@.str.3 = [31 x i8] c"no password file entry for you\00"
@.str.4 = [2 x i8] c"-\00"
@stdin = global i32* null
@.str.5 = [2 x i8] c"r\00"
@.str.6 = [14 x i8] c"can't read %s\00"
@.str.7 = [6 x i8] c"From \00"
@.str.8 = [3 x i8] c"%s\00"
@.str.9 = [49 x i8] c"There %s %d message%s in your incoming mailbox.\0A\00"
@.str.10 = [3 x i8] c"is\00"
@.str.11 = [4 x i8] c"are\00"
@.str.12 = [1 x i8] zeroinitializer
@.str.13 = [2 x i8] c"s\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca %struct.passwd*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca i8*
%15 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%16 = load i32, i32* @BUFSIZ
%17 = zext i32 %16 to i64
%18 = call i8* @llvm.stacksave()
store i8* %18, i8** %14
%19 = alloca i8, i64 %17
store i64 %17, i64* %15
store i8* null, i8** %12
store i8* null, i8** %11
store i32 -1, i32* %9
br label %20
20: ; preds = %49, %2
%21 = load i32, i32* %4
%22 = load i8**, i8*** %5
%23 = call i32 @getopt(i32 %21, i8** %22, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
store i32 %23, i32* %8
%24 = icmp ne i32 %23, -1
br i1 %24, label %25, label %50
25: ; preds = %20
%26 = load i32, i32* %8
switch i32 %26, label %47 [
i32 99, label %27
i32 102, label %28
i32 115, label %30
i32 63, label %46
]
27: ; preds = %25
store i32 0, i32* %9
br label %49
28: ; preds = %25
%29 = load i8*, i8** @optarg
store i8* %29, i8** %11
br label %49
30: ; preds = %25
%31 = load i8*, i8** @optarg
store i8* %31, i8** %12
%32 = load i8*, i8** %12
store i8* %32, i8** %13
br label %33
33: ; preds = %42, %30
%34 = load i8*, i8** %13
%35 = load i8, i8* %34
%36 = icmp ne i8 %35, 0
br i1 %36, label %37, label %45
37: ; preds = %33
%38 = load i8*, i8** %13
%39 = load i8, i8* %38
%40 = call signext i8 @tolower(i8 signext %39)
%41 = load i8*, i8** %13
store i8 %40, i8* %41
br label %42
42: ; preds = %37
%43 = load i8*, i8** %13
%44 = getelementptr inbounds i8, i8* %43, i32 1
store i8* %44, i8** %13
br label %33
45: ; preds = %33
br label %49
46: ; preds = %25
br label %47
47: ; preds = %25, %46
%48 = call i32 (...) @usage()
br label %49
49: ; preds = %47, %45, %28, %27
br label %20
50: ; preds = %20
%51 = load i64, i64* @optind
%52 = load i32, i32* %4
%53 = sext i32 %52 to i64
%54 = sub nsw i64 %53, %51
%55 = trunc i64 %54 to i32
store i32 %55, i32* %4
%56 = load i64, i64* @optind
%57 = load i8**, i8*** %5
%58 = getelementptr inbounds i8*, i8** %57, i64 %56
store i8** %58, i8*** %5
%59 = load i8*, i8** %11
%60 = icmp eq i8* %59, null
br i1 %60, label %61, label %89
61: ; preds = %50
%62 = load i32, i32* %4
%63 = icmp ne i32 %62, 0
br i1 %63, label %64, label %70
64: ; preds = %61
%65 = trunc i64 %17 to i32
%66 = load i8*, i8** @_PATH_MAILDIR
%67 = load i8**, i8*** %5
%68 = load i8*, i8** %67
%69 = call i32 @snprintf(i8* %19, i32 %65, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %66, i8* %68)
store i8* %19, i8** %11
br label %88
70: ; preds = %61
%71 = call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
store i8* %71, i8** %11
%72 = icmp ne i8* %71, null
br i1 %72, label %87, label %73
73: ; preds = %70
%74 = call i32 (...) @getuid()
%75 = call %struct.passwd* @getpwuid(i32 %74)
store %struct.passwd* %75, %struct.passwd** %7
%76 = icmp ne %struct.passwd* %75, null
br i1 %76, label %79, label %77
77: ; preds = %73
%78 = call i32 (i32, i8*, ...) @errx(i32 1, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0))
br label %79
79: ; preds = %77, %73
%80 = load %struct.passwd*, %struct.passwd** %7
%81 = getelementptr inbounds %struct.passwd, %struct.passwd* %80, i32 0, i32 0
%82 = load i8*, i8** %81
store i8* %82, i8** %11
%83 = trunc i64 %17 to i32
%84 = load i8*, i8** @_PATH_MAILDIR
%85 = load i8*, i8** %11
%86 = call i32 @snprintf(i8* %19, i32 %83, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %84, i8* %85)
store i8* %19, i8** %11
br label %87
87: ; preds = %79, %70
br label %88
88: ; preds = %87, %64
br label %89
89: ; preds = %88, %50
%90 = load i8*, i8** %11
%91 = call i64 @strcmp(i8* %90, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%92 = icmp eq i64 %91, 0
br i1 %92, label %93, label %95
93: ; preds = %89
%94 = load i32*, i32** @stdin
store i32* %94, i32** %6
br label %103
95: ; preds = %89
%96 = load i8*, i8** %11
%97 = call i32* @fopen(i8* %96, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
store i32* %97, i32** %6
%98 = icmp eq i32* %97, null
br i1 %98, label %99, label %102
99: ; preds = %95
%100 = load i8*, i8** %11
%101 = call i32 (i32, i8*, ...) @errx(i32 1, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0), i8* %100)
br label %102
102: ; preds = %99, %95
br label %103
103: ; preds = %102, %93
store i32 1, i32* %10
br label %104
104: ; preds = %137, %113, %103
%105 = trunc i64 %17 to i32
%106 = load i32*, i32** %6
%107 = call i64 @fgets(i8* %19, i32 %105, i32* %106)
%108 = icmp ne i64 %107, 0
br i1 %108, label %109, label %138
109: ; preds = %104
%110 = load i8, i8* %19
%111 = sext i8 %110 to i32
%112 = icmp eq i32 %111, 10
br i1 %112, label %113, label %114
113: ; preds = %109
store i32 1, i32* %10
br label %104
114: ; preds = %109
%115 = load i32, i32* %10
%116 = icmp ne i32 %115, 0
br i1 %116, label %117, label %137
117: ; preds = %114
%118 = call i32 @strncmp(i8* %19, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), i32 5)
%119 = icmp ne i32 %118, 0
br i1 %119, label %137, label %120
120: ; preds = %117
%121 = load i8*, i8** %12
%122 = icmp ne i8* %121, null
br i1 %122, label %123, label %128
123: ; preds = %120
%124 = getelementptr inbounds i8, i8* %19, i64 5
%125 = load i8*, i8** %12
%126 = call i64 @match(i8* %124, i8* %125)
%127 = icmp ne i64 %126, 0
br i1 %127, label %128, label %137
128: ; preds = %123, %120
%129 = load i32, i32* %9
%130 = icmp ne i32 %129, -1
br i1 %130, label %131, label %134
131: ; preds = %128
%132 = load i32, i32* %9
%133 = add nsw i32 %132, 1
store i32 %133, i32* %9
br label %136
134: ; preds = %128
%135 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i8* %19)
br label %136
136: ; preds = %134, %131
br label %137
137: ; preds = %136, %123, %117, %114
store i32 0, i32* %10
br label %104
138: ; preds = %104
%139 = load i32, i32* %9
%140 = icmp ne i32 %139, -1
br i1 %140, label %141, label %152
141: ; preds = %138
%142 = load i32, i32* %9
%143 = icmp eq i32 %142, 1
%144 = zext i1 %143 to i64
%145 = select i1 %143, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i64 0, i64 0)
%146 = load i32, i32* %9
%147 = load i32, i32* %9
%148 = icmp eq i32 %147, 1
%149 = zext i1 %148 to i64
%150 = select i1 %148, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.13, i64 0, i64 0)
%151 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.9, i64 0, i64 0), i8* %145, i32 %146, i8* %150)
br label %152
152: ; preds = %141, %138
%153 = load i32*, i32** %6
%154 = call i32 @fclose(i32* %153)
%155 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
%struct.passwd = type { i8* }
@BUFSIZ = global i32 0
@.str = [6 x i8] c"cf:s:\00"
@optarg = global i8* null
@optind = global i64 0
@.str.1 = [6 x i8] c"%s/%s\00"
@_PATH_MAILDIR = global i8* null
@.str.2 = [5 x i8] c"MAIL\00"
@.str.3 = [31 x i8] c"no password file entry for you\00"
@.str.4 = [2 x i8] c"-\00"
@stdin = global i32* null
@.str.5 = [2 x i8] c"r\00"
@.str.6 = [14 x i8] c"can't read %s\00"
@.str.7 = [6 x i8] c"From \00"
@.str.8 = [3 x i8] c"%s\00"
@.str.9 = [49 x i8] c"There %s %d message%s in your incoming mailbox.\0A\00"
@.str.10 = [3 x i8] c"is\00"
@.str.11 = [4 x i8] c"are\00"
@.str.12 = [1 x i8] zeroinitializer
@.str.13 = [2 x i8] c"s\00"
define i32 @main(i32 %0, i8** %1) {
%3 = load i32, i32* @BUFSIZ
%4 = zext i32 %3 to i64
%5 = alloca i8, i64 %4
br label %6
6: ; preds = %12, %2
%7 = phi i32 [ -1, %2 ], [ 0, %12 ]
%8 = phi i8* [ null, %2 ], [ %17, %12 ]
%9 = phi i8* [ null, %2 ], [ %11, %12 ]
br label %16
10: ; preds = %23, %16
%11 = phi i8* [ %18, %16 ], [ %20, %23 ]
br label %12
12: ; preds = %10, %31
%13 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
switch i32 %13, label %31 [
i32 -1, label %33
i32 99, label %6
i32 102, label %14
i32 115, label %19
]
14: ; preds = %12
%15 = load i8*, i8** @optarg
br label %16
16: ; preds = %6, %14
%17 = phi i8* [ %8, %6 ], [ %15, %14 ]
%18 = phi i8* [ %9, %6 ], [ %11, %14 ]
br label %10
19: ; preds = %12
%20 = load i8*, i8** @optarg
%21 = load i8, i8* %20
%22 = icmp eq i8 %21, 0
br i1 %22, label %23, label %24
23: ; preds = %24, %19
br label %10
24: ; preds = %19, %24
%25 = phi i8 [ %29, %24 ], [ %21, %19 ]
%26 = phi i8* [ %28, %24 ], [ %20, %19 ]
%27 = tail call signext i8 @tolower(i8 signext %25)
store i8 %27, i8* %26
%28 = getelementptr inbounds i8, i8* %26, i64 1
%29 = load i8, i8* %28
%30 = icmp eq i8 %29, 0
br i1 %30, label %23, label %24
31: ; preds = %12
%32 = tail call i32 (...) @usage()
br label %12
33: ; preds = %12
%34 = load i64, i64* @optind
%35 = icmp eq i8* %17, null
br i1 %35, label %36, label %56
36: ; preds = %33
%37 = getelementptr inbounds i8*, i8** %1, i64 %34
%38 = trunc i64 %34 to i32
%39 = icmp eq i32 %38, %0
br i1 %39, label %40, label %51
40: ; preds = %36
%41 = tail call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%42 = icmp eq i8* %41, null
br i1 %42, label %43, label %56
43: ; preds = %40
%44 = tail call i32 (...) @getuid()
%45 = tail call %struct.passwd* @getpwuid(i32 %44)
%46 = icmp eq %struct.passwd* %45, null
br i1 %46, label %47, label %49
47: ; preds = %43
%48 = tail call i32 (i32, i8*, ...) @errx(i32 1, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0))
br label %49
49: ; preds = %47, %43
%50 = getelementptr inbounds %struct.passwd, %struct.passwd* %45, i64 0, i32 0
br label %51
51: ; preds = %36, %49
%52 = phi i8** [ %50, %49 ], [ %37, %36 ]
%53 = load i8*, i8** @_PATH_MAILDIR
%54 = load i8*, i8** %52
%55 = call i32 @snprintf(i8* %5, i32 %3, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %53, i8* %54)
br label %56
56: ; preds = %51, %40, %33
%57 = phi i8* [ %41, %40 ], [ %17, %33 ], [ %5, %51 ]
%58 = call i64 @strcmp(i8* %57, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%59 = icmp eq i64 %58, 0
br i1 %59, label %60, label %62
60: ; preds = %56
%61 = load i32*, i32** @stdin
br label %67
62: ; preds = %56
%63 = call i32* @fopen(i8* %57, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%64 = icmp eq i32* %63, null
br i1 %64, label %65, label %67
65: ; preds = %62
%66 = call i32 (i32, i8*, ...) @errx(i32 1, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0), i8* %57)
br label %67
67: ; preds = %62, %65, %60
%68 = phi i32* [ %61, %60 ], [ null, %65 ], [ %63, %62 ]
%69 = icmp eq i8* %11, null
%70 = getelementptr inbounds i8, i8* %5, i64 5
br label %71
71: ; preds = %96, %67
%72 = phi i32 [ %7, %67 ], [ %97, %96 ]
%73 = phi i1 [ false, %67 ], [ true, %96 ]
br label %74
74: ; preds = %91, %71
%75 = phi i1 [ %73, %71 ], [ true, %91 ]
br label %76
76: ; preds = %74, %80
%77 = phi i1 [ false, %80 ], [ %75, %74 ]
%78 = call i64 @fgets(i8* %5, i32 %3, i32* %68)
%79 = icmp eq i64 %78, 0
br i1 %79, label %100, label %80
80: ; preds = %76
%81 = load i8, i8* %5
%82 = icmp eq i8 %81, 10
br i1 %82, label %76, label %83
83: ; preds = %80
br i1 %77, label %91, label %84
84: ; preds = %83
%85 = call i32 @strncmp(i8* %5, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), i32 5)
%86 = icmp eq i32 %85, 0
br i1 %86, label %87, label %91
87: ; preds = %84
br i1 %69, label %92, label %88
88: ; preds = %87
%89 = call i64 @match(i8* %70, i8* %11)
%90 = icmp eq i64 %89, 0
br i1 %90, label %91, label %92
91: ; preds = %88, %84, %83
br label %74
92: ; preds = %88, %87
%93 = icmp eq i32 %72, -1
br i1 %93, label %98, label %94
94: ; preds = %92
%95 = add nuw nsw i32 %72, 1
br label %96
96: ; preds = %94, %98
%97 = phi i32 [ -1, %98 ], [ %95, %94 ]
br label %71
98: ; preds = %92
%99 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i8* %5)
br label %96
100: ; preds = %76
%101 = icmp eq i32 %72, -1
br i1 %101, label %107, label %102
102: ; preds = %100
%103 = icmp eq i32 %72, 1
%104 = select i1 %103, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i64 0, i64 0)
%105 = select i1 %103, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.13, i64 0, i64 0)
%106 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.9, i64 0, i64 0), i8* %104, i32 %72, i8* %105)
br label %107
107: ; preds = %102, %100
%108 = call i32 @fclose(i32* %68)
%109 = call i32 @exit(i32 0)
unreachable
}