#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
scalar_t__ errno;
int /*<<< orphan*/ exit(scalar_t__);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *, ...);
int /*<<< orphan*/ stderr;
char *strerror(scalar_t__);
void oops(const char *msg) {
  if (errno != 0) {
    fprintf(stderr, "Oops: %s: %s\n", strerror(errno), msg);
  } else
    fprintf(stderr, "Oops: %s\n", msg);
  exit(errno);
}


x86 assembly (clang, -O0):
<oops>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    0x2e95(%rip),%rax
cmpq   $0x0,(%rax)
je     1185 <oops+0x55>
mov    0x2e8c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xc(%rbp)
mov    0x2e78(%rip),%rax
mov    (%rax),%rdi
call   1050 <strerror@plt>
mov    -0xc(%rbp),%edi
mov    %rax,%rdx
mov    -0x8(%rbp),%rcx
lea    0xe87(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    11a0 <oops+0x70>
mov    0x2e54(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xe75(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    0x2e31(%rip),%rax
mov    (%rax),%rdi
call   1040 <exit@plt>

x86 assembly (clang, -O2):
<oops>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%rbx
mov    0x2e9a(%rip),%r14
mov    (%r14),%rdi
mov    0x2e98(%rip),%rax
mov    (%rax),%ebp
test   %rdi,%rdi
jne    116a <oops+0x3a>
lea    0xeb8(%rip),%rsi
mov    %ebp,%edi
mov    %rbx,%rdx
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    (%r14),%rdi
call   1040 <exit@plt>
call   1050 <strerror@plt>
lea    0xe8a(%rip),%rsi
mov    %ebp,%edi
mov    %rax,%rdx
mov    %rbx,%rcx
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    (%r14),%rdi
call   1040 <exit@plt>

LLVM IR (-O0):
@errno = global i64 0
@stderr = global i32 0
@.str = [14 x i8] c"Oops: %s: %s\0A\00"
@.str.1 = [10 x i8] c"Oops: %s\0A\00"
define void @oops(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i64, i64* @errno
%4 = icmp ne i64 %3, 0
br i1 %4, label %5, label %11
5: ; preds = %1
%6 = load i32, i32* @stderr
%7 = load i64, i64* @errno
%8 = call i8* @strerror(i64 %7)
%9 = load i8*, i8** %2
%10 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %6, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* %8, i8* %9)
br label %15
11: ; preds = %1
%12 = load i32, i32* @stderr
%13 = load i8*, i8** %2
%14 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %12, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %13)
br label %15
15: ; preds = %11, %5
%16 = load i64, i64* @errno
%17 = call i32 @exit(i64 %16)
unreachable
}

LLVM IR (-O2):
@errno = global i64 0
@stderr = global i32 0
@.str = [14 x i8] c"Oops: %s: %s\0A\00"
@.str.1 = [10 x i8] c"Oops: %s\0A\00"
define void @oops(i8* %0) {
%2 = load i64, i64* @errno
%3 = icmp eq i64 %2, 0
%4 = load i32, i32* @stderr
br i1 %3, label %8, label %5
5: ; preds = %1
%6 = tail call i8* @strerror(i64 %2)
%7 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %4, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* %6, i8* %0)
br label %10
8: ; preds = %1
%9 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %4, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %0)
br label %10
10: ; preds = %8, %5
%11 = load i64, i64* @errno
%12 = tail call i32 @exit(i64 %11)
unreachable
}