openfil(s, b) char *s;
int *b;
{
  if (s[0] == '-' && s[1] == 0)
    b[0] = 0;
  else if (fopen(s, b) == -1) {
    printf("Can't open %s\n", s);
    exit(1);
  }
}


x86 assembly (clang, -O0):
<openfil>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    1170 <openfil+0x40>
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x0,%eax
jne    1170 <openfil+0x40>
mov    -0x18(%rbp),%rax
movl   $0x0,(%rax)
jmp    11a9 <openfil+0x79>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    $0x0,%al
call   1040 <fopen@plt>
cmp    $0xffffffff,%eax
jne    11a4 <openfil+0x74>
mov    -0x10(%rbp),%rsi
lea    0xe6d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
jmp    11a9 <openfil+0x79>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<openfil>:
push   %rbx
mov    %rdi,%rbx
cmpb   $0x2d,(%rdi)
jne    113f <openfil+0xf>
cmpb   $0x0,0x1(%rbx)
je     1150 <openfil+0x20>
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <fopen@plt>
cmp    $0xffffffff,%eax
je     1158 <openfil+0x28>
pop    %rbx
ret
movl   $0x0,(%rsi)
pop    %rbx
ret
lea    0xea1(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@.str = [15 x i8] c"Can't open %s\0A\00"
define i32 @openfil(i8* %0, i32* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32*
store i8* %0, i8** %4
store i32* %1, i32** %5
%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, 45
br i1 %10, label %11, label %20
11: ; preds = %2
%12 = load i8*, i8** %4
%13 = getelementptr inbounds i8, i8* %12, i64 1
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %20
17: ; preds = %11
%18 = load i32*, i32** %5
%19 = getelementptr inbounds i32, i32* %18, i64 0
store i32 0, i32* %19
br label %29
20: ; preds = %11, %2
%21 = load i8*, i8** %4
%22 = load i32*, i32** %5
%23 = call i32 (i8*, i32*, ...) bitcast (i32 (...)* @fopen to i32 (i8*, i32*, ...)*)(i8* %21, i32* %22)
%24 = icmp eq i32 %23, -1
br i1 %24, label %25, label %28
25: ; preds = %20
%26 = load i8*, i8** %4
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* %26)
unreachable
28: ; preds = %20
br label %29
29: ; preds = %28, %17
%30 = load i32, i32* %3
ret i32 %30
}

LLVM IR (-O2):
@.str = [15 x i8] c"Can't open %s\0A\00"
define i32 @openfil(i8* %0, i32* %1) {
%3 = load i8, i8* %0
%4 = icmp eq i8 %3, 45
br i1 %4, label %5, label %10
5: ; preds = %2
%6 = getelementptr inbounds i8, i8* %0, i64 1
%7 = load i8, i8* %6
%8 = icmp eq i8 %7, 0
br i1 %8, label %9, label %10
9: ; preds = %5
store i32 0, i32* %1
br label %15
10: ; preds = %5, %2
%11 = tail call i32 (i8*, i32*, ...) bitcast (i32 (...)* @fopen to i32 (i8*, i32*, ...)*)(i8* %0, i32* %1)
%12 = icmp eq i32 %11, -1
br i1 %12, label %13, label %15
13: ; preds = %10
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* %0)
tail call void @exit(i32 1)
unreachable
15: ; preds = %10, %9
ret i32 undef
}