#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 */
typedef int /*<<< orphan*/ c;

/* Variables and functions */
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, unsigned int);
int /*<<< orphan*/ memcpy(unsigned int *, unsigned char *, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
scalar_t__ strcmp(char *, char *);
int main(int argc, char **argv) {
  unsigned int c;
  unsigned char cbuf[sizeof(c)];
  int i;
  int outform = 1;
  if ((argc > 1) && (strcmp(argv[1], "--configh") == 0))
    outform = 0;
  for (i = 0; (i < sizeof(c)); i++) {
    cbuf[i] = (i % 2);
  }
  memcpy(&c, cbuf, sizeof(c));
  if (c == 65537) {
    if (outform == 0)
      printf("#ifndef XYMON_BIG_ENDIAN\n#define XYMON_BIG_ENDIAN\n#endif\n");
    else
      printf(" -DXYMON_BIG_ENDIAN");
  } else if (c == 16777472) {
    if (outform == 0)
      printf(
          "#ifndef XYMON_LITTLE_ENDIAN\n#define XYMON_LITTLE_ENDIAN\n#endif\n");
    else
      printf(" -DXYMON_LITTLE_ENDIAN");
  } else {
    fprintf(stderr, "UNKNOWN ENDIANNESS! testvalue is %u\n", c);
  }
  fflush(stdout);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x20(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    119c <main+0x4c>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe7a(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    119c <main+0x4c>
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x1c(%rbp)
movslq -0x1c(%rbp),%rax
cmp    $0x4,%rax
jae    11d4 <main+0x84>
mov    -0x1c(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %dl,%cl
movslq -0x1c(%rbp),%rax
mov    %cl,-0x18(%rbp,%rax,1)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11a3 <main+0x53>
lea    -0x18(%rbp),%rsi
lea    -0x14(%rbp),%rdi
mov    $0x4,%edx
call   1060 <memcpy@plt>
cmpl   $0x10001,-0x14(%rbp)
jne    121f <main+0xcf>
cmpl   $0x0,-0x20(%rbp)
jne    120e <main+0xbe>
lea    0xe06(%rip),%rdi
call   1030 <printf@plt>
jmp    121a <main+0xca>
lea    0xe2f(%rip),%rdi
call   1030 <printf@plt>
jmp    1275 <main+0x125>
cmpl   $0x1000100,-0x14(%rbp)
jne    1258 <main+0x108>
cmpl   $0x0,-0x20(%rbp)
jne    1247 <main+0xf7>
lea    0xe1b(%rip),%rdi
call   1030 <printf@plt>
jmp    1253 <main+0x103>
lea    0xe4a(%rip),%rdi
call   1030 <printf@plt>
jmp    1270 <main+0x120>
mov    0x2d81(%rip),%rax
mov    (%rax),%edi
mov    -0x14(%rbp),%edx
lea    0xe44(%rip),%rsi
call   1050 <fprintf@plt>
jmp    1275 <main+0x125>
mov    0x2d5c(%rip),%rax
mov    (%rax),%edi
call   1070 <fflush@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
cmp    $0x2,%edi
jl     1182 <main+0x22>
mov    0x8(%rsi),%rdi
lea    0xe8b(%rip),%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
sete   %bl
jmp    1184 <main+0x24>
xor    %ebx,%ebx
movl   $0x1000100,0xc(%rsp)
01
lea    0x8(%rsp),%rdi
lea    0xc(%rsp),%rsi
mov    $0x4,%edx
call   1070 <memcpy@plt>
mov    0x8(%rsp),%edx
cmp    $0x1000100,%edx
je     11c6 <main+0x66>
cmp    $0x10001,%edx
jne    11d8 <main+0x78>
test   %bl,%bl
je     11ef <main+0x8f>
lea    0xeda(%rip),%rdi
call   1030 <puts@plt>
jmp    1204 <main+0xa4>
test   %bl,%bl
je     11f8 <main+0x98>
lea    0xe89(%rip),%rdi
call   1030 <puts@plt>
jmp    1204 <main+0xa4>
mov    0x2e01(%rip),%rax
mov    (%rax),%edi
lea    0xe4d(%rip),%rsi
call   1060 <fprintf@plt>
jmp    1204 <main+0xa4>
lea    0xe14(%rip),%rdi
jmp    11ff <main+0x9f>
lea    0xe1f(%rip),%rdi
call   1040 <printf@plt>
mov    0x2dcd(%rip),%rax
mov    (%rax),%edi
call   1080 <fflush@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [10 x i8] c"--configh\00"
@.str.1 = [58 x i8] c"#ifndef XYMON_BIG_ENDIAN\0A#define XYMON_BIG_ENDIAN\0A#endif\0A\00"
@.str.2 = [20 x i8] c" -DXYMON_BIG_ENDIAN\00"
@.str.3 = [64 x i8] c"#ifndef XYMON_LITTLE_ENDIAN\0A#define XYMON_LITTLE_ENDIAN\0A#endif\0A\00"
@.str.4 = [23 x i8] c" -DXYMON_LITTLE_ENDIAN\00"
@stderr = global i32 0
@.str.5 = [37 x i8] c"UNKNOWN ENDIANNESS! testvalue is %u\0A\00"
@stdout = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca [4 x i8]
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1, i32* %9
%10 = load i32, i32* %4
%11 = icmp sgt i32 %10, 1
br i1 %11, label %12, label %19
12: ; preds = %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
%16 = call i64 @strcmp(i8* %15, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %19
18: ; preds = %12
store i32 0, i32* %9
br label %19
19: ; preds = %18, %12, %2
store i32 0, i32* %8
br label %20
20: ; preds = %31, %19
%21 = load i32, i32* %8
%22 = sext i32 %21 to i64
%23 = icmp ult i64 %22, 4
br i1 %23, label %24, label %34
24: ; preds = %20
%25 = load i32, i32* %8
%26 = srem i32 %25, 2
%27 = trunc i32 %26 to i8
%28 = load i32, i32* %8
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [4 x i8], [4 x i8]* %7, i64 0, i64 %29
store i8 %27, i8* %30
br label %31
31: ; preds = %24
%32 = load i32, i32* %8
%33 = add nsw i32 %32, 1
store i32 %33, i32* %8
br label %20
34: ; preds = %20
%35 = getelementptr inbounds [4 x i8], [4 x i8]* %7, i64 0, i64 0
%36 = call i32 @memcpy(i32* %6, i8* %35, i32 4)
%37 = load i32, i32* %6
%38 = icmp eq i32 %37, 65537
br i1 %38, label %39, label %47
39: ; preds = %34
%40 = load i32, i32* %9
%41 = icmp eq i32 %40, 0
br i1 %41, label %42, label %44
42: ; preds = %39
%43 = call i32 @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.1, i64 0, i64 0))
br label %46
44: ; preds = %39
%45 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
br label %46
46: ; preds = %44, %42
br label %63
47: ; preds = %34
%48 = load i32, i32* %6
%49 = icmp eq i32 %48, 16777472
br i1 %49, label %50, label %58
50: ; preds = %47
%51 = load i32, i32* %9
%52 = icmp eq i32 %51, 0
br i1 %52, label %53, label %55
53: ; preds = %50
%54 = call i32 @printf(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str.3, i64 0, i64 0))
br label %57
55: ; preds = %50
%56 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0))
br label %57
57: ; preds = %55, %53
br label %62
58: ; preds = %47
%59 = load i32, i32* @stderr
%60 = load i32, i32* %6
%61 = call i32 @fprintf(i32 %59, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.5, i64 0, i64 0), i32 %60)
br label %62
62: ; preds = %58, %57
br label %63
63: ; preds = %62, %46
%64 = load i32, i32* @stdout
%65 = call i32 @fflush(i32 %64)
ret i32 0
}

