int file_read(env, fname)
struct wnn_env *env;
char *fname;
{
  register int fid;
  if (fname[0] == '!') {
    fid = js_file_send(env, fname + 1);
  } else {
    fid = js_file_read(env, fname);
  }
  if (fid >= 0) {
    add_file_to_env(env, fid, fname);
  }
  return (fid);
}


x86 assembly (clang, -O0):
<file_read>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x21,%eax
jne    116b <file_read+0x3b>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
add    $0x1,%rsi
mov    $0x0,%al
call   1030 <js_file_send@plt>
mov    %eax,-0x14(%rbp)
jmp    117d <file_read+0x4d>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0x0,%al
call   1050 <js_file_read@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jl     1199 <file_read+0x69>
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x10(%rbp),%rdx
mov    $0x0,%al
call   1040 <add_file_to_env@plt>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<file_read>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    %rdi,%r14
cmpb   $0x21,(%rsi)
jne    114f <file_read+0x1f>
lea    0x1(%rbx),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <js_file_send@plt>
jmp    115c <file_read+0x2c>
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <js_file_read@plt>
mov    %eax,%ebp
test   %eax,%eax
js     1171 <file_read+0x41>
mov    %r14,%rdi
mov    %ebp,%esi
mov    %rbx,%rdx
xor    %eax,%eax
call   1040 <add_file_to_env@plt>
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.wnn_env = type opaque
define i32 @file_read(%struct.wnn_env* %0, i8* %1) {
%3 = alloca %struct.wnn_env*
%4 = alloca i8*
%5 = alloca i32
store %struct.wnn_env* %0, %struct.wnn_env** %3
store i8* %1, i8** %4
%6 = load i8*, i8** %4
%7 = getelementptr inbounds i8, i8* %6, i64 0
%8 = load i8, i8* %7
%9 = sext i8 %8 to i32
%10 = icmp eq i32 %9, 33
br i1 %10, label %11, label %16
11: ; preds = %2
%12 = load %struct.wnn_env*, %struct.wnn_env** %3
%13 = load i8*, i8** %4
%14 = getelementptr inbounds i8, i8* %13, i64 1
%15 = call i32 (%struct.wnn_env*, i8*, ...) bitcast (i32 (...)* @js_file_send to i32 (%struct.wnn_env*, i8*, ...)*)(%struct.wnn_env* %12, i8* %14)
store i32 %15, i32* %5
br label %20
16: ; preds = %2
%17 = load %struct.wnn_env*, %struct.wnn_env** %3
%18 = load i8*, i8** %4
%19 = call i32 (%struct.wnn_env*, i8*, ...) bitcast (i32 (...)* @js_file_read to i32 (%struct.wnn_env*, i8*, ...)*)(%struct.wnn_env* %17, i8* %18)
store i32 %19, i32* %5
br label %20
20: ; preds = %16, %11
%21 = load i32, i32* %5
%22 = icmp sge i32 %21, 0
br i1 %22, label %23, label %28
23: ; preds = %20
%24 = load %struct.wnn_env*, %struct.wnn_env** %3
%25 = load i32, i32* %5
%26 = load i8*, i8** %4
%27 = call i32 (%struct.wnn_env*, i32, i8*, ...) bitcast (i32 (...)* @add_file_to_env to i32 (%struct.wnn_env*, i32, i8*, ...)*)(%struct.wnn_env* %24, i32 %25, i8* %26)
br label %28
28: ; preds = %23, %20
%29 = load i32, i32* %5
ret i32 %29
}

LLVM IR (-O2):
%struct.wnn_env = type opaque
define i32 @file_read(%struct.wnn_env* %0, i8* %1) {
%3 = load i8, i8* %1
%4 = icmp eq i8 %3, 33
br i1 %4, label %5, label %8
5: ; preds = %2
%6 = getelementptr inbounds i8, i8* %1, i64 1
%7 = tail call i32 (%struct.wnn_env*, i8*, ...) bitcast (i32 (...)* @js_file_send to i32 (%struct.wnn_env*, i8*, ...)*)(%struct.wnn_env* %0, i8* %6)
br label %10
8: ; preds = %2
%9 = tail call i32 (%struct.wnn_env*, i8*, ...) bitcast (i32 (...)* @js_file_read to i32 (%struct.wnn_env*, i8*, ...)*)(%struct.wnn_env* %0, i8* %1)
br label %10
10: ; preds = %8, %5
%11 = phi i32 [ %7, %5 ], [ %9, %8 ]
%12 = icmp sgt i32 %11, -1
br i1 %12, label %13, label %15
13: ; preds = %10
%14 = tail call i32 (%struct.wnn_env*, i32, i8*, ...) bitcast (i32 (...)* @add_file_to_env to i32 (%struct.wnn_env*, i32, i8*, ...)*)(%struct.wnn_env* %0, i32 %11, i8* %1)
br label %15
15: ; preds = %13, %10
ret i32 %11
}