#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 */
struct target {
  int dummy;
};

/* Variables and functions */
char *copy_params(char **, int, int *);
scalar_t__ dump_long_unsigned_int_from_mem(unsigned int, char **,
                                           struct target *);
int /*<<< orphan*/ free_dumped_params(char **, int);
void *malloc(int);
int dump_mmap_arg_struct(int depth, unsigned int addr, char **dumped_params,
                         struct target *target) {
  char **dumped_type_params;
  unsigned int arm_tracing_addr = addr;
  unsigned int arm_tracing_len = addr + 4;
  unsigned int arm_tracing_prot = addr + 8;
  unsigned int arm_tracing_flags = addr + 12;
  unsigned int arm_tracing_fd = addr + 16;
  unsigned int arm_tracing_offset = addr + 20;
  int len = 0;
  if (depth < 0) {
    *dumped_params = malloc(0);
    return len;
  }
  dumped_type_params = malloc(6 * (sizeof(char *)));
  if (depth >= 0) {
    len += dump_long_unsigned_int_from_mem(arm_tracing_addr,
                                           &dumped_type_params[0], target);
    len += dump_long_unsigned_int_from_mem(arm_tracing_len,
                                           &dumped_type_params[1], target);
    len += dump_long_unsigned_int_from_mem(arm_tracing_prot,
                                           &dumped_type_params[2], target);
    len += dump_long_unsigned_int_from_mem(arm_tracing_flags,
                                           &dumped_type_params[3], target);
    len += dump_long_unsigned_int_from_mem(arm_tracing_fd,
                                           &dumped_type_params[4], target);
    len += dump_long_unsigned_int_from_mem(arm_tracing_offset,
                                           &dumped_type_params[5], target);
  }
  *dumped_params = copy_params(dumped_type_params, 6, &len);
  free_dumped_params(dumped_type_params, 6);
  return len;
}


