#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 */

/* Variables and functions */
int copyWord(char const *, char *);
int /*<<< orphan*/ errmessage1(char *, char const *);
int /*<<< orphan*/ slideLeft(char *, int);
scalar_t__ startswith(char *, int, char *, int);
int strlen(char *);
int parseAccessionGI(const char *line, char *accession, char *gi) {
  unsigned int pos, p2;
  pos = 7 + 1 + copyWord(line + 7 + 1, accession);
  if (strlen(accession) < 4) {
    errmessage1("Could not parse an ACCESSION out of \"%s\"\n", line);
    return 0;
  }
  p2 = copyWord(line + pos, gi);
  if (p2 < 4 || 0 == startswith("GI:", 3, gi, strlen(gi))) {
    errmessage1("GI \"%s\"\n", gi);
    errmessage1("Could not parse a GI out of \"%s\"\n", line);
    return 0;
  }
  slideLeft(gi, 3);
  return 1;
}


x86 assembly (clang, -O0):
<parseAccessionGI>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
add    $0x7,%rdi
add    $0x1,%rdi
mov    -0x18(%rbp),%rsi
call   1060 <copyWord@plt>
add    $0x8,%eax
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x4,%eax
jge    11ad <parseAccessionGI+0x5d>
mov    -0x10(%rbp),%rsi
lea    0xe64(%rip),%rdi
call   1070 <errmessage1@plt>
movl   $0x0,-0x4(%rbp)
jmp    1244 <parseAccessionGI+0xf4>
mov    -0x10(%rbp),%rdi
mov    -0x24(%rbp),%eax
add    %rax,%rdi
mov    -0x20(%rbp),%rsi
call   1060 <copyWord@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0x4,-0x28(%rbp)
jb     1203 <parseAccessionGI+0xb3>
mov    -0x20(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x30(%rbp),%rdx
mov    %eax,%ecx
lea    0xe3f(%rip),%rdi
mov    $0x3,%esi
call   1040 <startswith@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    122f <parseAccessionGI+0xdf>
mov    -0x20(%rbp),%rsi
lea    0xe20(%rip),%rdi
call   1070 <errmessage1@plt>
mov    -0x10(%rbp),%rsi
lea    0xe19(%rip),%rdi
call   1070 <errmessage1@plt>
movl   $0x0,-0x4(%rbp)
jmp    1244 <parseAccessionGI+0xf4>
mov    -0x20(%rbp),%rdi
mov    $0x3,%esi
call   1050 <slideLeft@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parseAccessionGI>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %rdi,%r15
add    $0x8,%rdi
call   1060 <copyWord@plt>
mov    %eax,%r12d
mov    %rbx,%rdi
call   1030 <strlen@plt>
cmp    $0x3,%eax
jg     1183 <parseAccessionGI+0x33>
lea    0xe7f(%rip),%rdi
jmp    11e7 <parseAccessionGI+0x97>
add    $0x8,%r12d
add    %r15,%r12
mov    %r12,%rdi
mov    %r14,%rsi
call   1060 <copyWord@plt>
cmp    $0x4,%eax
jb     11d1 <parseAccessionGI+0x81>
mov    %r14,%rdi
call   1030 <strlen@plt>
lea    0xe81(%rip),%rdi
mov    $0x3,%esi
mov    %r14,%rdx
mov    %eax,%ecx
call   1040 <startswith@plt>
test   %rax,%rax
je     11d1 <parseAccessionGI+0x81>
mov    %r14,%rdi
mov    $0x3,%esi
call   1050 <slideLeft@plt>
mov    $0x1,%eax
jmp    11f1 <parseAccessionGI+0xa1>
lea    0xe56(%rip),%rdi
mov    %r14,%rsi
call   1070 <errmessage1@plt>
lea    0xe50(%rip),%rdi
mov    %r15,%rsi
call   1070 <errmessage1@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [42 x i8] c"Could not parse an ACCESSION out of \22%s\22\0A\00"
@.str.1 = [4 x i8] c"GI:\00"
@.str.2 = [9 x i8] c"GI \22%s\22\0A\00"
@.str.3 = [34 x i8] c"Could not parse a GI out of \22%s\22\0A\00"
define i32 @parseAccessionGI(i8* %0, i8* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
%10 = load i8*, i8** %5
%11 = getelementptr inbounds i8, i8* %10, i64 7
%12 = getelementptr inbounds i8, i8* %11, i64 1
%13 = load i8*, i8** %6
%14 = call i32 @copyWord(i8* %12, i8* %13)
%15 = add nsw i32 8, %14
store i32 %15, i32* %8
%16 = load i8*, i8** %6
%17 = call i32 @strlen(i8* %16)
%18 = icmp slt i32 %17, 4
br i1 %18, label %19, label %22
19: ; preds = %3
%20 = load i8*, i8** %5
%21 = call i32 @errmessage1(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0), i8* %20)
store i32 0, i32* %4
br label %45
22: ; preds = %3
%23 = load i8*, i8** %5
%24 = load i32, i32* %8
%25 = zext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %23, i64 %25
%27 = load i8*, i8** %7
%28 = call i32 @copyWord(i8* %26, i8* %27)
store i32 %28, i32* %9
%29 = load i32, i32* %9
%30 = icmp ult i32 %29, 4
br i1 %30, label %37, label %31
31: ; preds = %22
%32 = load i8*, i8** %7
%33 = load i8*, i8** %7
%34 = call i32 @strlen(i8* %33)
%35 = call i64 @startswith(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 3, i8* %32, i32 %34)
%36 = icmp eq i64 0, %35
br i1 %36, label %37, label %42
37: ; preds = %31, %22
%38 = load i8*, i8** %7
%39 = call i32 @errmessage1(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %38)
%40 = load i8*, i8** %5
%41 = call i32 @errmessage1(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0), i8* %40)
store i32 0, i32* %4
br label %45
42: ; preds = %31
%43 = load i8*, i8** %7
%44 = call i32 @slideLeft(i8* %43, i32 3)
store i32 1, i32* %4
br label %45
45: ; preds = %42, %37, %19
%46 = load i32, i32* %4
ret i32 %46
}

