#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 */
int /*<<< orphan*/ error_message(char *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
scalar_t__ getenv(char *);
int /*<<< orphan*/ stderr;
scalar_t__ strings_equal(char *, char *);
int little_endian() {
  char *ostype;
  if ((ostype = (char *)getenv("OSTYPE")) == NULL)
    error_message("environment variable OSTYPE not set!");
  if (strings_equal(ostype, "linux"))
    return 1;
  if (strings_equal(ostype, "hpux"))
    return 0;
  if (strings_equal(ostype, "solaris"))
    return 0;
  if (strings_equal(ostype, "darwin"))
    return 0;
  fprintf(stderr,
          "Your OSTYPE environment variable is defined but not recognized!\n");
  fprintf(
      stderr,
      "Consult and edit little_endian in swap_bytes.c and then recompile\n");
  fprintf(stderr,
          "the code if necessary... Contact dunc@naic.edu for further help\n");
  exit(0);
}


x86 assembly (clang, -O0):
<little_endian>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xea1(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
jne    117e <little_endian+0x2e>
lea    0xe8e(%rip),%rdi
call   1060 <error_message@plt>
mov    -0x10(%rbp),%rdi
lea    0xea3(%rip),%rsi
call   1040 <strings_equal@plt>
cmp    $0x0,%rax
je     11a4 <little_endian+0x54>
movl   $0x1,-0x4(%rbp)
jmp    125c <little_endian+0x10c>
mov    -0x10(%rbp),%rdi
lea    0xe83(%rip),%rsi
call   1040 <strings_equal@plt>
cmp    $0x0,%rax
je     11ca <little_endian+0x7a>
movl   $0x0,-0x4(%rbp)
jmp    125c <little_endian+0x10c>
mov    -0x10(%rbp),%rdi
lea    0xe62(%rip),%rsi
call   1040 <strings_equal@plt>
cmp    $0x0,%rax
je     11f0 <little_endian+0xa0>
movl   $0x0,-0x4(%rbp)
jmp    125c <little_endian+0x10c>
mov    -0x10(%rbp),%rdi
lea    0xe44(%rip),%rsi
call   1040 <strings_equal@plt>
cmp    $0x0,%rax
je     1216 <little_endian+0xc6>
movl   $0x0,-0x4(%rbp)
jmp    125c <little_endian+0x10c>
mov    0x2dc3(%rip),%rax
mov    (%rax),%edi
lea    0xe20(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2dae(%rip),%rax
mov    (%rax),%edi
lea    0xe4c(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2d99(%rip),%rax
mov    (%rax),%edi
lea    0xe7a(%rip),%rsi
call   1050 <fprintf@plt>
xor    %edi,%edi
call   1070 <exit@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<little_endian>:
push   %rbp
push   %rbx
push   %rax
lea    0xea6(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1173 <little_endian+0x23>
lea    0xe99(%rip),%rdi
call   1060 <error_message@plt>
lea    0xeb2(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strings_equal@plt>
mov    $0x1,%ebp
test   %rax,%rax
jne    11ca <little_endian+0x7a>
lea    0xe9f(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strings_equal@plt>
xor    %ebp,%ebp
test   %rax,%rax
jne    11ca <little_endian+0x7a>
lea    0xe8e(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strings_equal@plt>
test   %rax,%rax
jne    11ca <little_endian+0x7a>
lea    0xe82(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strings_equal@plt>
test   %rax,%rax
je     11d3 <little_endian+0x83>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
mov    0x2e06(%rip),%rbx
mov    (%rbx),%edi
lea    0xe63(%rip),%rsi
call   1050 <fprintf@plt>
mov    (%rbx),%edi
lea    0xe96(%rip),%rsi
call   1050 <fprintf@plt>
mov    (%rbx),%edi
lea    0xecb(%rip),%rsi
call   1050 <fprintf@plt>
xor    %edi,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [7 x i8] c"OSTYPE\00"
@.str.1 = [37 x i8] c"environment variable OSTYPE not set!\00"
@.str.2 = [6 x i8] c"linux\00"
@.str.3 = [5 x i8] c"hpux\00"
@.str.4 = [8 x i8] c"solaris\00"
@.str.5 = [7 x i8] c"darwin\00"
@stderr = global i32 0
@.str.6 = [65 x i8] c"Your OSTYPE environment variable is defined but not recognized!\0A\00"
@.str.7 = [67 x i8] c"Consult and edit little_endian in swap_bytes.c and then recompile\0A\00"
@.str.8 = [65 x i8] c"the code if necessary... Contact dunc@naic.edu for further help\0A\00"
define i32 @little_endian() {
%1 = alloca i32
%2 = alloca i8*
%3 = call i64 @getenv(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%4 = inttoptr i64 %3 to i8*
store i8* %4, i8** %2
%5 = icmp eq i8* %4, null
br i1 %5, label %6, label %8
6: ; preds = %0
%7 = call i32 @error_message(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0))
br label %8
8: ; preds = %6, %0
%9 = load i8*, i8** %2
%10 = call i64 @strings_equal(i8* %9, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%11 = icmp ne i64 %10, 0
br i1 %11, label %12, label %13
12: ; preds = %8
store i32 1, i32* %1
br label %36
13: ; preds = %8
%14 = load i8*, i8** %2
%15 = call i64 @strings_equal(i8* %14, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%16 = icmp ne i64 %15, 0
br i1 %16, label %17, label %18
17: ; preds = %13
store i32 0, i32* %1
br label %36
18: ; preds = %13
%19 = load i8*, i8** %2
%20 = call i64 @strings_equal(i8* %19, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
%21 = icmp ne i64 %20, 0
br i1 %21, label %22, label %23
22: ; preds = %18
store i32 0, i32* %1
br label %36
23: ; preds = %18
%24 = load i8*, i8** %2
%25 = call i64 @strings_equal(i8* %24, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
%26 = icmp ne i64 %25, 0
br i1 %26, label %27, label %28
27: ; preds = %23
store i32 0, i32* %1
br label %36
28: ; preds = %23
%29 = load i32, i32* @stderr
%30 = call i32 @fprintf(i32 %29, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.6, i64 0, i64 0))
%31 = load i32, i32* @stderr
%32 = call i32 @fprintf(i32 %31, i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str.7, i64 0, i64 0))
%33 = load i32, i32* @stderr
%34 = call i32 @fprintf(i32 %33, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.8, i64 0, i64 0))
%35 = call i32 @exit(i32 0)
unreachable
36: ; preds = %27, %22, %17, %12
%37 = load i32, i32* %1
ret i32 %37
}

LLVM IR (-O2):
@.str = [7 x i8] c"OSTYPE\00"
@.str.1 = [37 x i8] c"environment variable OSTYPE not set!\00"
@.str.2 = [6 x i8] c"linux\00"
@.str.3 = [5 x i8] c"hpux\00"
@.str.4 = [8 x i8] c"solaris\00"
@.str.5 = [7 x i8] c"darwin\00"
@stderr = global i32 0
@.str.6 = [65 x i8] c"Your OSTYPE environment variable is defined but not recognized!\0A\00"
@.str.7 = [67 x i8] c"Consult and edit little_endian in swap_bytes.c and then recompile\0A\00"
@.str.8 = [65 x i8] c"the code if necessary... Contact dunc@naic.edu for further help\0A\00"
define i32 @little_endian() {
%1 = tail call i64 @getenv(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%2 = inttoptr i64 %1 to i8*
%3 = icmp eq i64 %1, 0
br i1 %3, label %4, label %6
4: ; preds = %0
%5 = tail call i32 @error_message(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0))
br label %6
6: ; preds = %4, %0
%7 = tail call i64 @strings_equal(i8* %2, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %26
9: ; preds = %6
%10 = tail call i64 @strings_equal(i8* %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %26
12: ; preds = %9
%13 = tail call i64 @strings_equal(i8* %2, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %26
15: ; preds = %12
%16 = tail call i64 @strings_equal(i8* %2, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %26
18: ; preds = %15
%19 = load i32, i32* @stderr
%20 = tail call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.6, i64 0, i64 0))
%21 = load i32, i32* @stderr
%22 = tail call i32 @fprintf(i32 %21, i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str.7, i64 0, i64 0))
%23 = load i32, i32* @stderr
%24 = tail call i32 @fprintf(i32 %23, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.8, i64 0, i64 0))
%25 = tail call i32 @exit(i32 0)
unreachable
26: ; preds = %15, %12, %9, %6
%27 = phi i32 [ 1, %6 ], [ 0, %9 ], [ 0, %12 ], [ 0, %15 ]
ret i32 %27
}