#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 uint64_t;
typedef int uint32_t;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, unsigned long long);
int main(int argc, char *argv[]) {
  uint64_t original, expected;
  uint64_t actual1, actual2, actual3;
  original = 0x554E49584C4f5645;
  expected = 0x45564f4c58494e55;
  printf("     original: %0llx\n", (unsigned long long)original);
  printf("     expected: %0llx\n", (unsigned long long)expected);
  actual2 =
      ((((uint64_t)(((((uint32_t)original) & 0xff000000) >> 24) |
                    ((((uint32_t)original) & 0x00ff0000) >> 8) |
                    ((((uint32_t)original) & 0x0000ff00) << 8) |
                    ((((uint32_t)original) & 0x000000ff) << 24))
         << 32) |
        ((uint64_t)(((((uint32_t)(original >> 32)) & 0xff000000) >> 24) |
                    ((((uint32_t)(original >> 32)) & 0x00ff0000) >> 8) |
                    ((((uint32_t)(original >> 32)) & 0x0000ff00) << 8) |
                    ((((uint32_t)(original >> 32)) & 0x000000ff) << 24)))));
  printf("bswap_64_32x2: %0llx\n", (unsigned long long)actual2);
  actual3 =
      ((((uint64_t)(((((uint32_t)original) & 0xff000000) >> 24) |
                    ((((uint32_t)original) & 0x00ff0000) >> 8) |
                    ((((uint32_t)original) & 0x0000ff00) << 8) |
                    ((((uint32_t)original) & 0x000000ff) << 24))
         << 32) |
        ((uint64_t)(((((uint32_t)(original >> 32)) & 0xff000000) >> 24) |
                    ((((uint32_t)(original >> 32)) & 0x00ff0000) >> 8) |
                    ((((uint32_t)(original >> 32)) & 0x0000ff00) << 8) |
                    ((((uint32_t)(original >> 32)) & 0x000000ff) << 24)))));
  printf("     Bswap_64: %0llx\n", (unsigned long long)actual3);
  return actual2 == expected ? 0 : 1;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x4c4f5645,-0x14(%rbp)
movl   $0x58494e55,-0x18(%rbp)
movslq -0x14(%rbp),%rsi
lea    0xec1(%rip),%rdi
call   1030 <printf@plt>
movslq -0x18(%rbp),%rsi
lea    0xec7(%rip),%rdi
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
and    $0xff000000,%eax
shr    $0x18,%eax
mov    -0x14(%rbp),%ecx
and    $0xff0000,%ecx
sar    $0x8,%ecx
or     %ecx,%eax
mov    -0x14(%rbp),%ecx
and    $0xff00,%ecx
shl    $0x8,%ecx
or     %ecx,%eax
mov    -0x14(%rbp),%ecx
and    $0xff,%ecx
shl    $0x18,%ecx
or     %ecx,%eax
mov    $0x20,%ecx
shl    %cl,%eax
mov    -0x14(%rbp),%edx
mov    $0x20,%ecx
sar    %cl,%edx
mov    %edx,%ecx
and    $0xff000000,%ecx
shr    $0x18,%ecx
mov    %ecx,-0x3c(%rbp)
mov    -0x14(%rbp),%edx
mov    $0x20,%ecx
sar    %cl,%edx
mov    -0x3c(%rbp),%ecx
and    $0xff0000,%edx
sar    $0x8,%edx
or     %edx,%ecx
mov    %ecx,-0x38(%rbp)
mov    -0x14(%rbp),%edx
mov    $0x20,%ecx
sar    %cl,%edx
mov    -0x38(%rbp),%ecx
and    $0xff00,%edx
shl    $0x8,%edx
or     %edx,%ecx
mov    %ecx,-0x34(%rbp)
mov    -0x14(%rbp),%edx
mov    $0x20,%ecx
sar    %cl,%edx
mov    -0x34(%rbp),%ecx
and    $0xff,%edx
shl    $0x18,%edx
or     %edx,%ecx
or     %ecx,%eax
mov    %eax,-0x20(%rbp)
movslq -0x20(%rbp),%rsi
lea    0xe26(%rip),%rdi
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
and    $0xff000000,%eax
shr    $0x18,%eax
mov    -0x14(%rbp),%ecx
and    $0xff0000,%ecx
sar    $0x8,%ecx
or     %ecx,%eax
mov    -0x14(%rbp),%ecx
and    $0xff00,%ecx
shl    $0x8,%ecx
or     %ecx,%eax
mov    -0x14(%rbp),%ecx
and    $0xff,%ecx
shl    $0x18,%ecx
or     %ecx,%eax
mov    $0x20,%ecx
shl    %cl,%eax
mov    -0x14(%rbp),%edx
mov    $0x20,%ecx
sar    %cl,%edx
mov    %edx,%ecx
and    $0xff000000,%ecx
shr    $0x18,%ecx
mov    %ecx,-0x30(%rbp)
mov    -0x14(%rbp),%edx
mov    $0x20,%ecx
sar    %cl,%edx
mov    -0x30(%rbp),%ecx
and    $0xff0000,%edx
sar    $0x8,%edx
or     %edx,%ecx
mov    %ecx,-0x2c(%rbp)
mov    -0x14(%rbp),%edx
mov    $0x20,%ecx
sar    %cl,%edx
mov    -0x2c(%rbp),%ecx
and    $0xff00,%edx
shl    $0x8,%edx
or     %edx,%ecx
mov    %ecx,-0x28(%rbp)
mov    -0x14(%rbp),%edx
mov    $0x20,%ecx
sar    %cl,%edx
mov    -0x28(%rbp),%ecx
and    $0xff,%edx
shl    $0x18,%edx
or     %edx,%ecx
or     %ecx,%eax
mov    %eax,-0x24(%rbp)
movslq -0x24(%rbp),%rsi
lea    0xd85(%rip),%rdi
call   1030 <printf@plt>
mov    -0x20(%rbp),%edx
mov    -0x18(%rbp),%esi
mov    $0x1,%eax
xor    %ecx,%ecx
cmp    %esi,%edx
cmove  %ecx,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xee8(%rip),%rdi
mov    $0x4c4f5645,%esi
call   1030 <printf@plt>
lea    0xeed(%rip),%rdi
mov    $0x58494e55,%esi
call   1030 <printf@plt>
lea    0xef2(%rip),%rdi
call   1030 <printf@plt>
lea    0xefc(%rip),%rdi
pop    %rax
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [22 x i8] c" original: %0llx\0A\00"
@.str.1 = [22 x i8] c" expected: %0llx\0A\00"
@.str.2 = [22 x i8] c"bswap_64_32x2: %0llx\0A\00"
@.str.3 = [22 x i8] c" Bswap_64: %0llx\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1280267845, i32* %6
store i32 1481199189, i32* %7
%11 = load i32, i32* %6
%12 = sext i32 %11 to i64
%13 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i64 %12)
%14 = load i32, i32* %7
%15 = sext i32 %14 to i64
%16 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i64 %15)
%17 = load i32, i32* %6
%18 = and i32 %17, -16777216
%19 = lshr i32 %18, 24
%20 = load i32, i32* %6
%21 = and i32 %20, 16711680
%22 = ashr i32 %21, 8
%23 = or i32 %19, %22
%24 = load i32, i32* %6
%25 = and i32 %24, 65280
%26 = shl i32 %25, 8
%27 = or i32 %23, %26
%28 = load i32, i32* %6
%29 = and i32 %28, 255
%30 = shl i32 %29, 24
%31 = or i32 %27, %30
%32 = shl i32 %31, 32
%33 = load i32, i32* %6
%34 = ashr i32 %33, 32
%35 = and i32 %34, -16777216
%36 = lshr i32 %35, 24
%37 = load i32, i32* %6
%38 = ashr i32 %37, 32
%39 = and i32 %38, 16711680
%40 = ashr i32 %39, 8
%41 = or i32 %36, %40
%42 = load i32, i32* %6
%43 = ashr i32 %42, 32
%44 = and i32 %43, 65280
%45 = shl i32 %44, 8
%46 = or i32 %41, %45
%47 = load i32, i32* %6
%48 = ashr i32 %47, 32
%49 = and i32 %48, 255
%50 = shl i32 %49, 24
%51 = or i32 %46, %50
%52 = or i32 %32, %51
store i32 %52, i32* %9
%53 = load i32, i32* %9
%54 = sext i32 %53 to i64
%55 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i64 %54)
%56 = load i32, i32* %6
%57 = and i32 %56, -16777216
%58 = lshr i32 %57, 24
%59 = load i32, i32* %6
%60 = and i32 %59, 16711680
%61 = ashr i32 %60, 8
%62 = or i32 %58, %61
%63 = load i32, i32* %6
%64 = and i32 %63, 65280
%65 = shl i32 %64, 8
%66 = or i32 %62, %65
%67 = load i32, i32* %6
%68 = and i32 %67, 255
%69 = shl i32 %68, 24
%70 = or i32 %66, %69
%71 = shl i32 %70, 32
%72 = load i32, i32* %6
%73 = ashr i32 %72, 32
%74 = and i32 %73, -16777216
%75 = lshr i32 %74, 24
%76 = load i32, i32* %6
%77 = ashr i32 %76, 32
%78 = and i32 %77, 16711680
%79 = ashr i32 %78, 8
%80 = or i32 %75, %79
%81 = load i32, i32* %6
%82 = ashr i32 %81, 32
%83 = and i32 %82, 65280
%84 = shl i32 %83, 8
%85 = or i32 %80, %84
%86 = load i32, i32* %6
%87 = ashr i32 %86, 32
%88 = and i32 %87, 255
%89 = shl i32 %88, 24
%90 = or i32 %85, %89
%91 = or i32 %71, %90
store i32 %91, i32* %10
%92 = load i32, i32* %10
%93 = sext i32 %92 to i64
%94 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i64 %93)
%95 = load i32, i32* %9
%96 = load i32, i32* %7
%97 = icmp eq i32 %95, %96
%98 = zext i1 %97 to i64
%99 = select i1 %97, i32 0, i32 1
ret i32 %99
}

LLVM IR (-O2):
@.str = [22 x i8] c" original: %0llx\0A\00"
@.str.1 = [22 x i8] c" expected: %0llx\0A\00"
@.str.2 = [22 x i8] c"bswap_64_32x2: %0llx\0A\00"
@.str.3 = [22 x i8] c" Bswap_64: %0llx\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i64 1280267845)
%4 = tail call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i64 1481199189)
%5 = tail call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i64 poison)
%6 = tail call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i64 poison)
ret i32 poison
}