#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 fscanf(int /*<<< orphan*/ *, char *, int *, int *);
int Load_N_Values(FILE *FP, int N, int Array[]) {
  int i, NumVals, Addr, Value;
  for (i = 0; i < N; i++) {
    NumVals = fscanf(FP, "%d: %d", &Addr, &Value);
    if (NumVals == 2)
      Array[i] = Value;
    else
      return (i);
  }
  return (N);
}


x86 assembly (clang, -O0):
<Load_N_Values>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    118c <Load_N_Values+0x7c>
mov    -0x10(%rbp),%rdi
lea    0xebf(%rip),%rsi
lea    -0x2c(%rbp),%rdx
lea    -0x30(%rbp),%rcx
call   1030 <fscanf@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0x2,-0x28(%rbp)
jne    116e <Load_N_Values+0x5e>
mov    -0x30(%rbp),%edx
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
jmp    1179 <Load_N_Values+0x69>
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1192 <Load_N_Values+0x82>
jmp    117e <Load_N_Values+0x6e>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    112a <Load_N_Values+0x1a>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Load_N_Values>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,%r12d
test   %esi,%esi
jle    116f <Load_N_Values+0x5f>
mov    %rdx,%r14
mov    %rdi,%rbx
xor    %r15d,%r15d
lea    0x4(%rsp),%r13
mov    %rsp,%rbp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rbx,%rdi
lea    0xeb6(%rip),%rsi
mov    %r13,%rdx
mov    %rbp,%rcx
call   1030 <fscanf@plt>
cmp    $0x2,%eax
jne    116c <Load_N_Values+0x5c>
mov    (%rsp),%eax
mov    %eax,(%r14,%r15,4)
add    $0x1,%r15
cmp    %r15,%r12
jne    1140 <Load_N_Values+0x30>
jmp    116f <Load_N_Values+0x5f>
mov    %r15d,%r12d
mov    %r12d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"%d: %d\00"
define i32 @Load_N_Values(i32* %0, i32 %1, i32* %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32*
%8 = alloca i32
%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 i32 0, i32* %8
br label %12
12: ; preds = %30, %3
%13 = load i32, i32* %8
%14 = load i32, i32* %6
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %33
16: ; preds = %12
%17 = load i32*, i32** %5
%18 = call i32 @fscanf(i32* %17, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32* %10, i32* %11)
store i32 %18, i32* %9
%19 = load i32, i32* %9
%20 = icmp eq i32 %19, 2
br i1 %20, label %21, label %27
21: ; preds = %16
%22 = load i32, i32* %11
%23 = load i32*, i32** %7
%24 = load i32, i32* %8
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i32, i32* %23, i64 %25
store i32 %22, i32* %26
br label %29
27: ; preds = %16
%28 = load i32, i32* %8
store i32 %28, i32* %4
br label %35
29: ; preds = %21
br label %30
30: ; preds = %29
%31 = load i32, i32* %8
%32 = add nsw i32 %31, 1
store i32 %32, i32* %8
br label %12
33: ; preds = %12
%34 = load i32, i32* %6
store i32 %34, i32* %4
br label %35
35: ; preds = %33, %27
%36 = load i32, i32* %4
ret i32 %36
}

LLVM IR (-O2):
@.str = [7 x i8] c"%d: %d\00"
define i32 @Load_N_Values(i32* nocapture %0, i32 %1, i32* nocapture writeonly %2) {
%4 = alloca i32
%5 = alloca i32
%6 = bitcast i32* %4 to i8*
%7 = bitcast i32* %5 to i8*
%8 = icmp sgt i32 %1, 0
br i1 %8, label %9, label %22
9: ; preds = %3
%10 = zext i32 %1 to i64
br label %11
11: ; preds = %9, %15
%12 = phi i64 [ 0, %9 ], [ %18, %15 ]
%13 = call i32 @fscanf(i32* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32* %4, i32* %5)
%14 = icmp eq i32 %13, 2
br i1 %14, label %15, label %20
15: ; preds = %11
%16 = load i32, i32* %5
%17 = getelementptr inbounds i32, i32* %2, i64 %12
store i32 %16, i32* %17
%18 = add nuw nsw i64 %12, 1
%19 = icmp eq i64 %18, %10
br i1 %19, label %22, label %11
20: ; preds = %11
%21 = trunc i64 %12 to i32
br label %22
22: ; preds = %15, %20, %3
%23 = phi i32 [ %1, %3 ], [ %21, %20 ], [ %1, %15 ]
ret i32 %23
}