#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 */
struct cjet_utf8_checker {
  int dummy;
};
typedef scalar_t__ clock_t;

/* Variables and functions */
double CLOCKS_PER_SEC;
int cjet_is_word_sequence_valid(struct cjet_utf8_checker *,
                                unsigned int const *, size_t, int);
scalar_t__ clock();
int /*<<< orphan*/ printf(char *, ...);
void test_word(struct cjet_utf8_checker *c, const unsigned int *testdata_word,
               size_t length) {
  clock_t start, stop;
  start = clock();
  int ret = cjet_is_word_sequence_valid(c, testdata_word, length, 1);
  stop = clock();
  printf("Runtime test_word %ld cycles, %f sec\n", stop - start,
         (double)(stop - start) / CLOCKS_PER_SEC);
  if (ret) {
    printf("Word: ret true\n");
  } else {
    printf("Word: ret false\n");
  }
}


x86 assembly (clang, -O0):
<test_word>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    $0x0,%al
call   1040 <clock@plt>
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    $0x1,%ecx
call   1030 <cjet_is_word_sequence_valid@plt>
mov    %eax,-0x2c(%rbp)
mov    $0x0,%al
call   1040 <clock@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rsi
sub    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rax
sub    -0x20(%rbp),%rax
cvtsi2sd %rax,%xmm0
mov    0x2e59(%rip),%rax
divsd  (%rax),%xmm0
lea    0xe66(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
cmpl   $0x0,-0x2c(%rbp)
je     11be <test_word+0x8e>
lea    0xe74(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    11cc <test_word+0x9c>
lea    0xe71(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_word>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
xor    %eax,%eax
call   1050 <clock@plt>
mov    %rax,%r12
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r14,%rdx
mov    $0x1,%ecx
call   1030 <cjet_is_word_sequence_valid@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1050 <clock@plt>
sub    %r12,%rax
cvtsi2sd %rax,%xmm0
mov    0x2e62(%rip),%rcx
divsd  (%rcx),%xmm0
lea    0xe6f(%rip),%rdi
mov    %rax,%rsi
mov    $0x1,%al
call   1060 <printf@plt>
test   %ebx,%ebx
lea    0xe82(%rip),%rax
lea    0xe8b(%rip),%rdi
cmove  %rax,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1040 <puts@plt>

LLVM IR (-O0):
%struct.cjet_utf8_checker = type { i32 }
@.str = [38 x i8] c"Runtime test_word %ld cycles, %f sec\0A\00"
@CLOCKS_PER_SEC = global double 0.000000e+00
@.str.1 = [16 x i8] c"Word: ret true\0A\00"
@.str.2 = [17 x i8] c"Word: ret false\0A\00"
define void @test_word(%struct.cjet_utf8_checker* %0, i32* %1, i64 %2) {
%4 = alloca %struct.cjet_utf8_checker*
%5 = alloca i32*
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64
%9 = alloca i32
store %struct.cjet_utf8_checker* %0, %struct.cjet_utf8_checker** %4
store i32* %1, i32** %5
store i64 %2, i64* %6
%10 = call i64 (...) @clock()
store i64 %10, i64* %7
%11 = load %struct.cjet_utf8_checker*, %struct.cjet_utf8_checker** %4
%12 = load i32*, i32** %5
%13 = load i64, i64* %6
%14 = call i32 @cjet_is_word_sequence_valid(%struct.cjet_utf8_checker* %11, i32* %12, i64 %13, i32 1)
store i32 %14, i32* %9
%15 = call i64 (...) @clock()
store i64 %15, i64* %8
%16 = load i64, i64* %8
%17 = load i64, i64* %7
%18 = sub nsw i64 %16, %17
%19 = load i64, i64* %8
%20 = load i64, i64* %7
%21 = sub nsw i64 %19, %20
%22 = sitofp i64 %21 to double
%23 = load double, double* @CLOCKS_PER_SEC
%24 = fdiv double %22, %23
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i64 %18, double %24)
%26 = load i32, i32* %9
%27 = icmp ne i32 %26, 0
br i1 %27, label %28, label %30
28: ; preds = %3
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
br label %32
30: ; preds = %3
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
br label %32
32: ; preds = %30, %28
ret void
}

LLVM IR (-O2):
%struct.cjet_utf8_checker = type { i32 }
@.str = [38 x i8] c"Runtime test_word %ld cycles, %f sec\0A\00"
@CLOCKS_PER_SEC = global double 0.000000e+00
@str = [16 x i8] c"Word: ret false\00"
@str.3 = [15 x i8] c"Word: ret true\00"
define void @test_word(%struct.cjet_utf8_checker* %0, i32* %1, i64 %2) {
%4 = tail call i64 (...) @clock()
%5 = tail call i32 @cjet_is_word_sequence_valid(%struct.cjet_utf8_checker* %0, i32* %1, i64 %2, i32 1)
%6 = tail call i64 (...) @clock()
%7 = sub nsw i64 %6, %4
%8 = sitofp i64 %7 to double
%9 = load double, double* @CLOCKS_PER_SEC
%10 = fdiv double %8, %9
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i64 %7, double %10)
%12 = icmp eq i32 %5, 0
%13 = select i1 %12, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @str, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @str.3, i64 0, i64 0)
%14 = tail call i32 @puts(i8* dereferenceable(1) %13)
ret void
}