#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*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, double *);
int /*<<< orphan*/ printf(char *);
void signal_loader(double *signal) {
  FILE *signal_file;
  int i;
  signal_file = fopen("signal.txt", "r");
  for (i = 0; i < 128; i++) {
    fscanf(signal_file, "%lf", &signal[i]);
    if (i >= 128) {
      printf("Too much signal samples!\n");
      break;
    }
  }
  fclose(signal_file);
}


x86 assembly (clang, -O0):
<signal_loader>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xead(%rip),%rdi
lea    0xeb1(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x80,-0x14(%rbp)
jge    11c7 <signal_loader+0x87>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rdx
movslq -0x14(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rdx
lea    0xe7c(%rip),%rsi
call   1050 <fscanf@plt>
cmpl   $0x80,-0x14(%rbp)
jl     11b4 <signal_loader+0x74>
lea    0xe67(%rip),%rdi
call   1040 <printf@plt>
jmp    11c7 <signal_loader+0x87>
jmp    11b9 <signal_loader+0x79>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    116a <signal_loader+0x2a>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<signal_loader>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r14
lea    0xebe(%rip),%rdi
lea    0xec2(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,%r12
xor    %ebx,%ebx
lea    0xeb3(%rip),%r15
nopw   0x0(%rax,%rax,1)
lea    (%r14,%rbx,1),%rdx
mov    %r12,%rdi
mov    %r15,%rsi
call   1040 <fscanf@plt>
add    $0x8,%rbx
cmp    $0x400,%rbx
jne    1160 <signal_loader+0x30>
mov    %r12,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1030 <fclose@plt>

LLVM IR (-O0):
@.str = [11 x i8] c"signal.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [4 x i8] c"%lf\00"
@.str.3 = [26 x i8] c"Too much signal samples!\0A\00"
define void @signal_loader(double* %0) {
%2 = alloca double*
%3 = alloca i32*
%4 = alloca i32
store double* %0, double** %2
%5 = call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %5, i32** %3
store i32 0, i32* %4
br label %6
6: ; preds = %21, %1
%7 = load i32, i32* %4
%8 = icmp slt i32 %7, 128
br i1 %8, label %9, label %24
9: ; preds = %6
%10 = load i32*, i32** %3
%11 = load double*, double** %2
%12 = load i32, i32* %4
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds double, double* %11, i64 %13
%15 = call i32 @fscanf(i32* %10, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %14)
%16 = load i32, i32* %4
%17 = icmp sge i32 %16, 128
br i1 %17, label %18, label %20
18: ; preds = %9
%19 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0))
br label %24
20: ; preds = %9
br label %21
21: ; preds = %20
%22 = load i32, i32* %4
%23 = add nsw i32 %22, 1
store i32 %23, i32* %4
br label %6
24: ; preds = %18, %6
%25 = load i32*, i32** %3
%26 = call i32 @fclose(i32* %25)
ret void
}

LLVM IR (-O2):
@.str = [11 x i8] c"signal.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [4 x i8] c"%lf\00"
define void @signal_loader(double* %0) {
%2 = tail call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %3
3: ; preds = %1, %3
%4 = phi i64 [ 0, %1 ], [ %7, %3 ]
%5 = getelementptr inbounds double, double* %0, i64 %4
%6 = tail call i32 @fscanf(i32* %2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %5)
%7 = add nuw nsw i64 %4, 1
%8 = icmp eq i64 %7, 128
br i1 %8, label %9, label %3
9: ; preds = %3
%10 = tail call i32 @fclose(i32* %2)
ret void
}