#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 /*<<< orphan*/ edfread_physical_samples(int const, int, int const,
                                            double *);
int /*<<< orphan*/ edfseek(int const, int, int const, int /*<<< orphan*/);
void read_physical_samples(const int hdl, int *channels, const int CHANNELS,
                           const int START, const int SIZE, double *buf) {
  int j;
  for (j = 0; j < CHANNELS; j++) {
    edfseek(hdl, channels[j], START, 0);
    edfread_physical_samples(hdl, channels[j], SIZE, &(buf[SIZE * j]));
  }
}


x86 assembly (clang, -O0):
<read_physical_samples>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    %r8d,-0x1c(%rbp)
mov    %r9,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11a0 <read_physical_samples+0x80>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
mov    -0x18(%rbp),%edx
xor    %ecx,%ecx
call   1040 <edfseek@plt>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
mov    -0x1c(%rbp),%edx
mov    -0x28(%rbp),%rcx
mov    -0x1c(%rbp),%eax
imul   -0x2c(%rbp),%eax
cltq
shl    $0x3,%rax
add    %rax,%rcx
call   1030 <edfread_physical_samples@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1144 <read_physical_samples+0x24>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_physical_samples>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r8d,0xc(%rsp)
test   %edx,%edx
jle    1190 <read_physical_samples+0x70>
mov    %r9,%rbx
mov    %ecx,%r14d
mov    %rsi,%r12
mov    %edi,%ebp
movslq 0xc(%rsp),%r13
mov    %edx,%eax
mov    %rax,0x10(%rsp)
shl    $0x3,%r13
xor    %r15d,%r15d
cs nopw 0x0(%rax,%rax,1)
nop
mov    (%r12,%r15,4),%esi
mov    %ebp,%edi
mov    %r14d,%edx
xor    %ecx,%ecx
call   1040 <edfseek@plt>
mov    (%r12,%r15,4),%esi
mov    %ebp,%edi
mov    0xc(%rsp),%edx
mov    %rbx,%rcx
call   1030 <edfread_physical_samples@plt>
add    $0x1,%r15
add    %r13,%rbx
cmp    %r15,0x10(%rsp)
jne    1160 <read_physical_samples+0x40>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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