#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*/ doCriticalErrorAndQuit(char *, int, int);
int /*<<< orphan*/ memcpy(char *, char *, int);
char *simpleArrayCreateRelease(int, int);
int /*<<< orphan*/ strcpy(char *, char *);
char *seqdupPlusTuple(int length, char *in, int tsize) {
  char *res;
  int start, stop, i;
  if (tsize > length)
    doCriticalErrorAndQuit(
        "Tuple size (%d) is larger than sequence(%d). Aborting!", tsize,
        length);
  res = (simpleArrayCreateRelease(1, ((length + tsize + 2) * sizeof(char))));
  strcpy(res, in);
  memcpy(res + length, in, tsize);
  res[length + tsize] = 0;
  return res;
}


x86 assembly (clang, -O0):
<seqdupPlusTuple>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jle    1170 <seqdupPlusTuple+0x30>
mov    -0x14(%rbp),%esi
mov    -0x4(%rbp),%edx
lea    0xe95(%rip),%rdi
call   1060 <doCriticalErrorAndQuit@plt>
mov    -0x4(%rbp),%eax
add    -0x14(%rbp),%eax
add    $0x2,%eax
cltq
shl    $0x0,%rax
mov    %eax,%esi
mov    $0x1,%edi
call   1040 <simpleArrayCreateRelease@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x20(%rbp),%rdi
movslq -0x4(%rbp),%rax
add    %rax,%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1050 <memcpy@plt>
mov    -0x20(%rbp),%rax
mov    -0x4(%rbp),%ecx
add    -0x14(%rbp),%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x20(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<seqdupPlusTuple>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edx,%r15d
mov    %rsi,%r14
mov    %edi,%r12d
cmp    %edi,%edx
jle    1167 <seqdupPlusTuple+0x27>
lea    0xea4(%rip),%rdi
mov    %r15d,%esi
mov    %r12d,%edx
call   1060 <doCriticalErrorAndQuit@plt>
lea    (%r15,%r12,1),%ebp
lea    (%r15,%r12,1),%esi
add    $0x2,%esi
mov    $0x1,%edi
call   1040 <simpleArrayCreateRelease@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r14,%rsi
call   1030 <strcpy@plt>
movslq %r12d,%rdi
add    %rbx,%rdi
mov    %r14,%rsi
mov    %r15d,%edx
call   1050 <memcpy@plt>
movslq %ebp,%rax
movb   $0x0,(%rbx,%rax,1)
mov    %rbx,%rax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [55 x i8] c"Tuple size (%d) is larger than sequence(%d). Aborting!\00"
define i8* @seqdupPlusTuple(i32 %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 %0, i32* %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%11 = load i32, i32* %6
%12 = load i32, i32* %4
%13 = icmp sgt i32 %11, %12
br i1 %13, label %14, label %18
14: ; preds = %3
%15 = load i32, i32* %6
%16 = load i32, i32* %4
%17 = call i32 @doCriticalErrorAndQuit(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str, i64 0, i64 0), i32 %15, i32 %16)
br label %18
18: ; preds = %14, %3
%19 = load i32, i32* %4
%20 = load i32, i32* %6
%21 = add nsw i32 %19, %20
%22 = add nsw i32 %21, 2
%23 = sext i32 %22 to i64
%24 = mul i64 %23, 1
%25 = trunc i64 %24 to i32
%26 = call i8* @simpleArrayCreateRelease(i32 1, i32 %25)
store i8* %26, i8** %7
%27 = load i8*, i8** %7
%28 = load i8*, i8** %5
%29 = call i32 @strcpy(i8* %27, i8* %28)
%30 = load i8*, i8** %7
%31 = load i32, i32* %4
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i8, i8* %30, i64 %32
%34 = load i8*, i8** %5
%35 = load i32, i32* %6
%36 = call i32 @memcpy(i8* %33, i8* %34, i32 %35)
%37 = load i8*, i8** %7
%38 = load i32, i32* %4
%39 = load i32, i32* %6
%40 = add nsw i32 %38, %39
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i8, i8* %37, i64 %41
store i8 0, i8* %42
%43 = load i8*, i8** %7
ret i8* %43
}

LLVM IR (-O2):
@.str = [55 x i8] c"Tuple size (%d) is larger than sequence(%d). Aborting!\00"
define i8* @seqdupPlusTuple(i32 %0, i8* %1, i32 %2) {
%4 = icmp sgt i32 %2, %0
br i1 %4, label %5, label %7
5: ; preds = %3
%6 = tail call i32 @doCriticalErrorAndQuit(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str, i64 0, i64 0), i32 %2, i32 %0)
br label %7
7: ; preds = %5, %3
%8 = add nsw i32 %2, %0
%9 = add nsw i32 %8, 2
%10 = tail call i8* @simpleArrayCreateRelease(i32 1, i32 %9)
%11 = tail call i32 @strcpy(i8* %10, i8* %1)
%12 = sext i32 %0 to i64
%13 = getelementptr inbounds i8, i8* %10, i64 %12
%14 = tail call i32 @memcpy(i8* %13, i8* %1, i32 %2)
%15 = sext i32 %8 to i64
%16 = getelementptr inbounds i8, i8* %10, i64 %15
store i8 0, i8* %16
ret i8* %10
}