#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 */
scalar_t__ EOF;
unsigned long igray(unsigned long, int);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ scanf(char *, unsigned long *, unsigned long *);
int main(void) {
  unsigned long jp, n, ng, nmax, nmin, nni, nxor;
  for (;;) {
    printf("input nmin,nmax: \n");
    if (scanf("%lu %lu", &nmin, &nmax) == EOF)
      break;
    jp = (nmax - nmin) / 11;
    if (jp < 1)
      jp = 1;
    printf("n, Gray[n], Gray(Gray[n]), Gray[n] ^ Gray[n+1]\n");
    for (n = nmin; n <= nmax; n++) {
      ng = igray(n, 1);
      nni = igray(ng, -1);
      if (nni != n)
        printf("WRONG ! AT %d %d %d\n", n, ng, nni);
      if (!((n - nmin) % jp)) {
        nxor = ng ^ igray(n + 1, 1);
        printf("%lu %lu %lu %lu\n", n, ng, nni, nxor);
      }
    }
  }
  printf("Normal completion\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xebf(%rip),%rdi
lea    -0x30(%rbp),%rsi
lea    -0x28(%rbp),%rdx
call   1050 <scanf@plt>
mov    0x2e80(%rip),%rcx
cmp    (%rcx),%rax
jne    1176 <main+0x46>
jmp    128a <main+0x15a>
mov    -0x28(%rbp),%rax
sub    -0x30(%rbp),%rax
mov    $0xb,%ecx
xor    %edx,%edx
div    %rcx
mov    %rax,-0x10(%rbp)
cmpq   $0x1,-0x10(%rbp)
jae    119f <main+0x6f>
movq   $0x1,-0x10(%rbp)
lea    0xe75(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x30(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x28(%rbp),%rax
ja     1285 <main+0x155>
mov    -0x18(%rbp),%rdi
mov    $0x1,%esi
call   1040 <igray@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    $0xffffffff,%esi
call   1040 <igray@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
cmp    -0x18(%rbp),%rax
je     120f <main+0xdf>
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x38(%rbp),%rcx
lea    0xe43(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rax
sub    -0x30(%rbp),%rax
xor    %ecx,%ecx
mov    %ecx,%edx
divq   -0x10(%rbp)
cmp    $0x0,%rdx
jne    126f <main+0x13f>
mov    -0x20(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x18(%rbp),%rdi
add    $0x1,%rdi
mov    $0x1,%esi
call   1040 <igray@plt>
mov    %rax,%rcx
mov    -0x48(%rbp),%rax
xor    %rcx,%rax
mov    %rax,-0x40(%rbp)
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x38(%rbp),%rcx
mov    -0x40(%rbp),%r8
lea    0xdf8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1274 <main+0x144>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    11b5 <main+0x85>
jmp    113f <main+0xf>
lea    0xde0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xed9(%rip),%rdi
call   1030 <puts@plt>
lea    0xe9f(%rip),%rdi
lea    0x8(%rsp),%rsi
lea    0x10(%rsp),%rdx
call   1060 <scanf@plt>
mov    0x2e71(%rip),%rcx
cmp    (%rcx),%rax
jne    1199 <main+0x59>
lea    0xeec(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe68(%rip),%r14
jmp    11de <main+0x9e>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
lea    0xe77(%rip),%rdi
call   1030 <puts@plt>
lea    0xe3d(%rip),%rdi
lea    0x8(%rsp),%rsi
lea    0x10(%rsp),%rdx
call   1060 <scanf@plt>
mov    0x2e0f(%rip),%rcx
cmp    (%rcx),%rax
je     117c <main+0x3c>
mov    0x10(%rsp),%rax
sub    0x8(%rsp),%rax
mov    $0x1,%r15d
cmp    $0xb,%rax
jb     1207 <main+0xc7>
movabs $0x2e8ba2e8ba2e8ba3,%rcx
a2 8b 2e
mul    %rcx
mov    %rdx,%r15
shr    %r15
lea    0xe32(%rip),%rdi
call   1030 <puts@plt>
mov    0x8(%rsp),%r12
cmp    0x10(%rsp),%r12
jbe    123e <main+0xfe>
jmp    11b0 <main+0x70>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rbp,%r12
cmp    0x10(%rsp),%rbp
ja     11b0 <main+0x70>
mov    %r12,%rdi
mov    $0x1,%esi
call   1050 <igray@plt>
mov    %rax,%r13
mov    %rax,%rdi
mov    $0xffffffff,%esi
call   1050 <igray@plt>
mov    %rax,%rbx
cmp    %rax,%r12
je     1276 <main+0x136>
mov    %r14,%rdi
mov    %r12,%rsi
mov    %r13,%rdx
mov    %rbx,%rcx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rax
sub    0x8(%rsp),%rax
mov    %rax,%rcx
or     %r15,%rcx
shr    $0x20,%rcx
je     12a0 <main+0x160>
xor    %edx,%edx
div    %r15
jmp    12a5 <main+0x165>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xor    %edx,%edx
div    %r15d
lea    0x1(%r12),%rbp
test   %rdx,%rdx
jne    1230 <main+0xf0>
mov    %rbp,%rdi
mov    $0x1,%esi
call   1050 <igray@plt>
mov    %r13,%r8
xor    %rax,%r8
lea    0xd54(%rip),%rdi
mov    %r12,%rsi
mov    %r13,%rdx
mov    %rbx,%rcx
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1230 <main+0xf0>

LLVM IR (-O0):
@.str = [19 x i8] c"input nmin,nmax: \0A\00"
@.str.1 = [8 x i8] c"%lu %lu\00"
@EOF = global i64 0
@.str.2 = [48 x i8] c"n, Gray[n], Gray(Gray[n]), Gray[n] ^ Gray[n+1]\0A\00"
@.str.3 = [21 x i8] c"WRONG ! AT %d %d %d\0A\00"
@.str.4 = [17 x i8] c"%lu %lu %lu %lu\0A\00"
@.str.5 = [19 x i8] c"Normal completion\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64
store i32 0, i32* %1
br label %9
9: ; preds = %65, %0
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%11 = call i64 @scanf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i64* %6, i64* %5)
%12 = load i64, i64* @EOF
%13 = icmp eq i64 %11, %12
br i1 %13, label %14, label %15
14: ; preds = %9
br label %66
15: ; preds = %9
%16 = load i64, i64* %5
%17 = load i64, i64* %6
%18 = sub i64 %16, %17
%19 = udiv i64 %18, 11
store i64 %19, i64* %2
%20 = load i64, i64* %2
%21 = icmp ult i64 %20, 1
br i1 %21, label %22, label %23
22: ; preds = %15
store i64 1, i64* %2
br label %23
23: ; preds = %22, %15
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.2, i64 0, i64 0))
%25 = load i64, i64* %6
store i64 %25, i64* %3
br label %26
26: ; preds = %62, %23
%27 = load i64, i64* %3
%28 = load i64, i64* %5
%29 = icmp ule i64 %27, %28
br i1 %29, label %30, label %65
30: ; preds = %26
%31 = load i64, i64* %3
%32 = call i64 @igray(i64 %31, i32 1)
store i64 %32, i64* %4
%33 = load i64, i64* %4
%34 = call i64 @igray(i64 %33, i32 -1)
store i64 %34, i64* %7
%35 = load i64, i64* %7
%36 = load i64, i64* %3
%37 = icmp ne i64 %35, %36
br i1 %37, label %38, label %43
38: ; preds = %30
%39 = load i64, i64* %3
%40 = load i64, i64* %4
%41 = load i64, i64* %7
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i64 %39, i64 %40, i64 %41)
br label %43
43: ; preds = %38, %30
%44 = load i64, i64* %3
%45 = load i64, i64* %6
%46 = sub i64 %44, %45
%47 = load i64, i64* %2
%48 = urem i64 %46, %47
%49 = icmp ne i64 %48, 0
br i1 %49, label %61, label %50
50: ; preds = %43
%51 = load i64, i64* %4
%52 = load i64, i64* %3
%53 = add i64 %52, 1
%54 = call i64 @igray(i64 %53, i32 1)
%55 = xor i64 %51, %54
store i64 %55, i64* %8
%56 = load i64, i64* %3
%57 = load i64, i64* %4
%58 = load i64, i64* %7
%59 = load i64, i64* %8
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i64 %56, i64 %57, i64 %58, i64 %59)
br label %61
61: ; preds = %50, %43
br label %62
62: ; preds = %61
%63 = load i64, i64* %3
%64 = add i64 %63, 1
store i64 %64, i64* %3
br label %26
65: ; preds = %26
br label %9
66: ; preds = %14
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [8 x i8] c"%lu %lu\00"
@EOF = global i64 0
@.str.3 = [21 x i8] c"WRONG ! AT %d %d %d\0A\00"
@.str.4 = [17 x i8] c"%lu %lu %lu %lu\0A\00"
@str = [18 x i8] c"input nmin,nmax: \00"
@str.6 = [47 x i8] c"n, Gray[n], Gray(Gray[n]), Gray[n] ^ Gray[n+1]\00"
@str.7 = [18 x i8] c"Normal completion\00"
define i32 @main() {
%1 = alloca i64
%2 = alloca i64
%3 = bitcast i64* %1 to i8*
%4 = bitcast i64* %2 to i8*
%5 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str, i64 0, i64 0))
%6 = call i64 @scanf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i64* %2, i64* %1)
%7 = load i64, i64* @EOF
%8 = icmp eq i64 %6, %7
br i1 %8, label %45, label %14
9: ; preds = %42, %14
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str, i64 0, i64 0))
%11 = call i64 @scanf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i64* %2, i64* %1)
%12 = load i64, i64* @EOF
%13 = icmp eq i64 %11, %12
br i1 %13, label %45, label %14
14: ; preds = %0, %9
%15 = load i64, i64* %1
%16 = load i64, i64* %2
%17 = sub i64 %15, %16
%18 = udiv i64 %17, 11
%19 = icmp ult i64 %17, 11
%20 = select i1 %19, i64 1, i64 %18
%21 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @str.6, i64 0, i64 0))
%22 = load i64, i64* %2
%23 = load i64, i64* %1
%24 = icmp ugt i64 %22, %23
br i1 %24, label %9, label %25
25: ; preds = %14, %42
%26 = phi i64 [ %37, %42 ], [ %22, %14 ]
%27 = call i64 @igray(i64 %26, i32 1)
%28 = call i64 @igray(i64 %27, i32 -1)
%29 = icmp eq i64 %28, %26
br i1 %29, label %32, label %30
30: ; preds = %25
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i64 %26, i64 %27, i64 %28)
br label %32
32: ; preds = %30, %25
%33 = load i64, i64* %2
%34 = sub i64 %26, %33
%35 = urem i64 %34, %20
%36 = icmp eq i64 %35, 0
%37 = add i64 %26, 1
br i1 %36, label %38, label %42
38: ; preds = %32
%39 = call i64 @igray(i64 %37, i32 1)
%40 = xor i64 %39, %27
%41 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i64 %26, i64 %27, i64 %28, i64 %40)
br label %42
42: ; preds = %32, %38
%43 = load i64, i64* %1
%44 = icmp ugt i64 %37, %43
br i1 %44, label %9, label %25
45: ; preds = %9, %0
%46 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.7, i64 0, i64 0))
ret i32 0
}