#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*/ SEEK_SET;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ feof(int /*<<< orphan*/ *);
scalar_t__ ferror(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
scalar_t__ fread(float *, int, int, int /*<<< orphan*/ *);
scalar_t__ fseek(int /*<<< orphan*/ *, long, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ sscanf(char *, char *, long *);
int main(int argc, char **argv) {
  char *filename = 0;
  FILE *complexfile = 0;
  long offset;
  long number = 0;
  long i;
  if (argc != 4) {
    printf("usage: %s FILENAME NUMBEROFSAMPLES OFFSET\n", argv[0]);
    return 1;
  }
  filename = argv[1];
  if (sscanf(argv[2], "%ld", &number) == 0) {
    perror("something with the number of samples");
    return 1;
  }
  if (sscanf(argv[3], "%ld", &offset) == 0) {
    perror("something with the offset of the file");
    return 1;
  }
  complexfile = fopen(filename, "rb");
  if (complexfile == NULL) {
    perror("something when reading the file");
    return 1;
  }
  printf("filename %s, number of samples %ld, offset %ld:\n\n", filename,
         number, offset);
  if (fseek(complexfile, offset * 2 * sizeof(float), SEEK_SET) != 0) {
    perror("something when seeking the offset for the file");
    return 1;
  }
  for (i = 0; i < number; i++) {
    float a, b;
    if (fread(&a, sizeof(float), 1, complexfile) == 0 ||
        fread(&b, sizeof(float), 1, complexfile) == 0) {
      if (ferror(complexfile)) {
        perror("Something occurred while reading the file");
      }
      if (feof(complexfile)) {
        printf("end of the file\n");
      }
      break;
    }
    printf("%f %f\n", a, b);
  }
  fclose(complexfile);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x30(%rbp)
cmpl   $0x4,-0x8(%rbp)
je     11e9 <main+0x59>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe2a(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    13d8 <main+0x248>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe27(%rip),%rsi
lea    -0x30(%rbp),%rdx
call   1080 <sscanf@plt>
cmp    $0x0,%rax
jne    122f <main+0x9f>
lea    0xe11(%rip),%rdi
call   10b0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    13d8 <main+0x248>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
lea    0xded(%rip),%rsi
lea    -0x28(%rbp),%rdx
call   1080 <sscanf@plt>
cmp    $0x0,%rax
jne    1269 <main+0xd9>
lea    0xdfc(%rip),%rdi
call   10b0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    13d8 <main+0x248>
mov    -0x18(%rbp),%rdi
lea    0xe06(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    12a0 <main+0x110>
lea    0xdee(%rip),%rdi
call   10b0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    13d8 <main+0x248>
mov    -0x18(%rbp),%rsi
mov    -0x30(%rbp),%rdx
mov    -0x28(%rbp),%rcx
lea    0xdea(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
shl    $0x1,%rsi
shl    $0x2,%rsi
mov    0x2d0f(%rip),%rax
mov    (%rax),%edx
call   1090 <fseek@plt>
cmp    $0x0,%rax
je     12fa <main+0x16a>
lea    0xde6(%rip),%rdi
call   10b0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    13d8 <main+0x248>
movq   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%rax
cmp    -0x30(%rbp),%rax
jge    13c8 <main+0x238>
mov    -0x20(%rbp),%rcx
lea    -0x3c(%rbp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   1040 <fread@plt>
cmp    $0x0,%rax
je     1352 <main+0x1c2>
mov    -0x20(%rbp),%rcx
lea    -0x40(%rbp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   1040 <fread@plt>
cmp    $0x0,%rax
jne    1397 <main+0x207>
mov    -0x20(%rbp),%rdi
call   1030 <ferror@plt>
cmp    $0x0,%rax
je     1371 <main+0x1e1>
lea    0xd92(%rip),%rdi
call   10b0 <perror@plt>
mov    -0x20(%rbp),%rdi
call   1070 <feof@plt>
cmp    $0x0,%rax
je     1392 <main+0x202>
lea    0xd9d(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    13c8 <main+0x238>
movss  -0x3c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x40(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xd89(%rip),%rdi
mov    $0x2,%al
call   1060 <printf@plt>
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
jmp    1302 <main+0x172>
mov    -0x20(%rbp),%rdi
call   1050 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x20,%rsp
mov    %rsi,%rbx
movq   $0x0,0x8(%rsp)
cmp    $0x4,%edi
jne    12df <main+0x13f>
mov    0x8(%rbx),%r14
mov    0x10(%rbx),%rdi
lea    0xe5a(%rip),%rsi
lea    0x8(%rsp),%rdx
call   1090 <sscanf@plt>
test   %rax,%rax
je     1335 <main+0x195>
mov    0x18(%rbx),%rdi
lea    0xe3c(%rip),%rsi
lea    0x18(%rsp),%rdx
call   1090 <sscanf@plt>
test   %rax,%rax
je     133e <main+0x19e>
lea    0xe71(%rip),%rsi
mov    %r14,%rdi
call   10b0 <fopen@plt>
test   %rax,%rax
je     1347 <main+0x1a7>
mov    %rax,%r13
mov    0x8(%rsp),%rdx
mov    0x18(%rsp),%rcx
lea    0xe6f(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x18(%rsp),%rsi
shl    $0x3,%rsi
mov    0x2d98(%rip),%rax
mov    (%rax),%edx
mov    %r13,%rdi
call   10a0 <fseek@plt>
test   %rax,%rax
jne    1350 <main+0x1b0>
cmpq   $0x0,0x8(%rsp)
jle    131d <main+0x17d>
xor    %ebx,%ebx
lea    0x14(%rsp),%r14
lea    0x10(%rsp),%r15
lea    0xeae(%rip),%r12
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %r13,%rcx
call   1050 <fread@plt>
test   %rax,%rax
je     12f7 <main+0x157>
mov    %r15,%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %r13,%rcx
call   1050 <fread@plt>
test   %rax,%rax
je     12f7 <main+0x157>
movss  0x14(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  0x10(%rsp),%xmm1
cvtss2sd %xmm1,%xmm1
mov    %r12,%rdi
mov    $0x2,%al
call   1070 <printf@plt>
add    $0x1,%rbx
cmp    0x8(%rsp),%rbx
jl     1280 <main+0xe0>
jmp    131d <main+0x17d>
mov    (%rbx),%rsi
lea    0xd17(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    $0x1,%eax
jmp    1327 <main+0x187>
mov    %r13,%rdi
call   1040 <ferror@plt>
test   %rax,%rax
jne    135e <main+0x1be>
mov    %r13,%rdi
call   1080 <feof@plt>
test   %rax,%rax
je     131d <main+0x17d>
lea    0xe17(%rip),%rdi
call   1030 <puts@plt>
mov    %r13,%rdi
call   1060 <fclose@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
lea    0xcf3(%rip),%rdi
jmp    1357 <main+0x1b7>
lea    0xd0f(%rip),%rdi
jmp    1357 <main+0x1b7>
lea    0xd2f(%rip),%rdi
jmp    1357 <main+0x1b7>
lea    0xd78(%rip),%rdi
call   10c0 <perror@plt>
jmp    12f0 <main+0x150>
lea    0xd99(%rip),%rdi
call   10c0 <perror@plt>
jmp    1304 <main+0x164>

LLVM IR (-O0):
@.str = [43 x i8] c"usage: %s FILENAME NUMBEROFSAMPLES OFFSET\0A\00"
@.str.1 = [4 x i8] c"%ld\00"
@.str.2 = [37 x i8] c"something with the number of samples\00"
@.str.3 = [38 x i8] c"something with the offset of the file\00"
@.str.4 = [3 x i8] c"rb\00"
@.str.5 = [32 x i8] c"something when reading the file\00"
@.str.6 = [50 x i8] c"filename %s, number of samples %ld, offset %ld:\0A\0A\00"
@SEEK_SET = global i32 0
@.str.7 = [47 x i8] c"something when seeking the offset for the file\00"
@.str.8 = [42 x i8] c"Something occurred while reading the file\00"
@.str.9 = [17 x i8] c"end of the file\0A\00"
@.str.10 = [7 x i8] c"%f %f\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32*
%8 = alloca i64
%9 = alloca i64
%10 = alloca i64
%11 = alloca float
%12 = alloca float
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* null, i8** %6
store i32* null, i32** %7
store i64 0, i64* %9
%13 = load i32, i32* %4
%14 = icmp ne i32 %13, 4
br i1 %14, label %15, label %20
15: ; preds = %2
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 0
%18 = load i8*, i8** %17
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i8* %18)
store i32 1, i32* %3
br label %98
20: ; preds = %2
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 1
%23 = load i8*, i8** %22
store i8* %23, i8** %6
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 2
%26 = load i8*, i8** %25
%27 = call i64 @sscanf(i8* %26, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64* %9)
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %31
29: ; preds = %20
%30 = call i32 @perror(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %3
br label %98
31: ; preds = %20
%32 = load i8**, i8*** %5
%33 = getelementptr inbounds i8*, i8** %32, i64 3
%34 = load i8*, i8** %33
%35 = call i64 @sscanf(i8* %34, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64* %8)
%36 = icmp eq i64 %35, 0
br i1 %36, label %37, label %39
37: ; preds = %31
%38 = call i32 @perror(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0))
store i32 1, i32* %3
br label %98
39: ; preds = %31
%40 = load i8*, i8** %6
%41 = call i32* @fopen(i8* %40, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
store i32* %41, i32** %7
%42 = load i32*, i32** %7
%43 = icmp eq i32* %42, null
br i1 %43, label %44, label %46
44: ; preds = %39
%45 = call i32 @perror(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.5, i64 0, i64 0))
store i32 1, i32* %3
br label %98
46: ; preds = %39
%47 = load i8*, i8** %6
%48 = load i64, i64* %9
%49 = load i64, i64* %8
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.6, i64 0, i64 0), i8* %47, i64 %48, i64 %49)
%51 = load i32*, i32** %7
%52 = load i64, i64* %8
%53 = mul nsw i64 %52, 2
%54 = mul i64 %53, 4
%55 = load i32, i32* @SEEK_SET
%56 = call i64 @fseek(i32* %51, i64 %54, i32 %55)
%57 = icmp ne i64 %56, 0
br i1 %57, label %58, label %60
58: ; preds = %46
%59 = call i32 @perror(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.7, i64 0, i64 0))
store i32 1, i32* %3
br label %98
60: ; preds = %46
store i64 0, i64* %10
br label %61
61: ; preds = %92, %60
%62 = load i64, i64* %10
%63 = load i64, i64* %9
%64 = icmp slt i64 %62, %63
br i1 %64, label %65, label %95
65: ; preds = %61
%66 = load i32*, i32** %7
%67 = call i64 @fread(float* %11, i32 4, i32 1, i32* %66)
%68 = icmp eq i64 %67, 0
br i1 %68, label %73, label %69
69: ; preds = %65
%70 = load i32*, i32** %7
%71 = call i64 @fread(float* %12, i32 4, i32 1, i32* %70)
%72 = icmp eq i64 %71, 0
br i1 %72, label %73, label %86
73: ; preds = %69, %65
%74 = load i32*, i32** %7
%75 = call i64 @ferror(i32* %74)
%76 = icmp ne i64 %75, 0
br i1 %76, label %77, label %79
77: ; preds = %73
%78 = call i32 @perror(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.8, i64 0, i64 0))
br label %79
79: ; preds = %77, %73
%80 = load i32*, i32** %7
%81 = call i64 @feof(i32* %80)
%82 = icmp ne i64 %81, 0
br i1 %82, label %83, label %85
83: ; preds = %79
%84 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.9, i64 0, i64 0))
br label %85
85: ; preds = %83, %79
br label %95
86: ; preds = %69
%87 = load float, float* %11
%88 = fpext float %87 to double
%89 = load float, float* %12
%90 = fpext float %89 to double
%91 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.10, i64 0, i64 0), double %88, double %90)
br label %92
92: ; preds = %86
%93 = load i64, i64* %10
%94 = add nsw i64 %93, 1
store i64 %94, i64* %10
br label %61
95: ; preds = %85, %61
%96 = load i32*, i32** %7
%97 = call i32 @fclose(i32* %96)
store i32 0, i32* %3
br label %98
98: ; preds = %95, %58, %44, %37, %29, %15
%99 = load i32, i32* %3
ret i32 %99
}

LLVM IR (-O2):
@.str = [43 x i8] c"usage: %s FILENAME NUMBEROFSAMPLES OFFSET\0A\00"
@.str.1 = [4 x i8] c"%ld\00"
@.str.2 = [37 x i8] c"something with the number of samples\00"
@.str.3 = [38 x i8] c"something with the offset of the file\00"
@.str.4 = [3 x i8] c"rb\00"
@.str.5 = [32 x i8] c"something when reading the file\00"
@.str.6 = [50 x i8] c"filename %s, number of samples %ld, offset %ld:\0A\0A\00"
@SEEK_SET = global i32 0
@.str.7 = [47 x i8] c"something when seeking the offset for the file\00"
@.str.8 = [42 x i8] c"Something occurred while reading the file\00"
@.str.10 = [7 x i8] c"%f %f\0A\00"
@str = [16 x i8] c"end of the file\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i64
%4 = alloca i64
%5 = alloca float
%6 = alloca float
%7 = bitcast i64* %3 to i8*
%8 = bitcast i64* %4 to i8*
store i64 0, i64* %4
%9 = icmp eq i32 %0, 4
br i1 %9, label %13, label %10
10: ; preds = %2
%11 = load i8*, i8** %1
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i8* %11)
br label %80
13: ; preds = %2
%14 = getelementptr inbounds i8*, i8** %1, i64 1
%15 = load i8*, i8** %14
%16 = getelementptr inbounds i8*, i8** %1, i64 2
%17 = load i8*, i8** %16
%18 = call i64 @sscanf(i8* %17, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64* %4)
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %13
%21 = call i32 @perror(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0))
br label %80
22: ; preds = %13
%23 = getelementptr inbounds i8*, i8** %1, i64 3
%24 = load i8*, i8** %23
%25 = call i64 @sscanf(i8* %24, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64* %3)
%26 = icmp eq i64 %25, 0
br i1 %26, label %27, label %29
27: ; preds = %22
%28 = call i32 @perror(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0))
br label %80
29: ; preds = %22
%30 = call i32* @fopen(i8* %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%31 = icmp eq i32* %30, null
br i1 %31, label %32, label %34
32: ; preds = %29
%33 = call i32 @perror(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.5, i64 0, i64 0))
br label %80
34: ; preds = %29
%35 = load i64, i64* %4
%36 = load i64, i64* %3
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @.str.6, i64 0, i64 0), i8* %15, i64 %35, i64 %36)
%38 = load i64, i64* %3
%39 = shl i64 %38, 3
%40 = load i32, i32* @SEEK_SET
%41 = call i64 @fseek(i32* %30, i64 %39, i32 %40)
%42 = icmp eq i64 %41, 0
br i1 %42, label %43, label %49
43: ; preds = %34
%44 = load i64, i64* %4
%45 = icmp sgt i64 %44, 0
br i1 %45, label %46, label %78
46: ; preds = %43
%47 = bitcast float* %5 to i8*
%48 = bitcast float* %6 to i8*
br label %51
49: ; preds = %34
%50 = call i32 @perror(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.7, i64 0, i64 0))
br label %80
51: ; preds = %46, %69
%52 = phi i64 [ 0, %46 ], [ %75, %69 ]
%53 = call i64 @fread(float* %5, i32 4, i32 1, i32* %30)
%54 = icmp eq i64 %53, 0
br i1 %54, label %58, label %55
55: ; preds = %51
%56 = call i64 @fread(float* %6, i32 4, i32 1, i32* %30)
%57 = icmp eq i64 %56, 0
br i1 %57, label %58, label %69
58: ; preds = %55, %51
%59 = call i64 @ferror(i32* %30)
%60 = icmp eq i64 %59, 0
br i1 %60, label %63, label %61
61: ; preds = %58
%62 = call i32 @perror(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.8, i64 0, i64 0))
br label %63
63: ; preds = %61, %58
%64 = call i64 @feof(i32* %30)
%65 = icmp eq i64 %64, 0
br i1 %65, label %68, label %66
66: ; preds = %63
%67 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str, i64 0, i64 0))
br label %68
68: ; preds = %66, %63
br label %78
69: ; preds = %55
%70 = load float, float* %5
%71 = fpext float %70 to double
%72 = load float, float* %6
%73 = fpext float %72 to double
%74 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.10, i64 0, i64 0), double %71, double %73)
%75 = add nuw nsw i64 %52, 1
%76 = load i64, i64* %4
%77 = icmp slt i64 %75, %76
br i1 %77, label %51, label %78
78: ; preds = %69, %43, %68
%79 = call i32 @fclose(i32* %30)
br label %80
80: ; preds = %78, %49, %32, %27, %20, %10
%81 = phi i32 [ 1, %10 ], [ 1, %20 ], [ 1, %27 ], [ 1, %32 ], [ 1, %49 ], [ 0, %78 ]
ret i32 %81
}