#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 */
void *_talloc_realloc(void const *, void *, size_t, char *);
int /*<<< orphan*/ talloc_set_name_const(void *, char const *);
void *talloc_realloc_array(const void *ctx, void *ptr, size_t el_size,
                           unsigned count, const char *name) {
  if (count >= 0x10000000 / el_size) {
    return NULL;
  }
  ptr = _talloc_realloc(
      ctx, ptr, el_size * count,
      "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
      "2022-01-22/02-19-57/repos/ZHAW-INES/rioxo-uClinux-dist/refs/heads/"
      "master/openswan/testing/kunit/libkern/talloc.c"
      ":"
      "984");
  if (ptr) {
    talloc_set_name_const(ptr, name);
  }
  return ptr;
}


x86 assembly (clang, -O0):
<talloc_realloc_array>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
mov    %r8,-0x30(%rbp)
mov    -0x24(%rbp),%eax
mov    %rax,-0x38(%rbp)
mov    $0x10000000,%eax
xor    %ecx,%ecx
mov    %ecx,%edx
divq   -0x20(%rbp)
mov    %rax,%rcx
mov    -0x38(%rbp),%rax
cmp    %rcx,%rax
jb     116c <talloc_realloc_array+0x4c>
movq   $0x0,-0x8(%rbp)
jmp    11af <talloc_realloc_array+0x8f>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x24(%rbp),%eax
imul   %rax,%rdx
lea    0xe7a(%rip),%rcx
call   1030 <_talloc_realloc@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11a7 <talloc_realloc_array+0x87>
mov    -0x18(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1040 <talloc_set_name_const@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<talloc_realloc_array>:
push   %r14
push   %rbx
push   %rax
mov    %r8,%r14
mov    %rdx,%r8
mov    %ecx,%ebx
cmp    $0x10000000,%rdx
ja     1146 <talloc_realloc_array+0x26>
mov    $0x10000000,%eax
xor    %edx,%edx
div    %r8d
cmp    %rbx,%rax
ja     114d <talloc_realloc_array+0x2d>
jmp    1175 <talloc_realloc_array+0x55>
xor    %eax,%eax
cmp    %rbx,%rax
jbe    1175 <talloc_realloc_array+0x55>
imul   %r8,%rbx
lea    0xea8(%rip),%rcx
mov    %rbx,%rdx
call   1030 <_talloc_realloc@plt>
test   %rax,%rax
je     1175 <talloc_realloc_array+0x55>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r14,%rsi
call   1040 <talloc_set_name_const@plt>
jmp    1177 <talloc_realloc_array+0x57>
xor    %ebx,%ebx
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [181 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/ZHAW-INES/rioxo-uClinux-dist/refs/heads/master/openswan/testing/kunit/libkern/talloc.c:984\00"
define i8* @talloc_realloc_array(i8* %0, i8* %1, i64 %2, i32 %3, i8* %4) {
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i64
%10 = alloca i32
%11 = alloca i8*
store i8* %0, i8** %7
store i8* %1, i8** %8
store i64 %2, i64* %9
store i32 %3, i32* %10
store i8* %4, i8** %11
%12 = load i32, i32* %10
%13 = zext i32 %12 to i64
%14 = load i64, i64* %9
%15 = udiv i64 268435456, %14
%16 = icmp uge i64 %13, %15
br i1 %16, label %17, label %18
17: ; preds = %5
store i8* null, i8** %6
br label %34
18: ; preds = %5
%19 = load i8*, i8** %7
%20 = load i8*, i8** %8
%21 = load i64, i64* %9
%22 = load i32, i32* %10
%23 = zext i32 %22 to i64
%24 = mul i64 %21, %23
%25 = call i8* @_talloc_realloc(i8* %19, i8* %20, i64 %24, i8* getelementptr inbounds ([181 x i8], [181 x i8]* @.str, i64 0, i64 0))
store i8* %25, i8** %8
%26 = load i8*, i8** %8
%27 = icmp ne i8* %26, null
br i1 %27, label %28, label %32
28: ; preds = %18
%29 = load i8*, i8** %8
%30 = load i8*, i8** %11
%31 = call i32 @talloc_set_name_const(i8* %29, i8* %30)
br label %32
32: ; preds = %28, %18
%33 = load i8*, i8** %8
store i8* %33, i8** %6
br label %34
34: ; preds = %32, %17
%35 = load i8*, i8** %6
ret i8* %35
}

LLVM IR (-O2):
@.str = [181 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/ZHAW-INES/rioxo-uClinux-dist/refs/heads/master/openswan/testing/kunit/libkern/talloc.c:984\00"
define i8* @talloc_realloc_array(i8* %0, i8* %1, i64 %2, i32 %3, i8* %4) {
%6 = zext i32 %3 to i64
%7 = udiv i64 268435456, %2
%8 = icmp ugt i64 %7, %6
br i1 %8, label %9, label %15
9: ; preds = %5
%10 = mul i64 %6, %2
%11 = tail call i8* @_talloc_realloc(i8* %0, i8* %1, i64 %10, i8* getelementptr inbounds ([181 x i8], [181 x i8]* @.str, i64 0, i64 0))
%12 = icmp eq i8* %11, null
br i1 %12, label %15, label %13
13: ; preds = %9
%14 = tail call i32 @talloc_set_name_const(i8* %11, i8* %4)
br label %15
15: ; preds = %9, %13, %5
%16 = phi i8* [ null, %5 ], [ %11, %13 ], [ null, %9 ]
ret i8* %16
}