#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 /*<<< orphan*/ uint8_t;
typedef int /*<<< orphan*/ uint32_t;

/* Variables and functions */
scalar_t__ read_int(int /*<<< orphan*/ const *, int /*<<< orphan*/ *);
size_t read_ints_single(const uint8_t *in, uint32_t *out, int length) {
  size_t consumed = 0;
  for (int count = 0; count < length; count++) {
    consumed += read_int(in + consumed, out + count);
  }
  return consumed;
}


x86 assembly (clang, -O0):
<read_ints_single>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movq   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1177 <read_ints_single+0x67>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdi
mov    -0x10(%rbp),%rsi
movslq -0x24(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
call   1030 <read_int@plt>
add    -0x20(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1132 <read_ints_single+0x22>
mov    -0x20(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_ints_single>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
test   %edx,%edx
jle    114e <read_ints_single+0x3e>
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %edx,%r15d
xor    %r12d,%r12d
nopl   0x0(%rax,%rax,1)
lea    (%r14,%r12,4),%rdi
mov    %rbx,%rsi
call   1030 <read_int@plt>
add    %r12,%rax
add    $0x4,%rbx
mov    %rax,%r12
add    $0xffffffffffffffff,%r15
jne    1130 <read_ints_single+0x20>
jmp    1150 <read_ints_single+0x40>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define i64 @read_ints_single(i32* %0, i32* %1, i32 %2) {
%4 = icmp sgt i32 %2, 0
br i1 %4, label %5, label %7
5: ; preds = %3
%6 = zext i32 %2 to i64
br label %9
7: ; preds = %9, %3
%8 = phi i64 [ 0, %3 ], [ %15, %9 ]
ret i64 %8
9: ; preds = %5, %9
%10 = phi i64 [ 0, %5 ], [ %16, %9 ]
%11 = phi i64 [ 0, %5 ], [ %15, %9 ]
%12 = getelementptr inbounds i32, i32* %0, i64 %11
%13 = getelementptr inbounds i32, i32* %1, i64 %10
%14 = tail call i64 @read_int(i32* %12, i32* %13)
%15 = add i64 %14, %11
%16 = add nuw nsw i64 %10, 1
%17 = icmp eq i64 %16, %6
br i1 %17, label %7, label %9
}