#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*/ free(int *);
scalar_t__ malloc(int);
scalar_t__ mumps_io_alloc_pointers(int *, int *);
int /*<<< orphan*/ mumps_io_set_last_file(int *, int *);
void mumps_ooc_alloc_pointers_c(int *nb_file_type, int *dim, int *ierr) {
  int i = 0;
  int nb_file_type_loc, *dim_loc;
  nb_file_type_loc = (int)*nb_file_type;
  dim_loc = (int *)malloc(*nb_file_type * sizeof(int));
  for (i = 0; i < nb_file_type_loc; i++) {
    dim_loc[i] = (int)dim[i];
  }
  *ierr = (int)mumps_io_alloc_pointers(&nb_file_type_loc, dim_loc);
  for (i = 0; i < nb_file_type_loc; i++) {
    mumps_io_set_last_file(dim_loc + i, &i);
  }
  free(dim_loc);
  return;
}


x86 assembly (clang, -O0):
<mumps_ooc_alloc_pointers_c>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
movslq (%rax),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    11b1 <mumps_ooc_alloc_pointers_c+0x71>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
mov    -0x28(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1181 <mumps_ooc_alloc_pointers_c+0x41>
mov    -0x28(%rbp),%rsi
lea    -0x20(%rbp),%rdi
call   1040 <mumps_io_alloc_pointers@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    11ff <mumps_ooc_alloc_pointers_c+0xbf>
mov    -0x28(%rbp),%rdi
movslq -0x1c(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdi
lea    -0x1c(%rbp),%rsi
call   1060 <mumps_io_set_last_file@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11cd <mumps_ooc_alloc_pointers_c+0x8d>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mumps_ooc_alloc_pointers_c>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%r15
mov    (%rdi),%r12d
mov    %r12d,0x4(%rsp)
lea    0x0(,%r12,4),%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
movl   $0x0,(%rsp)
test   %r12d,%r12d
jle    1198 <mumps_ooc_alloc_pointers_c+0x58>
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
cltq
mov    (%r15,%rax,4),%ecx
mov    %ecx,(%rbx,%rax,4)
mov    (%rsp),%eax
add    $0x1,%eax
mov    %eax,(%rsp)
cmp    0x4(%rsp),%eax
jl     1180 <mumps_ooc_alloc_pointers_c+0x40>
lea    0x4(%rsp),%rdi
mov    %rbx,%rsi
call   1040 <mumps_io_alloc_pointers@plt>
mov    %eax,(%r14)
movl   $0x0,(%rsp)
cmpl   $0x0,0x4(%rsp)
jle    11dd <mumps_ooc_alloc_pointers_c+0x9d>
xor    %eax,%eax
mov    %rsp,%r14
nopl   0x0(%rax,%rax,1)
cltq
lea    (%rbx,%rax,4),%rdi
mov    %r14,%rsi
call   1060 <mumps_io_set_last_file@plt>
mov    (%rsp),%eax
add    $0x1,%eax
mov    %eax,(%rsp)
cmp    0x4(%rsp),%eax
jl     11c0 <mumps_ooc_alloc_pointers_c+0x80>
mov    %rbx,%rdi
call   1030 <free@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @mumps_ooc_alloc_pointers_c(i32* %0, i32* %1, i32* %2) {
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32*
store i32* %0, i32** %4
store i32* %1, i32** %5
store i32* %2, i32** %6
store i32 0, i32* %7
%10 = load i32*, i32** %4
%11 = load i32, i32* %10
store i32 %11, i32* %8
%12 = load i32*, i32** %4
%13 = load i32, i32* %12
%14 = sext i32 %13 to i64
%15 = mul i64 %14, 4
%16 = trunc i64 %15 to i32
%17 = call i64 @malloc(i32 %16)
%18 = inttoptr i64 %17 to i32*
store i32* %18, i32** %9
store i32 0, i32* %7
br label %19
19: ; preds = %33, %3
%20 = load i32, i32* %7
%21 = load i32, i32* %8
%22 = icmp slt i32 %20, %21
br i1 %22, label %23, label %36
23: ; preds = %19
%24 = load i32*, i32** %5
%25 = load i32, i32* %7
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i32, i32* %24, i64 %26
%28 = load i32, i32* %27
%29 = load i32*, i32** %9
%30 = load i32, i32* %7
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i32, i32* %29, i64 %31
store i32 %28, i32* %32
br label %33
33: ; preds = %23
%34 = load i32, i32* %7
%35 = add nsw i32 %34, 1
store i32 %35, i32* %7
br label %19
36: ; preds = %19
%37 = load i32*, i32** %9
%38 = call i64 @mumps_io_alloc_pointers(i32* %8, i32* %37)
%39 = trunc i64 %38 to i32
%40 = load i32*, i32** %6
store i32 %39, i32* %40
store i32 0, i32* %7
br label %41
41: ; preds = %51, %36
%42 = load i32, i32* %7
%43 = load i32, i32* %8
%44 = icmp slt i32 %42, %43
br i1 %44, label %45, label %54
45: ; preds = %41
%46 = load i32*, i32** %9
%47 = load i32, i32* %7
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds i32, i32* %46, i64 %48
%50 = call i32 @mumps_io_set_last_file(i32* %49, i32* %7)
br label %51
51: ; preds = %45
%52 = load i32, i32* %7
%53 = add nsw i32 %52, 1
store i32 %53, i32* %7
br label %41
54: ; preds = %41
%55 = load i32*, i32** %9
%56 = call i32 @free(i32* %55)
ret void
}

LLVM IR (-O2):
define void @mumps_ooc_alloc_pointers_c(i32* nocapture %0, i32* nocapture %1, i32* nocapture writeonly %2) {
%4 = alloca i32
%5 = alloca i32
%6 = bitcast i32* %4 to i8*
%7 = bitcast i32* %5 to i8*
%8 = load i32, i32* %0
store i32 %8, i32* %5
%9 = shl i32 %8, 2
%10 = tail call i64 @malloc(i32 %9)
%11 = inttoptr i64 %10 to i32*
store i32 0, i32* %4
%12 = icmp sgt i32 %8, 0
br i1 %12, label %13, label %23
13: ; preds = %3, %13
%14 = phi i32 [ %20, %13 ], [ 0, %3 ]
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i32, i32* %1, i64 %15
%17 = load i32, i32* %16
%18 = getelementptr inbounds i32, i32* %11, i64 %15
store i32 %17, i32* %18
%19 = load i32, i32* %4
%20 = add nsw i32 %19, 1
store i32 %20, i32* %4
%21 = load i32, i32* %5
%22 = icmp slt i32 %20, %21
br i1 %22, label %13, label %23
23: ; preds = %13, %3
%24 = call i64 @mumps_io_alloc_pointers(i32* %5, i32* %11)
%25 = trunc i64 %24 to i32
store i32 %25, i32* %2
store i32 0, i32* %4
%26 = load i32, i32* %5
%27 = icmp sgt i32 %26, 0
br i1 %27, label %28, label %37
28: ; preds = %23, %28
%29 = phi i32 [ %34, %28 ], [ 0, %23 ]
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i32, i32* %11, i64 %30
%32 = call i32 @mumps_io_set_last_file(i32* %31, i32* %4)
%33 = load i32, i32* %4
%34 = add nsw i32 %33, 1
store i32 %34, i32* %4
%35 = load i32, i32* %5
%36 = icmp slt i32 %34, %35
br i1 %36, label %28, label %37
37: ; preds = %28, %23
%38 = call i32 @free(i32* %11)
ret void
}