#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*/ memset(int *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *);
void get_test_data(int *data, float *rating) {
  FILE *fp;
  int i = 0;
  memset(data, 0, sizeof(int));
  if ((fp = fopen("r1.test", "r")) == NULL) {
    printf("cannot open this file");
    exit(0);
  }
  int user_id, item_id, timestamp;
  float rating_temp;
  while (fscanf(fp, "%d %d %f %d", &user_id, &item_id, &rating_temp,
                &timestamp) != EOF) {
    data[i * 2 + 0] = user_id - 1;
    data[i * 2 + 1] = item_id - 1;
    rating[i] = rating_temp;
    i++;
  }
  fclose(fp);
}


x86 assembly (clang, -O0):
<get_test_data>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1050 <memset@plt>
lea    0xe72(%rip),%rdi
lea    0xe73(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    11bb <get_test_data+0x5b>
lea    0xe5b(%rip),%rdi
call   1040 <printf@plt>
xor    %edi,%edi
call   1080 <exit@plt>
jmp    11c0 <get_test_data+0x60>
mov    -0x18(%rbp),%rdi
lea    0xe55(%rip),%rsi
lea    -0x20(%rbp),%rdx
lea    -0x24(%rbp),%rcx
lea    -0x2c(%rbp),%r8
lea    -0x28(%rbp),%r9
call   1060 <fscanf@plt>
mov    0x2e01(%rip),%rcx
cmp    (%rcx),%rax
je     1242 <get_test_data+0xe2>
mov    -0x20(%rbp),%edx
sub    $0x1,%edx
mov    -0x8(%rbp),%rax
mov    -0x1c(%rbp),%ecx
shl    $0x1,%ecx
add    $0x0,%ecx
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x24(%rbp),%edx
sub    $0x1,%edx
mov    -0x8(%rbp),%rax
mov    -0x1c(%rbp),%ecx
shl    $0x1,%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
movss  -0x2c(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11c0 <get_test_data+0x60>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_test_data>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
xor    %esi,%esi
mov    $0x4,%edx
call   1050 <memset@plt>
lea    0xe79(%rip),%rdi
lea    0xe7a(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     1243 <get_test_data+0xe3>
mov    %rax,%r15
lea    0xe7a(%rip),%rsi
lea    0x10(%rsp),%rdx
lea    0xc(%rsp),%rcx
lea    0x8(%rsp),%r8
lea    0x14(%rsp),%r9
mov    %rax,%rdi
call   1060 <fscanf@plt>
mov    0x2e1f(%rip),%r12
cmp    (%r12),%rax
je     122c <get_test_data+0xcc>
xor    %ebp,%ebp
lea    0x14(%rsp),%r13
cs nopw 0x0(%rax,%rax,1)
mov    0x10(%rsp),%eax
add    $0xffffffff,%eax
mov    %eax,(%rbx,%rbp,2)
mov    0xc(%rsp),%eax
add    $0xffffffff,%eax
mov    %eax,0x4(%rbx,%rbp,2)
movss  0x8(%rsp),%xmm0
movss  %xmm0,(%r14,%rbp,1)
mov    %r15,%rdi
lea    0xe15(%rip),%rsi
lea    0x10(%rsp),%rdx
lea    0xc(%rsp),%rcx
lea    0x8(%rsp),%r8
mov    %r13,%r9
call   1060 <fscanf@plt>
add    $0x4,%rbp
cmp    (%r12),%rax
jne    11e0 <get_test_data+0x80>
mov    %r15,%rdi
call   1030 <fclose@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xdc0(%rip),%rdi
call   1040 <printf@plt>
xor    %edi,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [8 x i8] c"r1.test\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 void @get_test_data(i32* %0, float* %1) {
%3 = alloca i32*
%4 = alloca float*
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca float
store i32* %0, i32** %3
store float* %1, float** %4
store i32 0, i32* %6
%11 = load i32*, i32** %3
%12 = call i32 @memset(i32* %11, i32 0, i32 4)
%13 = call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %13, i32** %5
%14 = icmp eq i32* %13, null
br i1 %14, label %15, label %18
15: ; preds = %2
%16 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
%17 = call i32 @exit(i32 0)
unreachable
18: ; preds = %2
br label %19
19: ; preds = %24, %18
%20 = load i32*, i32** %5
%21 = call i64 @fscanf(i32* %20, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32* %7, i32* %8, float* %10, i32* %9)
%22 = load i64, i64* @EOF
%23 = icmp ne i64 %21, %22
br i1 %23, label %24, label %48
24: ; preds = %19
%25 = load i32, i32* %7
%26 = sub nsw i32 %25, 1
%27 = load i32*, i32** %3
%28 = load i32, i32* %6
%29 = mul nsw i32 %28, 2
%30 = add nsw i32 %29, 0
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i32, i32* %27, i64 %31
store i32 %26, i32* %32
%33 = load i32, i32* %8
%34 = sub nsw i32 %33, 1
%35 = load i32*, i32** %3
%36 = load i32, i32* %6
%37 = mul nsw i32 %36, 2
%38 = add nsw i32 %37, 1
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i32, i32* %35, i64 %39
store i32 %34, i32* %40
%41 = load float, float* %10
%42 = load float*, float** %4
%43 = load i32, i32* %6
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds float, float* %42, i64 %44
store float %41, float* %45
%46 = load i32, i32* %6
%47 = add nsw i32 %46, 1
store i32 %47, i32* %6
br label %19
48: ; preds = %19
%49 = load i32*, i32** %5
%50 = call i32 @fclose(i32* %49)
ret void
}

LLVM IR (-O2):
@.str = [8 x i8] c"r1.test\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 void @get_test_data(i32* %0, float* nocapture writeonly %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca float
%7 = tail call i32 @memset(i32* %0, i32 0, i32 4)
%8 = tail call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%9 = icmp eq i32* %8, null
br i1 %9, label %10, label %13
10: ; preds = %2
%11 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
%12 = tail call i32 @exit(i32 0)
unreachable
13: ; preds = %2
%14 = bitcast i32* %3 to i8*
%15 = bitcast i32* %4 to i8*
%16 = bitcast i32* %5 to i8*
%17 = bitcast float* %6 to i8*
%18 = call i64 @fscanf(i32* %8, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32* %3, i32* %4, float* %6, i32* %5)
%19 = load i64, i64* @EOF
%20 = icmp eq i64 %18, %19
br i1 %20, label %37, label %21
21: ; preds = %13, %21
%22 = phi i64 [ %33, %21 ], [ 0, %13 ]
%23 = load i32, i32* %3
%24 = add nsw i32 %23, -1
%25 = shl nuw nsw i64 %22, 1
%26 = getelementptr inbounds i32, i32* %0, i64 %25
store i32 %24, i32* %26
%27 = load i32, i32* %4
%28 = add nsw i32 %27, -1
%29 = or i64 %25, 1
%30 = getelementptr inbounds i32, i32* %0, i64 %29
store i32 %28, i32* %30
%31 = load float, float* %6
%32 = getelementptr inbounds float, float* %1, i64 %22
store float %31, float* %32
%33 = add nuw i64 %22, 1
%34 = call i64 @fscanf(i32* %8, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32* %3, i32* %4, float* %6, i32* %5)
%35 = load i64, i64* @EOF
%36 = icmp eq i64 %34, %35
br i1 %36, label %37, label %21
37: ; preds = %21, %13
%38 = call i32 @fclose(i32* %8)
ret void
}