#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 */
scalar_t__ calloc(short, int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
char *strsep(char **, char *);
scalar_t__ strtol(char *, char **, int);
void applyOrderFile(FILE *inputfile, char **nodes) {
  char line[80], *line_ptr, *protein, *pos_ptr, *end_ptr;
  short protein_length;
  int pos;
  while (fgets(line, 80, inputfile) != NULL) {
    line_ptr = line;
    protein = strsep(&line_ptr, " \t\n");
    protein_length = strlen(protein) + 1;
    pos_ptr = strsep(&line_ptr, " \t\n");
    if ((protein != NULL) && (pos_ptr != NULL)) {
      if (strcmp(protein, "Protein")) {
        pos = (int)strtol(pos_ptr, &end_ptr, 10);
        if (pos_ptr == end_ptr) {
          printf("Invalid order file format.\n");
          exit(1);
        } else {
          nodes[pos] = (char *)calloc(protein_length, sizeof(char));
          strcpy(nodes[pos], protein);
        }
      }
    } else {
      printf("ERROR while reading order file.\n");
      exit(1);
    }
  }
}


x86 assembly (clang, -O0):
<applyOrderFile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x60(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    $0x50,%esi
call   1060 <fgets@plt>
cmp    $0x0,%rax
je     12ce <applyOrderFile+0x13e>
lea    -0x60(%rbp),%rax
mov    %rax,-0x68(%rbp)
lea    -0x68(%rbp),%rdi
lea    0xe2e(%rip),%rsi
call   10a0 <strsep@plt>
mov    %rax,-0x70(%rbp)
mov    -0x70(%rbp),%rdi
call   1040 <strlen@plt>
add    $0x1,%eax
mov    %ax,-0x82(%rbp)
lea    -0x68(%rbp),%rdi
lea    0xe07(%rip),%rsi
call   10a0 <strsep@plt>
mov    %rax,-0x78(%rbp)
cmpq   $0x0,-0x70(%rbp)
je     12b3 <applyOrderFile+0x123>
cmpq   $0x0,-0x78(%rbp)
je     12b3 <applyOrderFile+0x123>
mov    -0x70(%rbp),%rdi
lea    0xde1(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
je     12ae <applyOrderFile+0x11e>
mov    -0x78(%rbp),%rdi
lea    -0x80(%rbp),%rsi
mov    $0xa,%edx
call   1090 <strtol@plt>
mov    %eax,-0x88(%rbp)
mov    -0x78(%rbp),%rax
cmp    -0x80(%rbp),%rax
jne    126e <applyOrderFile+0xde>
lea    0xdad(%rip),%rdi
call   1050 <printf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
mov    $0x1,%esi
movswl -0x82(%rbp),%edi
call   1070 <calloc@plt>
mov    %rax,%rdx
mov    -0x10(%rbp),%rax
movslq -0x88(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x10(%rbp),%rax
movslq -0x88(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x70(%rbp),%rsi
call   1030 <strcpy@plt>
jmp    12ae <applyOrderFile+0x11e>
jmp    12c9 <applyOrderFile+0x139>
lea    0xd6e(%rip),%rdi
call   1050 <printf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
jmp    11a3 <applyOrderFile+0x13>
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<applyOrderFile>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x78,%rsp
mov    %rsi,(%rsp)
mov    %rdi,%rdx
lea    0x20(%rsp),%r12
mov    %r12,%rdi
mov    $0x50,%esi
mov    %rdx,0x8(%rsp)
call   1060 <fgets@plt>
test   %rax,%rax
je     128f <applyOrderFile+0xff>
lea    0x18(%rsp),%r13
jmp    1215 <applyOrderFile+0x85>
nopl   0x0(%rax)
mov    %rax,%r12
add    $0x1,%r14d
movswl %r14w,%edi
mov    $0x1,%esi
call   1070 <calloc@plt>
movslq %r12d,%rcx
mov    (%rsp),%rdx
mov    %rax,(%rdx,%rcx,8)
mov    %rax,%rdi
mov    %rbp,%rsi
call   1030 <strcpy@plt>
mov    %rbx,%r12
mov    %r12,%rdi
mov    $0x50,%esi
mov    0x8(%rsp),%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     128f <applyOrderFile+0xff>
mov    %r12,0x18(%rsp)
mov    %r13,%rdi
lea    0xddc(%rip),%rbx
mov    %rbx,%rsi
call   10a0 <strsep@plt>
mov    %rax,%rbp
mov    %rax,%rdi
call   1050 <strlen@plt>
mov    %eax,%r14d
mov    %r13,%rdi
mov    %rbx,%rsi
call   10a0 <strsep@plt>
test   %rbp,%rbp
je     129e <applyOrderFile+0x10e>
mov    %rax,%r15
test   %rax,%rax
je     129e <applyOrderFile+0x10e>
mov    %rbp,%rdi
lea    0xda8(%rip),%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
je     11fe <applyOrderFile+0x6e>
mov    %r12,%rbx
mov    %r15,%rdi
lea    0x10(%rsp),%rsi
mov    $0xa,%edx
call   1090 <strtol@plt>
cmp    0x10(%rsp),%r15
jne    11d0 <applyOrderFile+0x40>
lea    0xd9f(%rip),%rdi
jmp    12a5 <applyOrderFile+0x115>
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xd67(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>

LLVM IR (-O0):
@.str = [4 x i8] c" \09\0A\00"
@.str.1 = [8 x i8] c"Protein\00"
@.str.2 = [28 x i8] c"Invalid order file format.\0A\00"
@.str.3 = [33 x i8] c"ERROR while reading order file.\0A\00"
define void @applyOrderFile(i32* %0, i8** %1) {
%3 = alloca i32*
%4 = alloca i8**
%5 = alloca [80 x i8]
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i16
%11 = alloca i32
store i32* %0, i32** %3
store i8** %1, i8*** %4
br label %12
12: ; preds = %64, %2
%13 = getelementptr inbounds [80 x i8], [80 x i8]* %5, i64 0, i64 0
%14 = load i32*, i32** %3
%15 = call i32* @fgets(i8* %13, i32 80, i32* %14)
%16 = icmp ne i32* %15, null
br i1 %16, label %17, label %65
17: ; preds = %12
%18 = getelementptr inbounds [80 x i8], [80 x i8]* %5, i64 0, i64 0
store i8* %18, i8** %6
%19 = call i8* @strsep(i8** %6, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
store i8* %19, i8** %7
%20 = load i8*, i8** %7
%21 = call i32 @strlen(i8* %20)
%22 = add nsw i32 %21, 1
%23 = trunc i32 %22 to i16
store i16 %23, i16* %10
%24 = call i8* @strsep(i8** %6, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
store i8* %24, i8** %8
%25 = load i8*, i8** %7
%26 = icmp ne i8* %25, null
br i1 %26, label %27, label %61
27: ; preds = %17
%28 = load i8*, i8** %8
%29 = icmp ne i8* %28, null
br i1 %29, label %30, label %61
30: ; preds = %27
%31 = load i8*, i8** %7
%32 = call i64 @strcmp(i8* %31, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%33 = icmp ne i64 %32, 0
br i1 %33, label %34, label %60
34: ; preds = %30
%35 = load i8*, i8** %8
%36 = call i64 @strtol(i8* %35, i8** %9, i32 10)
%37 = trunc i64 %36 to i32
store i32 %37, i32* %11
%38 = load i8*, i8** %8
%39 = load i8*, i8** %9
%40 = icmp eq i8* %38, %39
br i1 %40, label %41, label %44
41: ; preds = %34
%42 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
%43 = call i32 @exit(i32 1)
unreachable
44: ; preds = %34
%45 = load i16, i16* %10
%46 = call i64 @calloc(i16 signext %45, i32 1)
%47 = inttoptr i64 %46 to i8*
%48 = load i8**, i8*** %4
%49 = load i32, i32* %11
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds i8*, i8** %48, i64 %50
store i8* %47, i8** %51
%52 = load i8**, i8*** %4
%53 = load i32, i32* %11
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds i8*, i8** %52, i64 %54
%56 = load i8*, i8** %55
%57 = load i8*, i8** %7
%58 = call i32 @strcpy(i8* %56, i8* %57)
br label %59
59: ; preds = %44
br label %60
60: ; preds = %59, %30
br label %64
61: ; preds = %27, %17
%62 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0))
%63 = call i32 @exit(i32 1)
unreachable
64: ; preds = %60
br label %12
65: ; preds = %12
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c" \09\0A\00"
@.str.1 = [8 x i8] c"Protein\00"
@str = [32 x i8] c"ERROR while reading order file.\00"
@str.4 = [27 x i8] c"Invalid order file format.\00"
define void @applyOrderFile(i32* nocapture %0, i8** nocapture writeonly %1) {
%3 = alloca [80 x i8]
%4 = alloca i8*
%5 = alloca i8*
%6 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 0
%7 = bitcast i8** %4 to i8*
%8 = bitcast i8** %5 to i8*
%9 = call i32* @fgets(i8* %6, i32 80, i32* %0)
%10 = icmp eq i32* %9, null
br i1 %10, label %43, label %11
11: ; preds = %2, %40
store i8* %6, i8** %4
%12 = call i8* @strsep(i8** %4, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%13 = call i32 @strlen(i8* %12)
%14 = trunc i32 %13 to i16
%15 = add i16 %14, 1
%16 = call i8* @strsep(i8** %4, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%17 = icmp ne i8* %12, null
%18 = icmp ne i8* %16, null
%19 = select i1 %17, i1 %18, i1 false
br i1 %19, label %20, label %37
20: ; preds = %11
%21 = call i64 @strcmp(i8* %12, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%22 = icmp eq i64 %21, 0
br i1 %22, label %40, label %23
23: ; preds = %20
%24 = call i64 @strtol(i8* %16, i8** %5, i32 10)
%25 = load i8*, i8** %5
%26 = icmp eq i8* %16, %25
br i1 %26, label %27, label %30
27: ; preds = %23
%28 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.4, i64 0, i64 0))
%29 = call i32 @exit(i32 1)
unreachable
30: ; preds = %23
%31 = call i64 @calloc(i16 signext %15, i32 1)
%32 = inttoptr i64 %31 to i8*
%33 = shl i64 %24, 32
%34 = ashr exact i64 %33, 32
%35 = getelementptr inbounds i8*, i8** %1, i64 %34
store i8* %32, i8** %35
%36 = call i32 @strcpy(i8* %32, i8* %12)
br label %40
37: ; preds = %11
%38 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str, i64 0, i64 0))
%39 = call i32 @exit(i32 1)
unreachable
40: ; preds = %20, %30
%41 = call i32* @fgets(i8* %6, i32 80, i32* %0)
%42 = icmp eq i32* %41, null
br i1 %42, label %43, label %11
43: ; preds = %40, %2
ret void
}