#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*/ buffer;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
char *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ rewind(int /*<<< orphan*/ *);
char *strtok(char *, char *);
int File_Size(FILE *fstream, int *row, int *col) {
  FILE *fstream_inside = fstream;
  char buffer[2048];
  char *record, *line;
  int i = 0, j = 0;
  if (fstream_inside == NULL) {
    printf("\n file opening failed \n");
    return -1;
  }
  while ((line = fgets(buffer, sizeof(buffer), fstream_inside)) != NULL) {
    record = strtok(line, ",");
    j = 0;
    while (record != NULL) {
      ++j;
      record = strtok(NULL, ",");
    }
    ++i;
  }
  *row = i;
  *col = j;
  rewind(fstream_inside);
  return 0;
}


x86 assembly (clang, -O0):
<File_Size>:
push   %rbp
mov    %rsp,%rbp
sub    $0x850,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x844(%rbp)
movl   $0x0,-0x848(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1196 <File_Size+0x56>
lea    0xe7b(%rip),%rdi
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    125a <File_Size+0x11a>
jmp    119b <File_Size+0x5b>
lea    -0x830(%rbp),%rdi
mov    -0x28(%rbp),%rdx
mov    $0x800,%esi
call   1050 <fgets@plt>
mov    %rax,-0x840(%rbp)
cmp    $0x0,%rax
je     1232 <File_Size+0xf2>
mov    -0x840(%rbp),%rdi
lea    0xe49(%rip),%rsi
call   1060 <strtok@plt>
mov    %rax,-0x838(%rbp)
movl   $0x0,-0x848(%rbp)
cmpq   $0x0,-0x838(%rbp)
je     121e <File_Size+0xde>
mov    -0x848(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x848(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xe0b(%rip),%rsi
call   1060 <strtok@plt>
mov    %rax,-0x838(%rbp)
jmp    11e5 <File_Size+0xa5>
mov    -0x844(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x844(%rbp)
jmp    119b <File_Size+0x5b>
mov    -0x844(%rbp),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x848(%rbp),%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x28(%rbp),%rdi
call   1040 <rewind@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x850,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<File_Size>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x818,%rsp
test   %rdi,%rdi
je     120e <File_Size+0xce>
mov    %rdi,%rbx
mov    %rsi,(%rsp)
mov    %rdx,0x8(%rsp)
lea    0x10(%rsp),%rdi
mov    $0x800,%esi
mov    %rbx,%rdx
call   1050 <fgets@plt>
xor    %r12d,%r12d
mov    $0x0,%r14d
mov    $0x0,%r15d
test   %rax,%rax
je     11f5 <File_Size+0xb5>
xor    %r14d,%r14d
lea    0xe6a(%rip),%rbp
lea    0x10(%rsp),%r13
jmp    11b9 <File_Size+0x79>
nopl   (%rax)
add    $0x1,%r14d
mov    %r13,%rdi
mov    $0x800,%esi
mov    %rbx,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
je     11f5 <File_Size+0xb5>
mov    %rax,%rdi
mov    %rbp,%rsi
call   1060 <strtok@plt>
mov    $0x0,%r15d
test   %rax,%rax
je     11a0 <File_Size+0x60>
xor    %r15d,%r15d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x1,%r15d
xor    %edi,%edi
mov    %rbp,%rsi
call   1060 <strtok@plt>
test   %rax,%rax
jne    11e0 <File_Size+0xa0>
jmp    11a0 <File_Size+0x60>
mov    (%rsp),%rax
mov    %r14d,(%rax)
mov    0x8(%rsp),%rax
mov    %r15d,(%rax)
mov    %rbx,%rdi
call   1040 <rewind@plt>
jmp    1220 <File_Size+0xe0>
lea    0xded(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%r12d
mov    %r12d,%eax
add    $0x818,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [24 x i8] c"\0A file opening failed \0A\00"
@.str.1 = [2 x i8] c",\00"
define i32 @File_Size(i32* %0, i32* %1, i32* %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca [2048 x i8]
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i32
%13 = alloca i32
store i32* %0, i32** %5
store i32* %1, i32** %6
store i32* %2, i32** %7
%14 = load i32*, i32** %5
store i32* %14, i32** %8
store i32 0, i32* %12
store i32 0, i32* %13
%15 = load i32*, i32** %8
%16 = icmp eq i32* %15, null
br i1 %16, label %17, label %19
17: ; preds = %3
%18 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %4
br label %45
19: ; preds = %3
br label %20
20: ; preds = %35, %19
%21 = getelementptr inbounds [2048 x i8], [2048 x i8]* %9, i64 0, i64 0
%22 = load i32*, i32** %8
%23 = call i8* @fgets(i8* %21, i32 2048, i32* %22)
store i8* %23, i8** %11
%24 = icmp ne i8* %23, null
br i1 %24, label %25, label %38
25: ; preds = %20
%26 = load i8*, i8** %11
%27 = call i8* @strtok(i8* %26, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i8* %27, i8** %10
store i32 0, i32* %13
br label %28
28: ; preds = %31, %25
%29 = load i8*, i8** %10
%30 = icmp ne i8* %29, null
br i1 %30, label %31, label %35
31: ; preds = %28
%32 = load i32, i32* %13
%33 = add nsw i32 %32, 1
store i32 %33, i32* %13
%34 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i8* %34, i8** %10
br label %28
35: ; preds = %28
%36 = load i32, i32* %12
%37 = add nsw i32 %36, 1
store i32 %37, i32* %12
br label %20
38: ; preds = %20
%39 = load i32, i32* %12
%40 = load i32*, i32** %6
store i32 %39, i32* %40
%41 = load i32, i32* %13
%42 = load i32*, i32** %7
store i32 %41, i32* %42
%43 = load i32*, i32** %8
%44 = call i32 @rewind(i32* %43)
store i32 0, i32* %4
br label %45
45: ; preds = %38, %17
%46 = load i32, i32* %4
ret i32 %46
}

LLVM IR (-O2):
@.str.1 = [2 x i8] c",\00"
@str = [23 x i8] c"\0A file opening failed \00"
define i32 @File_Size(i32* %0, i32* nocapture writeonly %1, i32* nocapture writeonly %2) {
%4 = alloca [2048 x i8]
%5 = getelementptr inbounds [2048 x i8], [2048 x i8]* %4, i64 0, i64 0
%6 = icmp eq i32* %0, null
br i1 %6, label %10, label %7
7: ; preds = %3
%8 = call i8* @fgets(i8* %5, i32 2048, i32* %0)
%9 = icmp eq i8* %8, null
br i1 %9, label %27, label %12
10: ; preds = %3
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0))
br label %31
12: ; preds = %7, %22
%13 = phi i8* [ %25, %22 ], [ %8, %7 ]
%14 = phi i32 [ %24, %22 ], [ 0, %7 ]
%15 = call i8* @strtok(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%16 = icmp eq i8* %15, null
br i1 %16, label %22, label %17
17: ; preds = %12, %17
%18 = phi i32 [ %19, %17 ], [ 0, %12 ]
%19 = add nuw nsw i32 %18, 1
%20 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%21 = icmp eq i8* %20, null
br i1 %21, label %22, label %17
22: ; preds = %17, %12
%23 = phi i32 [ 0, %12 ], [ %19, %17 ]
%24 = add nuw nsw i32 %14, 1
%25 = call i8* @fgets(i8* %5, i32 2048, i32* %0)
%26 = icmp eq i8* %25, null
br i1 %26, label %27, label %12
27: ; preds = %22, %7
%28 = phi i32 [ 0, %7 ], [ %24, %22 ]
%29 = phi i32 [ 0, %7 ], [ %23, %22 ]
store i32 %28, i32* %1
store i32 %29, i32* %2
%30 = call i32 @rewind(i32* %0)
br label %31
31: ; preds = %27, %10
%32 = phi i32 [ -1, %10 ], [ 0, %27 ]
ret i32 %32
}