#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__ Strchr(char *, char);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char **argv) {
  unsigned int test = 1;
  unsigned char *x;
  int macro = 0, debug = 0, help = 0, j;
  for (j = 1; j < argc; j++) {
    if (Strchr(argv[j], 'm'))
      macro = 1;
    if (Strchr(argv[j], 'd'))
      debug = 1;
    if (Strchr(argv[j], 'h'))
      help = 1;
  }
  if (help) {
    printf("-m	macro output\n"
           "-d	debug\n"
           "-h	help\n");
    return 0;
  }
  x = (unsigned char *)&test;
  if (*x == 0x00) {
    if (macro)
      printf("__BIG_ENDIAN_BITFIELD\n");
    else
      printf("big endian\n");
  } else if (*x == 0x01) {
    if (macro)
      printf("__LITTLE_ENDIAN_BITFIELD\n");
    else
      printf("little endian\n");
  } else {
    printf("\nWARNING!!! byteorder exception\n\n");
    debug = 1;
  }
  if (debug) {
    printf("sizeof(unsigned int) = %d\n", (int)sizeof(unsigned int));
    printf("unsigned int test = 1;\n");
    printf("in memory as: ");
    for (j = 0; j < sizeof(unsigned int); j++)
      printf("%02x ", x[j]);
    printf("\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
movl   $0x1,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11ed <main+0xcd>
mov    -0x10(%rbp),%rax
movslq -0x30(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    $0x6d,%esi
call   1040 <Strchr@plt>
cmp    $0x0,%rax
je     118c <main+0x6c>
movl   $0x1,-0x24(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x30(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    $0x64,%esi
call   1040 <Strchr@plt>
cmp    $0x0,%rax
je     11b3 <main+0x93>
movl   $0x1,-0x28(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x30(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    $0x68,%esi
call   1040 <Strchr@plt>
cmp    $0x0,%rax
je     11da <main+0xba>
movl   $0x1,-0x2c(%rbp)
jmp    11df <main+0xbf>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1159 <main+0x39>
cmpl   $0x0,-0x2c(%rbp)
je     1211 <main+0xf1>
lea    0xe02(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    133e <main+0x21e>
lea    -0x14(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movzbl (%rax),%eax
cmp    $0x0,%eax
jne    1259 <main+0x139>
cmpl   $0x0,-0x24(%rbp)
je     1246 <main+0x126>
lea    0xde8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1254 <main+0x134>
lea    0xdec(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12b3 <main+0x193>
mov    -0x20(%rbp),%rax
movzbl (%rax),%eax
cmp    $0x1,%eax
jne    1299 <main+0x179>
cmpl   $0x0,-0x24(%rbp)
je     1286 <main+0x166>
lea    0xdcb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1294 <main+0x174>
lea    0xdd2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12ae <main+0x18e>
lea    0xdce(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x28(%rbp)
jmp    12b3 <main+0x193>
cmpl   $0x0,-0x28(%rbp)
je     1337 <main+0x217>
lea    0xdcc(%rip),%rdi
mov    $0x4,%esi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xdd4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xdde(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x30(%rbp)
movslq -0x30(%rbp),%rax
cmp    $0x4,%rax
jae    1329 <main+0x209>
mov    -0x20(%rbp),%rax
movslq -0x30(%rbp),%rcx
movzbl (%rax,%rcx,1),%esi
lea    0xdbe(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    12f3 <main+0x1d3>
lea    0xd5e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %r12d,%r12d
cmp    $0x2,%edi
jl     11ec <main+0xac>
mov    %rsi,%r15
mov    %edi,%eax
mov    %rax,(%rsp)
xor    %ebx,%ebx
mov    $0x1,%ebp
mov    $0x1,%r13d
xor    %r12d,%r12d
xor    %r14d,%r14d
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    (%r15,%rbp,8),%rdi
mov    $0x6d,%esi
call   1060 <Strchr@plt>
test   %rax,%rax
cmovne %r13d,%r14d
mov    (%r15,%rbp,8),%rdi
mov    $0x64,%esi
call   1060 <Strchr@plt>
test   %rax,%rax
cmovne %r13d,%r12d
mov    (%r15,%rbp,8),%rdi
mov    $0x68,%esi
call   1060 <Strchr@plt>
test   %rax,%rax
cmovne %r13d,%ebx
add    $0x1,%rbp
cmp    %rbp,(%rsp)
jne    1180 <main+0x40>
test   %ebx,%ebx
je     11de <main+0x9e>
lea    0xe9a(%rip),%rdi
call   1040 <puts@plt>
jmp    126e <main+0x12e>
test   %r14d,%r14d
je     11ec <main+0xac>
lea    0xe6b(%rip),%rdi
jmp    11f3 <main+0xb3>
lea    0xe54(%rip),%rdi
call   1040 <puts@plt>
test   %r12d,%r12d
je     126e <main+0x12e>
lea    0xdfc(%rip),%rdi
mov    $0x4,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe19(%rip),%rdi
call   1040 <puts@plt>
lea    0xdf8(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xdf9(%rip),%rbx
mov    %rbx,%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [34 x i8] c"-m\09macro output\0A-d\09debug\0A-h\09help\0A\00"
@.str.1 = [23 x i8] c"__BIG_ENDIAN_BITFIELD\0A\00"
@.str.2 = [12 x i8] c"big endian\0A\00"
@.str.3 = [26 x i8] c"__LITTLE_ENDIAN_BITFIELD\0A\00"
@.str.4 = [15 x i8] c"little endian\0A\00"
@.str.5 = [34 x i8] c"\0AWARNING!!! byteorder exception\0A\0A\00"
@.str.6 = [27 x i8] c"sizeof(unsigned int) = %d\0A\00"
@.str.7 = [24 x i8] c"unsigned int test = 1;\0A\00"
@.str.8 = [15 x i8] c"in memory as: \00"
@.str.9 = [6 x i8] c"%02x \00"
@.str.10 = [2 x i8] c"\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1, i32* %6
store i32 0, i32* %8
store i32 0, i32* %9
store i32 0, i32* %10
store i32 1, i32* %11
br label %12
12: ; preds = %44, %2
%13 = load i32, i32* %11
%14 = load i32, i32* %4
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %47
16: ; preds = %12
%17 = load i8**, i8*** %5
%18 = load i32, i32* %11
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8*, i8** %17, i64 %19
%21 = load i8*, i8** %20
%22 = call i64 @Strchr(i8* %21, i8 signext 109)
%23 = icmp ne i64 %22, 0
br i1 %23, label %24, label %25
24: ; preds = %16
store i32 1, i32* %8
br label %25
25: ; preds = %24, %16
%26 = load i8**, i8*** %5
%27 = load i32, i32* %11
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8*, i8** %26, i64 %28
%30 = load i8*, i8** %29
%31 = call i64 @Strchr(i8* %30, i8 signext 100)
%32 = icmp ne i64 %31, 0
br i1 %32, label %33, label %34
33: ; preds = %25
store i32 1, i32* %9
br label %34
34: ; preds = %33, %25
%35 = load i8**, i8*** %5
%36 = load i32, i32* %11
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i8*, i8** %35, i64 %37
%39 = load i8*, i8** %38
%40 = call i64 @Strchr(i8* %39, i8 signext 104)
%41 = icmp ne i64 %40, 0
br i1 %41, label %42, label %43
42: ; preds = %34
store i32 1, i32* %10
br label %43
43: ; preds = %42, %34
br label %44
44: ; preds = %43
%45 = load i32, i32* %11
%46 = add nsw i32 %45, 1
store i32 %46, i32* %11
br label %12
47: ; preds = %12
%48 = load i32, i32* %10
%49 = icmp ne i32 %48, 0
br i1 %49, label %50, label %52
50: ; preds = %47
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %3
br label %107
52: ; preds = %47
%53 = bitcast i32* %6 to i8*
store i8* %53, i8** %7
%54 = load i8*, i8** %7
%55 = load i8, i8* %54
%56 = zext i8 %55 to i32
%57 = icmp eq i32 %56, 0
br i1 %57, label %58, label %66
58: ; preds = %52
%59 = load i32, i32* %8
%60 = icmp ne i32 %59, 0
br i1 %60, label %61, label %63
61: ; preds = %58
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
br label %65
63: ; preds = %58
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
br label %65
65: ; preds = %63, %61
br label %82
66: ; preds = %52
%67 = load i8*, i8** %7
%68 = load i8, i8* %67
%69 = zext i8 %68 to i32
%70 = icmp eq i32 %69, 1
br i1 %70, label %71, label %79
71: ; preds = %66
%72 = load i32, i32* %8
%73 = icmp ne i32 %72, 0
br i1 %73, label %74, label %76
74: ; preds = %71
%75 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0))
br label %78
76: ; preds = %71
%77 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
br label %78
78: ; preds = %76, %74
br label %81
79: ; preds = %66
%80 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.5, i64 0, i64 0))
store i32 1, i32* %9
br label %81
81: ; preds = %79, %78
br label %82
82: ; preds = %81, %65
%83 = load i32, i32* %9
%84 = icmp ne i32 %83, 0
br i1 %84, label %85, label %106
85: ; preds = %82
%86 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.6, i64 0, i64 0), i32 4)
%87 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.7, i64 0, i64 0))
%88 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i64 0, i64 0))
store i32 0, i32* %11
br label %89
89: ; preds = %101, %85
%90 = load i32, i32* %11
%91 = sext i32 %90 to i64
%92 = icmp ult i64 %91, 4
br i1 %92, label %93, label %104
93: ; preds = %89
%94 = load i8*, i8** %7
%95 = load i32, i32* %11
%96 = sext i32 %95 to i64
%97 = getelementptr inbounds i8, i8* %94, i64 %96
%98 = load i8, i8* %97
%99 = zext i8 %98 to i32
%100 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0), i32 %99)
br label %101
101: ; preds = %93
%102 = load i32, i32* %11
%103 = add nsw i32 %102, 1
store i32 %103, i32* %11
br label %89
104: ; preds = %89
%105 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0))
br label %106
106: ; preds = %104, %82
store i32 0, i32* %3
br label %107
107: ; preds = %106, %50
%108 = load i32, i32* %3
ret i32 %108
}

