#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 bword(char *buf, int bloc, int bnum) {
  int i;
  int word = 0;
  char *byte = &word;
  buf += bloc;
  byte += 4 - bnum;
  for (i = 0; i < bnum; i++)
    *(byte++) = *(buf++);
  return word;
}


x86 assembly (clang, -O0):
<bword>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
lea    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0xc(%rbp),%ecx
mov    -0x8(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x8(%rbp)
mov    $0x4,%ecx
sub    -0x10(%rbp),%ecx
mov    -0x20(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    1187 <bword+0x87>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
mov    (%rax),%cl
mov    -0x20(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x20(%rbp)
mov    %cl,(%rax)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    114b <bword+0x4b>
mov    -0x18(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<bword>:
push   %rax
movl   $0x0,0x4(%rsp)
test   %edx,%edx
jle    1148 <bword+0x38>
mov    %rdi,%rax
mov    $0x4,%ecx
sub    %edx,%ecx
movslq %ecx,%rdi
movslq %esi,%rcx
add    %rcx,%rax
lea    0x4(%rsp),%rcx
add    %rcx,%rdi
mov    %edx,%edx
mov    %rax,%rsi
call   1030 <memcpy@plt>
mov    0x4(%rsp),%eax
pop    %rcx
ret
xor    %eax,%eax
pop    %rcx
ret

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

LLVM IR (-O2):
define i32 @bword(i8* nocapture %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = bitcast i32* %4 to i8*
store i32 0, i32* %4
%6 = icmp sgt i32 %2, 0
br i1 %6, label %7, label %18
7: ; preds = %3
%8 = sub nsw i32 4, %2
%9 = sext i32 %8 to i64
%10 = sext i32 %1 to i64
%11 = getelementptr i8, i8* %0, i64 %10
%12 = getelementptr inbounds i32, i32* %4, i64 1
%13 = bitcast i32* %12 to i8*
%14 = add nsw i64 %9, -4
%15 = getelementptr i8, i8* %13, i64 %14
%16 = zext i32 %2 to i64
%17 = load i32, i32* %4
br label %18
18: ; preds = %7, %3
%19 = phi i32 [ %17, %7 ], [ 0, %3 ]
ret i32 %19
}