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

/* Variables and functions */
int /*<<< orphan*/ fread(int *, int, int, int /*<<< orphan*/ *);
int read_our_data_into_two_vars_and_a_funky_block(FILE *fincoming,
                                                  uint8_t *paddress,
                                                  uint8_t *pcmd,
                                                  uint8_t *pblock_length,
                                                  uint8_t *block) {
  fread(paddress, 1, sizeof(__u8), fincoming);
  fread(pcmd, 1, sizeof(__u8), fincoming);
  fread(pblock_length, 1, 1, fincoming);
  for (int i = 0; i < *pblock_length; i++) {
    fread(&(block[i]), 1, sizeof(__u8), fincoming);
  }
  return (0);
}


x86 assembly (clang, -O0):
<read_our_data_into_two_vars_and_a_funky_block>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    $0x1,%esi
mov    $0x4,%edx
call   1030 <fread@plt>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    $0x1,%esi
mov    $0x4,%edx
call   1030 <fread@plt>
mov    -0x20(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    $0x1,%edx
mov    %edx,%esi
call   1030 <fread@plt>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    -0x20(%rbp),%rcx
cmp    (%rcx),%eax
jge    11b4 <read_our_data_into_two_vars_and_a_funky_block+0xa4>
mov    -0x28(%rbp),%rdi
movslq -0x2c(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdi
mov    -0x8(%rbp),%rcx
mov    $0x1,%esi
mov    $0x4,%edx
call   1030 <fread@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1175 <read_our_data_into_two_vars_and_a_funky_block+0x65>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_our_data_into_two_vars_and_a_funky_block>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %r8,%r13
mov    %rcx,%r14
mov    %rdx,%r12
mov    %rdi,%r15
mov    %rsi,%rdi
mov    $0x1,%esi
mov    $0x4,%edx
mov    %r15,%rcx
call   1030 <fread@plt>
mov    %r12,%rdi
mov    $0x1,%esi
mov    $0x4,%edx
mov    %r15,%rcx
call   1030 <fread@plt>
mov    %r14,%rdi
mov    $0x1,%esi
mov    $0x1,%edx
mov    %r15,%rcx
call   1030 <fread@plt>
cmpl   $0x0,(%r14)
jle    1195 <read_our_data_into_two_vars_and_a_funky_block+0x85>
xor    %ebx,%ebx
nopl   0x0(%rax)
mov    %r13,%rdi
mov    $0x1,%esi
mov    $0x4,%edx
mov    %r15,%rcx
call   1030 <fread@plt>
add    $0x1,%rbx
movslq (%r14),%rax
add    $0x4,%r13
cmp    %rax,%rbx
jl     1170 <read_our_data_into_two_vars_and_a_funky_block+0x60>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

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