#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(int);
int /*<<< orphan*/ printf(char *, char *);
scalar_t__ realloc(int *, int);
int enqueuePair(int element1, int **arr1, int element2, int **arr2, int *len) {
  (*len)++;
  {
    *arr1 = (int *)realloc((*arr1), ((*len) * sizeof(int)));
    if (!(*arr1)) {
      printf("\nError: realloc failed for %s.\n\n", ("arr1"));
      exit(1);
    }
  };
  (*arr1)[(*len) - 1] = element1;
  {
    *arr2 = (int *)realloc((*arr2), ((*len) * sizeof(int)));
    if (!(*arr2)) {
      printf("\nError: realloc failed for %s.\n\n", ("arr2"));
      exit(1);
    }
  };
  (*arr2)[(*len) - 1] = element2;
  return *len;
}


x86 assembly (clang, -O0):
<enqueuePair>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    -0x28(%rbp),%rax
movslq (%rax),%rax
shl    $0x2,%rax
mov    %eax,%esi
call   1040 <realloc@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x10(%rbp),%rax
cmpq   $0x0,(%rax)
jne    11a3 <enqueuePair+0x73>
lea    0xe73(%rip),%rdi
lea    0xe8d(%rip),%rsi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
mov    -0x4(%rbp),%edx
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    -0x28(%rbp),%rcx
mov    (%rcx),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x20(%rbp),%rax
mov    (%rax),%rdi
mov    -0x28(%rbp),%rax
movslq (%rax),%rax
shl    $0x2,%rax
mov    %eax,%esi
call   1040 <realloc@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x20(%rbp),%rax
cmpq   $0x0,(%rax)
jne    120a <enqueuePair+0xda>
lea    0xe0c(%rip),%rdi
lea    0xe2b(%rip),%rsi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
mov    -0x14(%rbp),%edx
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
mov    -0x28(%rbp),%rcx
mov    (%rcx),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x28(%rbp),%rax
mov    (%rax),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<enqueuePair>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %r8,%rbx
mov    %rcx,%r12
mov    %edx,%r14d
mov    %rsi,%rbp
mov    %edi,%r15d
mov    (%r8),%eax
lea    0x1(%rax),%ecx
mov    %ecx,(%r8)
mov    (%rsi),%rdi
lea    0x4(,%rax,4),%esi
call   1040 <realloc@plt>
mov    %rax,0x0(%rbp)
test   %rax,%rax
je     119a <enqueuePair+0x6a>
movslq (%rbx),%rcx
mov    %r15d,-0x4(%rax,%rcx,4)
mov    (%r12),%rdi
mov    (%rbx),%esi
shl    $0x2,%esi
call   1040 <realloc@plt>
mov    %rax,(%r12)
test   %rax,%rax
je     11aa <enqueuePair+0x7a>
movslq (%rbx),%rcx
mov    %r14d,-0x4(%rax,%rcx,4)
mov    (%rbx),%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe5f(%rip),%rdi
lea    0xe79(%rip),%rsi
jmp    11b8 <enqueuePair+0x88>
lea    0xe4f(%rip),%rdi
lea    0xe6e(%rip),%rsi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@.str = [33 x i8] c"\0AError: realloc failed for %s.\0A\0A\00"
@.str.1 = [5 x i8] c"arr1\00"
@.str.2 = [5 x i8] c"arr2\00"
define i32 @enqueuePair(i32 %0, i32** %1, i32 %2, i32** %3, i32* %4) {
%6 = alloca i32
%7 = alloca i32**
%8 = alloca i32
%9 = alloca i32**
%10 = alloca i32*
store i32 %0, i32* %6
store i32** %1, i32*** %7
store i32 %2, i32* %8
store i32** %3, i32*** %9
store i32* %4, i32** %10
%11 = load i32*, i32** %10
%12 = load i32, i32* %11
%13 = add nsw i32 %12, 1
store i32 %13, i32* %11
%14 = load i32**, i32*** %7
%15 = load i32*, i32** %14
%16 = load i32*, i32** %10
%17 = load i32, i32* %16
%18 = sext i32 %17 to i64
%19 = mul i64 %18, 4
%20 = trunc i64 %19 to i32
%21 = call i64 @realloc(i32* %15, i32 %20)
%22 = inttoptr i64 %21 to i32*
%23 = load i32**, i32*** %7
store i32* %22, i32** %23
%24 = load i32**, i32*** %7
%25 = load i32*, i32** %24
%26 = icmp ne i32* %25, null
br i1 %26, label %30, label %27
27: ; preds = %5
%28 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%29 = call i32 @exit(i32 1)
unreachable
30: ; preds = %5
%31 = load i32, i32* %6
%32 = load i32**, i32*** %7
%33 = load i32*, i32** %32
%34 = load i32*, i32** %10
%35 = load i32, i32* %34
%36 = sub nsw i32 %35, 1
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i32, i32* %33, i64 %37
store i32 %31, i32* %38
%39 = load i32**, i32*** %9
%40 = load i32*, i32** %39
%41 = load i32*, i32** %10
%42 = load i32, i32* %41
%43 = sext i32 %42 to i64
%44 = mul i64 %43, 4
%45 = trunc i64 %44 to i32
%46 = call i64 @realloc(i32* %40, i32 %45)
%47 = inttoptr i64 %46 to i32*
%48 = load i32**, i32*** %9
store i32* %47, i32** %48
%49 = load i32**, i32*** %9
%50 = load i32*, i32** %49
%51 = icmp ne i32* %50, null
br i1 %51, label %55, label %52
52: ; preds = %30
%53 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%54 = call i32 @exit(i32 1)
unreachable
55: ; preds = %30
%56 = load i32, i32* %8
%57 = load i32**, i32*** %9
%58 = load i32*, i32** %57
%59 = load i32*, i32** %10
%60 = load i32, i32* %59
%61 = sub nsw i32 %60, 1
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds i32, i32* %58, i64 %62
store i32 %56, i32* %63
%64 = load i32*, i32** %10
%65 = load i32, i32* %64
ret i32 %65
}

