#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 */
struct genome_struct {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ free(int *);
int hamming_distance(struct genome_struct *, struct genome_struct *, int, int,
                     int *);
scalar_t__ malloc(int);
int /*<<< orphan*/ stderr;
int hamming_distance_nomem(struct genome_struct *g1, struct genome_struct *g2,
                           int num_genes, int CIRCULAR) {
  int dist;
  int *geneAdj;
  geneAdj = (int *)malloc((num_genes + 1) * 2 * sizeof(int));
  if (geneAdj == (int *)NULL)
    fprintf(stderr, "ERROR: geneAdj NULL\n");
  dist = hamming_distance(g1, g2, num_genes, CIRCULAR, geneAdj);
  free(geneAdj);
  return (dist);
}


x86 assembly (clang, -O0):
<hamming_distance_nomem>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
shl    $0x1,%eax
cltq
shl    $0x2,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1190 <hamming_distance_nomem+0x50>
mov    0x2e5e(%rip),%rax
mov    (%rax),%edi
lea    0xe75(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
mov    -0x28(%rbp),%r8
call   1050 <hamming_distance@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x1c(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hamming_distance_nomem>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %ecx,%r14d
mov    %edx,%ebx
mov    %rsi,%r15
mov    %rdi,%r12
lea    0x8(,%rbx,8),%edi
call   1060 <malloc@plt>
mov    %rax,%rbp
test   %rax,%rax
jne    117c <hamming_distance_nomem+0x3c>
mov    0x2e72(%rip),%rax
mov    (%rax),%edi
lea    0xe89(%rip),%rsi
call   1040 <fprintf@plt>
mov    %r12,%rdi
mov    %r15,%rsi
mov    %ebx,%edx
mov    %r14d,%ecx
mov    %rbp,%r8
call   1050 <hamming_distance@plt>
mov    %eax,%ebx
mov    %rbp,%rdi
call   1030 <free@plt>
mov    %ebx,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.genome_struct = type { i32 }
@stderr = global i32 0
@.str = [21 x i8] c"ERROR: geneAdj NULL\0A\00"
define i32 @hamming_distance_nomem(%struct.genome_struct* %0, %struct.genome_struct* %1, i32 %2, i32 %3) {
%5 = alloca %struct.genome_struct*
%6 = alloca %struct.genome_struct*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32*
store %struct.genome_struct* %0, %struct.genome_struct** %5
store %struct.genome_struct* %1, %struct.genome_struct** %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%11 = load i32, i32* %7
%12 = add nsw i32 %11, 1
%13 = mul nsw i32 %12, 2
%14 = sext i32 %13 to i64
%15 = mul i64 %14, 4
%16 = trunc i64 %15 to i32
%17 = call i64 @malloc(i32 %16)
%18 = inttoptr i64 %17 to i32*
store i32* %18, i32** %10
%19 = load i32*, i32** %10
%20 = icmp eq i32* %19, null
br i1 %20, label %21, label %24
21: ; preds = %4
%22 = load i32, i32* @stderr
%23 = call i32 @fprintf(i32 %22, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
br label %24
24: ; preds = %21, %4
%25 = load %struct.genome_struct*, %struct.genome_struct** %5
%26 = load %struct.genome_struct*, %struct.genome_struct** %6
%27 = load i32, i32* %7
%28 = load i32, i32* %8
%29 = load i32*, i32** %10
%30 = call i32 @hamming_distance(%struct.genome_struct* %25, %struct.genome_struct* %26, i32 %27, i32 %28, i32* %29)
store i32 %30, i32* %9
%31 = load i32*, i32** %10
%32 = call i32 @free(i32* %31)
%33 = load i32, i32* %9
ret i32 %33
}

LLVM IR (-O2):
%struct.genome_struct = type { i32 }
@stderr = global i32 0
@.str = [21 x i8] c"ERROR: geneAdj NULL\0A\00"
define i32 @hamming_distance_nomem(%struct.genome_struct* %0, %struct.genome_struct* %1, i32 %2, i32 %3) {
%5 = shl i32 %2, 3
%6 = add i32 %5, 8
%7 = tail call i64 @malloc(i32 %6)
%8 = inttoptr i64 %7 to i32*
%9 = icmp eq i64 %7, 0
br i1 %9, label %10, label %13
10: ; preds = %4
%11 = load i32, i32* @stderr
%12 = tail call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
br label %13
13: ; preds = %10, %4
%14 = tail call i32 @hamming_distance(%struct.genome_struct* %0, %struct.genome_struct* %1, i32 %2, i32 %3, i32* %8)
%15 = tail call i32 @free(i32* %8)
ret i32 %14
}