#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 inet_addr(char *);
int /*<<< orphan*/ printf(char *);
int main() {
  int ip = inet_addr("255.128.0.192");
  switch (ip) {
  case 0xC00080FF:
    printf("LITTLE_ENDIAN\n");
    break;
  case 0xFF8000C0:
    printf("BIG_ENDIAN\n");
    break;
  default:
    printf("UNKNOWN\n");
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
call   1040 <inet_addr@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
sub    $0xc00080ff,%eax
je     1167 <main+0x47>
jmp    1154 <main+0x34>
mov    -0xc(%rbp),%eax
sub    $0xff8000c0,%eax
je     1178 <main+0x58>
jmp    1189 <main+0x69>
lea    0xea0(%rip),%rdi
call   1030 <printf@plt>
jmp    11a1 <main+0x81>
lea    0xe9e(%rip),%rdi
call   1030 <printf@plt>
jmp    11a1 <main+0x81>
lea    0xe99(%rip),%rdi
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11a8 <main+0x88>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xed8(%rip),%rdi
call   1040 <inet_addr@plt>
xor    %ebx,%ebx
cmp    $0xc00080ff,%eax
je     1146 <main+0x26>
cmp    $0xff8000c0,%eax
jne    114f <main+0x2f>
lea    0xeca(%rip),%rdi
jmp    115b <main+0x3b>
lea    0xecc(%rip),%rdi
jmp    115b <main+0x3b>
mov    $0x1,%ebx
lea    0xecc(%rip),%rdi
call   1030 <puts@plt>
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [14 x i8] c"255.128.0.192\00"
@.str.1 = [15 x i8] c"LITTLE_ENDIAN\0A\00"
@.str.2 = [12 x i8] c"BIG_ENDIAN\0A\00"
@.str.3 = [9 x i8] c"UNKNOWN\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
%3 = call i32 @inet_addr(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
store i32 %3, i32* %2
%4 = load i32, i32* %2
switch i32 %4, label %9 [
i32 -1073708801, label %5
i32 -8388416, label %7
]
5: ; preds = %0
%6 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
br label %11
7: ; preds = %0
%8 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
br label %11
9: ; preds = %0
%10 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
store i32 1, i32* %1
br label %12
11: ; preds = %7, %5
store i32 0, i32* %1
br label %12
12: ; preds = %11, %9
%13 = load i32, i32* %1
ret i32 %13
}

LLVM IR (-O2):
@.str = [14 x i8] c"255.128.0.192\00"
@str = [11 x i8] c"BIG_ENDIAN\00"
@str.4 = [14 x i8] c"LITTLE_ENDIAN\00"
@str.5 = [8 x i8] c"UNKNOWN\00"
define i32 @main() {
%1 = tail call i32 @inet_addr(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
switch i32 %1, label %3 [
i32 -1073708801, label %4
i32 -8388416, label %2
]
2: ; preds = %0
br label %4
3: ; preds = %0
br label %4
4: ; preds = %0, %2, %3
%5 = phi i8* [ getelementptr inbounds ([11 x i8], [11 x i8]* @str, i64 0, i64 0), %2 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @str.5, i64 0, i64 0), %3 ], [ getelementptr inbounds ([14 x i8], [14 x i8]* @str.4, i64 0, i64 0), %0 ]
%6 = phi i32 [ 0, %2 ], [ 1, %3 ], [ 0, %0 ]
%7 = tail call i32 @puts(i8* dereferenceable(1) %5)
ret i32 %6
}