printmail(argc, argv) char **argv;
{
  extern fin, fout;
  register n, c, f;
  if (fopen(".mail", &fin) >= 0 && (c = getchar())) {
    do {
      putchar(c);
    } while (c = getchar());
    close(fin);
    c = 'y';
    if (argc < 2) {
      if (ttyn(0) != 'x') {
        printf("Save?");
        fin = 0;
        c = getchar();
      }
    } else
      c = argv[1][1];
    if (c == 'y') {
      prepend(".mail", "mbox");
      printf("Saved mail in 'mbox'\n");
    }
    close(creat(".mail"));
  } else
    printf("No mail.\n");
}


x86 assembly (clang, -O0):
<printmail>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe6a(%rip),%rdi
mov    0x2e4b(%rip),%rsi
mov    $0x0,%al
call   1080 <fopen@plt>
cmp    $0x0,%eax
jl     1297 <printmail+0x117>
mov    $0x0,%al
call   1070 <getchar@plt>
mov    %eax,-0x18(%rbp)
cmp    $0x0,%eax
je     1297 <printmail+0x117>
jmp    11c5 <printmail+0x45>
mov    -0x18(%rbp),%edi
mov    $0x0,%al
call   1030 <putchar@plt>
mov    $0x0,%al
call   1070 <getchar@plt>
mov    %eax,-0x18(%rbp)
cmp    $0x0,%eax
jne    11c5 <printmail+0x45>
mov    0x2dff(%rip),%rax
mov    (%rax),%edi
mov    $0x0,%al
call   1060 <close@plt>
movl   $0x79,-0x18(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    123f <printmail+0xbf>
xor    %edi,%edi
mov    $0x0,%al
call   10a0 <ttyn@plt>
cmp    $0x78,%eax
je     123a <printmail+0xba>
lea    0xdea(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    0x2dbe(%rip),%rax
movl   $0x0,(%rax)
mov    $0x0,%al
call   1070 <getchar@plt>
mov    %eax,-0x18(%rbp)
jmp    124e <printmail+0xce>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movsbl 0x1(%rax),%eax
mov    %eax,-0x18(%rbp)
cmpl   $0x79,-0x18(%rbp)
jne    127b <printmail+0xfb>
lea    0xda1(%rip),%rdi
lea    0xda6(%rip),%rsi
mov    $0x0,%al
call   1040 <prepend@plt>
lea    0xd9d(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xd7e(%rip),%rdi
mov    $0x0,%al
call   1090 <creat@plt>
mov    %eax,%edi
mov    $0x0,%al
call   1060 <close@plt>
jmp    12a5 <printmail+0x125>
lea    0xd89(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printmail>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0xe60(%rip),%rdi
mov    0x2e41(%rip),%r14
mov    %r14,%rsi
xor    %eax,%eax
call   1090 <fopen@plt>
test   %eax,%eax
js     1214 <printmail+0x84>
xor    %eax,%eax
call   1080 <getchar@plt>
test   %eax,%eax
je     1214 <printmail+0x84>
mov    %eax,%edi
xor    %eax,%eax
call   1030 <putchar@plt>
xor    %eax,%eax
call   1080 <getchar@plt>
test   %eax,%eax
jne    11c0 <printmail+0x30>
mov    (%r14),%edi
xor    %eax,%eax
call   1070 <close@plt>
cmp    $0x1,%ebp
jg     1222 <printmail+0x92>
xor    %edi,%edi
xor    %eax,%eax
call   10b0 <ttyn@plt>
cmp    $0x78,%eax
je     122f <printmail+0x9f>
lea    0xe0e(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
movl   $0x0,(%r14)
xor    %eax,%eax
call   1080 <getchar@plt>
cmp    $0x79,%eax
je     122f <printmail+0x9f>
jmp    1250 <printmail+0xc0>
lea    0xdf6(%rip),%rdi
call   1050 <puts@plt>
jmp    1267 <printmail+0xd7>
mov    0x8(%rbx),%rax
movsbl 0x1(%rax),%eax
cmp    $0x79,%eax
jne    1250 <printmail+0xc0>
lea    0xdca(%rip),%rdi
lea    0xdcf(%rip),%rsi
xor    %eax,%eax
call   1040 <prepend@plt>
lea    0xdcf(%rip),%rdi
call   1050 <puts@plt>
lea    0xda9(%rip),%rdi
xor    %eax,%eax
call   10a0 <creat@plt>
mov    %eax,%edi
xor    %eax,%eax
call   1070 <close@plt>
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c".mail\00"
@fin = external global i32
@.str.1 = [6 x i8] c"Save?\00"
@.str.2 = [5 x i8] c"mbox\00"
@.str.3 = [22 x i8] c"Saved mail in 'mbox'\0A\00"
@.str.4 = [10 x i8] c"No mail.\0A\00"
define i32 @printmail(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = call i32 (i8*, i32*, ...) bitcast (i32 (...)* @fopen to i32 (i8*, i32*, ...)*)(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* @fin)
%10 = icmp sge i32 %9, 0
br i1 %10, label %11, label %49
11: ; preds = %2
%12 = call i32 (...) @getchar()
store i32 %12, i32* %7
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %49
14: ; preds = %11
br label %15
15: ; preds = %18, %14
%16 = load i32, i32* %7
%17 = call i32 (i32, ...) bitcast (i32 (...)* @putchar to i32 (i32, ...)*)(i32 %16)
br label %18
18: ; preds = %15
%19 = call i32 (...) @getchar()
store i32 %19, i32* %7
%20 = icmp ne i32 %19, 0
br i1 %20, label %15, label %21
21: ; preds = %18
%22 = load i32, i32* @fin
%23 = call i32 (i32, ...) bitcast (i32 (...)* @close to i32 (i32, ...)*)(i32 %22)
store i32 121, i32* %7
%24 = load i32, i32* %4
%25 = icmp slt i32 %24, 2
br i1 %25, label %26, label %33
26: ; preds = %21
%27 = call i32 (i32, ...) bitcast (i32 (...)* @ttyn to i32 (i32, ...)*)(i32 0)
%28 = icmp ne i32 %27, 120
br i1 %28, label %29, label %32
29: ; preds = %26
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* @fin
%31 = call i32 (...) @getchar()
store i32 %31, i32* %7
br label %32
32: ; preds = %29, %26
br label %40
33: ; preds = %21
%34 = load i8**, i8*** %5
%35 = getelementptr inbounds i8*, i8** %34, i64 1
%36 = load i8*, i8** %35
%37 = getelementptr inbounds i8, i8* %36, i64 1
%38 = load i8, i8* %37
%39 = sext i8 %38 to i32
store i32 %39, i32* %7
br label %40
40: ; preds = %33, %32
%41 = load i32, i32* %7
%42 = icmp eq i32 %41, 121
br i1 %42, label %43, label %46
43: ; preds = %40
%44 = call i32 (i8*, i8*, ...) bitcast (i32 (...)* @prepend to i32 (i8*, i8*, ...)*)(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
br label %46
46: ; preds = %43, %40
%47 = call i32 (i8*, ...) bitcast (i32 (...)* @creat to i32 (i8*, ...)*)(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%48 = call i32 (i32, ...) bitcast (i32 (...)* @close to i32 (i32, ...)*)(i32 %47)
br label %51
49: ; preds = %11, %2
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
br label %51
51: ; preds = %49, %46
%52 = load i32, i32* %3
ret i32 %52
}

LLVM IR (-O2):
@.str = [6 x i8] c".mail\00"
@fin = external global i32
@.str.1 = [6 x i8] c"Save?\00"
@.str.2 = [5 x i8] c"mbox\00"
@str = [9 x i8] c"No mail.\00"
@str.5 = [21 x i8] c"Saved mail in 'mbox'\00"
define i32 @printmail(i32 %0, i8** nocapture %1) {
%3 = tail call i32 (i8*, i32*, ...) bitcast (i32 (...)* @fopen to i32 (i8*, i32*, ...)*)(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* @fin)
%4 = icmp sgt i32 %3, -1
br i1 %4, label %5, label %38
5: ; preds = %2
%6 = tail call i32 (...) @getchar()
%7 = icmp eq i32 %6, 0
br i1 %7, label %38, label %8
8: ; preds = %5, %8
%9 = phi i32 [ %11, %8 ], [ %6, %5 ]
%10 = tail call i32 (i32, ...) bitcast (i32 (...)* @putchar to i32 (i32, ...)*)(i32 %9)
%11 = tail call i32 (...) @getchar()
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %8
13: ; preds = %8
%14 = load i32, i32* @fin
%15 = tail call i32 (i32, ...) bitcast (i32 (...)* @close to i32 (i32, ...)*)(i32 %14)
%16 = icmp slt i32 %0, 2
br i1 %16, label %17, label %23
17: ; preds = %13
%18 = tail call i32 (i32, ...) bitcast (i32 (...)* @ttyn to i32 (i32, ...)*)(i32 0)
%19 = icmp eq i32 %18, 120
br i1 %19, label %32, label %20
20: ; preds = %17
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* @fin
%22 = tail call i32 (...) @getchar()
br label %29
23: ; preds = %13
%24 = getelementptr inbounds i8*, i8** %1, i64 1
%25 = load i8*, i8** %24
%26 = getelementptr inbounds i8, i8* %25, i64 1
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
br label %29
29: ; preds = %20, %23
%30 = phi i32 [ %22, %20 ], [ %28, %23 ]
%31 = icmp eq i32 %30, 121
br i1 %31, label %32, label %35
32: ; preds = %17, %29
%33 = tail call i32 (i8*, i8*, ...) bitcast (i32 (...)* @prepend to i32 (i8*, i8*, ...)*)(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%34 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.5, i64 0, i64 0))
br label %35
35: ; preds = %32, %29
%36 = tail call i32 (i8*, ...) bitcast (i32 (...)* @creat to i32 (i8*, ...)*)(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%37 = tail call i32 (i32, ...) bitcast (i32 (...)* @close to i32 (i32, ...)*)(i32 %36)
br label %40
38: ; preds = %5, %2
%39 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str, i64 0, i64 0))
br label %40
40: ; preds = %38, %35
ret i32 undef
}