#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 */
struct in_addr {
  int s_addr;
};

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ abort();
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int htonl(int);
int /*<<< orphan*/ inet_pton(int /*<<< orphan*/, char *, struct in_addr *);
int /*<<< orphan*/ printf(char *, int, int, int, int);
int main(void) {
  int i, segment;
  int order[4];
  struct in_addr endiant;
  inet_pton(AF_INET, "127.0.1.255", &endiant);
  endiant.s_addr = htonl(endiant.s_addr);
  for (i = 0; i < 4; i++) {
    segment = endiant.s_addr >> (i * 8) & 255;
    switch (segment) {
    case 127:
      order[i] = 0;
      break;
    case 0:
      order[i] = 1;
      break;
    case 1:
      order[i] = 2;
      break;
    case 255:
      order[i] = 3;
      break;
    default:
      abort();
      abort();
      abort();
    }
  }
  printf("ordering: %d %d %d %d\n", order[0], order[1], order[2], order[3]);
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e82(%rip),%rax
mov    (%rax),%edi
lea    0xe91(%rip),%rsi
lea    -0x28(%rbp),%rdx
call   1060 <inet_pton@plt>
mov    -0x28(%rbp),%edi
call   1050 <htonl@plt>
mov    %eax,-0x28(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x4,-0x8(%rbp)
jge    124b <main+0xfb>
mov    -0x28(%rbp),%eax
mov    -0x8(%rbp),%cl
shl    $0x3,%cl
sar    %cl,%eax
movzbl %al,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x2c(%rbp)
test   %eax,%eax
je     11fe <main+0xae>
jmp    11b8 <main+0x68>
mov    -0x2c(%rbp),%eax
sub    $0x1,%eax
je     120f <main+0xbf>
jmp    11c9 <main+0x79>
mov    -0x2c(%rbp),%eax
sub    $0x7f,%eax
je     11ed <main+0x9d>
jmp    11da <main+0x8a>
mov    -0x2c(%rbp),%eax
sub    $0xff,%eax
je     1220 <main+0xd0>
jmp    1231 <main+0xe1>
movslq -0x8(%rbp),%rax
movl   $0x0,-0x20(%rbp,%rax,4)
jmp    1238 <main+0xe8>
movslq -0x8(%rbp),%rax
movl   $0x1,-0x20(%rbp,%rax,4)
jmp    1238 <main+0xe8>
movslq -0x8(%rbp),%rax
movl   $0x2,-0x20(%rbp,%rax,4)
jmp    1238 <main+0xe8>
movslq -0x8(%rbp),%rax
movl   $0x3,-0x20(%rbp,%rax,4)
jmp    1238 <main+0xe8>
mov    $0x0,%al
call   1030 <abort@plt>
jmp    123d <main+0xed>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    118a <main+0x3a>
mov    -0x20(%rbp),%esi
mov    -0x1c(%rbp),%edx
mov    -0x18(%rbp),%ecx
mov    -0x14(%rbp),%r8d
lea    0xdad(%rip),%rdi
call   1040 <printf@plt>
xor    %edi,%edi
call   1070 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    0x2e90(%rip),%rax
mov    (%rax),%edi
lea    0xe9f(%rip),%rsi
mov    %rsp,%rdx
call   1060 <inet_pton@plt>
mov    (%rsp),%edi
call   1050 <htonl@plt>
mov    %eax,(%rsp)
test   %al,%al
jg     118b <main+0x3b>
cmp    $0xff,%al
je     119a <main+0x4a>
test   %al,%al
jne    1233 <main+0xe3>
mov    $0x1,%esi
jmp    11a6 <main+0x56>
cmp    $0x1,%al
je     11a1 <main+0x51>
xor    %esi,%esi
cmp    $0x7f,%al
je     11a6 <main+0x56>
jmp    1233 <main+0xe3>
mov    $0x3,%esi
jmp    11a6 <main+0x56>
mov    $0x2,%esi
mov    %eax,%ecx
shr    $0x8,%ecx
test   %cl,%cl
jg     11bf <main+0x6f>
cmp    $0xff,%cl
je     11d0 <main+0x80>
test   %cl,%cl
jne    1233 <main+0xe3>
mov    $0x1,%edx
jmp    11d9 <main+0x89>
cmp    $0x7f,%cl
je     11d7 <main+0x87>
cmp    $0x1,%cl
jne    1233 <main+0xe3>
mov    $0x2,%edx
jmp    11d9 <main+0x89>
mov    $0x3,%edx
jmp    11d9 <main+0x89>
xor    %edx,%edx
mov    %eax,%ecx
shr    $0x10,%ecx
test   %cl,%cl
jg     11f2 <main+0xa2>
cmp    $0xff,%cl
je     1203 <main+0xb3>
test   %cl,%cl
jne    1233 <main+0xe3>
mov    $0x1,%ecx
jmp    120c <main+0xbc>
cmp    $0x7f,%cl
je     120a <main+0xba>
cmp    $0x1,%cl
jne    1233 <main+0xe3>
mov    $0x2,%ecx
jmp    120c <main+0xbc>
mov    $0x3,%ecx
jmp    120c <main+0xbc>
xor    %ecx,%ecx
shr    $0x18,%eax
test   %al,%al
jg     1223 <main+0xd3>
cmp    $0xff,%al
je     123a <main+0xea>
test   %al,%al
jne    1233 <main+0xe3>
mov    $0x1,%r8d
jmp    1245 <main+0xf5>
cmp    $0x7f,%al
je     1242 <main+0xf2>
cmp    $0x1,%al
jne    1233 <main+0xe3>
mov    $0x2,%r8d
jmp    1245 <main+0xf5>
xor    %eax,%eax
call   1030 <abort@plt>
mov    $0x3,%r8d
jmp    1245 <main+0xf5>
xor    %r8d,%r8d
lea    0xdc0(%rip),%rdi
call   1040 <printf@plt>
xor    %edi,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
%struct.in_addr = type { i32 }
@AF_INET = global i32 0
@.str = [12 x i8] c"127.0.1.255\00"
@.str.1 = [23 x i8] c"ordering: %d %d %d %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [4 x i32]
%5 = alloca %struct.in_addr
store i32 0, i32* %1
%6 = load i32, i32* @AF_INET
%7 = call i32 @inet_pton(i32 %6, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), %struct.in_addr* %5)
%8 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %5, i32 0, i32 0
%9 = load i32, i32* %8
%10 = call i32 @htonl(i32 %9)
%11 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %5, i32 0, i32 0
store i32 %10, i32* %11
store i32 0, i32* %2
br label %12
12: ; preds = %42, %0
%13 = load i32, i32* %2
%14 = icmp slt i32 %13, 4
br i1 %14, label %15, label %45
15: ; preds = %12
%16 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %5, i32 0, i32 0
%17 = load i32, i32* %16
%18 = load i32, i32* %2
%19 = mul nsw i32 %18, 8
%20 = ashr i32 %17, %19
%21 = and i32 %20, 255
store i32 %21, i32* %3
%22 = load i32, i32* %3
switch i32 %22, label %39 [
i32 127, label %23
i32 0, label %27
i32 1, label %31
i32 255, label %35
]
23: ; preds = %15
%24 = load i32, i32* %2
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [4 x i32], [4 x i32]* %4, i64 0, i64 %25
store i32 0, i32* %26
br label %41
27: ; preds = %15
%28 = load i32, i32* %2
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [4 x i32], [4 x i32]* %4, i64 0, i64 %29
store i32 1, i32* %30
br label %41
31: ; preds = %15
%32 = load i32, i32* %2
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [4 x i32], [4 x i32]* %4, i64 0, i64 %33
store i32 2, i32* %34
br label %41
35: ; preds = %15
%36 = load i32, i32* %2
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [4 x i32], [4 x i32]* %4, i64 0, i64 %37
store i32 3, i32* %38
br label %41
39: ; preds = %15
%40 = call i32 (...) @abort()
unreachable
41: ; preds = %35, %31, %27, %23
br label %42
42: ; preds = %41
%43 = load i32, i32* %2
%44 = add nsw i32 %43, 1
store i32 %44, i32* %2
br label %12
45: ; preds = %12
%46 = getelementptr inbounds [4 x i32], [4 x i32]* %4, i64 0, i64 0
%47 = load i32, i32* %46
%48 = getelementptr inbounds [4 x i32], [4 x i32]* %4, i64 0, i64 1
%49 = load i32, i32* %48
%50 = getelementptr inbounds [4 x i32], [4 x i32]* %4, i64 0, i64 2
%51 = load i32, i32* %50
%52 = getelementptr inbounds [4 x i32], [4 x i32]* %4, i64 0, i64 3
%53 = load i32, i32* %52
%54 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 %47, i32 %49, i32 %51, i32 %53)
%55 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
%struct.in_addr = type { i32 }
@AF_INET = global i32 0
@.str = [12 x i8] c"127.0.1.255\00"
@.str.1 = [23 x i8] c"ordering: %d %d %d %d\0A\00"
define i32 @main() {
%1 = alloca %struct.in_addr
%2 = bitcast %struct.in_addr* %1 to i8*
%3 = load i32, i32* @AF_INET
%4 = call i32 @inet_pton(i32 %3, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), %struct.in_addr* %1)
%5 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %1, i64 0, i32 0
%6 = load i32, i32* %5
%7 = call i32 @htonl(i32 %6)
store i32 %7, i32* %5
%8 = trunc i32 %7 to i8
switch i8 %8, label %12 [
i8 127, label %14
i8 0, label %9
i8 1, label %10
i8 -1, label %11
]
9: ; preds = %0
br label %14
10: ; preds = %0
br label %14
11: ; preds = %0
br label %14
12: ; preds = %28, %21, %14, %0
%13 = call i32 (...) @abort()
unreachable
14: ; preds = %0, %9, %10, %11
%15 = phi i32 [ 3, %11 ], [ 2, %10 ], [ 1, %9 ], [ 0, %0 ]
%16 = lshr i32 %7, 8
%17 = trunc i32 %16 to i8
switch i8 %17, label %12 [
i8 127, label %20
i8 0, label %19
i8 1, label %18
i8 -1, label %21
]
18: ; preds = %14
br label %21
19: ; preds = %14
br label %21
20: ; preds = %14
br label %21
21: ; preds = %14, %20, %19, %18
%22 = phi i32 [ 2, %18 ], [ 1, %19 ], [ 0, %20 ], [ 3, %14 ]
%23 = lshr i32 %7, 16
%24 = trunc i32 %23 to i8
switch i8 %24, label %12 [
i8 127, label %27
i8 0, label %26
i8 1, label %25
i8 -1, label %28
]
25: ; preds = %21
br label %28
26: ; preds = %21
br label %28
27: ; preds = %21
br label %28
28: ; preds = %21, %27, %26, %25
%29 = phi i32 [ 2, %25 ], [ 1, %26 ], [ 0, %27 ], [ 3, %21 ]
%30 = lshr i32 %7, 24
%31 = trunc i32 %30 to i8
switch i8 %31, label %12 [
i8 127, label %34
i8 0, label %33
i8 1, label %32
i8 -1, label %35
]
32: ; preds = %28
br label %35
33: ; preds = %28
br label %35
34: ; preds = %28
br label %35
35: ; preds = %28, %34, %33, %32
%36 = phi i32 [ 2, %32 ], [ 1, %33 ], [ 0, %34 ], [ 3, %28 ]
%37 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 %15, i32 %22, i32 %29, i32 %36)
%38 = call i32 @exit(i32 0)
unreachable
}