#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 */
unsigned int *alloc_uivector(unsigned int);
scalar_t__ malloc(size_t);
unsigned int **alloc_uimatrix(unsigned int n2h, unsigned int nh) {
  unsigned int **v =
      (unsigned int **)malloc((size_t)((n2h + 1) * (sizeof(unsigned int *))));
  for (unsigned int i = 1; i <= n2h; i++) {
    v[i] = alloc_uivector(nh);
  }
  return v;
}


x86 assembly (clang, -O0):
<alloc_uimatrix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,%eax
mov    %eax,%edi
shl    $0x3,%rdi
call   1040 <malloc@plt>
mov    %rax,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
ja     117c <alloc_uimatrix+0x5c>
mov    -0x8(%rbp),%edi
call   1030 <alloc_uivector@plt>
mov    %rax,%rdx
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
mov    %rdx,(%rax,%rcx,8)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    114c <alloc_uimatrix+0x2c>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<alloc_uimatrix>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%r14d
mov    %edi,%r15d
lea    0x1(%r15),%edi
shl    $0x3,%rdi
call   1040 <malloc@plt>
mov    %rax,%rbp
test   %r15d,%r15d
je     1167 <alloc_uimatrix+0x47>
mov    $0x1,%ebx
nopw   0x0(%rax,%rax,1)
mov    %r14d,%edi
call   1030 <alloc_uivector@plt>
mov    %ebx,%ecx
mov    %rax,0x0(%rbp,%rcx,8)
add    $0x1,%ebx
cmp    %r15d,%ebx
jbe    1150 <alloc_uimatrix+0x30>
mov    %rbp,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32** @alloc_uimatrix(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32**
%6 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%7 = load i32, i32* %3
%8 = add i32 %7, 1
%9 = zext i32 %8 to i64
%10 = mul i64 %9, 8
%11 = call i64 @malloc(i64 %10)
%12 = inttoptr i64 %11 to i32**
store i32** %12, i32*** %5
store i32 1, i32* %6
br label %13
13: ; preds = %24, %2
%14 = load i32, i32* %6
%15 = load i32, i32* %3
%16 = icmp ule i32 %14, %15
br i1 %16, label %17, label %27
17: ; preds = %13
%18 = load i32, i32* %4
%19 = call i32* @alloc_uivector(i32 %18)
%20 = load i32**, i32*** %5
%21 = load i32, i32* %6
%22 = zext i32 %21 to i64
%23 = getelementptr inbounds i32*, i32** %20, i64 %22
store i32* %19, i32** %23
br label %24
24: ; preds = %17
%25 = load i32, i32* %6
%26 = add i32 %25, 1
store i32 %26, i32* %6
br label %13
27: ; preds = %13
%28 = load i32**, i32*** %5
ret i32** %28
}

LLVM IR (-O2):
define i32** @alloc_uimatrix(i32 %0, i32 %1) {
%3 = add i32 %0, 1
%4 = zext i32 %3 to i64
%5 = shl nuw nsw i64 %4, 3
%6 = tail call i64 @malloc(i64 %5)
%7 = inttoptr i64 %6 to i32**
%8 = icmp eq i32 %0, 0
br i1 %8, label %9, label %10
9: ; preds = %10, %2
ret i32** %7
10: ; preds = %2, %10
%11 = phi i32 [ %15, %10 ], [ 1, %2 ]
%12 = tail call i32* @alloc_uivector(i32 %1)
%13 = zext i32 %11 to i64
%14 = getelementptr inbounds i32*, i32** %7, i64 %13
store i32* %12, i32** %14
%15 = add i32 %11, 1
%16 = icmp ugt i32 %15, %0
br i1 %16, label %9, label %10
}