LLVM IR (-O2):
@.str = [10 x i8] c"--configh\00"
@.str.2 = [20 x i8] c" -DXYMON_BIG_ENDIAN\00"
@.str.4 = [23 x i8] c" -DXYMON_LITTLE_ENDIAN\00"
@stderr = global i32 0
@.str.5 = [37 x i8] c"UNKNOWN ENDIANNESS! testvalue is %u\0A\00"
@stdout = global i32 0
@str = [63 x i8] c"#ifndef XYMON_LITTLE_ENDIAN\0A#define XYMON_LITTLE_ENDIAN\0A#endif\00"
@str.6 = [57 x i8] c"#ifndef XYMON_BIG_ENDIAN\0A#define XYMON_BIG_ENDIAN\0A#endif\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca [4 x i8]
%5 = bitcast i32* %3 to i8*
%6 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 0
%7 = icmp sgt i32 %0, 1
br i1 %7, label %8, label %13
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i64 @strcmp(i8* %10, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
br label %13
13: ; preds = %8, %2
%14 = phi i1 [ false, %2 ], [ %12, %8 ]
store i8 0, i8* %6
%15 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 1
store i8 1, i8* %15
%16 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 2
store i8 0, i8* %16
%17 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 3
store i8 1, i8* %17
%18 = call i32 @memcpy(i32* %3, i8* %6, i32 4)
%19 = load i32, i32* %3
switch i32 %19, label %30 [
i32 65537, label %20
i32 16777472, label %25
]
20: ; preds = %13
br i1 %14, label %21, label %23
21: ; preds = %20
%22 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([57 x i8], [57 x i8]* @str.6, i64 0, i64 0))
br label %33
23: ; preds = %20
%24 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
br label %33
25: ; preds = %13
br i1 %14, label %26, label %28
26: ; preds = %25
%27 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([63 x i8], [63 x i8]* @str, i64 0, i64 0))
br label %33
28: ; preds = %25
%29 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0))
br label %33
30: ; preds = %13
%31 = load i32, i32* @stderr
%32 = call i32 @fprintf(i32 %31, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.5, i64 0, i64 0), i32 %19)
br label %33
33: ; preds = %30, %28, %26, %21, %23
%34 = load i32, i32* @stdout
%35 = call i32 @fflush(i32 %34)
ret i32 0
}