#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 uint32_t;

/* Variables and functions */
int utf8_char_int(char const *);
char *utf8_next_char(char const *);
void gui_nick_hash_djb2_32(const char *nickname, uint32_t *color_32) {
  while (nickname && nickname[0]) {
    *color_32 ^= (*color_32 << 5) + (*color_32 >> 2) + utf8_char_int(nickname);
    nickname = utf8_next_char(nickname);
  }
}


x86 assembly (clang, -O0):
<gui_nick_hash_djb2_32>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x8(%rbp)
mov    %al,-0x11(%rbp)
je     1150 <gui_nick_hash_djb2_32+0x30>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    1160 <gui_nick_hash_djb2_32+0x40>
jmp    119f <gui_nick_hash_djb2_32+0x7f>
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
shl    $0x5,%eax
mov    -0x10(%rbp),%rcx
mov    (%rcx),%ecx
sar    $0x2,%ecx
add    %ecx,%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <utf8_char_int@plt>
mov    -0x18(%rbp),%ecx
add    %eax,%ecx
mov    -0x10(%rbp),%rax
xor    (%rax),%ecx
mov    %ecx,(%rax)
mov    -0x8(%rbp),%rdi
call   1040 <utf8_next_char@plt>
mov    %rax,-0x8(%rbp)
jmp    1130 <gui_nick_hash_djb2_32+0x10>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gui_nick_hash_djb2_32>:
push   %rbp
push   %r14
push   %rbx
test   %rdi,%rdi
je     115f <gui_nick_hash_djb2_32+0x3f>
mov    %rsi,%r14
mov    %rdi,%rbx
nop
cmpb   $0x0,(%rbx)
je     115f <gui_nick_hash_djb2_32+0x3f>
mov    (%r14),%ebp
mov    %ebp,%eax
shl    $0x5,%eax
sar    $0x2,%ebp
add    %eax,%ebp
mov    %rbx,%rdi
call   1030 <utf8_char_int@plt>
add    %ebp,%eax
xor    %eax,(%r14)
mov    %rbx,%rdi
call   1040 <utf8_next_char@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1130 <gui_nick_hash_djb2_32+0x10>
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define void @gui_nick_hash_djb2_32(i8* %0, i32* %1) {
%3 = alloca i8*
%4 = alloca i32*
store i8* %0, i8** %3
store i32* %1, i32** %4
br label %5
5: ; preds = %16, %2
%6 = load i8*, i8** %3
%7 = icmp ne i8* %6, null
br i1 %7, label %8, label %14
8: ; preds = %5
%9 = load i8*, i8** %3
%10 = getelementptr inbounds i8, i8* %9, i64 0
%11 = load i8, i8* %10
%12 = sext i8 %11 to i32
%13 = icmp ne i32 %12, 0
br label %14
14: ; preds = %8, %5
%15 = phi i1 [ false, %5 ], [ %13, %8 ]
br i1 %15, label %16, label %32
16: ; preds = %14
%17 = load i32*, i32** %4
%18 = load i32, i32* %17
%19 = shl i32 %18, 5
%20 = load i32*, i32** %4
%21 = load i32, i32* %20
%22 = ashr i32 %21, 2
%23 = add nsw i32 %19, %22
%24 = load i8*, i8** %3
%25 = call i32 @utf8_char_int(i8* %24)
%26 = add nsw i32 %23, %25
%27 = load i32*, i32** %4
%28 = load i32, i32* %27
%29 = xor i32 %28, %26
store i32 %29, i32* %27
%30 = load i8*, i8** %3
%31 = call i8* @utf8_next_char(i8* %30)
store i8* %31, i8** %3
br label %5
32: ; preds = %14
ret void
}

LLVM IR (-O2):
define void @gui_nick_hash_djb2_32(i8* %0, i32* nocapture %1) {
%3 = icmp eq i8* %0, null
br i1 %3, label %19, label %4
4: ; preds = %2, %8
%5 = phi i8* [ %17, %8 ], [ %0, %2 ]
%6 = load i8, i8* %5
%7 = icmp eq i8 %6, 0
br i1 %7, label %19, label %8
8: ; preds = %4
%9 = load i32, i32* %1
%10 = shl i32 %9, 5
%11 = ashr i32 %9, 2
%12 = add nsw i32 %10, %11
%13 = tail call i32 @utf8_char_int(i8* %5)
%14 = add nsw i32 %12, %13
%15 = load i32, i32* %1
%16 = xor i32 %14, %15
store i32 %16, i32* %1
%17 = tail call i8* @utf8_next_char(i8* %5)
%18 = icmp eq i8* %17, null
br i1 %18, label %19, label %4
19: ; preds = %4, %8, %2
ret void
}