#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_equals(int, int, char *);
int **decomp2d(int, int, int, int);
int /*<<< orphan*/ free_decomp2d(int **);
void test_decomp2d() {
  int width = 99;
  int height = 99;
  int x = 2;
  int y = 5;
  int **dims = decomp2d(width, height, x, y);
  assert_equals(50, dims[0][0], "test_decomp2d_00");
  assert_equals(49, dims[0][1], "test_decomp2d_01");
  assert_equals(20, dims[1][0], "test_decomp2d_10");
  assert_equals(20, dims[1][1], "test_decomp2d_11");
  assert_equals(20, dims[1][2], "test_decomp2d_12");
  assert_equals(20, dims[1][3], "test_decomp2d_13");
  assert_equals(19, dims[1][4], "test_decomp2d_14");
  free_decomp2d(dims);
}


x86 assembly (clang, -O0):
<test_decomp2d>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x63,-0x4(%rbp)
movl   $0x63,-0x8(%rbp)
movl   $0x2,-0xc(%rbp)
movl   $0x5,-0x10(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
call   1050 <decomp2d@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    (%rax),%esi
mov    $0x32,%edi
lea    0xe82(%rip),%rdx
call   1040 <assert_equals@plt>
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    0x4(%rax),%esi
mov    $0x31,%edi
lea    0xe78(%rip),%rdx
call   1040 <assert_equals@plt>
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rax
mov    (%rax),%esi
mov    $0x14,%edi
lea    0xe6e(%rip),%rdx
call   1040 <assert_equals@plt>
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rax
mov    0x4(%rax),%esi
mov    $0x14,%edi
lea    0xe63(%rip),%rdx
call   1040 <assert_equals@plt>
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rax
mov    0x8(%rax),%esi
mov    $0x14,%edi
lea    0xe58(%rip),%rdx
call   1040 <assert_equals@plt>
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rax
mov    0xc(%rax),%esi
mov    $0x14,%edi
lea    0xe4d(%rip),%rdx
call   1040 <assert_equals@plt>
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rax
mov    0x10(%rax),%esi
mov    $0x13,%edi
lea    0xe42(%rip),%rdx
call   1040 <assert_equals@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free_decomp2d@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_decomp2d>:
push   %rbx
mov    $0x63,%edi
mov    $0x63,%esi
mov    $0x2,%edx
mov    $0x5,%ecx
call   1050 <decomp2d@plt>
mov    %rax,%rbx
mov    (%rax),%rax
mov    (%rax),%esi
lea    0xea7(%rip),%rdx
mov    $0x32,%edi
call   1040 <assert_equals@plt>
mov    (%rbx),%rax
mov    0x4(%rax),%esi
lea    0xea1(%rip),%rdx
mov    $0x31,%edi
call   1040 <assert_equals@plt>
mov    0x8(%rbx),%rax
mov    (%rax),%esi
lea    0xe9b(%rip),%rdx
mov    $0x14,%edi
call   1040 <assert_equals@plt>
mov    0x8(%rbx),%rax
mov    0x4(%rax),%esi
lea    0xe94(%rip),%rdx
mov    $0x14,%edi
call   1040 <assert_equals@plt>
mov    0x8(%rbx),%rax
mov    0x8(%rax),%esi
lea    0xe8d(%rip),%rdx
mov    $0x14,%edi
call   1040 <assert_equals@plt>
mov    0x8(%rbx),%rax
mov    0xc(%rax),%esi
lea    0xe86(%rip),%rdx
mov    $0x14,%edi
call   1040 <assert_equals@plt>
mov    0x8(%rbx),%rax
mov    0x10(%rax),%esi
lea    0xe7f(%rip),%rdx
mov    $0x13,%edi
call   1040 <assert_equals@plt>
mov    %rbx,%rdi
pop    %rbx
jmp    1030 <free_decomp2d@plt>

LLVM IR (-O0):
@.str = [17 x i8] c"test_decomp2d_00\00"
@.str.1 = [17 x i8] c"test_decomp2d_01\00"
@.str.2 = [17 x i8] c"test_decomp2d_10\00"
@.str.3 = [17 x i8] c"test_decomp2d_11\00"
@.str.4 = [17 x i8] c"test_decomp2d_12\00"
@.str.5 = [17 x i8] c"test_decomp2d_13\00"
@.str.6 = [17 x i8] c"test_decomp2d_14\00"
define void @test_decomp2d() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32**
store i32 99, i32* %1
store i32 99, i32* %2
store i32 2, i32* %3
store i32 5, i32* %4
%6 = load i32, i32* %1
%7 = load i32, i32* %2
%8 = load i32, i32* %3
%9 = load i32, i32* %4
%10 = call i32** @decomp2d(i32 %6, i32 %7, i32 %8, i32 %9)
store i32** %10, i32*** %5
%11 = load i32**, i32*** %5
%12 = getelementptr inbounds i32*, i32** %11, i64 0
%13 = load i32*, i32** %12
%14 = getelementptr inbounds i32, i32* %13, i64 0
%15 = load i32, i32* %14
%16 = call i32 @assert_equals(i32 50, i32 %15, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%17 = load i32**, i32*** %5
%18 = getelementptr inbounds i32*, i32** %17, i64 0
%19 = load i32*, i32** %18
%20 = getelementptr inbounds i32, i32* %19, i64 1
%21 = load i32, i32* %20
%22 = call i32 @assert_equals(i32 49, i32 %21, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%23 = load i32**, i32*** %5
%24 = getelementptr inbounds i32*, i32** %23, i64 1
%25 = load i32*, i32** %24
%26 = getelementptr inbounds i32, i32* %25, i64 0
%27 = load i32, i32* %26
%28 = call i32 @assert_equals(i32 20, i32 %27, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
%29 = load i32**, i32*** %5
%30 = getelementptr inbounds i32*, i32** %29, i64 1
%31 = load i32*, i32** %30
%32 = getelementptr inbounds i32, i32* %31, i64 1
%33 = load i32, i32* %32
%34 = call i32 @assert_equals(i32 20, i32 %33, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
%35 = load i32**, i32*** %5
%36 = getelementptr inbounds i32*, i32** %35, i64 1
%37 = load i32*, i32** %36
%38 = getelementptr inbounds i32, i32* %37, i64 2
%39 = load i32, i32* %38
%40 = call i32 @assert_equals(i32 20, i32 %39, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0))
%41 = load i32**, i32*** %5
%42 = getelementptr inbounds i32*, i32** %41, i64 1
%43 = load i32*, i32** %42
%44 = getelementptr inbounds i32, i32* %43, i64 3
%45 = load i32, i32* %44
%46 = call i32 @assert_equals(i32 20, i32 %45, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0))
%47 = load i32**, i32*** %5
%48 = getelementptr inbounds i32*, i32** %47, i64 1
%49 = load i32*, i32** %48
%50 = getelementptr inbounds i32, i32* %49, i64 4
%51 = load i32, i32* %50
%52 = call i32 @assert_equals(i32 19, i32 %51, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0))
%53 = load i32**, i32*** %5
%54 = call i32 @free_decomp2d(i32** %53)
ret void
}

LLVM IR (-O2):
@.str = [17 x i8] c"test_decomp2d_00\00"
@.str.1 = [17 x i8] c"test_decomp2d_01\00"
@.str.2 = [17 x i8] c"test_decomp2d_10\00"
@.str.3 = [17 x i8] c"test_decomp2d_11\00"
@.str.4 = [17 x i8] c"test_decomp2d_12\00"
@.str.5 = [17 x i8] c"test_decomp2d_13\00"
@.str.6 = [17 x i8] c"test_decomp2d_14\00"
define void @test_decomp2d() {
%1 = tail call i32** @decomp2d(i32 99, i32 99, i32 2, i32 5)
%2 = load i32*, i32** %1
%3 = load i32, i32* %2
%4 = tail call i32 @assert_equals(i32 50, i32 %3, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%5 = load i32*, i32** %1
%6 = getelementptr inbounds i32, i32* %5, i64 1
%7 = load i32, i32* %6
%8 = tail call i32 @assert_equals(i32 49, i32 %7, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%9 = getelementptr inbounds i32*, i32** %1, i64 1
%10 = load i32*, i32** %9
%11 = load i32, i32* %10
%12 = tail call i32 @assert_equals(i32 20, i32 %11, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
%13 = load i32*, i32** %9
%14 = getelementptr inbounds i32, i32* %13, i64 1
%15 = load i32, i32* %14
%16 = tail call i32 @assert_equals(i32 20, i32 %15, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
%17 = load i32*, i32** %9
%18 = getelementptr inbounds i32, i32* %17, i64 2
%19 = load i32, i32* %18
%20 = tail call i32 @assert_equals(i32 20, i32 %19, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0))
%21 = load i32*, i32** %9
%22 = getelementptr inbounds i32, i32* %21, i64 3
%23 = load i32, i32* %22
%24 = tail call i32 @assert_equals(i32 20, i32 %23, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0))
%25 = load i32*, i32** %9
%26 = getelementptr inbounds i32, i32* %25, i64 4
%27 = load i32, i32* %26
%28 = tail call i32 @assert_equals(i32 19, i32 %27, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0))
%29 = tail call i32 @free_decomp2d(i32** %1)
ret void
}