#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 */
char getfield(char *, int, int, int);
void getbytes(char *block, char *s, int wordoff, int max) {
  register int i;
  int ct = 0;
  while (ct < max) {
    for (i = 0; i < 4; i++) {
      *s = getfield(block, wordoff, i * 8, 8);
      s++;
    }
    wordoff++;
    ct += 4;
  }
}


x86 assembly (clang, -O0):
<getbytes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    119a <getbytes+0x8a>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x4,-0x1c(%rbp)
jge    1183 <getbytes+0x73>
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x1c(%rbp),%edx
shl    $0x3,%edx
mov    $0x8,%ecx
call   1030 <getfield@plt>
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,(%rax)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1140 <getbytes+0x30>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x20(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0x20(%rbp)
jmp    112d <getbytes+0x1d>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getbytes>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
test   %ecx,%ecx
jle    119c <getbytes+0x8c>
mov    %ecx,%r14d
mov    %edx,%ebp
mov    %rsi,%r15
mov    %rdi,%r12
xor    %ebx,%ebx
nopl   (%rax)
mov    %r12,%rdi
mov    %ebp,%esi
xor    %edx,%edx
mov    $0x8,%ecx
call   1030 <getfield@plt>
mov    %al,(%r15,%rbx,1)
mov    %r12,%rdi
mov    %ebp,%esi
mov    $0x8,%edx
mov    $0x8,%ecx
call   1030 <getfield@plt>
mov    %al,0x1(%r15,%rbx,1)
mov    %r12,%rdi
mov    %ebp,%esi
mov    $0x10,%edx
mov    $0x8,%ecx
call   1030 <getfield@plt>
mov    %al,0x2(%r15,%rbx,1)
mov    %r12,%rdi
mov    %ebp,%esi
mov    $0x18,%edx
mov    $0x8,%ecx
call   1030 <getfield@plt>
mov    %al,0x3(%r15,%rbx,1)
add    $0x1,%ebp
add    $0x4,%rbx
cmp    %r14d,%ebx
jl     1130 <getbytes+0x20>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @getbytes(i8* %0, i8* nocapture writeonly %1, i32 %2, i32 %3) {
%5 = icmp sgt i32 %3, 0
br i1 %5, label %6, label %21
6: ; preds = %4, %6
%7 = phi i32 [ %19, %6 ], [ 0, %4 ]
%8 = phi i8* [ %17, %6 ], [ %1, %4 ]
%9 = phi i32 [ %18, %6 ], [ %2, %4 ]
%10 = tail call signext i8 @getfield(i8* %0, i32 %9, i32 0, i32 8)
store i8 %10, i8* %8
%11 = getelementptr inbounds i8, i8* %8, i64 1
%12 = tail call signext i8 @getfield(i8* %0, i32 %9, i32 8, i32 8)
store i8 %12, i8* %11
%13 = getelementptr inbounds i8, i8* %8, i64 2
%14 = tail call signext i8 @getfield(i8* %0, i32 %9, i32 16, i32 8)
store i8 %14, i8* %13
%15 = getelementptr inbounds i8, i8* %8, i64 3
%16 = tail call signext i8 @getfield(i8* %0, i32 %9, i32 24, i32 8)
store i8 %16, i8* %15
%17 = getelementptr inbounds i8, i8* %8, i64 4
%18 = add nsw i32 %9, 1
%19 = add nuw nsw i32 %7, 4
%20 = icmp slt i32 %19, %3
br i1 %20, label %6, label %21
21: ; preds = %6, %4
ret void
}