x86 assembly (clang, -O0):
<dump_mmap_arg_struct>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0xc(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0x30(%rbp)
mov    -0xc(%rbp),%eax
add    $0x8,%eax
mov    %eax,-0x34(%rbp)
mov    -0xc(%rbp),%eax
add    $0xc,%eax
mov    %eax,-0x38(%rbp)
mov    -0xc(%rbp),%eax
add    $0x10,%eax
mov    %eax,-0x3c(%rbp)
mov    -0xc(%rbp),%eax
add    $0x14,%eax
mov    %eax,-0x40(%rbp)
movl   $0x0,-0x44(%rbp)
cmpl   $0x0,-0x8(%rbp)
jge    11b6 <dump_mmap_arg_struct+0x76>
xor    %edi,%edi
call   1060 <malloc@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x44(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    12c0 <dump_mmap_arg_struct+0x180>
mov    $0x30,%edi
call   1060 <malloc@plt>
mov    %rax,-0x28(%rbp)
cmpl   $0x0,-0x8(%rbp)
jl     1290 <dump_mmap_arg_struct+0x150>
mov    -0x2c(%rbp),%edi
mov    -0x28(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1030 <dump_long_unsigned_int_from_mem@plt>
mov    %rax,%rcx
movslq -0x44(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x44(%rbp)
mov    -0x30(%rbp),%edi
mov    -0x28(%rbp),%rsi
add    $0x8,%rsi
mov    -0x20(%rbp),%rdx
call   1030 <dump_long_unsigned_int_from_mem@plt>
mov    %rax,%rcx
movslq -0x44(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x44(%rbp)
mov    -0x34(%rbp),%edi
mov    -0x28(%rbp),%rsi
add    $0x10,%rsi
mov    -0x20(%rbp),%rdx
call   1030 <dump_long_unsigned_int_from_mem@plt>
mov    %rax,%rcx
movslq -0x44(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x44(%rbp)
mov    -0x38(%rbp),%edi
mov    -0x28(%rbp),%rsi
add    $0x18,%rsi
mov    -0x20(%rbp),%rdx
call   1030 <dump_long_unsigned_int_from_mem@plt>
mov    %rax,%rcx
movslq -0x44(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x44(%rbp)
mov    -0x3c(%rbp),%edi
mov    -0x28(%rbp),%rsi
add    $0x20,%rsi
mov    -0x20(%rbp),%rdx
call   1030 <dump_long_unsigned_int_from_mem@plt>
mov    %rax,%rcx
movslq -0x44(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x44(%rbp)
mov    -0x40(%rbp),%edi
mov    -0x28(%rbp),%rsi
add    $0x28,%rsi
mov    -0x20(%rbp),%rdx
call   1030 <dump_long_unsigned_int_from_mem@plt>
mov    %rax,%rcx
movslq -0x44(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x44(%rbp)
mov    -0x28(%rbp),%rdi
mov    $0x6,%esi
lea    -0x44(%rbp),%rdx
call   1050 <copy_params@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x28(%rbp),%rdi
mov    $0x6,%esi
call   1040 <free_dumped_params@plt>
mov    -0x44(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dump_mmap_arg_struct>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdx,%rbp
test   %edi,%edi
js     1238 <dump_mmap_arg_struct+0xf8>
mov    %rcx,%r15
mov    %esi,%r12d
lea    0x14(%r12),%eax
mov    %eax,0xc(%rsp)
lea    0x10(%r12),%eax
mov    %eax,0x8(%rsp)
lea    0xc(%r12),%eax
mov    %eax,0x4(%rsp)
lea    0x8(%r12),%ebx
mov    %rbp,0x10(%rsp)
lea    0x4(%r12),%r14d
mov    $0x30,%edi
call   1060 <malloc@plt>
mov    %rax,%r13
mov    %r12d,%edi
mov    %rax,%rsi
mov    %r15,%rdx
call   1030 <dump_long_unsigned_int_from_mem@plt>
mov    %rax,%r12
lea    0x8(%r13),%rsi
mov    %r14d,%edi
mov    %r15,%rdx
call   1030 <dump_long_unsigned_int_from_mem@plt>
mov    %rax,%rbp
add    %r12d,%ebp
lea    0x10(%r13),%rsi
mov    %ebx,%edi
mov    %r15,%rdx
call   1030 <dump_long_unsigned_int_from_mem@plt>
mov    %rax,%rbx
add    %ebp,%ebx
lea    0x18(%r13),%rsi
mov    0x4(%rsp),%edi
mov    %r15,%rdx
call   1030 <dump_long_unsigned_int_from_mem@plt>
mov    %rax,%rbp
add    %ebx,%ebp
lea    0x20(%r13),%rsi
mov    0x8(%rsp),%edi
mov    %r15,%rdx
call   1030 <dump_long_unsigned_int_from_mem@plt>
mov    %rax,%rbx
add    %ebp,%ebx
lea    0x28(%r13),%rsi
mov    0xc(%rsp),%edi
mov    %r15,%rdx
call   1030 <dump_long_unsigned_int_from_mem@plt>
add    %ebx,%eax
mov    %eax,(%rsp)
mov    %rsp,%rdx
mov    %r13,%rdi
mov    $0x6,%esi
call   1050 <copy_params@plt>
mov    0x10(%rsp),%rcx
mov    %rax,(%rcx)
mov    %r13,%rdi
mov    $0x6,%esi
call   1040 <free_dumped_params@plt>
mov    (%rsp),%ebx
jmp    1245 <dump_mmap_arg_struct+0x105>
xor    %ebx,%ebx
xor    %edi,%edi
call   1060 <malloc@plt>
mov    %rax,0x0(%rbp)
mov    %ebx,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.target = type { i32 }
define i32 @dump_mmap_arg_struct(i32 %0, i32 %1, i8** %2, %struct.target* %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8**
%9 = alloca %struct.target*
%10 = alloca i8**
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
store i32 %0, i32* %6
store i32 %1, i32* %7
store i8** %2, i8*** %8
store %struct.target* %3, %struct.target** %9
%18 = load i32, i32* %7
store i32 %18, i32* %11
%19 = load i32, i32* %7
%20 = add i32 %19, 4
store i32 %20, i32* %12
%21 = load i32, i32* %7
%22 = add i32 %21, 8
store i32 %22, i32* %13
%23 = load i32, i32* %7
%24 = add i32 %23, 12
store i32 %24, i32* %14
%25 = load i32, i32* %7
%26 = add i32 %25, 16
store i32 %26, i32* %15
%27 = load i32, i32* %7
%28 = add i32 %27, 20
store i32 %28, i32* %16
store i32 0, i32* %17
%29 = load i32, i32* %6
%30 = icmp slt i32 %29, 0
br i1 %30, label %31, label %35
31: ; preds = %4
%32 = call i8* @malloc(i32 0)
%33 = load i8**, i8*** %8
store i8* %32, i8** %33
%34 = load i32, i32* %17
store i32 %34, i32* %5
br label %102
35: ; preds = %4
%36 = call i8* @malloc(i32 48)
%37 = bitcast i8* %36 to i8**
store i8** %37, i8*** %10
%38 = load i32, i32* %6
%39 = icmp sge i32 %38, 0
br i1 %39, label %40, label %95
40: ; preds = %35
%41 = load i32, i32* %11
%42 = load i8**, i8*** %10
%43 = getelementptr inbounds i8*, i8** %42, i64 0
%44 = load %struct.target*, %struct.target** %9
%45 = call i64 @dump_long_unsigned_int_from_mem(i32 %41, i8** %43, %struct.target* %44)
%46 = load i32, i32* %17
%47 = sext i32 %46 to i64
%48 = add nsw i64 %47, %45
%49 = trunc i64 %48 to i32
store i32 %49, i32* %17
%50 = load i32, i32* %12
%51 = load i8**, i8*** %10
%52 = getelementptr inbounds i8*, i8** %51, i64 1
%53 = load %struct.target*, %struct.target** %9
%54 = call i64 @dump_long_unsigned_int_from_mem(i32 %50, i8** %52, %struct.target* %53)
%55 = load i32, i32* %17
%56 = sext i32 %55 to i64
%57 = add nsw i64 %56, %54
%58 = trunc i64 %57 to i32
store i32 %58, i32* %17
%59 = load i32, i32* %13
%60 = load i8**, i8*** %10
%61 = getelementptr inbounds i8*, i8** %60, i64 2
%62 = load %struct.target*, %struct.target** %9
%63 = call i64 @dump_long_unsigned_int_from_mem(i32 %59, i8** %61, %struct.target* %62)
%64 = load i32, i32* %17
%65 = sext i32 %64 to i64
%66 = add nsw i64 %65, %63
%67 = trunc i64 %66 to i32
store i32 %67, i32* %17
%68 = load i32, i32* %14
%69 = load i8**, i8*** %10
%70 = getelementptr inbounds i8*, i8** %69, i64 3
%71 = load %struct.target*, %struct.target** %9
%72 = call i64 @dump_long_unsigned_int_from_mem(i32 %68, i8** %70, %struct.target* %71)
%73 = load i32, i32* %17
%74 = sext i32 %73 to i64
%75 = add nsw i64 %74, %72
%76 = trunc i64 %75 to i32
store i32 %76, i32* %17
%77 = load i32, i32* %15
%78 = load i8**, i8*** %10
%79 = getelementptr inbounds i8*, i8** %78, i64 4
%80 = load %struct.target*, %struct.target** %9
%81 = call i64 @dump_long_unsigned_int_from_mem(i32 %77, i8** %79, %struct.target* %80)
%82 = load i32, i32* %17
%83 = sext i32 %82 to i64
%84 = add nsw i64 %83, %81
%85 = trunc i64 %84 to i32
store i32 %85, i32* %17
%86 = load i32, i32* %16
%87 = load i8**, i8*** %10
%88 = getelementptr inbounds i8*, i8** %87, i64 5
%89 = load %struct.target*, %struct.target** %9
%90 = call i64 @dump_long_unsigned_int_from_mem(i32 %86, i8** %88, %struct.target* %89)
%91 = load i32, i32* %17
%92 = sext i32 %91 to i64
%93 = add nsw i64 %92, %90
%94 = trunc i64 %93 to i32
store i32 %94, i32* %17
br label %95
95: ; preds = %40, %35
%96 = load i8**, i8*** %10
%97 = call i8* @copy_params(i8** %96, i32 6, i32* %17)
%98 = load i8**, i8*** %8
store i8* %97, i8** %98
%99 = load i8**, i8*** %10
%100 = call i32 @free_dumped_params(i8** %99, i32 6)
%101 = load i32, i32* %17
store i32 %101, i32* %5
br label %102
102: ; preds = %95, %31
%103 = load i32, i32* %5
ret i32 %103
}

LLVM IR (-O2):
%struct.target = type { i32 }
define i32 @dump_mmap_arg_struct(i32 %0, i32 %1, i8** nocapture writeonly %2, %struct.target* %3) {
%5 = alloca i32
%6 = bitcast i32* %5 to i8*
%7 = icmp slt i32 %0, 0
br i1 %7, label %8, label %10
8: ; preds = %4
%9 = tail call i8* @malloc(i32 0)
store i8* %9, i8** %2
br label %43
10: ; preds = %4
%11 = add i32 %1, 20
%12 = add i32 %1, 16
%13 = add i32 %1, 12
%14 = add i32 %1, 8
%15 = add i32 %1, 4
%16 = tail call dereferenceable_or_null(48) i8* @malloc(i32 48)
%17 = bitcast i8* %16 to i8**
%18 = tail call i64 @dump_long_unsigned_int_from_mem(i32 %1, i8** %17, %struct.target* %3)
%19 = trunc i64 %18 to i32
%20 = getelementptr inbounds i8*, i8** %17, i64 1
%21 = tail call i64 @dump_long_unsigned_int_from_mem(i32 %15, i8** %20, %struct.target* %3)
%22 = trunc i64 %21 to i32
%23 = add i32 %19, %22
%24 = getelementptr inbounds i8*, i8** %17, i64 2
%25 = tail call i64 @dump_long_unsigned_int_from_mem(i32 %14, i8** %24, %struct.target* %3)
%26 = trunc i64 %25 to i32
%27 = add i32 %23, %26
%28 = getelementptr inbounds i8*, i8** %17, i64 3
%29 = tail call i64 @dump_long_unsigned_int_from_mem(i32 %13, i8** %28, %struct.target* %3)
%30 = trunc i64 %29 to i32
%31 = add i32 %27, %30
%32 = getelementptr inbounds i8*, i8** %17, i64 4
%33 = tail call i64 @dump_long_unsigned_int_from_mem(i32 %12, i8** %32, %struct.target* %3)
%34 = trunc i64 %33 to i32
%35 = add i32 %31, %34
%36 = getelementptr inbounds i8*, i8** %17, i64 5
%37 = tail call i64 @dump_long_unsigned_int_from_mem(i32 %11, i8** %36, %struct.target* %3)
%38 = trunc i64 %37 to i32
%39 = add i32 %35, %38
store i32 %39, i32* %5
%40 = call i8* @copy_params(i8** %17, i32 6, i32* %5)
store i8* %40, i8** %2
%41 = call i32 @free_dumped_params(i8** %17, i32 6)
%42 = load i32, i32* %5
br label %43
43: ; preds = %10, %8
%44 = phi i32 [ %42, %10 ], [ 0, %8 ]
ret i32 %44
}