LLVM IR (-O2):
@.str.6 = [27 x i8] c"sizeof(unsigned int) = %d\0A\00"
@.str.8 = [15 x i8] c"in memory as: \00"
@.str.9 = [6 x i8] c"%02x \00"
@str.11 = [23 x i8] c"unsigned int test = 1;\00"
@str.12 = [14 x i8] c"little endian\00"
@str.13 = [25 x i8] c"__LITTLE_ENDIAN_BITFIELD\00"
@str.16 = [33 x i8] c"-m\09macro output\0A-d\09debug\0A-h\09help\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 1
br i1 %3, label %4, label %32
4: ; preds = %2
%5 = zext i32 %0 to i64
br label %6
6: ; preds = %4, %6
%7 = phi i64 [ 1, %4 ], [ %24, %6 ]
%8 = phi i32 [ 0, %4 ], [ %23, %6 ]
%9 = phi i32 [ 0, %4 ], [ %19, %6 ]
%10 = phi i32 [ 0, %4 ], [ %15, %6 ]
%11 = getelementptr inbounds i8*, i8** %1, i64 %7
%12 = load i8*, i8** %11
%13 = tail call i64 @Strchr(i8* %12, i8 signext 109)
%14 = icmp eq i64 %13, 0
%15 = select i1 %14, i32 %10, i32 1
%16 = load i8*, i8** %11
%17 = tail call i64 @Strchr(i8* %16, i8 signext 100)
%18 = icmp eq i64 %17, 0
%19 = select i1 %18, i32 %9, i32 1
%20 = load i8*, i8** %11
%21 = tail call i64 @Strchr(i8* %20, i8 signext 104)
%22 = icmp eq i64 %21, 0
%23 = select i1 %22, i32 %8, i32 1
%24 = add nuw nsw i64 %7, 1
%25 = icmp eq i64 %24, %5
br i1 %25, label %26, label %6
26: ; preds = %6
%27 = icmp eq i32 %23, 0
br i1 %27, label %30, label %28
28: ; preds = %26
%29 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str.16, i64 0, i64 0))
br label %48
30: ; preds = %26
%31 = icmp eq i32 %15, 0
br i1 %31, label %32, label %34
32: ; preds = %2, %30
%33 = phi i32 [ %19, %30 ], [ 0, %2 ]
br label %34
34: ; preds = %30, %32
%35 = phi i8* [ getelementptr inbounds ([14 x i8], [14 x i8]* @str.12, i64 0, i64 0), %32 ], [ getelementptr inbounds ([25 x i8], [25 x i8]* @str.13, i64 0, i64 0), %30 ]
%36 = phi i32 [ %33, %32 ], [ %19, %30 ]
%37 = tail call i32 @puts(i8* dereferenceable(1) %35)
%38 = icmp eq i32 %36, 0
br i1 %38, label %48, label %39
39: ; preds = %34
%40 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.6, i64 0, i64 0), i32 4)
%41 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.11, i64 0, i64 0))
%42 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i64 0, i64 0))
%43 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0), i32 1)
%44 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0), i32 0)
%45 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0), i32 0)
%46 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0), i32 0)
%47 = tail call i32 @putchar(i32 10)
br label %48
48: ; preds = %34, %39, %28
ret i32 0
}