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

/* Variables and functions */
scalar_t__ fgets(char *, int, int /*<<< orphan*/);
unsigned int func(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char *, unsigned int);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ strlen(char *);
int /*<<< orphan*/ strsep(char **, char *);
void bench() {
  char word[512], *p;
  unsigned int hash;
  while (fgets(word, sizeof(word), stdin)) {
    p = word;
    strsep(&p, "/ \t\f\r\n");
    if (!*word)
      continue;
    hash = func(word, strlen(word));
    printf("%s  %08x\n", word, hash);
  }
}


x86 assembly (clang, -O0):
<bench>:
push   %rbp
mov    %rsp,%rbp
sub    $0x220,%rsp
lea    -0x200(%rbp),%rdi
mov    0x2e7f(%rip),%rax
mov    (%rax),%edx
mov    $0x200,%esi
call   1050 <fgets@plt>
cmp    $0x0,%rax
je     11fe <bench+0xae>
lea    -0x200(%rbp),%rax
mov    %rax,-0x208(%rbp)
lea    -0x208(%rbp),%rdi
lea    0xe65(%rip),%rsi
call   1070 <strsep@plt>
cmpb   $0x0,-0x200(%rbp)
jne    11b2 <bench+0x62>
jmp    115b <bench+0xb>
lea    -0x200(%rbp),%rax
mov    %rax,-0x218(%rbp)
lea    -0x200(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x218(%rbp),%rdi
mov    %eax,%esi
call   1060 <func@plt>
mov    %eax,-0x20c(%rbp)
lea    -0x200(%rbp),%rsi
mov    -0x20c(%rbp),%edx
lea    0xe13(%rip),%rdi
call   1040 <printf@plt>
jmp    115b <bench+0xb>
add    $0x220,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bench>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x210,%rsp
mov    0x2e81(%rip),%r13
mov    0x0(%r13),%edx
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x200,%esi
call   1050 <fgets@plt>
test   %rax,%rax
je     11ee <bench+0x9e>
lea    0xe77(%rip),%r14
lea    0x8(%rsp),%r15
lea    0xe72(%rip),%r12
jmp    11b6 <bench+0x66>
nopw   0x0(%rax,%rax,1)
mov    0x0(%r13),%edx
mov    %rbx,%rdi
mov    $0x200,%esi
call   1050 <fgets@plt>
test   %rax,%rax
je     11ee <bench+0x9e>
mov    %rbx,0x8(%rsp)
mov    %r15,%rdi
mov    %r14,%rsi
call   1070 <strsep@plt>
cmpb   $0x0,0x10(%rsp)
je     11a0 <bench+0x50>
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1060 <func@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1040 <printf@plt>
jmp    11a0 <bench+0x50>
add    $0x210,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@stdin = global i32 0
@.str = [7 x i8] c"/ \09\0C\0D\0A\00"
@.str.1 = [10 x i8] c"%s %08x\0A\00"
define void @bench() {
%1 = alloca [512 x i8]
%2 = alloca i8*
%3 = alloca i32
br label %4
4: ; preds = %16, %15, %0
%5 = getelementptr inbounds [512 x i8], [512 x i8]* %1, i64 0, i64 0
%6 = load i32, i32* @stdin
%7 = call i64 @fgets(i8* %5, i32 512, i32 %6)
%8 = icmp ne i64 %7, 0
br i1 %8, label %9, label %24
9: ; preds = %4
%10 = getelementptr inbounds [512 x i8], [512 x i8]* %1, i64 0, i64 0
store i8* %10, i8** %2
%11 = call i32 @strsep(i8** %2, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%12 = getelementptr inbounds [512 x i8], [512 x i8]* %1, i64 0, i64 0
%13 = load i8, i8* %12
%14 = icmp ne i8 %13, 0
br i1 %14, label %16, label %15
15: ; preds = %9
br label %4
16: ; preds = %9
%17 = getelementptr inbounds [512 x i8], [512 x i8]* %1, i64 0, i64 0
%18 = getelementptr inbounds [512 x i8], [512 x i8]* %1, i64 0, i64 0
%19 = call i32 @strlen(i8* %18)
%20 = call i32 @func(i8* %17, i32 %19)
store i32 %20, i32* %3
%21 = getelementptr inbounds [512 x i8], [512 x i8]* %1, i64 0, i64 0
%22 = load i32, i32* %3
%23 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %21, i32 %22)
br label %4
24: ; preds = %4
ret void
}

LLVM IR (-O2):
@stdin = global i32 0
@.str = [7 x i8] c"/ \09\0C\0D\0A\00"
@.str.1 = [10 x i8] c"%s %08x\0A\00"
define void @bench() {
%1 = alloca [512 x i8]
%2 = alloca i8*
%3 = getelementptr inbounds [512 x i8], [512 x i8]* %1, i64 0, i64 0
%4 = bitcast i8** %2 to i8*
%5 = load i32, i32* @stdin
%6 = call i64 @fgets(i8* %3, i32 512, i32 %5)
%7 = icmp eq i64 %6, 0
br i1 %7, label %20, label %8
8: ; preds = %0, %16
store i8* %3, i8** %2
%9 = call i32 @strsep(i8** %2, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%10 = load i8, i8* %3
%11 = icmp eq i8 %10, 0
br i1 %11, label %16, label %12
12: ; preds = %8
%13 = call i32 @strlen(i8* %3)
%14 = call i32 @func(i8* %3, i32 %13)
%15 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %3, i32 %14)
br label %16
16: ; preds = %12, %8
%17 = load i32, i32* @stdin
%18 = call i64 @fgets(i8* %3, i32 512, i32 %17)
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %8
20: ; preds = %16, %0
ret void
}