LLVM IR (-O2):
@.str = [33 x i8] c"\0AError: realloc failed for %s.\0A\0A\00"
@.str.1 = [5 x i8] c"arr1\00"
@.str.2 = [5 x i8] c"arr2\00"
define i32 @enqueuePair(i32 %0, i32** nocapture %1, i32 %2, i32** nocapture %3, i32* nocapture %4) {
%6 = load i32, i32* %4
%7 = add nsw i32 %6, 1
store i32 %7, i32* %4
%8 = load i32*, i32** %1
%9 = shl i32 %7, 2
%10 = tail call i64 @realloc(i32* %8, i32 %9)
%11 = inttoptr i64 %10 to i32*
store i32* %11, i32** %1
%12 = icmp eq i64 %10, 0
br i1 %12, label %13, label %16
13: ; preds = %5
%14 = tail call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%15 = tail call i32 @exit(i32 1)
unreachable
16: ; preds = %5
%17 = load i32, i32* %4
%18 = add nsw i32 %17, -1
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i32, i32* %11, i64 %19
store i32 %0, i32* %20
%21 = load i32*, i32** %3
%22 = load i32, i32* %4
%23 = shl i32 %22, 2
%24 = tail call i64 @realloc(i32* %21, i32 %23)
%25 = inttoptr i64 %24 to i32*
store i32* %25, i32** %3
%26 = icmp eq i64 %24, 0
br i1 %26, label %27, label %30
27: ; preds = %16
%28 = tail call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%29 = tail call i32 @exit(i32 1)
unreachable
30: ; preds = %16
%31 = load i32, i32* %4
%32 = add nsw i32 %31, -1
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i32, i32* %25, i64 %33
store i32 %2, i32* %34
%35 = load i32, i32* %4
ret i32 %35
}