#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 */
unsigned long long hil_s_from_xy_64(unsigned int, unsigned int, unsigned int);
int /*<<< orphan*/ hil_xy_from_s_64(unsigned long long, unsigned int,
                                    unsigned long long *, unsigned long long *);
int /*<<< orphan*/ printf(char *);
unsigned test_hil_64_alt() {
  unsigned c = 0;
  unsigned z = 20;
  unsigned long long s, px, py;
  const unsigned stridex = 503;
  const unsigned stridey = 509;
  for (unsigned x = 0; x < (1 << z); x += stridex) {
    for (unsigned y = 0; y < (1 << z); y += stridey) {
      s = hil_s_from_xy_64(x, y, z);
      hil_xy_from_s_64(s, z, &px, &py);
      if (px != x || py != y) {
        printf("~~~~ failed! ~~~~\n");
        return 0;
      }
      ++c;
    }
  }
  return c;
}


x86 assembly (clang, -O0):
<test_hil_64_alt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x8(%rbp)
movl   $0x14,-0xc(%rbp)
movl   $0x1f7,-0x2c(%rbp)
movl   $0x1fd,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
mov    -0xc(%rbp),%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,%ecx
cmp    %ecx,%eax
jae    121c <test_hil_64_alt+0xec>
movl   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%eax
mov    -0xc(%rbp),%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,%ecx
cmp    %ecx,%eax
jae    1207 <test_hil_64_alt+0xd7>
mov    -0x34(%rbp),%edi
mov    -0x38(%rbp),%esi
mov    -0xc(%rbp),%edx
call   1040 <hil_s_from_xy_64@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0xc(%rbp),%esi
lea    -0x20(%rbp),%rdx
lea    -0x28(%rbp),%rcx
call   1050 <hil_xy_from_s_64@plt>
mov    -0x20(%rbp),%rax
mov    -0x34(%rbp),%ecx
cmp    %rcx,%rax
jne    11d6 <test_hil_64_alt+0xa6>
mov    -0x28(%rbp),%rax
mov    -0x38(%rbp),%ecx
cmp    %rcx,%rax
je     11ee <test_hil_64_alt+0xbe>
lea    0xe23(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1222 <test_hil_64_alt+0xf2>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0x38(%rbp),%eax
add    $0x1fd,%eax
mov    %eax,-0x38(%rbp)
jmp    1179 <test_hil_64_alt+0x49>
jmp    120c <test_hil_64_alt+0xdc>
mov    -0x34(%rbp),%eax
add    $0x1f7,%eax
mov    %eax,-0x34(%rbp)
jmp    115b <test_hil_64_alt+0x2b>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_hil_64_alt>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
xor    %eax,%eax
lea    0x10(%rsp),%r14
lea    0x8(%rsp),%r15
mov    %eax,%r12d
xor    %ebx,%ebx
nopl   0x0(%rax)
mov    %r12d,%edi
mov    %ebx,%esi
mov    $0x14,%edx
call   1040 <hil_s_from_xy_64@plt>
mov    %rax,%rdi
mov    $0x14,%esi
mov    %r14,%rdx
mov    %r15,%rcx
call   1050 <hil_xy_from_s_64@plt>
cmp    %r12,0x10(%rsp)
jne    11a7 <test_hil_64_alt+0x77>
cmp    0x8(%rsp),%rbx
jne    11a7 <test_hil_64_alt+0x77>
add    $0x1fd,%rbx
cmp    $0x1001d9,%ebx
jne    1150 <test_hil_64_alt+0x20>
lea    0x1f7(%r12),%eax
cmp    $0xffe09,%r12d
jb     1147 <test_hil_64_alt+0x17>
mov    $0x4191e1,%eax
jmp    11b5 <test_hil_64_alt+0x85>
lea    0xe52(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [19 x i8] c"~~~~ failed! ~~~~\0A\00"
define i32 @test_hil_64_alt() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i64
%5 = alloca i64
%6 = alloca i64
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %2
store i32 20, i32* %3
store i32 503, i32* %7
store i32 509, i32* %8
store i32 0, i32* %9
br label %11
11: ; preds = %48, %0
%12 = load i32, i32* %9
%13 = load i32, i32* %3
%14 = shl i32 1, %13
%15 = icmp ult i32 %12, %14
br i1 %15, label %16, label %51
16: ; preds = %11
store i32 0, i32* %10
br label %17
17: ; preds = %44, %16
%18 = load i32, i32* %10
%19 = load i32, i32* %3
%20 = shl i32 1, %19
%21 = icmp ult i32 %18, %20
br i1 %21, label %22, label %47
22: ; preds = %17
%23 = load i32, i32* %9
%24 = load i32, i32* %10
%25 = load i32, i32* %3
%26 = call i64 @hil_s_from_xy_64(i32 %23, i32 %24, i32 %25)
store i64 %26, i64* %4
%27 = load i64, i64* %4
%28 = load i32, i32* %3
%29 = call i32 @hil_xy_from_s_64(i64 %27, i32 %28, i64* %5, i64* %6)
%30 = load i64, i64* %5
%31 = load i32, i32* %9
%32 = zext i32 %31 to i64
%33 = icmp ne i64 %30, %32
br i1 %33, label %39, label %34
34: ; preds = %22
%35 = load i64, i64* %6
%36 = load i32, i32* %10
%37 = zext i32 %36 to i64
%38 = icmp ne i64 %35, %37
br i1 %38, label %39, label %41
39: ; preds = %34, %22
%40 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %1
br label %53
41: ; preds = %34
%42 = load i32, i32* %2
%43 = add i32 %42, 1
store i32 %43, i32* %2
br label %44
44: ; preds = %41
%45 = load i32, i32* %10
%46 = add i32 %45, 509
store i32 %46, i32* %10
br label %17
47: ; preds = %17
br label %48
48: ; preds = %47
%49 = load i32, i32* %9
%50 = add i32 %49, 503
store i32 %50, i32* %9
br label %11
51: ; preds = %11
%52 = load i32, i32* %2
store i32 %52, i32* %1
br label %53
53: ; preds = %51, %39
%54 = load i32, i32* %1
ret i32 %54
}

LLVM IR (-O2):
@str = [18 x i8] c"~~~~ failed! ~~~~\00"
define i32 @test_hil_64_alt() {
%1 = alloca i64
%2 = alloca i64
%3 = bitcast i64* %1 to i8*
%4 = bitcast i64* %2 to i8*
br label %5
5: ; preds = %0, %26
%6 = phi i32 [ 2061, %0 ], [ %29, %26 ]
%7 = phi i32 [ 0, %0 ], [ %27, %26 ]
%8 = phi i32 [ 0, %0 ], [ %10, %26 ]
%9 = zext i32 %7 to i64
%10 = add nuw nsw i32 %8, 2061
br label %11
11: ; preds = %5, %22
%12 = phi i64 [ 0, %5 ], [ %24, %22 ]
%13 = phi i32 [ %8, %5 ], [ %23, %22 ]
%14 = trunc i64 %12 to i32
%15 = call i64 @hil_s_from_xy_64(i32 %7, i32 %14, i32 20)
%16 = call i32 @hil_xy_from_s_64(i64 %15, i32 20, i64* %1, i64* %2)
%17 = load i64, i64* %1
%18 = icmp eq i64 %17, %9
%19 = load i64, i64* %2
%20 = icmp eq i64 %19, %12
%21 = select i1 %18, i1 %20, i1 false
br i1 %21, label %22, label %30
22: ; preds = %11
%23 = add i32 %13, 1
%24 = add nuw nsw i64 %12, 509
%25 = icmp eq i32 %23, %6
br i1 %25, label %26, label %11
26: ; preds = %22
%27 = add nuw nsw i32 %7, 503
%28 = icmp ult i32 %7, 1048073
%29 = add nuw nsw i32 %6, 2061
br i1 %28, label %5, label %32
30: ; preds = %11
%31 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str, i64 0, i64 0))
br label %32
32: ; preds = %26, %30
%33 = phi i32 [ 0, %30 ], [ 4297185, %26 ]
ret i32 %33
}