#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*/ printf(char *, unsigned int, unsigned int, ...);
unsigned dbgHashMake(const char *Name) {
  unsigned hash = 0;
  int i = 0;
  while (*Name) {
    hash = (hash << 1) | (1 & (hash >> (8 - 1)));
    printf("%d hash int %d, hex 0x%x\n", i++, hash, hash);
    hash ^= *Name++;
    printf("%d hash int %d, hex 0x%x\n", i++, hash, hash);
  }
  hash &= ((1 << 8) - 1);
  printf("final value hash %d 0x%x\n", hash, hash);
  return hash;
}


x86 assembly (clang, -O0):
<dbgHashMake>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
je     11a6 <dbgHashMake+0x96>
mov    -0xc(%rbp),%eax
shl    $0x1,%eax
mov    -0xc(%rbp),%ecx
shr    $0x7,%ecx
and    $0x1,%ecx
or     %ecx,%eax
mov    %eax,-0xc(%rbp)
mov    -0x10(%rbp),%esi
mov    %esi,%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%edx
mov    -0xc(%rbp),%ecx
lea    0xe9d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movsbl (%rax),%eax
xor    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x10(%rbp),%esi
mov    %esi,%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%edx
mov    -0xc(%rbp),%ecx
lea    0xe66(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    112a <dbgHashMake+0x1a>
mov    -0xc(%rbp),%eax
and    $0xff,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xe5c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dbgHashMake>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
cmpb   $0x0,(%rdi)
je     1179 <dbgHashMake+0x69>
mov    %rdi,%r15
add    $0x1,%r15
lea    0xed5(%rip),%r14
xor    %r12d,%r12d
xor    %ebx,%ebx
mov    %ebx,%eax
shr    $0x7,%eax
and    $0x1,%eax
lea    (%rax,%rbx,2),%ebp
mov    %r14,%rdi
mov    %r12d,%esi
mov    %ebp,%edx
mov    %ebp,%ecx
xor    %eax,%eax
call   1030 <printf@plt>
movsbl -0x1(%r15),%ebx
xor    %ebp,%ebx
lea    0x1(%r12),%esi
mov    %r14,%rdi
mov    %ebx,%edx
mov    %ebx,%ecx
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x2,%r12d
cmpb   $0x0,(%r15)
lea    0x1(%r15),%r15
jne    1130 <dbgHashMake+0x20>
movzbl %bl,%ebx
jmp    117b <dbgHashMake+0x6b>
xor    %ebx,%ebx
lea    0xe98(%rip),%rdi
mov    %ebx,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %ebx,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [26 x i8] c"%d hash int %d, hex 0x%x\0A\00"
@.str.1 = [26 x i8] c"final value hash %d 0x%x\0A\00"
define i32 @dbgHashMake(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %3
store i32 0, i32* %4
br label %5
5: ; preds = %9, %1
%6 = load i8*, i8** %2
%7 = load i8, i8* %6
%8 = icmp ne i8 %7, 0
br i1 %8, label %9, label %32
9: ; preds = %5
%10 = load i32, i32* %3
%11 = shl i32 %10, 1
%12 = load i32, i32* %3
%13 = lshr i32 %12, 7
%14 = and i32 1, %13
%15 = or i32 %11, %14
store i32 %15, i32* %3
%16 = load i32, i32* %4
%17 = add nsw i32 %16, 1
store i32 %17, i32* %4
%18 = load i32, i32* %3
%19 = load i32, i32* %3
%20 = call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %16, i32 %18, i32 %19)
%21 = load i8*, i8** %2
%22 = getelementptr inbounds i8, i8* %21, i32 1
store i8* %22, i8** %2
%23 = load i8, i8* %21
%24 = sext i8 %23 to i32
%25 = load i32, i32* %3
%26 = xor i32 %25, %24
store i32 %26, i32* %3
%27 = load i32, i32* %4
%28 = add nsw i32 %27, 1
store i32 %28, i32* %4
%29 = load i32, i32* %3
%30 = load i32, i32* %3
%31 = call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %27, i32 %29, i32 %30)
br label %5
32: ; preds = %5
%33 = load i32, i32* %3
%34 = and i32 %33, 255
store i32 %34, i32* %3
%35 = load i32, i32* %3
%36 = load i32, i32* %3
%37 = call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i32 %35, i32 %36)
%38 = load i32, i32* %3
ret i32 %38
}

LLVM IR (-O2):
@.str = [26 x i8] c"%d hash int %d, hex 0x%x\0A\00"
@.str.1 = [26 x i8] c"final value hash %d 0x%x\0A\00"
define i32 @dbgHashMake(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 0
br i1 %3, label %24, label %4
4: ; preds = %1, %4
%5 = phi i32 [ %18, %4 ], [ 0, %1 ]
%6 = phi i32 [ %17, %4 ], [ 0, %1 ]
%7 = phi i8* [ %14, %4 ], [ %0, %1 ]
%8 = shl i32 %6, 1
%9 = lshr i32 %6, 7
%10 = and i32 %9, 1
%11 = or i32 %10, %8
%12 = or i32 %5, 1
%13 = tail call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %5, i32 %11, i32 %11)
%14 = getelementptr inbounds i8, i8* %7, i64 1
%15 = load i8, i8* %7
%16 = sext i8 %15 to i32
%17 = xor i32 %11, %16
%18 = add nuw nsw i32 %5, 2
%19 = tail call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %12, i32 %17, i32 %17)
%20 = load i8, i8* %14
%21 = icmp eq i8 %20, 0
br i1 %21, label %22, label %4
22: ; preds = %4
%23 = and i32 %17, 255
br label %24
24: ; preds = %22, %1
%25 = phi i32 [ 0, %1 ], [ %23, %22 ]
%26 = tail call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i32 %25, i32 %25)
ret i32 %25
}