#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 *, int *);
void read_file(int nbc, int nbr, int s[nbc][nbr], char *filename) {
  int i, j;
  FILE *fic = NULL;
  fic = fopen(filename, "r");
  if (fic != NULL) {
    for (i = 0; i < nbc; i++) {
      for (j = 0; j < nbr; j++) {
        fscanf(fic, "%d ", &s[i][j]);
      }
    }
    fclose(fic);
  }
}


x86 assembly (clang, -O0):
<read_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    -0x8(%rbp),%eax
mov    %rax,-0x30(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xea0(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     11f6 <read_file+0xc6>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11ed <read_file+0xbd>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11da <read_file+0xaa>
mov    -0x30(%rbp),%rcx
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rdx
movslq -0x1c(%rbp),%rax
imul   %rcx,%rax
shl    $0x2,%rax
add    %rax,%rdx
movslq -0x20(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdx
lea    0xe3b(%rip),%rsi
call   1040 <fscanf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    118e <read_file+0x5e>
jmp    11df <read_file+0xaf>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    117b <read_file+0x4b>
mov    -0x28(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_file>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rdx,%r15
mov    %esi,0xc(%rsp)
mov    %edi,%ebx
lea    0xeb2(%rip),%rsi
mov    %rcx,%rdi
call   1050 <fopen@plt>
test   %rax,%rax
je     11e0 <read_file+0xb0>
mov    %rax,%rbp
test   %ebx,%ebx
jle    11ca <read_file+0x9a>
mov    0xc(%rsp),%eax
mov    %ebx,%ecx
mov    %rcx,0x20(%rsp)
mov    %rax,0x10(%rsp)
lea    0x0(,%rax,4),%rax
mov    %rax,0x18(%rsp)
xor    %r13d,%r13d
lea    0xe75(%rip),%r12
jmp    11a0 <read_file+0x70>
nop
add    $0x1,%r13
add    0x18(%rsp),%r15
cmp    0x20(%rsp),%r13
je     11ca <read_file+0x9a>
cmpl   $0x0,0xc(%rsp)
jle    1190 <read_file+0x60>
mov    0x10(%rsp),%r14
mov    %r15,%rbx
nop
mov    %rbp,%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
call   1040 <fscanf@plt>
add    $0x4,%rbx
add    $0xffffffffffffffff,%r14
jne    11b0 <read_file+0x80>
jmp    1190 <read_file+0x60>
mov    %rbp,%rdi
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <fclose@plt>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [4 x i8] c"%d \00"
define void @read_file(i32 %0, i32 %1, i32* %2, i8* nocapture %3) {
%5 = zext i32 %1 to i64
%6 = tail call i32* @fopen(i8* %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i32* %6, null
br i1 %7, label %29, label %8
8: ; preds = %4
%9 = icmp sgt i32 %0, 0
br i1 %9, label %10, label %27
10: ; preds = %8
%11 = icmp sgt i32 %1, 0
%12 = zext i32 %0 to i64
br label %13
13: ; preds = %10, %24
%14 = phi i64 [ 0, %10 ], [ %25, %24 ]
br i1 %11, label %15, label %24
15: ; preds = %13
%16 = mul nuw nsw i64 %14, %5
%17 = getelementptr inbounds i32, i32* %2, i64 %16
br label %18
18: ; preds = %15, %18
%19 = phi i64 [ 0, %15 ], [ %22, %18 ]
%20 = getelementptr inbounds i32, i32* %17, i64 %19
%21 = tail call i32 @fscanf(i32* %6, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32* %20)
%22 = add nuw nsw i64 %19, 1
%23 = icmp eq i64 %22, %5
br i1 %23, label %24, label %18
24: ; preds = %18, %13
%25 = add nuw nsw i64 %14, 1
%26 = icmp eq i64 %25, %12
br i1 %26, label %27, label %13
27: ; preds = %24, %8
%28 = tail call i32 @fclose(i32* %6)
br label %29
29: ; preds = %27, %4
ret void
}