#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*/ fprintf(int /*<<< orphan*/, char *, ...);
char *getenv(char *);
int /*<<< orphan*/ stderr;
char *strerror(scalar_t__);
scalar_t__ strstr(char *, char *);
void check_shell() {
  char *shell = getenv("SHELL");
  if (errno) {
    fprintf(stderr,
            "Could not get the shell. This isn't anything to worry about. "
            "Error: %s",
            strerror(errno));
  } else if (!shell) {
    fprintf(stderr, "Could not determine the shell we're running under. This "
                    "isn't anything to worry about.\n");
  } else if (!(strstr(shell, "/bash") || strstr(shell, "/sh"))) {
    fprintf(
        stderr,
        "This program works best with a bourne shell (sh or bash). \n"
        "Using the one you've chosen (%s) may cause issues. \n"
        "I'm not going to quit because you're an adult and can handle the \n"
        "consequences of what you're doing.\n",
        shell);
  }
}


x86 assembly (clang, -O0):
<check_shell>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xeb1(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x8(%rbp)
mov    0x2e79(%rip),%rax
cmpq   $0x0,(%rax)
je     119d <check_shell+0x5d>
mov    0x2e70(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xc(%rbp)
mov    0x2e5c(%rip),%rax
mov    (%rax),%rdi
call   1050 <strerror@plt>
mov    -0xc(%rbp),%edi
mov    %rax,%rdx
lea    0xe75(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
jmp    121d <check_shell+0xdd>
cmpq   $0x0,-0x8(%rbp)
jne    11c4 <check_shell+0x84>
mov    0x2e31(%rip),%rax
mov    (%rax),%edi
lea    0xe95(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
jmp    1218 <check_shell+0xd8>
mov    -0x8(%rbp),%rdi
lea    0xed6(%rip),%rsi
call   1060 <strstr@plt>
cmp    $0x0,%rax
jne    1213 <check_shell+0xd3>
mov    -0x8(%rbp),%rdi
lea    0xec2(%rip),%rsi
call   1060 <strstr@plt>
cmp    $0x0,%rax
jne    1213 <check_shell+0xd3>
mov    0x2de1(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xea3(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
jmp    1218 <check_shell+0xd8>
jmp    121d <check_shell+0xdd>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_shell>:
push   %rbx
lea    0xeb8(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,%rbx
mov    0x2e81(%rip),%rax
mov    (%rax),%rdi
test   %rdi,%rdi
je     1181 <check_shell+0x41>
mov    0x2e7a(%rip),%rax
mov    (%rax),%ebx
call   1050 <strerror@plt>
lea    0xe92(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
xor    %eax,%eax
pop    %rbx
jmp    1040 <fprintf@plt>
test   %rbx,%rbx
je     11b0 <check_shell+0x70>
lea    0xf18(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strstr@plt>
test   %rax,%rax
jne    11ae <check_shell+0x6e>
lea    0xf0a(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strstr@plt>
test   %rax,%rax
je     11c8 <check_shell+0x88>
pop    %rbx
ret
mov    0x2e29(%rip),%rax
mov    (%rax),%edi
lea    0xe8d(%rip),%rsi
xor    %eax,%eax
pop    %rbx
jmp    1040 <fprintf@plt>
mov    0x2e11(%rip),%rax
mov    (%rax),%edi
lea    0xed7(%rip),%rsi
mov    %rbx,%rdx
jmp    1179 <check_shell+0x39>

LLVM IR (-O0):
@.str = [6 x i8] c"SHELL\00"
@errno = global i64 0
@stderr = global i32 0
@.str.1 = [71 x i8] c"Could not get the shell. This isn't anything to worry about. Error: %s\00"
@.str.2 = [88 x i8] c"Could not determine the shell we're running under. This isn't anything to worry about.\0A\00"
@.str.3 = [6 x i8] c"/bash\00"
@.str.4 = [4 x i8] c"/sh\00"
@.str.5 = [213 x i8] c"This program works best with a bourne shell (sh or bash). \0AUsing the one you've chosen (%s) may cause issues. \0AI'm not going to quit because you're an adult and can handle the \0Aconsequences of what you're doing.\0A\00"
define void @check_shell() {
%1 = alloca i8*
%2 = call i8* @getenv(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
store i8* %2, i8** %1
%3 = load i64, i64* @errno
%4 = icmp ne i64 %3, 0
br i1 %4, label %5, label %10
5: ; preds = %0
%6 = load i32, i32* @stderr
%7 = load i64, i64* @errno
%8 = call i8* @strerror(i64 %7)
%9 = call i32 (i32, i8*, ...) @fprintf(i32 %6, i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str.1, i64 0, i64 0), i8* %8)
br label %30
10: ; preds = %0
%11 = load i8*, i8** %1
%12 = icmp ne i8* %11, null
br i1 %12, label %16, label %13
13: ; preds = %10
%14 = load i32, i32* @stderr
%15 = call i32 (i32, i8*, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([88 x i8], [88 x i8]* @.str.2, i64 0, i64 0))
br label %29
16: ; preds = %10
%17 = load i8*, i8** %1
%18 = call i64 @strstr(i8* %17, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%19 = icmp ne i64 %18, 0
br i1 %19, label %28, label %20
20: ; preds = %16
%21 = load i8*, i8** %1
%22 = call i64 @strstr(i8* %21, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%23 = icmp ne i64 %22, 0
br i1 %23, label %28, label %24
24: ; preds = %20
%25 = load i32, i32* @stderr
%26 = load i8*, i8** %1
%27 = call i32 (i32, i8*, ...) @fprintf(i32 %25, i8* getelementptr inbounds ([213 x i8], [213 x i8]* @.str.5, i64 0, i64 0), i8* %26)
br label %28
28: ; preds = %24, %20, %16
br label %29
29: ; preds = %28, %13
br label %30
30: ; preds = %29, %5
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"SHELL\00"
@errno = global i64 0
@stderr = global i32 0
@.str.1 = [71 x i8] c"Could not get the shell. This isn't anything to worry about. Error: %s\00"
@.str.2 = [88 x i8] c"Could not determine the shell we're running under. This isn't anything to worry about.\0A\00"
@.str.3 = [6 x i8] c"/bash\00"
@.str.4 = [4 x i8] c"/sh\00"
@.str.5 = [213 x i8] c"This program works best with a bourne shell (sh or bash). \0AUsing the one you've chosen (%s) may cause issues. \0AI'm not going to quit because you're an adult and can handle the \0Aconsequences of what you're doing.\0A\00"
define void @check_shell() {
%1 = tail call i8* @getenv(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%2 = load i64, i64* @errno
%3 = icmp eq i64 %2, 0
br i1 %3, label %8, label %4
4: ; preds = %0
%5 = load i32, i32* @stderr
%6 = tail call i8* @strerror(i64 %2)
%7 = tail call i32 (i32, i8*, ...) @fprintf(i32 %5, i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str.1, i64 0, i64 0), i8* %6)
br label %22
8: ; preds = %0
%9 = icmp eq i8* %1, null
br i1 %9, label %10, label %13
10: ; preds = %8
%11 = load i32, i32* @stderr
%12 = tail call i32 (i32, i8*, ...) @fprintf(i32 %11, i8* getelementptr inbounds ([88 x i8], [88 x i8]* @.str.2, i64 0, i64 0))
br label %22
13: ; preds = %8
%14 = tail call i64 @strstr(i8* %1, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %22
16: ; preds = %13
%17 = tail call i64 @strstr(i8* %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %22
19: ; preds = %16
%20 = load i32, i32* @stderr
%21 = tail call i32 (i32, i8*, ...) @fprintf(i32 %20, i8* getelementptr inbounds ([213 x i8], [213 x i8]* @.str.5, i64 0, i64 0), i8* %1)
br label %22
22: ; preds = %10, %19, %16, %13, %4
ret void
}