#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 uint32_t;
typedef int uint16_t;
typedef int /*<<< orphan*/ target32;
typedef int /*<<< orphan*/ hash32;

/* Variables and functions */
int /*<<< orphan*/ swap256(unsigned char *, unsigned char const *);
int fulltest(const unsigned char *hash, const unsigned char *target) {
  unsigned char hash_swap[32], target_swap[32];
  uint32_t *hash32 = (uint32_t *)hash_swap;
  uint32_t *target32 = (uint32_t *)target_swap;
  int i;
  int rc = 1;
  swap256(hash_swap, hash);
  swap256(target_swap, target);
  for (i = 0; i < 32 / 4; i++) {
    uint32_t h32tmp =
        (((uint32_t)(((((uint16_t)((hash32[i]) & 0xFFFF)) & 0xFF) << 8) |
                     (((uint16_t)((hash32[i]) & 0xFFFF)) >> 8))
          << 16) |
         (uint32_t)(((((uint16_t)((hash32[i]) >> 16)) & 0xFF) << 8) |
                    (((uint16_t)((hash32[i]) >> 16)) >> 8)));
    uint32_t t32tmp = target32[i];
    target32[i] =
        (((uint32_t)(((((uint16_t)((target32[i]) & 0xFFFF)) & 0xFF) << 8) |
                     (((uint16_t)((target32[i]) & 0xFFFF)) >> 8))
          << 16) |
         (uint32_t)(((((uint16_t)((target32[i]) >> 16)) & 0xFF) << 8) |
                    (((uint16_t)((target32[i]) >> 16)) >> 8)));
    if (h32tmp > t32tmp) {
      rc = 0;
      break;
    }
    if (h32tmp < t32tmp) {
      rc = 1;
      break;
    }
  }
  return (rc);
}


