#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_char_from_mem(unsigned int, char **, struct target *);
int /*<<< orphan*/ free_dumped_params(char **, int);
void *malloc(int);
int dump_new_utsname(int depth, unsigned int addr, char **dumped_params,
                     struct target *target) {
  char **dumped_type_params;
  unsigned int arm_tracing_sysname = addr;
  unsigned int arm_tracing_nodename = addr + 65;
  unsigned int arm_tracing_release = addr + 130;
  unsigned int arm_tracing_version = addr + 195;
  unsigned int arm_tracing_machine = addr + 260;
  unsigned int arm_tracing_domainname = addr + 325;
  int len = 0;
  if (depth < 0) {
    *dumped_params = malloc(0);
    return len;
  }
  dumped_type_params = malloc(6 * (sizeof(char *)));
  if (depth >= 0) {
    len +=
        dump_char_from_mem(arm_tracing_sysname, &dumped_type_params[0], target);
    len += dump_char_from_mem(arm_tracing_nodename, &dumped_type_params[1],
                              target);
    len +=
        dump_char_from_mem(arm_tracing_release, &dumped_type_params[2], target);
    len +=
        dump_char_from_mem(arm_tracing_version, &dumped_type_params[3], target);
    len +=
        dump_char_from_mem(arm_tracing_machine, &dumped_type_params[4], target);
    len += dump_char_from_mem(arm_tracing_domainname, &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_new_utsname>:
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    $0x41,%eax
mov    %eax,-0x30(%rbp)
mov    -0xc(%rbp),%eax
add    $0x82,%eax
mov    %eax,-0x34(%rbp)
mov    -0xc(%rbp),%eax
add    $0xc3,%eax
mov    %eax,-0x38(%rbp)
mov    -0xc(%rbp),%eax
add    $0x104,%eax
mov    %eax,-0x3c(%rbp)
mov    -0xc(%rbp),%eax
add    $0x145,%eax
mov    %eax,-0x40(%rbp)
movl   $0x0,-0x44(%rbp)
cmpl   $0x0,-0x8(%rbp)
jge    11be <dump_new_utsname+0x7e>
xor    %edi,%edi
call   1050 <malloc@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x44(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    12c8 <dump_new_utsname+0x188>
mov    $0x30,%edi
call   1050 <malloc@plt>
mov    %rax,-0x28(%rbp)
cmpl   $0x0,-0x8(%rbp)
jl     1298 <dump_new_utsname+0x158>
mov    -0x2c(%rbp),%edi
mov    -0x28(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1060 <dump_char_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   1060 <dump_char_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   1060 <dump_char_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   1060 <dump_char_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   1060 <dump_char_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   1060 <dump_char_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   1040 <copy_params@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x28(%rbp),%rdi
mov    $0x6,%esi
call   1030 <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_new_utsname>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdx,%rbp
test   %edi,%edi
js     1244 <dump_new_utsname+0x104>
mov    %rcx,%r15
mov    %esi,%r12d
lea    0x145(%r12),%eax
mov    %eax,0xc(%rsp)
lea    0x104(%r12),%eax
mov    %eax,0x8(%rsp)
lea    0xc3(%r12),%eax
mov    %eax,0x4(%rsp)
lea    0x82(%r12),%ebx
mov    %rbp,0x10(%rsp)
lea    0x41(%r12),%r14d
mov    $0x30,%edi
call   1050 <malloc@plt>
mov    %rax,%r13
mov    %r12d,%edi
mov    %rax,%rsi
mov    %r15,%rdx
call   1060 <dump_char_from_mem@plt>
mov    %rax,%r12
lea    0x8(%r13),%rsi
mov    %r14d,%edi
mov    %r15,%rdx
call   1060 <dump_char_from_mem@plt>
mov    %rax,%rbp
add    %r12d,%ebp
lea    0x10(%r13),%rsi
mov    %ebx,%edi
mov    %r15,%rdx
call   1060 <dump_char_from_mem@plt>
mov    %rax,%rbx
add    %ebp,%ebx
lea    0x18(%r13),%rsi
mov    0x4(%rsp),%edi
mov    %r15,%rdx
call   1060 <dump_char_from_mem@plt>
mov    %rax,%rbp
add    %ebx,%ebp
lea    0x20(%r13),%rsi
mov    0x8(%rsp),%edi
mov    %r15,%rdx
call   1060 <dump_char_from_mem@plt>
mov    %rax,%rbx
add    %ebp,%ebx
lea    0x28(%r13),%rsi
mov    0xc(%rsp),%edi
mov    %r15,%rdx
call   1060 <dump_char_from_mem@plt>
add    %ebx,%eax
mov    %eax,(%rsp)
mov    %rsp,%rdx
mov    %r13,%rdi
mov    $0x6,%esi
call   1040 <copy_params@plt>
mov    0x10(%rsp),%rcx
mov    %rax,(%rcx)
mov    %r13,%rdi
mov    $0x6,%esi
call   1030 <free_dumped_params@plt>
mov    (%rsp),%ebx
jmp    1251 <dump_new_utsname+0x111>
xor    %ebx,%ebx
xor    %edi,%edi
call   1050 <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_new_utsname(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, 65
store i32 %20, i32* %12
%21 = load i32, i32* %7
%22 = add i32 %21, 130
store i32 %22, i32* %13
%23 = load i32, i32* %7
%24 = add i32 %23, 195
store i32 %24, i32* %14
%25 = load i32, i32* %7
%26 = add i32 %25, 260
store i32 %26, i32* %15
%27 = load i32, i32* %7
%28 = add i32 %27, 325
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_char_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_char_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_char_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_char_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_char_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_char_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_new_utsname(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, 325
%12 = add i32 %1, 260
%13 = add i32 %1, 195
%14 = add i32 %1, 130
%15 = add i32 %1, 65
%16 = tail call dereferenceable_or_null(48) i8* @malloc(i32 48)
%17 = bitcast i8* %16 to i8**
%18 = tail call i64 @dump_char_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_char_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_char_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_char_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_char_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_char_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
}