#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 atoi(char *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ free(int *);
int *ivector(int, int);
scalar_t__ malloc(int);
int strlen(char *);
char *strtok(char *, char *);
int ReadSequence1(FILE *fp, int *pT, int **pO, int maxlength) {
  int *O, *O1;
  int i;
  char buf[2 * maxlength];
  if (fgets(buf, 2 * maxlength, fp) == NULL)
    return -1;
  int len = strlen(buf);
  buf[len - 1] = '\0';
  O1 = (int *)malloc(sizeof(int) * maxlength);
  char *buf1;
  buf1 = strtok(buf, " ");
  int ind = 0;
  while (buf1 != NULL) {
    O1[ind] = atoi(buf1);
    buf1 = strtok(NULL, " ");
    ind++;
  }
  *pT = ind;
  O = ivector(1, *pT);
  for (i = 1; i <= *pT; i++)
    O[i] = O1[i - 1];
  *pO = O;
  free(O1);
  return 1;
}


x86 assembly (clang, -O0):
<ReadSequence1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
mov    -0x24(%rbp),%eax
add    %eax,%eax
mov    %rsp,%rcx
mov    %rcx,-0x48(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x70(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x50(%rbp)
mov    -0x24(%rbp),%esi
shl    $0x1,%esi
mov    -0x10(%rbp),%rdx
call   1050 <fgets@plt>
cmp    $0x0,%rax
jne    11db <ReadSequence1+0x6b>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x54(%rbp)
jmp    12e9 <ReadSequence1+0x179>
mov    -0x70(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x70(%rbp),%rax
mov    %ecx,-0x58(%rbp)
mov    -0x58(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
movslq -0x24(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    -0x70(%rbp),%rdi
mov    %rax,-0x38(%rbp)
lea    0xde8(%rip),%rsi
call   1080 <strtok@plt>
mov    %rax,-0x60(%rbp)
movl   $0x0,-0x64(%rbp)
cmpq   $0x0,-0x60(%rbp)
je     126b <ReadSequence1+0xfb>
mov    -0x60(%rbp),%rdi
call   1090 <atoi@plt>
mov    %eax,%edx
mov    -0x38(%rbp),%rax
movslq -0x64(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
xor    %eax,%eax
mov    %eax,%edi
lea    0xdac(%rip),%rsi
call   1080 <strtok@plt>
mov    %rax,-0x60(%rbp)
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
jmp    1228 <ReadSequence1+0xb8>
mov    -0x64(%rbp),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rax
mov    (%rax),%esi
mov    $0x1,%edi
call   1070 <ivector@plt>
mov    %rax,-0x30(%rbp)
movl   $0x1,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
mov    -0x18(%rbp),%rcx
cmp    (%rcx),%eax
jg     12c7 <ReadSequence1+0x157>
mov    -0x38(%rbp),%rax
mov    -0x3c(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%edx
mov    -0x30(%rbp),%rax
movslq -0x3c(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    128f <ReadSequence1+0x11f>
mov    -0x30(%rbp),%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
movl   $0x1,-0x4(%rbp)
movl   $0x1,-0x54(%rbp)
mov    -0x48(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ReadSequence1>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %ecx,%r12d
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rdx
lea    (%r12,%r12,1),%esi
mov    %rsp,%rbx
lea    0xf(%rsi),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
mov    %rbx,%rdi
call   1050 <fgets@plt>
test   %rax,%rax
je     1251 <ReadSequence1+0xe1>
mov    %rbx,%rdi
call   1040 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%rbx,1)
shl    $0x2,%r12d
mov    %r12d,%edi
call   1060 <malloc@plt>
mov    %rax,%r12
lea    0xe2b(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strtok@plt>
xor    %ebx,%ebx
test   %rax,%rax
je     120f <ReadSequence1+0x9f>
lea    0xe15(%rip),%r13
nopl   0x0(%rax,%rax,1)
mov    %rax,%rdi
call   1090 <atoi@plt>
mov    %eax,(%r12,%rbx,4)
xor    %edi,%edi
mov    %r13,%rsi
call   1080 <strtok@plt>
add    $0x1,%rbx
test   %rax,%rax
jne    11f0 <ReadSequence1+0x80>
mov    %ebx,(%r15)
mov    $0x1,%r13d
mov    $0x1,%edi
mov    %ebx,%esi
call   1070 <ivector@plt>
cmpl   $0x0,(%r15)
jle    1244 <ReadSequence1+0xd4>
xor    %ecx,%ecx
nopl   0x0(%rax)
mov    (%r12,%rcx,4),%edx
mov    %edx,0x4(%rax,%rcx,4)
movslq (%r15),%rdx
add    $0x1,%rcx
cmp    %rdx,%rcx
jl     1230 <ReadSequence1+0xc0>
mov    %rax,(%r14)
mov    %r12,%rdi
call   1030 <free@plt>
jmp    1257 <ReadSequence1+0xe7>
mov    $0xffffffff,%r13d
mov    %r13d,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c" \00"
define i32 @ReadSequence1(i32* %0, i32* %1, i32** %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i32**
%9 = alloca i32
%10 = alloca i32*
%11 = alloca i32*
%12 = alloca i32
%13 = alloca i8*
%14 = alloca i64
%15 = alloca i32
%16 = alloca i32
%17 = alloca i8*
%18 = alloca i32
store i32* %0, i32** %6
store i32* %1, i32** %7
store i32** %2, i32*** %8
store i32 %3, i32* %9
%19 = load i32, i32* %9
%20 = mul nsw i32 2, %19
%21 = zext i32 %20 to i64
%22 = call i8* @llvm.stacksave()
store i8* %22, i8** %13
%23 = alloca i8, i64 %21
store i64 %21, i64* %14
%24 = load i32, i32* %9
%25 = mul nsw i32 2, %24
%26 = load i32*, i32** %6
%27 = call i32* @fgets(i8* %23, i32 %25, i32* %26)
%28 = icmp eq i32* %27, null
br i1 %28, label %29, label %30
29: ; preds = %4
store i32 -1, i32* %5
store i32 1, i32* %15
br label %86
30: ; preds = %4
%31 = call i32 @strlen(i8* %23)
store i32 %31, i32* %16
%32 = load i32, i32* %16
%33 = sub nsw i32 %32, 1
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i8, i8* %23, i64 %34
store i8 0, i8* %35
%36 = load i32, i32* %9
%37 = sext i32 %36 to i64
%38 = mul i64 4, %37
%39 = trunc i64 %38 to i32
%40 = call i64 @malloc(i32 %39)
%41 = inttoptr i64 %40 to i32*
store i32* %41, i32** %11
%42 = call i8* @strtok(i8* %23, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %42, i8** %17
store i32 0, i32* %18
br label %43
43: ; preds = %46, %30
%44 = load i8*, i8** %17
%45 = icmp ne i8* %44, null
br i1 %45, label %46, label %56
46: ; preds = %43
%47 = load i8*, i8** %17
%48 = call i32 @atoi(i8* %47)
%49 = load i32*, i32** %11
%50 = load i32, i32* %18
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds i32, i32* %49, i64 %51
store i32 %48, i32* %52
%53 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %53, i8** %17
%54 = load i32, i32* %18
%55 = add nsw i32 %54, 1
store i32 %55, i32* %18
br label %43
56: ; preds = %43
%57 = load i32, i32* %18
%58 = load i32*, i32** %7
store i32 %57, i32* %58
%59 = load i32*, i32** %7
%60 = load i32, i32* %59
%61 = call i32* @ivector(i32 1, i32 %60)
store i32* %61, i32** %10
store i32 1, i32* %12
br label %62
62: ; preds = %78, %56
%63 = load i32, i32* %12
%64 = load i32*, i32** %7
%65 = load i32, i32* %64
%66 = icmp sle i32 %63, %65
br i1 %66, label %67, label %81
67: ; preds = %62
%68 = load i32*, i32** %11
%69 = load i32, i32* %12
%70 = sub nsw i32 %69, 1
%71 = sext i32 %70 to i64
%72 = getelementptr inbounds i32, i32* %68, i64 %71
%73 = load i32, i32* %72
%74 = load i32*, i32** %10
%75 = load i32, i32* %12
%76 = sext i32 %75 to i64
%77 = getelementptr inbounds i32, i32* %74, i64 %76
store i32 %73, i32* %77
br label %78
78: ; preds = %67
%79 = load i32, i32* %12
%80 = add nsw i32 %79, 1
store i32 %80, i32* %12
br label %62
81: ; preds = %62
%82 = load i32*, i32** %10
%83 = load i32**, i32*** %8
store i32* %82, i32** %83
%84 = load i32*, i32** %11
%85 = call i32 @free(i32* %84)
store i32 1, i32* %5
store i32 1, i32* %15
br label %86
86: ; preds = %81, %29
%87 = load i8*, i8** %13
%88 = load i32, i32* %5
ret i32 %88
}

LLVM IR (-O2):
@.str = [2 x i8] c" \00"
define i32 @ReadSequence1(i32* nocapture %0, i32* nocapture %1, i32** nocapture writeonly %2, i32 %3) {
%5 = shl nsw i32 %3, 1
%6 = zext i32 %5 to i64
%7 = alloca i8, i64 %6
%8 = call i32* @fgets(i8* %7, i32 %5, i32* %0)
%9 = icmp eq i32* %8, null
br i1 %9, label %47, label %10
10: ; preds = %4
%11 = call i32 @strlen(i8* %7)
%12 = add nsw i32 %11, -1
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i8, i8* %7, i64 %13
store i8 0, i8* %14
%15 = shl i32 %3, 2
%16 = call i64 @malloc(i32 %15)
%17 = inttoptr i64 %16 to i32*
%18 = call i8* @strtok(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%19 = icmp eq i8* %18, null
br i1 %19, label %30, label %20
20: ; preds = %10, %20
%21 = phi i64 [ %26, %20 ], [ 0, %10 ]
%22 = phi i8* [ %25, %20 ], [ %18, %10 ]
%23 = call i32 @atoi(i8* %22)
%24 = getelementptr inbounds i32, i32* %17, i64 %21
store i32 %23, i32* %24
%25 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%26 = add nuw i64 %21, 1
%27 = icmp eq i8* %25, null
br i1 %27, label %28, label %20
28: ; preds = %20
%29 = trunc i64 %26 to i32
br label %30
30: ; preds = %28, %10
%31 = phi i32 [ 0, %10 ], [ %29, %28 ]
store i32 %31, i32* %1
%32 = call i32* @ivector(i32 1, i32 %31)
%33 = load i32, i32* %1
%34 = icmp slt i32 %33, 1
br i1 %34, label %45, label %35
35: ; preds = %30, %35
%36 = phi i64 [ %41, %35 ], [ 1, %30 ]
%37 = add nsw i64 %36, -1
%38 = getelementptr inbounds i32, i32* %17, i64 %37
%39 = load i32, i32* %38
%40 = getelementptr inbounds i32, i32* %32, i64 %36
store i32 %39, i32* %40
%41 = add nuw nsw i64 %36, 1
%42 = load i32, i32* %1
%43 = sext i32 %42 to i64
%44 = icmp slt i64 %36, %43
br i1 %44, label %35, label %45
45: ; preds = %35, %30
store i32* %32, i32** %2
%46 = call i32 @free(i32* %17)
br label %47
47: ; preds = %4, %45
%48 = phi i32 [ 1, %45 ], [ -1, %4 ]
ret i32 %48
}