#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*/ EXIT_FAILURE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
scalar_t__ malloc(int const);
int /*<<< orphan*/ memcpy(char *, char const *, int const);
int /*<<< orphan*/ printf(char *, char *);
int const strlen(char const *);
char **queryKmersIntoArray(const char *dnaChars, const int KMERSIZE,
                           const int numberOfLines, const int LINESIZE) {
  const int numberOfKmers = numberOfLines * LINESIZE;
  char **kmersArrayMalloc = (char **)malloc(numberOfKmers * sizeof(char *));
  if (kmersArrayMalloc == NULL) {
    printf("%s", "Error: kmersArrayMalloc\n");
    exit(EXIT_FAILURE);
  }
  for (int i = 0; i < numberOfKmers; i++) {
    kmersArrayMalloc[i] = (char *)malloc(sizeof(char) * KMERSIZE * 10);
    if (kmersArrayMalloc[i] == NULL) {
      printf("%s", "Error: kmersArrayMalloc\n");
      exit(EXIT_FAILURE);
    }
  }
  for (int i = 0; i < strlen(dnaChars) - KMERSIZE + 1; i++) {
    memcpy(kmersArrayMalloc[i], &dnaChars[i], KMERSIZE);
  }
  return (char **)kmersArrayMalloc;
}


x86 assembly (clang, -O0):
<queryKmersIntoArray>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    -0x10(%rbp),%eax
imul   -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
movslq -0x18(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11ae <queryKmersIntoArray+0x5e>
lea    0xe6c(%rip),%rdi
lea    0xe68(%rip),%rsi
call   1040 <printf@plt>
mov    0x2e39(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    122a <queryKmersIntoArray+0xda>
movslq -0xc(%rbp),%rax
shl    $0x0,%rax
imul   $0xa,%rax,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,%rdx
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
jne    1217 <queryKmersIntoArray+0xc7>
lea    0xe03(%rip),%rdi
lea    0xdff(%rip),%rsi
call   1040 <printf@plt>
mov    0x2dd0(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
jmp    121c <queryKmersIntoArray+0xcc>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11b5 <queryKmersIntoArray+0x65>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x2c(%rbp),%eax
sub    -0xc(%rbp),%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
jge    1280 <queryKmersIntoArray+0x130>
mov    -0x20(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x8(%rbp),%rsi
movslq -0x28(%rbp),%rax
add    %rax,%rsi
mov    -0xc(%rbp),%edx
call   1050 <memcpy@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1231 <queryKmersIntoArray+0xe1>
mov    -0x20(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<queryKmersIntoArray>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%ebx
mov    %esi,%r15d
mov    %rdi,%r14
imul   %ecx,%ebx
lea    0x0(,%rbx,8),%edi
call   1060 <malloc@plt>
test   %rax,%rax
je     11fc <queryKmersIntoArray+0xac>
mov    %rax,%r13
test   %ebx,%ebx
jle    11ab <queryKmersIntoArray+0x5b>
lea    (%r15,%r15,1),%eax
lea    (%rax,%rax,4),%r12d
mov    %ebx,%ebx
xor    %ebp,%ebp
xchg   %ax,%ax
mov    %r12d,%edi
call   1060 <malloc@plt>
mov    %rax,0x0(%r13,%rbp,8)
test   %rax,%rax
je     11fc <queryKmersIntoArray+0xac>
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    1190 <queryKmersIntoArray+0x40>
mov    %r14,%rdi
call   1030 <strlen@plt>
cmp    %r15d,%eax
jl     11ea <queryKmersIntoArray+0x9a>
xor    %ebp,%ebp
nopw   0x0(%rax,%rax,1)
mov    0x0(%r13,%rbp,8),%rdi
lea    (%r14,%rbp,1),%rsi
mov    %r15d,%edx
call   1050 <memcpy@plt>
lea    0x1(%rbp),%rbx
mov    %r14,%rdi
call   1030 <strlen@plt>
sub    %r15d,%eax
cltq
cmp    %rax,%rbp
mov    %rbx,%rbp
jl     11c0 <queryKmersIntoArray+0x70>
mov    %r13,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xdfd(%rip),%rdi
lea    0xdf9(%rip),%rsi
call   1040 <printf@plt>
mov    0x2dca(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>

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

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@.str.1 = [25 x i8] c"Error: kmersArrayMalloc\0A\00"
@EXIT_FAILURE = global i32 0
define i8** @queryKmersIntoArray(i8* %0, i32 %1, i32 %2, i32 %3) {
%5 = mul nsw i32 %3, %2
%6 = shl i32 %5, 3
%7 = tail call i64 @malloc(i32 %6)
%8 = inttoptr i64 %7 to i8**
%9 = icmp eq i64 %7, 0
br i1 %9, label %15, label %10
10: ; preds = %4
%11 = icmp sgt i32 %5, 0
br i1 %11, label %12, label %21
12: ; preds = %10
%13 = mul i32 %1, 10
%14 = zext i32 %5 to i64
br label %24
15: ; preds = %4
%16 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
%17 = load i32, i32* @EXIT_FAILURE
%18 = tail call i32 @exit(i32 %17)
unreachable
19: ; preds = %24
%20 = icmp eq i64 %30, %14
br i1 %20, label %21, label %24
21: ; preds = %19, %10
%22 = tail call i32 @strlen(i8* %0)
%23 = icmp slt i32 %22, %1
br i1 %23, label %35, label %36
24: ; preds = %12, %19
%25 = phi i64 [ 0, %12 ], [ %30, %19 ]
%26 = tail call i64 @malloc(i32 %13)
%27 = inttoptr i64 %26 to i8*
%28 = getelementptr inbounds i8*, i8** %8, i64 %25
store i8* %27, i8** %28
%29 = icmp eq i64 %26, 0
%30 = add nuw nsw i64 %25, 1
br i1 %29, label %31, label %19
31: ; preds = %24
%32 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
%33 = load i32, i32* @EXIT_FAILURE
%34 = tail call i32 @exit(i32 %33)
unreachable
35: ; preds = %36, %21
ret i8** %8
36: ; preds = %21, %36
%37 = phi i64 [ %42, %36 ], [ 0, %21 ]
%38 = getelementptr inbounds i8*, i8** %8, i64 %37
%39 = load i8*, i8** %38
%40 = getelementptr inbounds i8, i8* %0, i64 %37
%41 = tail call i32 @memcpy(i8* %39, i8* %40, i32 %1)
%42 = add nuw nsw i64 %37, 1
%43 = tail call i32 @strlen(i8* %0)
%44 = sub nsw i32 %43, %1
%45 = sext i32 %44 to i64
%46 = icmp slt i64 %37, %45
br i1 %46, label %36, label %35
}