#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 getfield(char *, int, int, int);
void getwords(char *block, char *s, int wordoff, int max) {
  register int i;
  int ct = 0;
  while (ct < max) {
    for (i = 0; i < 5; i++)
      *s++ = getfield(block, wordoff, i * 7, 7);
    s[-1] |= getfield(block, wordoff, 35, 1) << 7;
    wordoff++;
    ct++;
  }
}


x86 assembly (clang, -O0):
<getwords>:
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    11bf <getwords+0xaf>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x5,-0x1c(%rbp)
jge    1180 <getwords+0x70>
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%esi
imul   $0x7,-0x1c(%rbp),%edx
mov    $0x7,%ecx
call   1030 <getfield@plt>
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x10(%rbp)
mov    %cl,(%rax)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1140 <getwords+0x30>
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    $0x23,%edx
mov    $0x1,%ecx
call   1030 <getfield@plt>
mov    %eax,%edx
shl    $0x7,%edx
mov    -0x10(%rbp),%rax
movsbl -0x1(%rax),%ecx
or     %edx,%ecx
mov    %cl,-0x1(%rax)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    112d <getwords+0x1d>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getwords>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
test   %ecx,%ecx
jle    11ca <getwords+0xba>
mov    %ecx,%r14d
mov    %edx,%ebp
mov    %rsi,%rbx
mov    %rdi,%r15
nopw   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %ebp,%esi
xor    %edx,%edx
mov    $0x7,%ecx
call   1030 <getfield@plt>
mov    %al,(%rbx)
mov    %r15,%rdi
mov    %ebp,%esi
mov    $0x7,%edx
mov    $0x7,%ecx
call   1030 <getfield@plt>
mov    %al,0x1(%rbx)
mov    %r15,%rdi
mov    %ebp,%esi
mov    $0xe,%edx
mov    $0x7,%ecx
call   1030 <getfield@plt>
mov    %al,0x2(%rbx)
mov    %r15,%rdi
mov    %ebp,%esi
mov    $0x15,%edx
mov    $0x7,%ecx
call   1030 <getfield@plt>
mov    %al,0x3(%rbx)
mov    %r15,%rdi
mov    %ebp,%esi
mov    $0x1c,%edx
mov    $0x7,%ecx
call   1030 <getfield@plt>
mov    %al,0x4(%rbx)
mov    %r15,%rdi
mov    %ebp,%esi
mov    $0x23,%edx
mov    $0x1,%ecx
call   1030 <getfield@plt>
shl    $0x7,%al
or     %al,0x4(%rbx)
add    $0x1,%ebp
add    $0x5,%rbx
add    $0xffffffff,%r14d
jne    1130 <getwords+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @getwords(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 %46
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, 5
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, 7
%24 = call i32 @getfield(i8* %20, i32 %21, i32 %23, i32 7)
%25 = trunc i32 %24 to i8
%26 = load i8*, i8** %6
%27 = getelementptr inbounds i8, i8* %26, i32 1
store i8* %27, i8** %6
store i8 %25, i8* %26
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 i8*, i8** %5
%33 = load i32, i32* %7
%34 = call i32 @getfield(i8* %32, i32 %33, i32 35, i32 1)
%35 = shl i32 %34, 7
%36 = load i8*, i8** %6
%37 = getelementptr inbounds i8, i8* %36, i64 -1
%38 = load i8, i8* %37
%39 = sext i8 %38 to i32
%40 = or i32 %39, %35
%41 = trunc i32 %40 to i8
store i8 %41, i8* %37
%42 = load i32, i32* %7
%43 = add nsw i32 %42, 1
store i32 %43, i32* %7
%44 = load i32, i32* %10
%45 = add nsw i32 %44, 1
store i32 %45, i32* %10
br label %11
46: ; preds = %11
ret void
}

LLVM IR (-O2):
define void @getwords(i8* %0, i8* nocapture %1, i32 %2, i32 %3) {
%5 = icmp sgt i32 %3, 0
br i1 %5, label %6, label %33
6: ; preds = %4, %6
%7 = phi i32 [ %31, %6 ], [ 0, %4 ]
%8 = phi i8* [ %24, %6 ], [ %1, %4 ]
%9 = phi i32 [ %30, %6 ], [ %2, %4 ]
%10 = tail call i32 @getfield(i8* %0, i32 %9, i32 0, i32 7)
%11 = trunc i32 %10 to i8
%12 = getelementptr inbounds i8, i8* %8, i64 1
store i8 %11, i8* %8
%13 = tail call i32 @getfield(i8* %0, i32 %9, i32 7, i32 7)
%14 = trunc i32 %13 to i8
%15 = getelementptr inbounds i8, i8* %8, i64 2
store i8 %14, i8* %12
%16 = tail call i32 @getfield(i8* %0, i32 %9, i32 14, i32 7)
%17 = trunc i32 %16 to i8
%18 = getelementptr inbounds i8, i8* %8, i64 3
store i8 %17, i8* %15
%19 = tail call i32 @getfield(i8* %0, i32 %9, i32 21, i32 7)
%20 = trunc i32 %19 to i8
%21 = getelementptr inbounds i8, i8* %8, i64 4
store i8 %20, i8* %18
%22 = tail call i32 @getfield(i8* %0, i32 %9, i32 28, i32 7)
%23 = trunc i32 %22 to i8
%24 = getelementptr inbounds i8, i8* %8, i64 5
store i8 %23, i8* %21
%25 = tail call i32 @getfield(i8* %0, i32 %9, i32 35, i32 1)
%26 = load i8, i8* %21
%27 = trunc i32 %25 to i8
%28 = shl i8 %27, 7
%29 = or i8 %28, %26
store i8 %29, i8* %21
%30 = add nsw i32 %9, 1
%31 = add nuw nsw i32 %7, 1
%32 = icmp eq i32 %31, %3
br i1 %32, label %33, label %6
33: ; preds = %6, %4
ret void
}