#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 /*<<< orphan*/ morton_decode(unsigned long long, unsigned int *,
                                 unsigned int *);
unsigned long long morton_encode(unsigned int, unsigned int);
char *test_morton1() {
  unsigned x = 104395303;
  unsigned y = 122949829;
  const unsigned stridex = 503;
  const unsigned stridey = 509;
  unsigned loop = 10000000;
  unsigned long long s;
  unsigned rx, ry;
  char outstr[256];
  for (; loop > 0; --loop) {
    s = morton_encode(x, y);
    morton_decode(s, &rx, &ry);
    do {
      if (!(((x == rx) && (y == ry))))
        return "result unequal\n";
    } while (0);
    x += stridex;
    y += stridey;
  }
  return 0;
}


x86 assembly (clang, -O0):
<test_morton1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
movl   $0x638f227,-0xc(%rbp)
movl   $0x75410c5,-0x10(%rbp)
movl   $0x1f7,-0x14(%rbp)
movl   $0x1fd,-0x18(%rbp)
movl   $0x989680,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jbe    11c9 <test_morton1+0xa9>
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
call   1030 <morton_encode@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
lea    -0x2c(%rbp),%rsi
lea    -0x30(%rbp),%rdx
call   1040 <morton_decode@plt>
mov    -0xc(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jne    1190 <test_morton1+0x70>
mov    -0x10(%rbp),%eax
cmp    -0x30(%rbp),%eax
je     11a0 <test_morton1+0x80>
lea    0xe69(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11d1 <test_morton1+0xb1>
jmp    11a5 <test_morton1+0x85>
mov    -0xc(%rbp),%eax
add    $0x1f7,%eax
mov    %eax,-0xc(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1fd,%eax
mov    %eax,-0x10(%rbp)
mov    -0x1c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x1c(%rbp)
jmp    114e <test_morton1+0x2e>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_morton1>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    $0x75410c5,%ebp
mov    $0x638f227,%ebx
mov    $0xff676980,%r13d
lea    0x4(%rsp),%r15
mov    %rsp,%r12
lea    0xeb6(%rip),%r14
nopw   0x0(%rax,%rax,1)
mov    %ebx,%edi
mov    %ebp,%esi
call   1030 <morton_encode@plt>
mov    %rax,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
call   1040 <morton_decode@plt>
cmp    0x4(%rsp),%ebx
jne    1186 <test_morton1+0x66>
cmp    (%rsp),%ebp
jne    1186 <test_morton1+0x66>
add    $0x1f7,%ebx
add    $0x1fd,%ebp
inc    %r13d
jne    1150 <test_morton1+0x30>
xor    %r14d,%r14d
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [16 x i8] c"result unequal\0A\00"
define i8* @test_morton1() {
%1 = alloca i8*
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i64
%8 = alloca i32
%9 = alloca i32
%10 = alloca [256 x i8]
store i32 104395303, i32* %2
store i32 122949829, i32* %3
store i32 503, i32* %4
store i32 509, i32* %5
store i32 10000000, i32* %6
br label %11
11: ; preds = %35, %0
%12 = load i32, i32* %6
%13 = icmp ugt i32 %12, 0
br i1 %13, label %14, label %38
14: ; preds = %11
%15 = load i32, i32* %2
%16 = load i32, i32* %3
%17 = call i64 @morton_encode(i32 %15, i32 %16)
store i64 %17, i64* %7
%18 = load i64, i64* %7
%19 = call i32 @morton_decode(i64 %18, i32* %8, i32* %9)
br label %20
20: ; preds = %14
%21 = load i32, i32* %2
%22 = load i32, i32* %8
%23 = icmp eq i32 %21, %22
br i1 %23, label %24, label %28
24: ; preds = %20
%25 = load i32, i32* %3
%26 = load i32, i32* %9
%27 = icmp eq i32 %25, %26
br i1 %27, label %29, label %28
28: ; preds = %24, %20
store i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8** %1
br label %39
29: ; preds = %24
br label %30
30: ; preds = %29
%31 = load i32, i32* %2
%32 = add i32 %31, 503
store i32 %32, i32* %2
%33 = load i32, i32* %3
%34 = add i32 %33, 509
store i32 %34, i32* %3
br label %35
35: ; preds = %30
%36 = load i32, i32* %6
%37 = add i32 %36, -1
store i32 %37, i32* %6
br label %11
38: ; preds = %11
store i8* null, i8** %1
br label %39
39: ; preds = %38, %28
%40 = load i8*, i8** %1
ret i8* %40
}

LLVM IR (-O2):
@.str = [16 x i8] c"result unequal\0A\00"
define i8* @test_morton1() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
br label %5
5: ; preds = %0, %16
%6 = phi i32 [ 104395303, %0 ], [ %17, %16 ]
%7 = phi i32 [ 10000000, %0 ], [ %19, %16 ]
%8 = phi i32 [ 122949829, %0 ], [ %18, %16 ]
%9 = call i64 @morton_encode(i32 %6, i32 %8)
%10 = call i32 @morton_decode(i64 %9, i32* %1, i32* %2)
%11 = load i32, i32* %1
%12 = icmp eq i32 %6, %11
%13 = load i32, i32* %2
%14 = icmp eq i32 %8, %13
%15 = select i1 %12, i1 %14, i1 false
br i1 %15, label %16, label %21
16: ; preds = %5
%17 = add i32 %6, 503
%18 = add i32 %8, 509
%19 = add nsw i32 %7, -1
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %5
21: ; preds = %16, %5
%22 = phi i8* [ getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), %5 ], [ null, %16 ]
ret i8* %22
}