#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 *);
scalar_t__ fscanf(int /*<<< orphan*/ *, char *, unsigned int *);
void initialize_ca(unsigned *CA, char *filename) {
  FILE *file;
  file = fopen(filename, "r");
  unsigned state = 0;
  for (int i = 0; i < 7 * 14 && fscanf(file, "%u", &state); i++) {
    CA[i] = state;
  }
  fclose(file);
}


x86 assembly (clang, -O0):
<initialize_ca>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xeb5(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
xor    %eax,%eax
cmpl   $0x62,-0x20(%rbp)
mov    %al,-0x21(%rbp)
jge    118f <initialize_ca+0x5f>
mov    -0x18(%rbp),%rdi
lea    0xe86(%rip),%rsi
lea    -0x1c(%rbp),%rdx
call   1040 <fscanf@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    119f <initialize_ca+0x6f>
jmp    11bb <initialize_ca+0x8b>
mov    -0x1c(%rbp),%edx
mov    -0x8(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1162 <initialize_ca+0x32>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<initialize_ca>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rax
mov    %rdi,%r14
lea    0xeb6(%rip),%rsi
mov    %rax,%rdi
call   1050 <fopen@plt>
mov    %rax,%r13
movl   $0x0,0xc(%rsp)
xor    %ebx,%ebx
lea    0xe9c(%rip),%r15
lea    0xc(%rsp),%r12
nopl   0x0(%rax,%rax,1)
mov    %r13,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
call   1040 <fscanf@plt>
test   %rax,%rax
je     1195 <initialize_ca+0x65>
mov    0xc(%rsp),%eax
mov    %eax,(%r14,%rbx,4)
add    $0x1,%rbx
cmp    $0x62,%rbx
jne    1170 <initialize_ca+0x40>
mov    %r13,%rdi
call   1030 <fclose@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [3 x i8] c"%u\00"
define void @initialize_ca(i32* %0, i8* %1) {
%3 = alloca i32*
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32
store i32* %0, i32** %3
store i8* %1, i8** %4
%8 = load i8*, i8** %4
%9 = call i32* @fopen(i8* %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %9, i32** %5
store i32 0, i32* %6
store i32 0, i32* %7
br label %10
10: ; preds = %25, %2
%11 = load i32, i32* %7
%12 = icmp slt i32 %11, 98
br i1 %12, label %13, label %17
13: ; preds = %10
%14 = load i32*, i32** %5
%15 = call i64 @fscanf(i32* %14, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %6)
%16 = icmp ne i64 %15, 0
br label %17
17: ; preds = %13, %10
%18 = phi i1 [ false, %10 ], [ %16, %13 ]
br i1 %18, label %19, label %28
19: ; preds = %17
%20 = load i32, i32* %6
%21 = load i32*, i32** %3
%22 = load i32, i32* %7
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i32, i32* %21, i64 %23
store i32 %20, i32* %24
br label %25
25: ; preds = %19
%26 = load i32, i32* %7
%27 = add nsw i32 %26, 1
store i32 %27, i32* %7
br label %10
28: ; preds = %17
%29 = load i32*, i32** %5
%30 = call i32 @fclose(i32* %29)
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [3 x i8] c"%u\00"
define void @initialize_ca(i32* nocapture writeonly %0, i8* nocapture %1) {
%3 = alloca i32
%4 = tail call i32* @fopen(i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%5 = bitcast i32* %3 to i8*
store i32 0, i32* %3
br label %6
6: ; preds = %2, %12
%7 = phi i64 [ 0, %2 ], [ %15, %12 ]
%8 = call i64 @fscanf(i32* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %12, %6
%11 = call i32 @fclose(i32* %4)
ret void
12: ; preds = %6
%13 = load i32, i32* %3
%14 = getelementptr inbounds i32, i32* %0, i64 %7
store i32 %13, i32* %14
%15 = add nuw nsw i64 %7, 1
%16 = icmp eq i64 %15, 98
br i1 %16, label %10, label %6
}