#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 /*<<< orphan*/ s;

/* Variables and functions */
int increment(char *, size_t const, size_t const);
unsigned int partial_hash(char *, size_t const);
int /*<<< orphan*/ printf(char *, char *);
int print_values_matching(unsigned pow) {
  char s[] = "00000000000";
  const size_t len = sizeof(s) - 1;
  unsigned mask = pow - 1;
  size_t total = 0;
  unsigned cache = partial_hash(s, len - 1);
  while (total < pow) {
    unsigned h = cache + s[len - 1];
    if (!(h & mask)) {
      printf("    \"%s\": null,\n", s);
      total++;
    }
    int ret = increment(s, len - 1, len);
    if (ret == 2)
      cache = partial_hash(s, len - 1);
    if (!ret)
      return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<print_values_matching>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x8(%rbp)
mov    0xebe(%rip),%rax
mov    %rax,-0x14(%rbp)
mov    0xebc(%rip),%eax
mov    %eax,-0xc(%rbp)
movq   $0xb,-0x20(%rbp)
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x24(%rbp)
movq   $0x0,-0x30(%rbp)
lea    -0x14(%rbp),%rdi
mov    $0xa,%esi
call   1050 <partial_hash@plt>
mov    %eax,-0x34(%rbp)
mov    -0x30(%rbp),%rax
mov    -0x8(%rbp),%ecx
cmp    %rcx,%rax
jae    120c <print_values_matching+0xdc>
mov    -0x34(%rbp),%eax
movsbl -0xa(%rbp),%ecx
add    %ecx,%eax
mov    %eax,-0x38(%rbp)
mov    -0x38(%rbp),%eax
and    -0x24(%rbp),%eax
cmp    $0x0,%eax
jne    11c0 <print_values_matching+0x90>
lea    -0x14(%rbp),%rsi
lea    0xe5d(%rip),%rdi
call   1040 <printf@plt>
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
lea    -0x14(%rbp),%rdi
mov    $0xa,%esi
mov    $0xb,%edx
call   1030 <increment@plt>
mov    %eax,-0x3c(%rbp)
cmpl   $0x2,-0x3c(%rbp)
jne    11f1 <print_values_matching+0xc1>
lea    -0x14(%rbp),%rdi
mov    $0xa,%esi
call   1050 <partial_hash@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x3c(%rbp)
jne    1207 <print_values_matching+0xd7>
movl   $0x1,-0x4(%rbp)
jmp    1213 <print_values_matching+0xe3>
jmp    1179 <print_values_matching+0x49>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_values_matching>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %edi,%ebx
movabs $0x3030303030303030,%rax
30 30 30
mov    %rax,0x8(%rsp)
movl   $0x303030,0x10(%rsp)
lea    -0x1(%rbx),%r13d
lea    0x8(%rsp),%r12
mov    $0xa,%esi
mov    %r12,%rdi
call   1050 <partial_hash@plt>
mov    %eax,%ebp
mov    %ebx,%r14d
xor    %r15d,%r15d
jmp    1184 <print_values_matching+0x54>
nopw   0x0(%rax,%rax,1)
test   %ebx,%ebx
je     11d2 <print_values_matching+0xa2>
cmp    %r14,%r15
jae    11d9 <print_values_matching+0xa9>
movsbl 0x12(%rsp),%eax
add    %ebp,%eax
test   %r13d,%eax
jne    11a8 <print_values_matching+0x78>
lea    0xe70(%rip),%rdi
mov    %r12,%rsi
call   1040 <printf@plt>
add    $0x1,%r15
mov    $0xa,%esi
mov    $0xb,%edx
mov    %r12,%rdi
call   1030 <increment@plt>
mov    %eax,%ebx
cmp    $0x2,%eax
jne    1180 <print_values_matching+0x50>
mov    $0xa,%esi
mov    %r12,%rdi
call   1050 <partial_hash@plt>
mov    %eax,%ebp
jmp    1180 <print_values_matching+0x50>
mov    $0x1,%eax
jmp    11db <print_values_matching+0xab>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@__const.print_values_matching.s = [12 x i8] c"00000000000\00"
@.str = [17 x i8] c" \22%s\22: null,\0A\00"
define i32 @print_values_matching(i32 %0) {
%2 = alloca [12 x i8]
%3 = getelementptr inbounds [12 x i8], [12 x i8]* %2, i64 0, i64 0
%4 = add i32 %0, -1
%5 = call i32 @partial_hash(i8* %3, i64 10)
%6 = zext i32 %0 to i64
%7 = getelementptr inbounds [12 x i8], [12 x i8]* %2, i64 0, i64 10
br label %8
8: ; preds = %27, %1
%9 = phi i32 [ %5, %1 ], [ %28, %27 ]
%10 = phi i64 [ 0, %1 ], [ %22, %27 ]
%11 = icmp ult i64 %10, %6
br i1 %11, label %12, label %30
12: ; preds = %8
%13 = load i8, i8* %7
%14 = sext i8 %13 to i32
%15 = add i32 %9, %14
%16 = and i32 %15, %4
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %21
18: ; preds = %12
%19 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %3)
%20 = add nuw i64 %10, 1
br label %21
21: ; preds = %18, %12
%22 = phi i64 [ %10, %12 ], [ %20, %18 ]
%23 = call i32 @increment(i8* %3, i64 10, i64 11)
%24 = icmp eq i32 %23, 2
br i1 %24, label %25, label %27
25: ; preds = %21
%26 = call i32 @partial_hash(i8* %3, i64 10)
br label %27
27: ; preds = %25, %21
%28 = phi i32 [ %26, %25 ], [ %9, %21 ]
%29 = icmp eq i32 %23, 0
br i1 %29, label %30, label %8
30: ; preds = %8, %27
%31 = phi i32 [ 1, %27 ], [ 0, %8 ]
ret i32 %31
}