#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 */
scalar_t__ EOF;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
scalar_t__ fscanf(int /*<<< orphan*/ *, char *, int *, int *, float *, int *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, long, int /*<<< orphan*/);
long ftell(int /*<<< orphan*/ *);
int /*<<< orphan*/ memset(float *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *);
long get_user_block_data(int round, float *data, long file_start_index) {
  FILE *fp;
  int i = 0;
  memset(data, 0, sizeof(float) * 6000 * 65133);
  if ((fp = fopen("r1.train.raw", "r")) == NULL) {
    printf("cannot open this file");
    exit(0);
  }
  int user_id, item_id, timestamp;
  float rating = 0;
  long file_offset = 0;
  fseek(fp, file_start_index, 0);
  while (fscanf(fp, "%d %d %f %d", &user_id, &item_id, &rating, &timestamp) !=
         EOF) {
    if ((user_id - 1) < round * 6000)
      continue;
    if ((user_id - 1) >= (round + 1) * 6000)
      break;
    data[(user_id - 1 - (round * 6000)) * 65133 + item_id - 1] = rating;
    file_offset = ftell(fp);
  }
  fclose(fp);
  return file_offset;
}


x86 assembly (clang, -O0):
<get_user_block_data>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x10(%rbp),%rdi
xor    %esi,%esi
mov    $0x5d2c6ac0,%edx
call   1050 <memset@plt>
lea    0xe4f(%rip),%rdi
lea    0xe55(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    11de <get_user_block_data+0x5e>
lea    0xe3d(%rip),%rdi
call   1040 <printf@plt>
xor    %edi,%edi
call   10a0 <exit@plt>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x34(%rbp)
movq   $0x0,-0x40(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
xor    %edx,%edx
call   1080 <fseek@plt>
mov    -0x20(%rbp),%rdi
lea    0xe1d(%rip),%rsi
lea    -0x28(%rbp),%rdx
lea    -0x2c(%rbp),%rcx
lea    -0x34(%rbp),%r8
lea    -0x30(%rbp),%r9
call   1060 <fscanf@plt>
mov    0x2dc4(%rip),%rcx
cmp    (%rcx),%rax
je     12a4 <get_user_block_data+0x124>
mov    -0x28(%rbp),%eax
sub    $0x1,%eax
imul   $0x1770,-0x4(%rbp),%ecx
cmp    %ecx,%eax
jge    1247 <get_user_block_data+0xc7>
jmp    11fd <get_user_block_data+0x7d>
mov    -0x28(%rbp),%eax
sub    $0x1,%eax
mov    -0x4(%rbp),%ecx
add    $0x1,%ecx
imul   $0x1770,%ecx,%ecx
cmp    %ecx,%eax
jl     1266 <get_user_block_data+0xe6>
jmp    12a4 <get_user_block_data+0x124>
movss  -0x34(%rbp),%xmm0
mov    -0x10(%rbp),%rax
mov    -0x28(%rbp),%ecx
sub    $0x1,%ecx
imul   $0x1770,-0x4(%rbp),%edx
sub    %edx,%ecx
imul   $0xfe6d,%ecx,%ecx
add    -0x2c(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x20(%rbp),%rdi
call   1070 <ftell@plt>
mov    %rax,-0x40(%rbp)
jmp    11fd <get_user_block_data+0x7d>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x40(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_user_block_data>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rdx,%rbp
mov    %edi,%r14d
mov    %rsi,0x28(%rsp)
mov    %rsi,%rdi
xor    %esi,%esi
mov    $0x5d2c6ac0,%edx
call   1050 <memset@plt>
lea    0xe51(%rip),%rdi
lea    0xe57(%rip),%rsi
call   1090 <fopen@plt>
test   %rax,%rax
je     12a2 <get_user_block_data+0x122>
mov    %rax,%rbx
movl   $0x0,0xc(%rsp)
xor    %eax,%eax
mov    %rax,0x20(%rsp)
mov    %rbx,%rdi
mov    %rbp,%rsi
xor    %edx,%edx
call   1080 <fseek@plt>
imul   $0x1770,%r14d,%r12d
lea    0x1770(%r12),%eax
mov    %eax,0x14(%rsp)
mov    %r12d,%eax
not    %eax
mov    %eax,0x10(%rsp)
lea    0x18(%rsp),%rbp
lea    0xc(%rsp),%r14
lea    0x34(%rsp),%r15
mov    0x2dd3(%rip),%r13
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rbx,%rdi
lea    0xdfb(%rip),%rsi
lea    0x1c(%rsp),%rdx
mov    %rbp,%rcx
mov    %r14,%r8
mov    %r15,%r9
call   1060 <fscanf@plt>
cmp    0x0(%r13),%rax
je     1286 <get_user_block_data+0x106>
mov    0x1c(%rsp),%eax
cmp    %r12d,%eax
jle    1220 <get_user_block_data+0xa0>
cmp    0x14(%rsp),%eax
jg     1286 <get_user_block_data+0x106>
movss  0xc(%rsp),%xmm0
add    0x10(%rsp),%eax
imul   $0xfe6d,%eax,%eax
mov    0x18(%rsp),%ecx
add    %ecx,%eax
add    $0xffffffff,%eax
cltq
mov    0x28(%rsp),%rcx
movss  %xmm0,(%rcx,%rax,4)
mov    %rbx,%rdi
call   1070 <ftell@plt>
mov    %rax,0x20(%rsp)
jmp    1220 <get_user_block_data+0xa0>
mov    %rbx,%rdi
call   1030 <fclose@plt>
mov    0x20(%rsp),%rax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xd66(%rip),%rdi
call   1040 <printf@plt>
xor    %edi,%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@.str = [13 x i8] c"r1.train.raw\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [22 x i8] c"cannot open this file\00"
@.str.3 = [12 x i8] c"%d %d %f %d\00"
@EOF = global i64 0
define i64 @get_user_block_data(i32 %0, float* %1, i64 %2) {
%4 = alloca i32
%5 = alloca float*
%6 = alloca i64
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca float
%13 = alloca i64
store i32 %0, i32* %4
store float* %1, float** %5
store i64 %2, i64* %6
store i32 0, i32* %8
%14 = load float*, float** %5
%15 = call i32 @memset(float* %14, i32 0, i32 1563192000)
%16 = call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %16, i32** %7
%17 = icmp eq i32* %16, null
br i1 %17, label %18, label %21
18: ; preds = %3
%19 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
%20 = call i32 @exit(i32 0)
unreachable
21: ; preds = %3
store float 0.000000e+00, float* %12
store i64 0, i64* %13
%22 = load i32*, i32** %7
%23 = load i64, i64* %6
%24 = call i32 @fseek(i32* %22, i64 %23, i32 0)
br label %25
25: ; preds = %45, %36, %21
%26 = load i32*, i32** %7
%27 = call i64 @fscanf(i32* %26, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32* %9, i32* %10, float* %12, i32* %11)
%28 = load i64, i64* @EOF
%29 = icmp ne i64 %27, %28
br i1 %29, label %30, label %61
30: ; preds = %25
%31 = load i32, i32* %9
%32 = sub nsw i32 %31, 1
%33 = load i32, i32* %4
%34 = mul nsw i32 %33, 6000
%35 = icmp slt i32 %32, %34
br i1 %35, label %36, label %37
36: ; preds = %30
br label %25
37: ; preds = %30
%38 = load i32, i32* %9
%39 = sub nsw i32 %38, 1
%40 = load i32, i32* %4
%41 = add nsw i32 %40, 1
%42 = mul nsw i32 %41, 6000
%43 = icmp sge i32 %39, %42
br i1 %43, label %44, label %45
44: ; preds = %37
br label %61
45: ; preds = %37
%46 = load float, float* %12
%47 = load float*, float** %5
%48 = load i32, i32* %9
%49 = sub nsw i32 %48, 1
%50 = load i32, i32* %4
%51 = mul nsw i32 %50, 6000
%52 = sub nsw i32 %49, %51
%53 = mul nsw i32 %52, 65133
%54 = load i32, i32* %10
%55 = add nsw i32 %53, %54
%56 = sub nsw i32 %55, 1
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds float, float* %47, i64 %57
store float %46, float* %58
%59 = load i32*, i32** %7
%60 = call i64 @ftell(i32* %59)
store i64 %60, i64* %13
br label %25
61: ; preds = %44, %25
%62 = load i32*, i32** %7
%63 = call i32 @fclose(i32* %62)
%64 = load i64, i64* %13
ret i64 %64
}

LLVM IR (-O2):
@.str = [13 x i8] c"r1.train.raw\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [22 x i8] c"cannot open this file\00"
@.str.3 = [12 x i8] c"%d %d %f %d\00"
@EOF = global i64 0
define i64 @get_user_block_data(i32 %0, float* %1, i64 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca float
%8 = tail call i32 @memset(float* %1, i32 0, i32 1563192000)
%9 = tail call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%10 = icmp eq i32* %9, null
br i1 %10, label %11, label %14
11: ; preds = %3
%12 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
%13 = tail call i32 @exit(i32 0)
unreachable
14: ; preds = %3
%15 = bitcast i32* %4 to i8*
%16 = bitcast i32* %5 to i8*
%17 = bitcast i32* %6 to i8*
%18 = bitcast float* %7 to i8*
store float 0.000000e+00, float* %7
%19 = tail call i32 @fseek(i32* %9, i64 %2, i32 0)
%20 = mul i32 %0, 6000
%21 = add i32 %20, 6000
%22 = xor i32 %20, -1
br label %23
23: ; preds = %34, %14
%24 = phi i64 [ %43, %34 ], [ 0, %14 ]
br label %25
25: ; preds = %23, %29
%26 = call i64 @fscanf(i32* %9, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32* %4, i32* %5, float* %7, i32* %6)
%27 = load i64, i64* @EOF
%28 = icmp eq i64 %26, %27
br i1 %28, label %44, label %29
29: ; preds = %25
%30 = load i32, i32* %4
%31 = icmp sgt i32 %30, %20
br i1 %31, label %32, label %25
32: ; preds = %29
%33 = icmp sgt i32 %30, %21
br i1 %33, label %44, label %34
34: ; preds = %32
%35 = load float, float* %7
%36 = add i32 %30, %22
%37 = mul nsw i32 %36, 65133
%38 = load i32, i32* %5
%39 = add i32 %37, -1
%40 = add i32 %39, %38
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds float, float* %1, i64 %41
store float %35, float* %42
%43 = call i64 @ftell(i32* %9)
br label %23
44: ; preds = %32, %25
%45 = call i32 @fclose(i32* %9)
ret i64 %24
}