#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*/ fprintf(int /*<<< orphan*/, char *);
char *getword(int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
scalar_t__ strtol(char *, char **, int);
int read_int4_f(FILE *fp, int *array, int size) {
  register int i;
  char *ch, *stat;
  for (i = 0; i < size; i++) {
    ch = getword(fp);
    array[i] = (int)strtol(ch, &stat, 10);
    if (*stat) {
      fprintf(stderr, "non-digits in datablock\n");
      return 1;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<read_int4_f>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11c3 <read_int4_f+0x93>
mov    -0x10(%rbp),%rdi
call   1030 <getword@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
lea    -0x30(%rbp),%rsi
mov    $0xa,%edx
call   1050 <strtol@plt>
mov    %eax,%edx
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x30(%rbp),%rax
cmpb   $0x0,(%rax)
je     11b0 <read_int4_f+0x80>
mov    0x2e4a(%rip),%rax
mov    (%rax),%edi
lea    0xe61(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11ca <read_int4_f+0x9a>
jmp    11b5 <read_int4_f+0x85>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    114a <read_int4_f+0x1a>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_int4_f>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
test   %edx,%edx
jle    118f <read_int4_f+0x5f>
mov    %rsi,%r14
mov    %rdi,%r13
mov    %edx,%r12d
xor    %ebx,%ebx
lea    0x8(%rsp),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r13,%rdi
call   1030 <getword@plt>
mov    %rax,%rdi
mov    %r15,%rsi
mov    $0xa,%edx
call   1050 <strtol@plt>
mov    %eax,(%r14,%rbx,4)
mov    0x8(%rsp),%rax
cmpb   $0x0,(%rax)
jne    1193 <read_int4_f+0x63>
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1160 <read_int4_f+0x30>
xor    %eax,%eax
jmp    11ad <read_int4_f+0x7d>
mov    0x2e46(%rip),%rax
mov    (%rax),%edi
lea    0xe5d(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [25 x i8] c"non-digits in datablock\0A\00"
define i32 @read_int4_f(i32* %0, i32* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i8*
store i32* %0, i32** %5
store i32* %1, i32** %6
store i32 %2, i32* %7
store i32 0, i32* %8
br label %11
11: ; preds = %32, %3
%12 = load i32, i32* %8
%13 = load i32, i32* %7
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %35
15: ; preds = %11
%16 = load i32*, i32** %5
%17 = call i8* @getword(i32* %16)
store i8* %17, i8** %9
%18 = load i8*, i8** %9
%19 = call i64 @strtol(i8* %18, i8** %10, i32 10)
%20 = trunc i64 %19 to i32
%21 = load i32*, i32** %6
%22 = load i32, i32* %8
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i32, i32* %21, i64 %23
store i32 %20, i32* %24
%25 = load i8*, i8** %10
%26 = load i8, i8* %25
%27 = icmp ne i8 %26, 0
br i1 %27, label %28, label %31
28: ; preds = %15
%29 = load i32, i32* @stderr
%30 = call i32 @fprintf(i32 %29, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %4
br label %36
31: ; preds = %15
br label %32
32: ; preds = %31
%33 = load i32, i32* %8
%34 = add nsw i32 %33, 1
store i32 %34, i32* %8
br label %11
35: ; preds = %11
store i32 0, i32* %4
br label %36
36: ; preds = %35, %28
%37 = load i32, i32* %4
ret i32 %37
}

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