int MAG_swab_type() {
  union swabtest {
    unsigned long l;
    unsigned char c[4];
  } swabtest;
  swabtest.l = 0xaabbccdd;
  if ((swabtest.c[0] == 0xaa) && (swabtest.c[1] == 0xbb) &&
      (swabtest.c[2] == 0xcc) && (swabtest.c[3] == 0xdd)) {
    return 0;
  } else if ((swabtest.c[0] == 0xdd) && (swabtest.c[1] == 0xcc) &&
             (swabtest.c[2] == 0xbb) && (swabtest.c[3] == 0xaa)) {
    return 1;
  } else if ((swabtest.c[0] == 0xbb) && (swabtest.c[1] == 0xaa) &&
             (swabtest.c[2] == 0xdd) && (swabtest.c[3] == 0xcc)) {
    return 2;
  } else {
    return -1;
  }
}


x86 assembly (clang, -O0):
<MAG_swab_type>:
push   %rbp
mov    %rsp,%rbp
mov    $0xaabbccdd,%eax
mov    %rax,-0x10(%rbp)
movzbl -0x10(%rbp),%eax
cmp    $0xaa,%eax
jne    1155 <MAG_swab_type+0x55>
movzbl -0xf(%rbp),%eax
cmp    $0xbb,%eax
jne    1155 <MAG_swab_type+0x55>
movzbl -0xe(%rbp),%eax
cmp    $0xcc,%eax
jne    1155 <MAG_swab_type+0x55>
movzbl -0xd(%rbp),%eax
cmp    $0xdd,%eax
jne    1155 <MAG_swab_type+0x55>
movl   $0x0,-0x4(%rbp)
jmp    11ec <MAG_swab_type+0xec>
movzbl -0x10(%rbp),%eax
cmp    $0xdd,%eax
jne    119d <MAG_swab_type+0x9d>
movzbl -0xf(%rbp),%eax
cmp    $0xcc,%eax
jne    119d <MAG_swab_type+0x9d>
movzbl -0xe(%rbp),%eax
cmp    $0xbb,%eax
jne    119d <MAG_swab_type+0x9d>
movzbl -0xd(%rbp),%eax
cmp    $0xaa,%eax
jne    119d <MAG_swab_type+0x9d>
movl   $0x1,-0x4(%rbp)
jmp    11ec <MAG_swab_type+0xec>
movzbl -0x10(%rbp),%eax
cmp    $0xbb,%eax
jne    11e5 <MAG_swab_type+0xe5>
movzbl -0xf(%rbp),%eax
cmp    $0xaa,%eax
jne    11e5 <MAG_swab_type+0xe5>
movzbl -0xe(%rbp),%eax
cmp    $0xdd,%eax
jne    11e5 <MAG_swab_type+0xe5>
movzbl -0xd(%rbp),%eax
cmp    $0xcc,%eax
jne    11e5 <MAG_swab_type+0xe5>
movl   $0x2,-0x4(%rbp)
jmp    11ec <MAG_swab_type+0xec>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<MAG_swab_type>:
mov    $0x1,%eax
ret

