#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 *, char *, char *);
int /*<<< orphan*/ printf(char *);
void load_char(char *file, int N, int M, char *out) {
  int i, j;
  FILE *m_File = NULL;
  char tmp1, tmp2;
  m_File = fopen(file, "r");
  if (!m_File)
    printf("Error: open prout\n");
  for (j = 0; j < M; j++) {
    for (i = 0; i < N; i++) {
      fscanf(m_File, "%c%c ", &tmp1, &tmp2);
      out[i * M + j] = (int)(tmp1 - '0') + (int)(tmp2 - '0');
    }
  }
  fclose(m_File);
}


x86 assembly (clang, -O0):
<load_char>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe97(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1189 <load_char+0x49>
lea    0xe7e(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    120e <load_char+0xce>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11fb <load_char+0xbb>
mov    -0x28(%rbp),%rdi
lea    0xe5b(%rip),%rsi
lea    -0x29(%rbp),%rdx
lea    -0x2a(%rbp),%rcx
call   1050 <fscanf@plt>
movsbl -0x29(%rbp),%eax
sub    $0x30,%eax
movsbl -0x2a(%rbp),%ecx
sub    $0x30,%ecx
add    %ecx,%eax
mov    %al,%dl
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
imul   -0x10(%rbp),%ecx
add    -0x20(%rbp),%ecx
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11a3 <load_char+0x63>
jmp    1200 <load_char+0xc0>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1190 <load_char+0x50>
mov    -0x28(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<load_char>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rcx,0x8(%rsp)
mov    %edx,%ebx
mov    %esi,0x4(%rsp)
lea    0xea0(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%r14
test   %rax,%rax
je     1176 <load_char+0x36>
test   %ebx,%ebx
jg     118a <load_char+0x4a>
jmp    1210 <load_char+0xd0>
lea    0xe8b(%rip),%rdi
call   1030 <puts@plt>
test   %ebx,%ebx
jle    1210 <load_char+0xd0>
mov    %ebx,%ecx
mov    0x4(%rsp),%eax
mov    %rax,0x10(%rsp)
xor    %eax,%eax
lea    0xe64(%rip),%r13
lea    0x3(%rsp),%rbx
lea    0x2(%rsp),%rbp
mov    %rcx,0x20(%rsp)
jmp    11c4 <load_char+0x84>
nop
mov    0x18(%rsp),%rax
add    $0x1,%rax
addq   $0x1,0x8(%rsp)
cmp    %rcx,%rax
je     1210 <load_char+0xd0>
mov    %rax,0x18(%rsp)
cmpl   $0x0,0x4(%rsp)
jle    11b0 <load_char+0x70>
mov    0x10(%rsp),%r15
mov    0x8(%rsp),%r12
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %r13,%rsi
mov    %rbx,%rdx
mov    %rbp,%rcx
call   1050 <fscanf@plt>
mov    0x20(%rsp),%rcx
movzbl 0x3(%rsp),%eax
add    0x2(%rsp),%al
add    $0xa0,%al
mov    %al,(%r12)
add    %rcx,%r12
add    $0xffffffffffffffff,%r15
jne    11e0 <load_char+0xa0>
jmp    11b0 <load_char+0x70>
mov    %r14,%rdi
call   1040 <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 = [19 x i8] c"Error: open prout\0A\00"
@.str.2 = [6 x i8] c"%c%c \00"
define void @load_char(i8* %0, i32 %1, i32 %2, i8* %3) {
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32*
%12 = alloca i8
%13 = alloca i8
store i8* %0, i8** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i8* %3, i8** %8
store i32* null, i32** %11
%14 = load i8*, i8** %5
%15 = call i32* @fopen(i8* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %15, i32** %11
%16 = load i32*, i32** %11
%17 = icmp ne i32* %16, null
br i1 %17, label %20, label %18
18: ; preds = %4
%19 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
br label %20
20: ; preds = %18, %4
store i32 0, i32* %10
br label %21
21: ; preds = %53, %20
%22 = load i32, i32* %10
%23 = load i32, i32* %7
%24 = icmp slt i32 %22, %23
br i1 %24, label %25, label %56
25: ; preds = %21
store i32 0, i32* %9
br label %26
26: ; preds = %49, %25
%27 = load i32, i32* %9
%28 = load i32, i32* %6
%29 = icmp slt i32 %27, %28
br i1 %29, label %30, label %52
30: ; preds = %26
%31 = load i32*, i32** %11
%32 = call i32 @fscanf(i32* %31, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %12, i8* %13)
%33 = load i8, i8* %12
%34 = sext i8 %33 to i32
%35 = sub nsw i32 %34, 48
%36 = load i8, i8* %13
%37 = sext i8 %36 to i32
%38 = sub nsw i32 %37, 48
%39 = add nsw i32 %35, %38
%40 = trunc i32 %39 to i8
%41 = load i8*, i8** %8
%42 = load i32, i32* %9
%43 = load i32, i32* %7
%44 = mul nsw i32 %42, %43
%45 = load i32, i32* %10
%46 = add nsw i32 %44, %45
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds i8, i8* %41, i64 %47
store i8 %40, i8* %48
br label %49
49: ; preds = %30
%50 = load i32, i32* %9
%51 = add nsw i32 %50, 1
store i32 %51, i32* %9
br label %26
52: ; preds = %26
br label %53
53: ; preds = %52
%54 = load i32, i32* %10
%55 = add nsw i32 %54, 1
store i32 %55, i32* %10
br label %21
56: ; preds = %21
%57 = load i32*, i32** %11
%58 = call i32 @fclose(i32* %57)
ret void
}

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