#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 */
char *ShareReallocM1c(char *, int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ printf(char *);
scalar_t__ realloc(char **, int);
char **ShareReallocM2c(char **s, int size1, int size2) {
  int i;
  if ((s = (char **)realloc(s, size1 * sizeof(char *))) == NULL) {
    printf("char ** realloc error!");
    exit(1);
  }
  if (size2 > 0) {
    for (i = 0; i < size1; i++)
      s[i] = ShareReallocM1c(s[i], size2);
  }
  return s;
}


x86 assembly (clang, -O0):
<ShareReallocM2c>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
movslq -0xc(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%esi
call   1040 <realloc@plt>
mov    %rax,-0x8(%rbp)
cmp    $0x0,%rax
jne    1189 <ShareReallocM2c+0x49>
lea    0xe86(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
cmpl   $0x0,-0x10(%rbp)
jle    11dc <ShareReallocM2c+0x9c>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11d7 <ShareReallocM2c+0x97>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x10(%rbp),%esi
call   1060 <ShareReallocM1c@plt>
mov    %rax,%rdx
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    119a <ShareReallocM2c+0x5a>
jmp    11dc <ShareReallocM2c+0x9c>
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ShareReallocM2c>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%r15d
mov    %esi,%r14d
lea    0x0(,%r14,8),%esi
call   1040 <realloc@plt>
test   %rax,%rax
je     11a7 <ShareReallocM2c+0x67>
mov    %rax,%rbx
test   %r15d,%r15d
jle    1199 <ShareReallocM2c+0x59>
test   %r14d,%r14d
jle    1199 <ShareReallocM2c+0x59>
mov    %r14d,%r14d
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    (%rbx,%rbp,8),%rdi
mov    %r15d,%esi
call   1060 <ShareReallocM1c@plt>
mov    %rax,(%rbx,%rbp,8)
add    $0x1,%rbp
cmp    %rbp,%r14
jne    1180 <ShareReallocM2c+0x40>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe52(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@.str = [23 x i8] c"char ** realloc error!\00"
define i8** @ShareReallocM2c(i8** %0, i32 %1, i32 %2) {
%4 = alloca i8**
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i8** %0, i8*** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%8 = load i8**, i8*** %4
%9 = load i32, i32* %5
%10 = sext i32 %9 to i64
%11 = mul i64 %10, 8
%12 = trunc i64 %11 to i32
%13 = call i64 @realloc(i8** %8, i32 %12)
%14 = inttoptr i64 %13 to i8**
store i8** %14, i8*** %4
%15 = icmp eq i8** %14, null
br i1 %15, label %16, label %19
16: ; preds = %3
%17 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%18 = call i32 @exit(i32 1)
unreachable
19: ; preds = %3
%20 = load i32, i32* %6
%21 = icmp sgt i32 %20, 0
br i1 %21, label %22, label %43
22: ; preds = %19
store i32 0, i32* %7
br label %23
23: ; preds = %39, %22
%24 = load i32, i32* %7
%25 = load i32, i32* %5
%26 = icmp slt i32 %24, %25
br i1 %26, label %27, label %42
27: ; preds = %23
%28 = load i8**, i8*** %4
%29 = load i32, i32* %7
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8*, i8** %28, i64 %30
%32 = load i8*, i8** %31
%33 = load i32, i32* %6
%34 = call i8* @ShareReallocM1c(i8* %32, i32 %33)
%35 = load i8**, i8*** %4
%36 = load i32, i32* %7
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i8*, i8** %35, i64 %37
store i8* %34, i8** %38
br label %39
39: ; preds = %27
%40 = load i32, i32* %7
%41 = add nsw i32 %40, 1
store i32 %41, i32* %7
br label %23
42: ; preds = %23
br label %43
43: ; preds = %42, %19
%44 = load i8**, i8*** %4
ret i8** %44
}

LLVM IR (-O2):
@.str = [23 x i8] c"char ** realloc error!\00"
define i8** @ShareReallocM2c(i8** %0, i32 %1, i32 %2) {
%4 = shl i32 %1, 3
%5 = tail call i64 @realloc(i8** %0, i32 %4)
%6 = inttoptr i64 %5 to i8**
%7 = icmp eq i64 %5, 0
br i1 %7, label %8, label %11
8: ; preds = %3
%9 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%10 = tail call i32 @exit(i32 1)
unreachable
11: ; preds = %3
%12 = icmp sgt i32 %2, 0
%13 = icmp sgt i32 %1, 0
%14 = and i1 %12, %13
br i1 %14, label %15, label %24
15: ; preds = %11
%16 = zext i32 %1 to i64
br label %17
17: ; preds = %15, %17
%18 = phi i64 [ 0, %15 ], [ %22, %17 ]
%19 = getelementptr inbounds i8*, i8** %6, i64 %18
%20 = load i8*, i8** %19
%21 = tail call i8* @ShareReallocM1c(i8* %20, i32 %2)
store i8* %21, i8** %19
%22 = add nuw nsw i64 %18, 1
%23 = icmp eq i64 %22, %16
br i1 %23, label %24, label %17
24: ; preds = %17, %11
ret i8** %6
}