#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 */
scalar_t__ malloc(unsigned int);
scalar_t__ malloc_aligned(unsigned long, unsigned int);
int alloc_seismic_buffers(unsigned width, unsigned height, unsigned timesteps,
                          unsigned alignment, float **VEL, float **APF,
                          float **NPPF, float **pulsevector) {
  unsigned long size_matrice = (width * height) * sizeof(float);
  *APF = (float *)malloc_aligned(size_matrice, alignment);
  *VEL = (float *)malloc_aligned(size_matrice, alignment);
  *NPPF = (float *)malloc_aligned(size_matrice, alignment);
  *pulsevector = (float *)malloc((timesteps + 1) * sizeof(float));
  return (*APF == NULL || *VEL == NULL || *NPPF == NULL ||
          *pulsevector == NULL) *
         -1;
}


x86 assembly (clang, -O0):
<alloc_seismic_buffers>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%rax
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    %r8,-0x18(%rbp)
mov    %r9,-0x20(%rbp)
mov    -0x4(%rbp),%eax
imul   -0x8(%rbp),%eax
mov    %eax,%eax
shl    $0x2,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%esi
call   1030 <malloc_aligned@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%esi
call   1030 <malloc_aligned@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%esi
call   1030 <malloc_aligned@plt>
mov    %rax,%rcx
mov    0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,%eax
shl    $0x2,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,%rcx
mov    0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x20(%rbp),%rcx
mov    $0x1,%al
cmpq   $0x0,(%rcx)
mov    %al,-0x29(%rbp)
je     11fb <alloc_seismic_buffers+0xdb>
mov    -0x18(%rbp),%rcx
mov    $0x1,%al
cmpq   $0x0,(%rcx)
mov    %al,-0x29(%rbp)
je     11fb <alloc_seismic_buffers+0xdb>
mov    0x10(%rbp),%rcx
mov    $0x1,%al
cmpq   $0x0,(%rcx)
mov    %al,-0x29(%rbp)
je     11fb <alloc_seismic_buffers+0xdb>
mov    0x18(%rbp),%rax
cmpq   $0x0,(%rax)
sete   %al
mov    %al,-0x29(%rbp)
mov    -0x29(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
imul   $0xffffffff,%eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<alloc_seismic_buffers>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r9,%r12
mov    %r8,%r14
mov    %ecx,%ebp
mov    %edx,%r15d
mov    %edi,%ebx
mov    0x40(%rsp),%r13
imul   %esi,%ebx
shl    $0x2,%rbx
mov    %rbx,%rdi
mov    %ecx,%esi
call   1030 <malloc_aligned@plt>
mov    %rax,(%r12)
mov    %rbx,%rdi
mov    %ebp,%esi
call   1030 <malloc_aligned@plt>
mov    %rax,(%r14)
mov    %rbx,%rdi
mov    %ebp,%esi
call   1030 <malloc_aligned@plt>
mov    %rax,0x0(%r13)
lea    0x4(,%r15,4),%edi
call   1040 <malloc@plt>
mov    %rax,%rcx
mov    0x48(%rsp),%rax
mov    %rcx,(%rax)
mov    $0xffffffff,%eax
cmpq   $0x0,(%r12)
je     11a4 <alloc_seismic_buffers+0x84>
cmpq   $0x0,(%r14)
je     11a4 <alloc_seismic_buffers+0x84>
cmpq   $0x0,0x0(%r13)
je     11a4 <alloc_seismic_buffers+0x84>
cmp    $0x1,%rcx
sbb    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @alloc_seismic_buffers(i32 %0, i32 %1, i32 %2, i32 %3, float** %4, float** %5, float** %6, float** %7) {
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca float**
%14 = alloca float**
%15 = alloca float**
%16 = alloca float**
%17 = alloca i64
store i32 %0, i32* %9
store i32 %1, i32* %10
store i32 %2, i32* %11
store i32 %3, i32* %12
store float** %4, float*** %13
store float** %5, float*** %14
store float** %6, float*** %15
store float** %7, float*** %16
%18 = load i32, i32* %9
%19 = load i32, i32* %10
%20 = mul i32 %18, %19
%21 = zext i32 %20 to i64
%22 = mul i64 %21, 4
store i64 %22, i64* %17
%23 = load i64, i64* %17
%24 = load i32, i32* %12
%25 = call i64 @malloc_aligned(i64 %23, i32 %24)
%26 = inttoptr i64 %25 to float*
%27 = load float**, float*** %14
store float* %26, float** %27
%28 = load i64, i64* %17
%29 = load i32, i32* %12
%30 = call i64 @malloc_aligned(i64 %28, i32 %29)
%31 = inttoptr i64 %30 to float*
%32 = load float**, float*** %13
store float* %31, float** %32
%33 = load i64, i64* %17
%34 = load i32, i32* %12
%35 = call i64 @malloc_aligned(i64 %33, i32 %34)
%36 = inttoptr i64 %35 to float*
%37 = load float**, float*** %15
store float* %36, float** %37
%38 = load i32, i32* %11
%39 = add i32 %38, 1
%40 = zext i32 %39 to i64
%41 = mul i64 %40, 4
%42 = trunc i64 %41 to i32
%43 = call i64 @malloc(i32 %42)
%44 = inttoptr i64 %43 to float*
%45 = load float**, float*** %16
store float* %44, float** %45
%46 = load float**, float*** %14
%47 = load float*, float** %46
%48 = icmp eq float* %47, null
br i1 %48, label %61, label %49
49: ; preds = %8
%50 = load float**, float*** %13
%51 = load float*, float** %50
%52 = icmp eq float* %51, null
br i1 %52, label %61, label %53
53: ; preds = %49
%54 = load float**, float*** %15
%55 = load float*, float** %54
%56 = icmp eq float* %55, null
br i1 %56, label %61, label %57
57: ; preds = %53
%58 = load float**, float*** %16
%59 = load float*, float** %58
%60 = icmp eq float* %59, null
br label %61
61: ; preds = %57, %53, %49, %8
%62 = phi i1 [ true, %53 ], [ true, %49 ], [ true, %8 ], [ %60, %57 ]
%63 = zext i1 %62 to i32
%64 = mul nsw i32 %63, -1
ret i32 %64
}

LLVM IR (-O2):
define i32 @alloc_seismic_buffers(i32 %0, i32 %1, i32 %2, i32 %3, float** nocapture %4, float** nocapture %5, float** nocapture %6, float** nocapture writeonly %7) {
%9 = mul i32 %1, %0
%10 = zext i32 %9 to i64
%11 = shl nuw nsw i64 %10, 2
%12 = tail call i64 @malloc_aligned(i64 %11, i32 %3)
%13 = inttoptr i64 %12 to float*
store float* %13, float** %5
%14 = tail call i64 @malloc_aligned(i64 %11, i32 %3)
%15 = inttoptr i64 %14 to float*
store float* %15, float** %4
%16 = tail call i64 @malloc_aligned(i64 %11, i32 %3)
%17 = inttoptr i64 %16 to float*
store float* %17, float** %6
%18 = shl i32 %2, 2
%19 = add i32 %18, 4
%20 = tail call i64 @malloc(i32 %19)
%21 = inttoptr i64 %20 to float*
store float* %21, float** %7
%22 = load float*, float** %5
%23 = icmp eq float* %22, null
br i1 %23, label %33, label %24
24: ; preds = %8
%25 = load float*, float** %4
%26 = icmp eq float* %25, null
br i1 %26, label %33, label %27
27: ; preds = %24
%28 = load float*, float** %6
%29 = icmp eq float* %28, null
br i1 %29, label %33, label %30
30: ; preds = %27
%31 = icmp eq i64 %20, 0
%32 = sext i1 %31 to i32
br label %33
33: ; preds = %30, %27, %24, %8
%34 = phi i32 [ -1, %27 ], [ -1, %24 ], [ -1, %8 ], [ %32, %30 ]
ret i32 %34
}