#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 u_int8_t;
typedef int u_int32_t;
typedef size_t u_int16_t;

/* Variables and functions */
u_int32_t Blowfish_stream2word(const u_int8_t *data, u_int16_t databytes,
                               u_int16_t *current) {
  u_int8_t i;
  u_int16_t j;
  u_int32_t temp;
  temp = 0x00000000;
  j = *current;
  for (i = 0; i < 4; i++, j++) {
    if (j >= databytes)
      j = 0;
    temp = (temp << 8) | data[j];
  }
  *current = j;
  return temp;
}


x86 assembly (clang, -O0):
<Blowfish_stream2word>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x4,-0x1c(%rbp)
jge    1177 <Blowfish_stream2word+0x77>
mov    -0x28(%rbp),%rax
cmp    -0x10(%rbp),%rax
jb     1149 <Blowfish_stream2word+0x49>
movq   $0x0,-0x28(%rbp)
mov    -0x2c(%rbp),%eax
shl    $0x8,%eax
mov    -0x8(%rbp),%rcx
mov    -0x28(%rbp),%rdx
or     (%rcx,%rdx,4),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    1129 <Blowfish_stream2word+0x29>
mov    -0x28(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x2c(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<Blowfish_stream2word>:
mov    (%rdx),%rcx
xor    %r8d,%r8d
cmp    %rsi,%rcx
cmovae %r8,%rcx
mov    (%rdi,%rcx,4),%r9d
add    $0x1,%rcx
cmp    %rsi,%rcx
cmovae %r8,%rcx
mov    (%rdi,%rcx,4),%eax
add    $0x1,%rcx
cmp    %rsi,%rcx
cmovae %r8,%rcx
shl    $0x10,%r9d
shl    $0x8,%eax
or     %r9d,%eax
or     (%rdi,%rcx,4),%eax
add    $0x1,%rcx
cmp    %rsi,%rcx
cmovae %r8,%rcx
shl    $0x8,%eax
or     (%rdi,%rcx,4),%eax
add    $0x1,%rcx
mov    %rcx,(%rdx)
ret

LLVM IR (-O0):
define i32 @Blowfish_stream2word(i32* %0, i64 %1, i64* %2) {
%4 = alloca i32*
%5 = alloca i64
%6 = alloca i64*
%7 = alloca i32
%8 = alloca i64
%9 = alloca i32
store i32* %0, i32** %4
store i64 %1, i64* %5
store i64* %2, i64** %6
store i32 0, i32* %9
%10 = load i64*, i64** %6
%11 = load i64, i64* %10
store i64 %11, i64* %8
store i32 0, i32* %7
br label %12
12: ; preds = %28, %3
%13 = load i32, i32* %7
%14 = icmp slt i32 %13, 4
br i1 %14, label %15, label %33
15: ; preds = %12
%16 = load i64, i64* %8
%17 = load i64, i64* %5
%18 = icmp uge i64 %16, %17
br i1 %18, label %19, label %20
19: ; preds = %15
store i64 0, i64* %8
br label %20
20: ; preds = %19, %15
%21 = load i32, i32* %9
%22 = shl i32 %21, 8
%23 = load i32*, i32** %4
%24 = load i64, i64* %8
%25 = getelementptr inbounds i32, i32* %23, i64 %24
%26 = load i32, i32* %25
%27 = or i32 %22, %26
store i32 %27, i32* %9
br label %28
28: ; preds = %20
%29 = load i32, i32* %7
%30 = add nsw i32 %29, 1
store i32 %30, i32* %7
%31 = load i64, i64* %8
%32 = add i64 %31, 1
store i64 %32, i64* %8
br label %12
33: ; preds = %12
%34 = load i64, i64* %8
%35 = load i64*, i64** %6
store i64 %34, i64* %35
%36 = load i32, i32* %9
ret i32 %36
}

LLVM IR (-O2):
define i32 @Blowfish_stream2word(i32* nocapture %0, i64 %1, i64* nocapture %2) {
%4 = load i64, i64* %2
%5 = icmp ult i64 %4, %1
%6 = select i1 %5, i64 %4, i64 0
%7 = getelementptr inbounds i32, i32* %0, i64 %6
%8 = load i32, i32* %7
%9 = add nuw i64 %6, 1
%10 = icmp ult i64 %9, %1
%11 = select i1 %10, i64 %9, i64 0
%12 = getelementptr inbounds i32, i32* %0, i64 %11
%13 = load i32, i32* %12
%14 = add nuw i64 %11, 1
%15 = icmp ult i64 %14, %1
%16 = select i1 %15, i64 %14, i64 0
%17 = shl i32 %8, 16
%18 = shl i32 %13, 8
%19 = or i32 %17, %18
%20 = getelementptr inbounds i32, i32* %0, i64 %16
%21 = load i32, i32* %20
%22 = or i32 %21, %19
%23 = add nuw i64 %16, 1
%24 = icmp ult i64 %23, %1
%25 = select i1 %24, i64 %23, i64 0
%26 = shl i32 %22, 8
%27 = getelementptr inbounds i32, i32* %0, i64 %25
%28 = load i32, i32* %27
%29 = or i32 %28, %26
%30 = add nuw i64 %25, 1
store i64 %30, i64* %2
ret i32 %29
}