#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 EOF;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *);
int fscanf(int /*<<< orphan*/ *, char *, int *);
int /*<<< orphan*/ stderr;
void read_sentence_lens(const char *file_path, int *sent_lens, int n_sents) {
  int len = 0;
  FILE *fp = fopen(file_path, "r");
  if (fp == NULL) {
    fprintf(stderr, "Can't open input file %s!\n", file_path);
    exit(1);
  }
  int fret = 1;
  for (int i = 0; (i < n_sents && fret != EOF); i++) {
    fret = fscanf(fp, "%d\n", &len);
    if (len > 125) {
      len = 125;
    }
    sent_lens[i] = len;
  }
  fclose(fp);
}


x86 assembly (clang, -O0):
<read_sentence_lens>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe8b(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11ac <read_sentence_lens+0x5c>
mov    0x2e48(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xe65(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
movl   $0x1,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%ecx
xor    %eax,%eax
cmp    -0x14(%rbp),%ecx
mov    %al,-0x29(%rbp)
jge    11dd <read_sentence_lens+0x8d>
mov    -0x24(%rbp),%eax
mov    0x2e13(%rip),%rcx
cmp    (%rcx),%eax
setne  %al
mov    %al,-0x29(%rbp)
mov    -0x29(%rbp),%al
test   $0x1,%al
jne    11ed <read_sentence_lens+0x9d>
jmp    1231 <read_sentence_lens+0xe1>
mov    -0x20(%rbp),%rdi
lea    0xe25(%rip),%rsi
lea    -0x18(%rbp),%rdx
call   1040 <fscanf@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x7d,-0x18(%rbp)
jle    1215 <read_sentence_lens+0xc5>
movl   $0x7d,-0x18(%rbp)
mov    -0x18(%rbp),%edx
mov    -0x10(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    11ba <read_sentence_lens+0x6a>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_sentence_lens>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%r12d
mov    %rsi,%r14
mov    %rdi,%r15
movl   $0x0,0x4(%rsp)
lea    0xe8d(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     1204 <read_sentence_lens+0xb4>
mov    %rax,%rbx
test   %r12d,%r12d
jle    11ed <read_sentence_lens+0x9d>
mov    0x2e58(%rip),%rax
cmpl   $0x1,(%rax)
je     11ed <read_sentence_lens+0x9d>
mov    %r12d,%ebp
mov    $0x1,%r13d
lea    0xe78(%rip),%r15
lea    0x4(%rsp),%r12
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
call   1040 <fscanf@plt>
mov    0x4(%rsp),%ecx
cmp    $0x7e,%ecx
jl     11d4 <read_sentence_lens+0x84>
movl   $0x7d,0x4(%rsp)
mov    $0x7d,%ecx
mov    %ecx,-0x4(%r14,%r13,4)
cmp    %rbp,%r13
jae    11ed <read_sentence_lens+0x9d>
add    $0x1,%r13
mov    0x2dff(%rip),%rcx
cmp    (%rcx),%eax
jne    11b0 <read_sentence_lens+0x60>
mov    %rbx,%rdi
call   1030 <fclose@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2dcd(%rip),%rax
mov    (%rax),%edi
lea    0xdee(%rip),%rsi
mov    %r15,%rdx
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.1 = [27 x i8] c"Can't open input file %s!\0A\00"
@EOF = global i32 0
@.str.2 = [4 x i8] c"%d\0A\00"
define void @read_sentence_lens(i8* %0, i32* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32*
%9 = alloca i32
%10 = alloca i32
store i8* %0, i8** %4
store i32* %1, i32** %5
store i32 %2, i32* %6
store i32 0, i32* %7
%11 = load i8*, i8** %4
%12 = call i32* @fopen(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %12, i32** %8
%13 = load i32*, i32** %8
%14 = icmp eq i32* %13, null
br i1 %14, label %15, label %20
15: ; preds = %3
%16 = load i32, i32* @stderr
%17 = load i8*, i8** %4
%18 = call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8* %17)
%19 = call i32 @exit(i32 1)
unreachable
20: ; preds = %3
store i32 1, i32* %9
store i32 0, i32* %10
br label %21
21: ; preds = %43, %20
%22 = load i32, i32* %10
%23 = load i32, i32* %6
%24 = icmp slt i32 %22, %23
br i1 %24, label %25, label %29
25: ; preds = %21
%26 = load i32, i32* %9
%27 = load i32, i32* @EOF
%28 = icmp ne i32 %26, %27
br label %29
29: ; preds = %25, %21
%30 = phi i1 [ false, %21 ], [ %28, %25 ]
br i1 %30, label %31, label %46
31: ; preds = %29
%32 = load i32*, i32** %8
%33 = call i32 @fscanf(i32* %32, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32* %7)
store i32 %33, i32* %9
%34 = load i32, i32* %7
%35 = icmp sgt i32 %34, 125
br i1 %35, label %36, label %37
36: ; preds = %31
store i32 125, i32* %7
br label %37
37: ; preds = %36, %31
%38 = load i32, i32* %7
%39 = load i32*, i32** %5
%40 = load i32, i32* %10
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i32, i32* %39, i64 %41
store i32 %38, i32* %42
br label %43
43: ; preds = %37
%44 = load i32, i32* %10
%45 = add nsw i32 %44, 1
store i32 %45, i32* %10
br label %21
46: ; preds = %29
%47 = load i32*, i32** %8
%48 = call i32 @fclose(i32* %47)
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.1 = [27 x i8] c"Can't open input file %s!\0A\00"
@EOF = global i32 0
@.str.2 = [4 x i8] c"%d\0A\00"
define void @read_sentence_lens(i8* %0, i32* nocapture writeonly %1, i32 %2) {
%4 = alloca i32
%5 = bitcast i32* %4 to i8*
store i32 0, i32* %4
%6 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i32* %6, null
br i1 %7, label %15, label %8
8: ; preds = %3
%9 = icmp sgt i32 %2, 0
%10 = load i32, i32* @EOF
%11 = icmp ne i32 %10, 1
%12 = select i1 %9, i1 %11, i1 false
br i1 %12, label %13, label %19
13: ; preds = %8
%14 = zext i32 %2 to i64
br label %21
15: ; preds = %3
%16 = load i32, i32* @stderr
%17 = tail call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%18 = tail call i32 @exit(i32 1)
unreachable
19: ; preds = %27, %8
%20 = call i32 @fclose(i32* %6)
ret void
21: ; preds = %13, %27
%22 = phi i64 [ 0, %13 ], [ %30, %27 ]
%23 = call i32 @fscanf(i32* %6, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32* %4)
%24 = load i32, i32* %4
%25 = icmp sgt i32 %24, 125
br i1 %25, label %26, label %27
26: ; preds = %21
store i32 125, i32* %4
br label %27
27: ; preds = %26, %21
%28 = phi i32 [ 125, %26 ], [ %24, %21 ]
%29 = getelementptr inbounds i32, i32* %1, i64 %22
store i32 %28, i32* %29
%30 = add nuw nsw i64 %22, 1
%31 = icmp ult i64 %30, %14
%32 = load i32, i32* @EOF
%33 = icmp ne i32 %23, %32
%34 = select i1 %31, i1 %33, i1 false
br i1 %34, label %21, label %19
}