LLVM IR (-O2):
@.str = [42 x i8] c"Could not parse an ACCESSION out of \22%s\22\0A\00"
@.str.1 = [4 x i8] c"GI:\00"
@.str.2 = [9 x i8] c"GI \22%s\22\0A\00"
@.str.3 = [34 x i8] c"Could not parse a GI out of \22%s\22\0A\00"
define i32 @parseAccessionGI(i8* %0, i8* %1, i8* %2) {
%4 = getelementptr inbounds i8, i8* %0, i64 8
%5 = tail call i32 @copyWord(i8* %4, i8* %1)
%6 = tail call i32 @strlen(i8* %1)
%7 = icmp slt i32 %6, 4
br i1 %7, label %8, label %10
8: ; preds = %3
%9 = tail call i32 @errmessage1(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %25
10: ; preds = %3
%11 = add nsw i32 %5, 8
%12 = zext i32 %11 to i64
%13 = getelementptr inbounds i8, i8* %0, i64 %12
%14 = tail call i32 @copyWord(i8* %13, i8* %2)
%15 = icmp ult i32 %14, 4
br i1 %15, label %20, label %16
16: ; preds = %10
%17 = tail call i32 @strlen(i8* %2)
%18 = tail call i64 @startswith(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 3, i8* %2, i32 %17)
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %23
20: ; preds = %16, %10
%21 = tail call i32 @errmessage1(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %2)
%22 = tail call i32 @errmessage1(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0), i8* %0)
br label %25
23: ; preds = %16
%24 = tail call i32 @slideLeft(i8* %2, i32 3)
br label %25
25: ; preds = %23, %20, %8
%26 = phi i32 [ 0, %8 ], [ 0, %20 ], [ 1, %23 ]
ret i32 %26
}