#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 /*<<< orphan*/ sprintf(char *, char *, int);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
void calc_short_header(char *header, char *short_header, int sctr) {
  int i;
  strcpy(short_header, header);
  for (i = 0; i < strlen(header); i++) {
    if (header[i] == ' ' || header[i] == '\t' || header[i] == '\r' ||
        header[i] == '\n') {
      strncpy(short_header, header, i);
      short_header[i] = '\0';
      break;
    }
  }
  if (i == 0) {
    sprintf(short_header, "Prodigal_Seq_%d", sctr);
  }
}


x86 assembly (clang, -O0):
<calc_short_header>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1040 <strcpy@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
cmp    %ecx,%eax
jge    120b <calc_short_header+0xcb>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x20,%eax
je     11d7 <calc_short_header+0x97>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x9,%eax
je     11d7 <calc_short_header+0x97>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0xd,%eax
je     11d7 <calc_short_header+0x97>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0xa,%eax
jne    11f8 <calc_short_header+0xb8>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x18(%rbp),%edx
call   1030 <strncpy@plt>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
jmp    120b <calc_short_header+0xcb>
jmp    11fd <calc_short_header+0xbd>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1167 <calc_short_header+0x27>
cmpl   $0x0,-0x18(%rbp)
jne    1228 <calc_short_header+0xe8>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%edx
lea    0xddd(%rip),%rsi
call   1060 <sprintf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<calc_short_header>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edx,%r14d
mov    %rsi,%r15
mov    %rdi,%rbp
mov    %rsi,%rdi
mov    %rbp,%rsi
call   1040 <strcpy@plt>
mov    %rbp,%rdi
call   1050 <strlen@plt>
test   %eax,%eax
jle    11c3 <calc_short_header+0x83>
xor    %ebx,%ebx
movabs $0x100002600,%r12
jmp    1193 <calc_short_header+0x53>
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%rbx
mov    %rbp,%rdi
call   1050 <strlen@plt>
cltq
cmp    %rax,%rbx
jge    11ba <calc_short_header+0x7a>
movzbl 0x0(%rbp,%rbx,1),%eax
cmp    $0x20,%rax
ja     1180 <calc_short_header+0x40>
bt     %rax,%r12
jae    1180 <calc_short_header+0x40>
mov    %r15,%rdi
mov    %rbp,%rsi
mov    %ebx,%edx
call   1030 <strncpy@plt>
movb   $0x0,(%r15,%rbx,1)
test   %ebx,%ebx
je     11c3 <calc_short_header+0x83>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe36(%rip),%rsi
mov    %r15,%rdi
mov    %r14d,%edx
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1060 <sprintf@plt>

LLVM IR (-O0):
@.str = [16 x i8] c"Prodigal_Seq_%d\00"
define void @calc_short_header(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%8 = load i8*, i8** %5
%9 = load i8*, i8** %4
%10 = call i32 @strcpy(i8* %8, i8* %9)
store i32 0, i32* %7
br label %11
11: ; preds = %58, %3
%12 = load i32, i32* %7
%13 = load i8*, i8** %4
%14 = call i32 @strlen(i8* %13)
%15 = icmp slt i32 %12, %14
br i1 %15, label %16, label %61
16: ; preds = %11
%17 = load i8*, i8** %4
%18 = load i32, i32* %7
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8, i8* %17, i64 %19
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = icmp eq i32 %22, 32
br i1 %23, label %48, label %24
24: ; preds = %16
%25 = load i8*, i8** %4
%26 = load i32, i32* %7
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i8, i8* %25, i64 %27
%29 = load i8, i8* %28
%30 = sext i8 %29 to i32
%31 = icmp eq i32 %30, 9
br i1 %31, label %48, label %32
32: ; preds = %24
%33 = load i8*, i8** %4
%34 = load i32, i32* %7
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i8, i8* %33, i64 %35
%37 = load i8, i8* %36
%38 = sext i8 %37 to i32
%39 = icmp eq i32 %38, 13
br i1 %39, label %48, label %40
40: ; preds = %32
%41 = load i8*, i8** %4
%42 = load i32, i32* %7
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i8, i8* %41, i64 %43
%45 = load i8, i8* %44
%46 = sext i8 %45 to i32
%47 = icmp eq i32 %46, 10
br i1 %47, label %48, label %57
48: ; preds = %40, %32, %24, %16
%49 = load i8*, i8** %5
%50 = load i8*, i8** %4
%51 = load i32, i32* %7
%52 = call i32 @strncpy(i8* %49, i8* %50, i32 %51)
%53 = load i8*, i8** %5
%54 = load i32, i32* %7
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds i8, i8* %53, i64 %55
store i8 0, i8* %56
br label %61
57: ; preds = %40
br label %58
58: ; preds = %57
%59 = load i32, i32* %7
%60 = add nsw i32 %59, 1
store i32 %60, i32* %7
br label %11
61: ; preds = %48, %11
%62 = load i32, i32* %7
%63 = icmp eq i32 %62, 0
br i1 %63, label %64, label %68
64: ; preds = %61
%65 = load i8*, i8** %5
%66 = load i32, i32* %6
%67 = call i32 @sprintf(i8* %65, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %66)
br label %68
68: ; preds = %64, %61
ret void
}

LLVM IR (-O2):
@.str = [16 x i8] c"Prodigal_Seq_%d\00"
define void @calc_short_header(i8* %0, i8* %1, i32 %2) {
%4 = tail call i32 @strcpy(i8* %1, i8* %0)
%5 = tail call i32 @strlen(i8* %0)
%6 = icmp sgt i32 %5, 0
br i1 %6, label %7, label %22
7: ; preds = %3, %11
%8 = phi i64 [ %12, %11 ], [ 0, %3 ]
%9 = getelementptr inbounds i8, i8* %0, i64 %8
%10 = load i8, i8* %9
switch i8 %10, label %11 [
i8 32, label %16
i8 9, label %16
i8 13, label %16
i8 10, label %16
]
11: ; preds = %7
%12 = add nuw nsw i64 %8, 1
%13 = tail call i32 @strlen(i8* %0)
%14 = sext i32 %13 to i64
%15 = icmp slt i64 %12, %14
br i1 %15, label %7, label %24
16: ; preds = %7, %7, %7, %7
%17 = trunc i64 %8 to i32
%18 = and i64 %8, 4294967295
%19 = tail call i32 @strncpy(i8* %1, i8* %0, i32 %17)
%20 = getelementptr inbounds i8, i8* %1, i64 %18
store i8 0, i8* %20
%21 = icmp eq i32 %17, 0
br i1 %21, label %22, label %24
22: ; preds = %3, %16
%23 = tail call i32 @sprintf(i8* dereferenceable(1) %1, i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %2)
br label %24
24: ; preds = %11, %22, %16
ret void
}