LLVM IR (-O0):
%union.swabtest = type { i64 }
define i32 @MAG_swab_type() {
%1 = alloca i32
%2 = alloca %union.swabtest
%3 = bitcast %union.swabtest* %2 to i64*
store i64 2864434397, i64* %3
%4 = bitcast %union.swabtest* %2 to [4 x i8]*
%5 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 0
%6 = load i8, i8* %5
%7 = zext i8 %6 to i32
%8 = icmp eq i32 %7, 170
br i1 %8, label %9, label %28
9: ; preds = %0
%10 = bitcast %union.swabtest* %2 to [4 x i8]*
%11 = getelementptr inbounds [4 x i8], [4 x i8]* %10, i64 0, i64 1
%12 = load i8, i8* %11
%13 = zext i8 %12 to i32
%14 = icmp eq i32 %13, 187
br i1 %14, label %15, label %28
15: ; preds = %9
%16 = bitcast %union.swabtest* %2 to [4 x i8]*
%17 = getelementptr inbounds [4 x i8], [4 x i8]* %16, i64 0, i64 2
%18 = load i8, i8* %17
%19 = zext i8 %18 to i32
%20 = icmp eq i32 %19, 204
br i1 %20, label %21, label %28
21: ; preds = %15
%22 = bitcast %union.swabtest* %2 to [4 x i8]*
%23 = getelementptr inbounds [4 x i8], [4 x i8]* %22, i64 0, i64 3
%24 = load i8, i8* %23
%25 = zext i8 %24 to i32
%26 = icmp eq i32 %25, 221
br i1 %26, label %27, label %28
27: ; preds = %21
store i32 0, i32* %1
br label %79
28: ; preds = %21, %15, %9, %0
%29 = bitcast %union.swabtest* %2 to [4 x i8]*
%30 = getelementptr inbounds [4 x i8], [4 x i8]* %29, i64 0, i64 0
%31 = load i8, i8* %30
%32 = zext i8 %31 to i32
%33 = icmp eq i32 %32, 221
br i1 %33, label %34, label %53
34: ; preds = %28
%35 = bitcast %union.swabtest* %2 to [4 x i8]*
%36 = getelementptr inbounds [4 x i8], [4 x i8]* %35, i64 0, i64 1
%37 = load i8, i8* %36
%38 = zext i8 %37 to i32
%39 = icmp eq i32 %38, 204
br i1 %39, label %40, label %53
40: ; preds = %34
%41 = bitcast %union.swabtest* %2 to [4 x i8]*
%42 = getelementptr inbounds [4 x i8], [4 x i8]* %41, i64 0, i64 2
%43 = load i8, i8* %42
%44 = zext i8 %43 to i32
%45 = icmp eq i32 %44, 187
br i1 %45, label %46, label %53
46: ; preds = %40
%47 = bitcast %union.swabtest* %2 to [4 x i8]*
%48 = getelementptr inbounds [4 x i8], [4 x i8]* %47, i64 0, i64 3
%49 = load i8, i8* %48
%50 = zext i8 %49 to i32
%51 = icmp eq i32 %50, 170
br i1 %51, label %52, label %53
52: ; preds = %46
store i32 1, i32* %1
br label %79
53: ; preds = %46, %40, %34, %28
%54 = bitcast %union.swabtest* %2 to [4 x i8]*
%55 = getelementptr inbounds [4 x i8], [4 x i8]* %54, i64 0, i64 0
%56 = load i8, i8* %55
%57 = zext i8 %56 to i32
%58 = icmp eq i32 %57, 187
br i1 %58, label %59, label %78
59: ; preds = %53
%60 = bitcast %union.swabtest* %2 to [4 x i8]*
%61 = getelementptr inbounds [4 x i8], [4 x i8]* %60, i64 0, i64 1
%62 = load i8, i8* %61
%63 = zext i8 %62 to i32
%64 = icmp eq i32 %63, 170
br i1 %64, label %65, label %78
65: ; preds = %59
%66 = bitcast %union.swabtest* %2 to [4 x i8]*
%67 = getelementptr inbounds [4 x i8], [4 x i8]* %66, i64 0, i64 2
%68 = load i8, i8* %67
%69 = zext i8 %68 to i32
%70 = icmp eq i32 %69, 221
br i1 %70, label %71, label %78
71: ; preds = %65
%72 = bitcast %union.swabtest* %2 to [4 x i8]*
%73 = getelementptr inbounds [4 x i8], [4 x i8]* %72, i64 0, i64 3
%74 = load i8, i8* %73
%75 = zext i8 %74 to i32
%76 = icmp eq i32 %75, 204
br i1 %76, label %77, label %78
77: ; preds = %71
store i32 2, i32* %1
br label %79
78: ; preds = %71, %65, %59, %53
store i32 -1, i32* %1
br label %79
79: ; preds = %78, %77, %52, %27
%80 = load i32, i32* %1
ret i32 %80
}

LLVM IR (-O2):
define i32 @MAG_swab_type() {
ret i32 1
}