newfile(s) register char *s;
{
  register f;
  if (strcmp(s, "-") != 0) {
    f = open(s, 0);
    if (f < 0) {
      prs(s);
      err(": cannot open");
      return (1);
    }
  } else
    f = 0;
  next(remap(f));
  return (0);
}


x86 assembly (clang, -O0):
<newfile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe89(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
je     11c9 <newfile+0x69>
mov    -0x10(%rbp),%rdi
xor    %esi,%esi
mov    $0x0,%al
call   1070 <open@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    11c4 <newfile+0x64>
mov    -0x10(%rbp),%rdi
mov    $0x0,%al
call   1060 <prs@plt>
lea    0xe51(%rip),%rdi
mov    $0x0,%al
call   1050 <err@plt>
movl   $0x1,-0x4(%rbp)
jmp    11ea <newfile+0x8a>
jmp    11d0 <newfile+0x70>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%edi
mov    $0x0,%al
call   1080 <remap@plt>
mov    %eax,%edi
mov    $0x0,%al
call   1030 <next@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<newfile>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0xe93(%rip),%rsi
call   1040 <strcmp@plt>
xor    %ebp,%ebp
mov    $0x0,%edi
test   %eax,%eax
je     118f <newfile+0x2f>
mov    %rbx,%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1070 <open@plt>
mov    %eax,%edi
test   %eax,%eax
js     11a1 <newfile+0x41>
xor    %eax,%eax
call   1080 <remap@plt>
mov    %eax,%edi
xor    %eax,%eax
call   1030 <next@plt>
jmp    11be <newfile+0x5e>
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <prs@plt>
lea    0xe50(%rip),%rdi
xor    %eax,%eax
call   1050 <err@plt>
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"-\00"
@.str.1 = [14 x i8] c": cannot open\00"
define i32 @newfile(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = call i32 @strcmp(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%7 = icmp ne i32 %6, 0
br i1 %7, label %8, label %18
8: ; preds = %1
%9 = load i8*, i8** %3
%10 = call i32 (i8*, i32, ...) bitcast (i32 (...)* @open to i32 (i8*, i32, ...)*)(i8* %9, i32 0)
store i32 %10, i32* %4
%11 = load i32, i32* %4
%12 = icmp slt i32 %11, 0
br i1 %12, label %13, label %17
13: ; preds = %8
%14 = load i8*, i8** %3
%15 = call i32 (i8*, ...) bitcast (i32 (...)* @prs to i32 (i8*, ...)*)(i8* %14)
%16 = call i32 (i8*, ...) bitcast (i32 (...)* @err to i32 (i8*, ...)*)(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %2
br label %23
17: ; preds = %8
br label %19
18: ; preds = %1
store i32 0, i32* %4
br label %19
19: ; preds = %18, %17
%20 = load i32, i32* %4
%21 = call i32 (i32, ...) bitcast (i32 (...)* @remap to i32 (i32, ...)*)(i32 %20)
%22 = call i32 (i32, ...) bitcast (i32 (...)* @next to i32 (i32, ...)*)(i32 %21)
store i32 0, i32* %2
br label %23
23: ; preds = %19, %13
%24 = load i32, i32* %2
ret i32 %24
}

LLVM IR (-O2):
@.str = [2 x i8] c"-\00"
@.str.1 = [14 x i8] c": cannot open\00"
define i32 @newfile(i8* %0) {
%2 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(2) getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i32 %2, 0
br i1 %3, label %10, label %4
4: ; preds = %1
%5 = tail call i32 (i8*, i32, ...) bitcast (i32 (...)* @open to i32 (i8*, i32, ...)*)(i8* %0, i32 0)
%6 = icmp slt i32 %5, 0
br i1 %6, label %7, label %10
7: ; preds = %4
%8 = tail call i32 (i8*, ...) bitcast (i32 (...)* @prs to i32 (i8*, ...)*)(i8* %0)
%9 = tail call i32 (i8*, ...) bitcast (i32 (...)* @err to i32 (i8*, ...)*)(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
br label %14
10: ; preds = %1, %4
%11 = phi i32 [ %5, %4 ], [ 0, %1 ]
%12 = tail call i32 (i32, ...) bitcast (i32 (...)* @remap to i32 (i32, ...)*)(i32 %11)
%13 = tail call i32 (i32, ...) bitcast (i32 (...)* @next to i32 (i32, ...)*)(i32 %12)
br label %14
14: ; preds = %10, %7
%15 = phi i32 [ 1, %7 ], [ 0, %10 ]
ret i32 %15
}