long long get_entry_fatal(const char *name, const char *buf) {
  long long val = get_entry(name, buf);
  if (val < 0) {
    warn("%s: fatal error, dumping buffer for later diagnosis:\n%s", __func__,
         buf);
    fatal(104, "could not find entry '%s' in /proc/meminfo: %s\n", name,
          strerror((int)-val));
  }
  return val;
}


x86 assembly (clang, -O0):
<get_entry_fatal>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0x0,%al
call   1030 <get_entry@plt>
cltq
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jge    11b8 <get_entry_fatal+0x78>
mov    -0x10(%rbp),%rdx
lea    0xe85(%rip),%rdi
lea    0xeb6(%rip),%rsi
mov    $0x0,%al
call   1040 <warn@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
xor    %eax,%eax
sub    -0x18(%rbp),%rax
mov    %eax,%edi
call   1050 <strerror@plt>
mov    -0x20(%rbp),%rdx
mov    %rax,%rcx
mov    $0x68,%edi
lea    0xe97(%rip),%rsi
mov    $0x0,%al
call   1060 <fatal@plt>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_entry_fatal>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    %rdi,%r14
xor    %eax,%eax
call   1030 <get_entry@plt>
mov    %eax,%ebp
test   %eax,%eax
jns    1191 <get_entry_fatal+0x51>
lea    0xea2(%rip),%rdi
lea    0xed3(%rip),%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1040 <warn@plt>
mov    %ebp,%edi
neg    %edi
call   1050 <strerror@plt>
lea    0xec9(%rip),%rsi
mov    $0x68,%edi
mov    %r14,%rdx
mov    %rax,%rcx
xor    %eax,%eax
call   1060 <fatal@plt>
movslq %ebp,%rax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [56 x i8] c"%s: fatal error, dumping buffer for later diagnosis:\0A%s\00"
@__func__.get_entry_fatal = [16 x i8] c"get_entry_fatal\00"
@.str.1 = [48 x i8] c"could not find entry '%s' in /proc/meminfo: %s\0A\00"
define i64 @get_entry_fatal(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i64
store i8* %0, i8** %3
store i8* %1, i8** %4
%6 = load i8*, i8** %3
%7 = load i8*, i8** %4
%8 = call i32 (i8*, i8*, ...) bitcast (i32 (...)* @get_entry to i32 (i8*, i8*, ...)*)(i8* %6, i8* %7)
%9 = sext i32 %8 to i64
store i64 %9, i64* %5
%10 = load i64, i64* %5
%11 = icmp slt i64 %10, 0
br i1 %11, label %12, label %21
12: ; preds = %2
%13 = load i8*, i8** %4
%14 = call i32 (i8*, i8*, i8*, ...) bitcast (i32 (...)* @warn to i32 (i8*, i8*, i8*, ...)*)(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @__func__.get_entry_fatal, i64 0, i64 0), i8* %13)
%15 = load i8*, i8** %3
%16 = load i64, i64* %5
%17 = sub nsw i64 0, %16
%18 = trunc i64 %17 to i32
%19 = call i8* @strerror(i32 %18)
%20 = call i32 (i32, i8*, i8*, i8*, ...) bitcast (i32 (...)* @fatal to i32 (i32, i8*, i8*, i8*, ...)*)(i32 104, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.1, i64 0, i64 0), i8* %15, i8* %19)
br label %21
21: ; preds = %12, %2
%22 = load i64, i64* %5
ret i64 %22
}

LLVM IR (-O2):
@.str = [56 x i8] c"%s: fatal error, dumping buffer for later diagnosis:\0A%s\00"
@__func__.get_entry_fatal = [16 x i8] c"get_entry_fatal\00"
@.str.1 = [48 x i8] c"could not find entry '%s' in /proc/meminfo: %s\0A\00"
define i64 @get_entry_fatal(i8* %0, i8* %1) {
%3 = tail call i32 (i8*, i8*, ...) bitcast (i32 (...)* @get_entry to i32 (i8*, i8*, ...)*)(i8* %0, i8* %1)
%4 = icmp slt i32 %3, 0
br i1 %4, label %5, label %10
5: ; preds = %2
%6 = tail call i32 (i8*, i8*, i8*, ...) bitcast (i32 (...)* @warn to i32 (i8*, i8*, i8*, ...)*)(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @__func__.get_entry_fatal, i64 0, i64 0), i8* %1)
%7 = sub i32 0, %3
%8 = tail call i8* @strerror(i32 %7)
%9 = tail call i32 (i32, i8*, i8*, i8*, ...) bitcast (i32 (...)* @fatal to i32 (i32, i8*, i8*, i8*, ...)*)(i32 104, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.1, i64 0, i64 0), i8* %0, i8* %8)
br label %10
10: ; preds = %5, %2
%11 = sext i32 %3 to i64
ret i64 %11
}