x86 assembly (clang, -O0):
<fulltest>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x30(%rbp),%rax
mov    %rax,-0x58(%rbp)
lea    -0x50(%rbp),%rax
mov    %rax,-0x60(%rbp)
movl   $0x1,-0x68(%rbp)
lea    -0x30(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <swap256@plt>
lea    -0x50(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <swap256@plt>
movl   $0x0,-0x64(%rbp)
cmpl   $0x8,-0x64(%rbp)
jge    127b <fulltest+0x16b>
mov    -0x58(%rbp),%rax
movslq -0x64(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
and    $0xffff,%eax
and    $0xff,%eax
shl    $0x8,%eax
mov    -0x58(%rbp),%rcx
movslq -0x64(%rbp),%rdx
mov    (%rcx,%rdx,4),%ecx
and    $0xffff,%ecx
sar    $0x8,%ecx
or     %ecx,%eax
shl    $0x10,%eax
mov    -0x58(%rbp),%rcx
movslq -0x64(%rbp),%rdx
mov    (%rcx,%rdx,4),%ecx
sar    $0x10,%ecx
and    $0xff,%ecx
shl    $0x8,%ecx
mov    -0x58(%rbp),%rdx
movslq -0x64(%rbp),%rsi
mov    (%rdx,%rsi,4),%edx
sar    $0x10,%edx
sar    $0x8,%edx
or     %edx,%ecx
or     %ecx,%eax
mov    %eax,-0x6c(%rbp)
mov    -0x60(%rbp),%rax
movslq -0x64(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x70(%rbp)
mov    -0x60(%rbp),%rax
movslq -0x64(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
and    $0xffff,%edx
and    $0xff,%edx
shl    $0x8,%edx
mov    -0x60(%rbp),%rax
movslq -0x64(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
and    $0xffff,%eax
sar    $0x8,%eax
or     %eax,%edx
shl    $0x10,%edx
mov    -0x60(%rbp),%rax
movslq -0x64(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
sar    $0x10,%eax
and    $0xff,%eax
shl    $0x8,%eax
mov    -0x60(%rbp),%rcx
movslq -0x64(%rbp),%rsi
mov    (%rcx,%rsi,4),%ecx
sar    $0x10,%ecx
sar    $0x8,%ecx
or     %ecx,%eax
or     %eax,%edx
mov    -0x60(%rbp),%rax
movslq -0x64(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x6c(%rbp),%eax
cmp    -0x70(%rbp),%eax
jle    1250 <fulltest+0x140>
movl   $0x0,-0x68(%rbp)
jmp    127b <fulltest+0x16b>
mov    -0x6c(%rbp),%eax
cmp    -0x70(%rbp),%eax
jge    1268 <fulltest+0x158>
movl   $0x1,-0x68(%rbp)
jmp    127b <fulltest+0x16b>
jmp    126d <fulltest+0x15d>
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
jmp    1158 <fulltest+0x48>
mov    -0x68(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fulltest>:
push   %rbx
sub    $0x40,%rsp
mov    %rsi,%rbx
mov    %rdi,%rsi
lea    0x20(%rsp),%rdi
call   1030 <swap256@plt>
mov    %rsp,%rdi
mov    %rbx,%rsi
call   1030 <swap256@plt>
mov    $0x1,%r8d
xor    %r9d,%r9d
xor    %r10d,%r10d
mov    $0x1,%eax
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    0x20(%rsp,%r10,4),%ebx
mov    %ebx,%ecx
rol    $0x8,%cx
shl    $0x10,%ecx
mov    %ebx,%edi
shr    $0x8,%edi
and    $0xff00,%edi
sar    $0x18,%ebx
or     %edi,%ebx
or     %ecx,%ebx
mov    (%rsp,%r10,4),%esi
mov    %esi,%edi
rol    $0x8,%di
shl    $0x10,%edi
mov    %esi,%ecx
shr    $0x8,%ecx
and    $0xff00,%ecx
mov    %esi,%edx
sar    $0x18,%edx
or     %ecx,%edx
or     %edi,%edx
mov    %edx,(%rsp,%r10,4)
cmp    %esi,%ebx
cmovl  %r8d,%eax
cmovg  %r9d,%eax
jne    11ae <fulltest+0x9e>
lea    0x1(%r10),%rcx
cmp    $0x7,%r10
mov    %rcx,%r10
jne    1150 <fulltest+0x40>
add    $0x40,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define i32 @fulltest(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca [32 x i8]
%6 = alloca [32 x i8]
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
%13 = getelementptr inbounds [32 x i8], [32 x i8]* %5, i64 0, i64 0
%14 = bitcast i8* %13 to i32*
store i32* %14, i32** %7
%15 = getelementptr inbounds [32 x i8], [32 x i8]* %6, i64 0, i64 0
%16 = bitcast i8* %15 to i32*
store i32* %16, i32** %8
store i32 1, i32* %10
%17 = getelementptr inbounds [32 x i8], [32 x i8]* %5, i64 0, i64 0
%18 = load i8*, i8** %3
%19 = call i32 @swap256(i8* %17, i8* %18)
%20 = getelementptr inbounds [32 x i8], [32 x i8]* %6, i64 0, i64 0
%21 = load i8*, i8** %4
%22 = call i32 @swap256(i8* %20, i8* %21)
store i32 0, i32* %9
br label %23
23: ; preds = %114, %2
%24 = load i32, i32* %9
%25 = icmp slt i32 %24, 8
br i1 %25, label %26, label %117
26: ; preds = %23
%27 = load i32*, i32** %7
%28 = load i32, i32* %9
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i32, i32* %27, i64 %29
%31 = load i32, i32* %30
%32 = and i32 %31, 65535
%33 = and i32 %32, 255
%34 = shl i32 %33, 8
%35 = load i32*, i32** %7
%36 = load i32, i32* %9
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i32, i32* %35, i64 %37
%39 = load i32, i32* %38
%40 = and i32 %39, 65535
%41 = ashr i32 %40, 8
%42 = or i32 %34, %41
%43 = shl i32 %42, 16
%44 = load i32*, i32** %7
%45 = load i32, i32* %9
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds i32, i32* %44, i64 %46
%48 = load i32, i32* %47
%49 = ashr i32 %48, 16
%50 = and i32 %49, 255
%51 = shl i32 %50, 8
%52 = load i32*, i32** %7
%53 = load i32, i32* %9
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds i32, i32* %52, i64 %54
%56 = load i32, i32* %55
%57 = ashr i32 %56, 16
%58 = ashr i32 %57, 8
%59 = or i32 %51, %58
%60 = or i32 %43, %59
store i32 %60, i32* %11
%61 = load i32*, i32** %8
%62 = load i32, i32* %9
%63 = sext i32 %62 to i64
%64 = getelementptr inbounds i32, i32* %61, i64 %63
%65 = load i32, i32* %64
store i32 %65, i32* %12
%66 = load i32*, i32** %8
%67 = load i32, i32* %9
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds i32, i32* %66, i64 %68
%70 = load i32, i32* %69
%71 = and i32 %70, 65535
%72 = and i32 %71, 255
%73 = shl i32 %72, 8
%74 = load i32*, i32** %8
%75 = load i32, i32* %9
%76 = sext i32 %75 to i64
%77 = getelementptr inbounds i32, i32* %74, i64 %76
%78 = load i32, i32* %77
%79 = and i32 %78, 65535
%80 = ashr i32 %79, 8
%81 = or i32 %73, %80
%82 = shl i32 %81, 16
%83 = load i32*, i32** %8
%84 = load i32, i32* %9
%85 = sext i32 %84 to i64
%86 = getelementptr inbounds i32, i32* %83, i64 %85
%87 = load i32, i32* %86
%88 = ashr i32 %87, 16
%89 = and i32 %88, 255
%90 = shl i32 %89, 8
%91 = load i32*, i32** %8
%92 = load i32, i32* %9
%93 = sext i32 %92 to i64
%94 = getelementptr inbounds i32, i32* %91, i64 %93
%95 = load i32, i32* %94
%96 = ashr i32 %95, 16
%97 = ashr i32 %96, 8
%98 = or i32 %90, %97
%99 = or i32 %82, %98
%100 = load i32*, i32** %8
%101 = load i32, i32* %9
%102 = sext i32 %101 to i64
%103 = getelementptr inbounds i32, i32* %100, i64 %102
store i32 %99, i32* %103
%104 = load i32, i32* %11
%105 = load i32, i32* %12
%106 = icmp sgt i32 %104, %105
br i1 %106, label %107, label %108
107: ; preds = %26
store i32 0, i32* %10
br label %117
108: ; preds = %26
%109 = load i32, i32* %11
%110 = load i32, i32* %12
%111 = icmp slt i32 %109, %110
br i1 %111, label %112, label %113
112: ; preds = %108
store i32 1, i32* %10
br label %117
113: ; preds = %108
br label %114
114: ; preds = %113
%115 = load i32, i32* %9
%116 = add nsw i32 %115, 1
store i32 %116, i32* %9
br label %23
117: ; preds = %112, %107, %23
%118 = load i32, i32* %10
ret i32 %118
}

LLVM IR (-O2):
define i32 @fulltest(i8* %0, i8* %1) {
%3 = alloca [32 x i8]
%4 = alloca [32 x i8]
%5 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [32 x i8], [32 x i8]* %4, i64 0, i64 0
%7 = bitcast [32 x i8]* %3 to i32*
%8 = bitcast [32 x i8]* %4 to i32*
%9 = call i32 @swap256(i8* %5, i8* %0)
%10 = call i32 @swap256(i8* %6, i8* %1)
br label %11
11: ; preds = %11, %2
%12 = phi i64 [ 0, %2 ], [ %41, %11 ]
%13 = phi i32 [ 1, %2 ], [ %39, %11 ]
%14 = getelementptr inbounds i32, i32* %7, i64 %12
%15 = load i32, i32* %14
%16 = trunc i32 %15 to i16
%17 = call i16 @llvm.bswap.i16(i16 %16)
%18 = zext i16 %17 to i32
%19 = shl nuw i32 %18, 16
%20 = lshr i32 %15, 8
%21 = and i32 %20, 65280
%22 = ashr i32 %15, 24
%23 = or i32 %21, %22
%24 = or i32 %23, %19
%25 = getelementptr inbounds i32, i32* %8, i64 %12
%26 = load i32, i32* %25
%27 = trunc i32 %26 to i16
%28 = call i16 @llvm.bswap.i16(i16 %27)
%29 = zext i16 %28 to i32
%30 = shl nuw i32 %29, 16
%31 = lshr i32 %26, 8
%32 = and i32 %31, 65280
%33 = ashr i32 %26, 24
%34 = or i32 %32, %33
%35 = or i32 %34, %30
store i32 %35, i32* %25
%36 = icmp sgt i32 %24, %26
%37 = icmp slt i32 %24, %26
%38 = select i1 %37, i32 1, i32 %13
%39 = select i1 %36, i32 0, i32 %38
%40 = icmp ne i32 %24, %26
%41 = add nuw nsw i64 %12, 1
%42 = icmp eq i64 %41, 8
%43 = select i1 %40, i1 true, i1 %42
br i1 %43, label %44, label %11
44: ; preds = %11
ret i32 %39
}