#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*/ _assert_true(int, char *, char *, int);
int *array_merge(int, int *, int **);
scalar_t__ arrays_match(int, int *, int *);
int *calloc(int, int);
void test_different_sizes_reversed(void) {
  int num_arrays = 11;
  int sizes[num_arrays];
  int *a[num_arrays];
  int expected[] = {10, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
  int *result;
  int i, j;
  for (i = num_arrays - 1; i >= 0; --i) {
    sizes[i] = i;
    a[i] = calloc(i, sizeof(int));
    for (j = 0; j < i; ++j) {
      a[i][j] = j;
    }
  }
  result = array_merge(num_arrays, sizes, a);
  _assert_true((int)(arrays_match(11, result, expected)),
               "arrays_match(11, result, expected)",
               "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
               "outputs/2022-01-22/02-19-57/repos/UMM-CSci-3401-F13/"
               "Lab_3_starter/refs/heads/master/array_merge/array_merge_test.c",
               115);
}


x86 assembly (clang, -O0):
<test_different_sizes_reversed>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0xb,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x10(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x70(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x18(%rbp)
mov    -0x4(%rbp),%eax
lea    0xf(,%rax,8),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x68(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x20(%rbp)
lea    -0x50(%rbp),%rdi
lea    0xe4f(%rip),%rsi
mov    $0x2c,%edx
call   1040 <memcpy@plt>
mov    -0x4(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x5c(%rbp)
cmpl   $0x0,-0x5c(%rbp)
jl     1242 <test_different_sizes_reversed+0xf2>
mov    -0x70(%rbp),%rax
mov    -0x5c(%rbp),%edx
movslq -0x5c(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x5c(%rbp),%edi
mov    $0x4,%esi
call   1030 <calloc@plt>
mov    %rax,%rdx
mov    -0x68(%rbp),%rax
movslq -0x5c(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
movl   $0x0,-0x60(%rbp)
mov    -0x60(%rbp),%eax
cmp    -0x5c(%rbp),%eax
jge    122f <test_different_sizes_reversed+0xdf>
mov    -0x68(%rbp),%rax
mov    -0x60(%rbp),%edx
movslq -0x5c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x60(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x60(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x60(%rbp)
jmp    11ff <test_different_sizes_reversed+0xaf>
jmp    1234 <test_different_sizes_reversed+0xe4>
mov    -0x5c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x5c(%rbp)
jmp    11c4 <test_different_sizes_reversed+0x74>
mov    -0x68(%rbp),%rdx
mov    -0x70(%rbp),%rsi
mov    -0x4(%rbp),%edi
call   1060 <array_merge@plt>
mov    %rax,-0x58(%rbp)
mov    -0x58(%rbp),%rsi
lea    -0x50(%rbp),%rdx
mov    $0xb,%edi
call   1070 <arrays_match@plt>
mov    %eax,%edi
lea    0xdbb(%rip),%rsi
lea    0xdd7(%rip),%rdx
mov    $0x73,%ecx
call   1050 <_assert_true@plt>
mov    -0x10(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_different_sizes_reversed>:
push   %r15
push   %r14
push   %rbx
sub    $0xc0,%rsp
movups 0xec9(%rip),%xmm0
movups %xmm0,0x1c(%rsp)
movaps 0xeb1(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xe95(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    $0xa,%ebx
xor    %r14d,%r14d
mov    $0xa,%r15d
jmp    1190 <test_different_sizes_reversed+0x50>
nop
add    $0x1,%r14
test   %rbx,%rbx
mov    %r15,%rbx
je     1232 <test_different_sizes_reversed+0xf2>
mov    %ebx,0x30(%rsp,%rbx,4)
mov    %ebx,%edi
mov    $0x4,%esi
call   1030 <calloc@plt>
mov    %rax,0x60(%rsp,%rbx,8)
sub    $0x1,%r15
jb     1232 <test_different_sizes_reversed+0xf2>
lea    -0x3(%r14),%rcx
cmp    $0x7,%rcx
jae    11c0 <test_different_sizes_reversed+0x80>
xor    %ecx,%ecx
jmp    120d <test_different_sizes_reversed+0xcd>
nopl   (%rax)
mov    %rbx,%rdx
and    $0xfffffffffffffff8,%rdx
xor    %ecx,%ecx
nopl   0x0(%rax)
mov    %ecx,(%rax,%rcx,4)
lea    0x1(%rcx),%esi
mov    %esi,0x4(%rax,%rcx,4)
lea    0x2(%rcx),%esi
mov    %esi,0x8(%rax,%rcx,4)
lea    0x3(%rcx),%esi
mov    %esi,0xc(%rax,%rcx,4)
lea    0x4(%rcx),%esi
mov    %esi,0x10(%rax,%rcx,4)
lea    0x5(%rcx),%esi
mov    %esi,0x14(%rax,%rcx,4)
lea    0x6(%rcx),%esi
mov    %esi,0x18(%rax,%rcx,4)
lea    0x7(%rcx),%esi
mov    %esi,0x1c(%rax,%rcx,4)
add    $0x8,%rcx
cmp    %rdx,%rcx
jne    11d0 <test_different_sizes_reversed+0x90>
test   $0x7,%bl
je     1180 <test_different_sizes_reversed+0x40>
mov    %ebx,%edx
and    $0x7,%edx
nopl   0x0(%rax,%rax,1)
mov    %ecx,(%rax,%rcx,4)
add    $0x1,%rcx
add    $0xffffffffffffffff,%rdx
jne    1220 <test_different_sizes_reversed+0xe0>
jmp    1180 <test_different_sizes_reversed+0x40>
lea    0x30(%rsp),%rsi
lea    0x60(%rsp),%rdx
mov    $0xb,%edi
call   1050 <array_merge@plt>
mov    %rsp,%rdx
mov    $0xb,%edi
mov    %rax,%rsi
call   1060 <arrays_match@plt>
lea    0xdcf(%rip),%rsi
lea    0xdeb(%rip),%rdx
mov    %eax,%edi
mov    $0x73,%ecx
call   1040 <_assert_true@plt>
add    $0xc0,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.test_different_sizes_reversed.expected = [11 x i32] [i32 10, i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9]
@.str = [35 x i8] c"arrays_match(11, result, expected)\00"
@.str.1 = [171 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/UMM-CSci-3401-F13/Lab_3_starter/refs/heads/master/array_merge/array_merge_test.c\00"
define void @test_different_sizes_reversed() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i64
%4 = alloca i64
%5 = alloca [11 x i32]
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
store i32 11, i32* %1
%9 = load i32, i32* %1
%10 = zext i32 %9 to i64
%11 = call i8* @llvm.stacksave()
store i8* %11, i8** %2
%12 = alloca i32, i64 %10
store i64 %10, i64* %3
%13 = load i32, i32* %1
%14 = zext i32 %13 to i64
%15 = alloca i32*, i64 %14
store i64 %14, i64* %4
%16 = bitcast [11 x i32]* %5 to i8*
%17 = load i32, i32* %1
%18 = sub nsw i32 %17, 1
store i32 %18, i32* %7
br label %19
19: ; preds = %49, %0
%20 = load i32, i32* %7
%21 = icmp sge i32 %20, 0
br i1 %21, label %22, label %52
22: ; preds = %19
%23 = load i32, i32* %7
%24 = load i32, i32* %7
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i32, i32* %12, i64 %25
store i32 %23, i32* %26
%27 = load i32, i32* %7
%28 = call i32* @calloc(i32 %27, i32 4)
%29 = load i32, i32* %7
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i32*, i32** %15, i64 %30
store i32* %28, i32** %31
store i32 0, i32* %8
br label %32
32: ; preds = %45, %22
%33 = load i32, i32* %8
%34 = load i32, i32* %7
%35 = icmp slt i32 %33, %34
br i1 %35, label %36, label %48
36: ; preds = %32
%37 = load i32, i32* %8
%38 = load i32, i32* %7
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i32*, i32** %15, i64 %39
%41 = load i32*, i32** %40
%42 = load i32, i32* %8
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i32, i32* %41, i64 %43
store i32 %37, i32* %44
br label %45
45: ; preds = %36
%46 = load i32, i32* %8
%47 = add nsw i32 %46, 1
store i32 %47, i32* %8
br label %32
48: ; preds = %32
br label %49
49: ; preds = %48
%50 = load i32, i32* %7
%51 = add nsw i32 %50, -1
store i32 %51, i32* %7
br label %19
52: ; preds = %19
%53 = load i32, i32* %1
%54 = call i32* @array_merge(i32 %53, i32* %12, i32** %15)
store i32* %54, i32** %6
%55 = load i32*, i32** %6
%56 = getelementptr inbounds [11 x i32], [11 x i32]* %5, i64 0, i64 0
%57 = call i64 @arrays_match(i32 11, i32* %55, i32* %56)
%58 = trunc i64 %57 to i32
%59 = call i32 @_assert_true(i32 %58, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([171 x i8], [171 x i8]* @.str.1, i64 0, i64 0), i32 115)
%60 = load i8*, i8** %2
ret void
}

LLVM IR (-O2):
@__const.test_different_sizes_reversed.expected = [11 x i32] [i32 10, i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9]
@.str = [35 x i8] c"arrays_match(11, result, expected)\00"
@.str.1 = [171 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/UMM-CSci-3401-F13/Lab_3_starter/refs/heads/master/array_merge/array_merge_test.c\00"
define void @test_different_sizes_reversed() {
%1 = alloca [11 x i32]
%2 = alloca [11 x i32]
%3 = alloca [11 x i32*]
%4 = bitcast [11 x i32]* %1 to i8*
br label %5
5: ; preds = %0, %59
%6 = phi i64 [ 0, %0 ], [ %61, %59 ]
%7 = phi i64 [ 10, %0 ], [ %60, %59 ]
%8 = getelementptr inbounds [11 x i32], [11 x i32]* %2, i64 0, i64 %7
%9 = trunc i64 %7 to i32
store i32 %9, i32* %8
%10 = tail call i32* @calloc(i32 %9, i32 4)
%11 = getelementptr inbounds [11 x i32*], [11 x i32*]* %3, i64 0, i64 %7
store i32* %10, i32** %11
%12 = icmp eq i64 %7, 0
br i1 %12, label %62, label %13
13: ; preds = %5
%14 = and i64 %7, 7
%15 = add i64 %6, -3
%16 = icmp ult i64 %15, 7
br i1 %16, label %48, label %17
17: ; preds = %13
%18 = and i64 %7, -8
br label %19
19: ; preds = %19, %17
%20 = phi i64 [ 0, %17 ], [ %45, %19 ]
%21 = phi i64 [ 0, %17 ], [ %46, %19 ]
%22 = getelementptr inbounds i32, i32* %10, i64 %20
%23 = trunc i64 %20 to i32
store i32 %23, i32* %22
%24 = or i64 %20, 1
%25 = getelementptr inbounds i32, i32* %10, i64 %24
%26 = trunc i64 %24 to i32
store i32 %26, i32* %25
%27 = or i64 %20, 2
%28 = getelementptr inbounds i32, i32* %10, i64 %27
%29 = trunc i64 %27 to i32
store i32 %29, i32* %28
%30 = or i64 %20, 3
%31 = getelementptr inbounds i32, i32* %10, i64 %30
%32 = trunc i64 %30 to i32
store i32 %32, i32* %31
%33 = or i64 %20, 4
%34 = getelementptr inbounds i32, i32* %10, i64 %33
%35 = trunc i64 %33 to i32
store i32 %35, i32* %34
%36 = or i64 %20, 5
%37 = getelementptr inbounds i32, i32* %10, i64 %36
%38 = trunc i64 %36 to i32
store i32 %38, i32* %37
%39 = or i64 %20, 6
%40 = getelementptr inbounds i32, i32* %10, i64 %39
%41 = trunc i64 %39 to i32
store i32 %41, i32* %40
%42 = or i64 %20, 7
%43 = getelementptr inbounds i32, i32* %10, i64 %42
%44 = trunc i64 %42 to i32
store i32 %44, i32* %43
%45 = add nuw nsw i64 %20, 8
%46 = add i64 %21, 8
%47 = icmp eq i64 %46, %18
br i1 %47, label %48, label %19
48: ; preds = %19, %13
%49 = phi i64 [ 0, %13 ], [ %45, %19 ]
%50 = icmp eq i64 %14, 0
br i1 %50, label %59, label %51
51: ; preds = %48, %51
%52 = phi i64 [ %56, %51 ], [ %49, %48 ]
%53 = phi i64 [ %57, %51 ], [ 0, %48 ]
%54 = getelementptr inbounds i32, i32* %10, i64 %52
%55 = trunc i64 %52 to i32
store i32 %55, i32* %54
%56 = add nuw nsw i64 %52, 1
%57 = add i64 %53, 1
%58 = icmp eq i64 %57, %14
br i1 %58, label %59, label %51
59: ; preds = %51, %48
%60 = add nsw i64 %7, -1
%61 = add i64 %6, 1
br i1 %12, label %62, label %5
62: ; preds = %5, %59
%63 = getelementptr inbounds [11 x i32*], [11 x i32*]* %3, i64 0, i64 0
%64 = getelementptr inbounds [11 x i32], [11 x i32]* %2, i64 0, i64 0
%65 = call i32* @array_merge(i32 11, i32* %64, i32** %63)
%66 = getelementptr inbounds [11 x i32], [11 x i32]* %1, i64 0, i64 0
%67 = call i64 @arrays_match(i32 11, i32* %65, i32* %66)
%68 = trunc i64 %67 to i32
%69 = call i32 @_assert_true(i32 %68, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([171 x i8], [171 x i8]* @.str.1, i64 0, i64 0), i32 115)
ret void
}