#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__ arm_arch(char const *);
scalar_t__ arm_implementer(char const *);
scalar_t__ arm_part(char const *, char const *);
int /*<<< orphan*/ free(char *);
char *malloc(int);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ sprintf(char *, char *, char const *, ...);
int strtol(char const *, int /*<<< orphan*/ *, int /*<<< orphan*/);
char *arm_decoded_name(const char *imp, const char *part, const char *var,
                       const char *rev, const char *arch,
                       const char *model_name) {
  char *dnbuff;
  char *imp_name = NULL, *part_desc = NULL, *arch_name = NULL;
  int r = 0, p = 0;
  dnbuff = malloc(256);
  if (dnbuff) {
    memset(dnbuff, 0, 256);
    if (imp && arch && part && rev) {
      r = strtol(var, NULL, 0);
      p = strtol(rev, NULL, 0);
      imp_name = (char *)arm_implementer(imp);
      part_desc = (char *)arm_part(imp, part);
      arch_name = (char *)arm_arch(arch);
      if (imp_name || part_desc) {
        if (arch_name != arch)
          sprintf(dnbuff, "%s %s r%dp%d (%s)", (imp_name) ? imp_name : imp,
                  (part_desc) ? part_desc : part, r, p, arch_name);
        else
          sprintf(dnbuff, "%s %s r%dp%d (arch:%s)", (imp_name) ? imp_name : imp,
                  (part_desc) ? part_desc : part, r, p, arch);
      } else {
        sprintf(dnbuff, "%s [imp:%s part:%s r%dp%d arch:%s]", model_name,
                (imp_name) ? imp_name : imp, (part_desc) ? part_desc : part, r,
                p, arch);
      }
    } else {
      if (model_name)
        sprintf(dnbuff, "%s", model_name);
      else {
        free(dnbuff);
        return NULL;
      }
    }
  }
  return dnbuff;
}


x86 assembly (clang, -O0):
<arm_decoded_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0xe0,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    %r9,-0x38(%rbp)
movq   $0x0,-0x48(%rbp)
movq   $0x0,-0x50(%rbp)
movq   $0x0,-0x58(%rbp)
movl   $0x0,-0x5c(%rbp)
movl   $0x0,-0x60(%rbp)
mov    $0x100,%edi
call   1090 <malloc@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
je     14a7 <arm_decoded_name+0x327>
mov    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1060 <memset@plt>
cmpq   $0x0,-0x10(%rbp)
je     1461 <arm_decoded_name+0x2e1>
cmpq   $0x0,-0x30(%rbp)
je     1461 <arm_decoded_name+0x2e1>
cmpq   $0x0,-0x18(%rbp)
je     1461 <arm_decoded_name+0x2e1>
cmpq   $0x0,-0x28(%rbp)
je     1461 <arm_decoded_name+0x2e1>
mov    -0x20(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   1080 <strtol@plt>
mov    %eax,-0x5c(%rbp)
mov    -0x28(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   1080 <strtol@plt>
mov    %eax,-0x60(%rbp)
mov    -0x10(%rbp),%rdi
call   1070 <arm_implementer@plt>
mov    %rax,-0x48(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <arm_part@plt>
mov    %rax,-0x50(%rbp)
mov    -0x30(%rbp),%rdi
call   1040 <arm_arch@plt>
mov    %rax,-0x58(%rbp)
cmpq   $0x0,-0x48(%rbp)
jne    1283 <arm_decoded_name+0x103>
cmpq   $0x0,-0x50(%rbp)
je     13ad <arm_decoded_name+0x22d>
mov    -0x58(%rbp),%rax
cmp    -0x30(%rbp),%rax
je     1310 <arm_decoded_name+0x190>
mov    -0x40(%rbp),%rax
mov    %rax,-0x68(%rbp)
cmpq   $0x0,-0x48(%rbp)
je     12b1 <arm_decoded_name+0x131>
mov    -0x48(%rbp),%rax
mov    %rax,-0x70(%rbp)
jmp    12b9 <arm_decoded_name+0x139>
mov    -0x10(%rbp),%rax
mov    %rax,-0x70(%rbp)
mov    -0x70(%rbp),%rax
mov    %rax,-0x78(%rbp)
cmpq   $0x0,-0x50(%rbp)
je     12d9 <arm_decoded_name+0x159>
mov    -0x50(%rbp),%rax
mov    %rax,-0x80(%rbp)
jmp    12e1 <arm_decoded_name+0x161>
mov    -0x18(%rbp),%rax
mov    %rax,-0x80(%rbp)
mov    -0x78(%rbp),%rdx
mov    -0x68(%rbp),%rdi
mov    -0x80(%rbp),%rcx
mov    -0x5c(%rbp),%r8d
mov    -0x60(%rbp),%r9d
mov    -0x58(%rbp),%rax
lea    0xd00(%rip),%rsi
mov    %rax,(%rsp)
mov    $0x0,%al
call   10a0 <sprintf@plt>
jmp    13a8 <arm_decoded_name+0x228>
mov    -0x40(%rbp),%rax
mov    %rax,-0x88(%rbp)
cmpq   $0x0,-0x48(%rbp)
je     1336 <arm_decoded_name+0x1b6>
mov    -0x48(%rbp),%rax
mov    %rax,-0x90(%rbp)
jmp    1341 <arm_decoded_name+0x1c1>
mov    -0x10(%rbp),%rax
mov    %rax,-0x90(%rbp)
mov    -0x90(%rbp),%rax
mov    %rax,-0x98(%rbp)
cmpq   $0x0,-0x50(%rbp)
je     136a <arm_decoded_name+0x1ea>
mov    -0x50(%rbp),%rax
mov    %rax,-0xa0(%rbp)
jmp    1375 <arm_decoded_name+0x1f5>
mov    -0x18(%rbp),%rax
mov    %rax,-0xa0(%rbp)
mov    -0x98(%rbp),%rdx
mov    -0x88(%rbp),%rdi
mov    -0xa0(%rbp),%rcx
mov    -0x5c(%rbp),%r8d
mov    -0x60(%rbp),%r9d
mov    -0x30(%rbp),%rax
lea    0xc75(%rip),%rsi
mov    %rax,(%rsp)
mov    $0x0,%al
call   10a0 <sprintf@plt>
jmp    145c <arm_decoded_name+0x2dc>
mov    -0x40(%rbp),%rax
mov    %rax,-0xb0(%rbp)
mov    -0x38(%rbp),%rax
mov    %rax,-0xa8(%rbp)
cmpq   $0x0,-0x48(%rbp)
je     13de <arm_decoded_name+0x25e>
mov    -0x48(%rbp),%rax
mov    %rax,-0xb8(%rbp)
jmp    13e9 <arm_decoded_name+0x269>
mov    -0x10(%rbp),%rax
mov    %rax,-0xb8(%rbp)
mov    -0xb8(%rbp),%rax
mov    %rax,-0xc0(%rbp)
cmpq   $0x0,-0x50(%rbp)
je     1412 <arm_decoded_name+0x292>
mov    -0x50(%rbp),%rax
mov    %rax,-0xc8(%rbp)
jmp    141d <arm_decoded_name+0x29d>
mov    -0x18(%rbp),%rax
mov    %rax,-0xc8(%rbp)
mov    -0xc0(%rbp),%rcx
mov    -0xa8(%rbp),%rdx
mov    -0xb0(%rbp),%rdi
mov    -0xc8(%rbp),%r8
mov    -0x5c(%rbp),%r9d
mov    -0x60(%rbp),%r10d
mov    -0x30(%rbp),%rax
lea    0xbdd(%rip),%rsi
mov    %r10d,(%rsp)
mov    %rax,0x8(%rsp)
mov    $0x0,%al
call   10a0 <sprintf@plt>
jmp    14a2 <arm_decoded_name+0x322>
cmpq   $0x0,-0x38(%rbp)
je     1487 <arm_decoded_name+0x307>
mov    -0x40(%rbp),%rdi
mov    -0x38(%rbp),%rdx
lea    0xbd1(%rip),%rsi
mov    $0x0,%al
call   10a0 <sprintf@plt>
jmp    149d <arm_decoded_name+0x31d>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x8(%rbp)
jmp    14af <arm_decoded_name+0x32f>
jmp    14a2 <arm_decoded_name+0x322>
jmp    14a7 <arm_decoded_name+0x327>
mov    -0x40(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0xe0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<arm_decoded_name>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %r9,0x20(%rsp)
mov    %r8,%r13
mov    %rcx,%rbp
mov    %rdx,%r12
mov    %rsi,%r14
mov    %rdi,%r15
mov    $0x100,%edi
call   10a0 <malloc@plt>
test   %rax,%rax
je     12ad <arm_decoded_name+0x11d>
mov    %rax,%rbx
mov    %rax,%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1070 <memset@plt>
test   %rbp,%rbp
je     1262 <arm_decoded_name+0xd2>
test   %r14,%r14
je     1262 <arm_decoded_name+0xd2>
test   %r15,%r15
je     1262 <arm_decoded_name+0xd2>
test   %r13,%r13
je     1262 <arm_decoded_name+0xd2>
mov    %r12,%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1090 <strtol@plt>
mov    %eax,0x1c(%rsp)
mov    %rbp,%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1090 <strtol@plt>
mov    %eax,0x18(%rsp)
mov    %r15,%rdi
call   1080 <arm_implementer@plt>
mov    %rax,%rbp
mov    %r15,%rdi
mov    %r14,%rsi
call   1050 <arm_part@plt>
mov    %rax,%r12
mov    %r13,%rdi
call   1040 <arm_arch@plt>
mov    %rbp,%rcx
or     %r12,%rcx
je     1276 <arm_decoded_name+0xe6>
mov    0x18(%rsp),%r9d
mov    0x1c(%rsp),%r8d
test   %rbp,%rbp
cmovne %rbp,%r15
test   %r12,%r12
cmovne %r12,%r14
cmp    %r13,%rax
je     12b1 <arm_decoded_name+0x121>
mov    %rax,(%rsp)
lea    0xda0(%rip),%rsi
jmp    12bc <arm_decoded_name+0x12c>
mov    0x20(%rsp),%rsi
test   %rsi,%rsi
je     12a5 <arm_decoded_name+0x115>
mov    %rbx,%rdi
call   1060 <strcpy@plt>
jmp    12cc <arm_decoded_name+0x13c>
mov    %r13,0x8(%rsp)
mov    0x18(%rsp),%eax
mov    %eax,(%rsp)
lea    0xda0(%rip),%rsi
mov    %rbx,%rdi
mov    0x20(%rsp),%rdx
mov    %r15,%rcx
mov    %r14,%r8
mov    0x1c(%rsp),%r9d
xor    %eax,%eax
call   10b0 <sprintf@plt>
jmp    12cc <arm_decoded_name+0x13c>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %ebx,%ebx
jmp    12cc <arm_decoded_name+0x13c>
mov    %r13,(%rsp)
lea    0xd56(%rip),%rsi
mov    %rbx,%rdi
mov    %r15,%rdx
mov    %r14,%rcx
xor    %eax,%eax
call   10b0 <sprintf@plt>
mov    %rbx,%rax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [18 x i8] c"%s %s r%dp%d (%s)\00"
@.str.1 = [23 x i8] c"%s %s r%dp%d (arch:%s)\00"
@.str.2 = [35 x i8] c"%s [imp:%s part:%s r%dp%d arch:%s]\00"
@.str.3 = [3 x i8] c"%s\00"
define i8* @arm_decoded_name(i8* %0, i8* %1, i8* %2, i8* %3, i8* %4, i8* %5) {
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca i8*
%15 = alloca i8*
%16 = alloca i8*
%17 = alloca i8*
%18 = alloca i32
%19 = alloca i32
store i8* %0, i8** %8
store i8* %1, i8** %9
store i8* %2, i8** %10
store i8* %3, i8** %11
store i8* %4, i8** %12
store i8* %5, i8** %13
store i8* null, i8** %15
store i8* null, i8** %16
store i8* null, i8** %17
store i32 0, i32* %18
store i32 0, i32* %19
%20 = call i8* @malloc(i32 256)
store i8* %20, i8** %14
%21 = load i8*, i8** %14
%22 = icmp ne i8* %21, null
br i1 %22, label %23, label %142
23: ; preds = %6
%24 = load i8*, i8** %14
%25 = call i32 @memset(i8* %24, i32 0, i32 256)
%26 = load i8*, i8** %8
%27 = icmp ne i8* %26, null
br i1 %27, label %28, label %130
28: ; preds = %23
%29 = load i8*, i8** %12
%30 = icmp ne i8* %29, null
br i1 %30, label %31, label %130
31: ; preds = %28
%32 = load i8*, i8** %9
%33 = icmp ne i8* %32, null
br i1 %33, label %34, label %130
34: ; preds = %31
%35 = load i8*, i8** %11
%36 = icmp ne i8* %35, null
br i1 %36, label %37, label %130
37: ; preds = %34
%38 = load i8*, i8** %10
%39 = call i32 @strtol(i8* %38, i32* null, i32 0)
store i32 %39, i32* %18
%40 = load i8*, i8** %11
%41 = call i32 @strtol(i8* %40, i32* null, i32 0)
store i32 %41, i32* %19
%42 = load i8*, i8** %8
%43 = call i64 @arm_implementer(i8* %42)
%44 = inttoptr i64 %43 to i8*
store i8* %44, i8** %15
%45 = load i8*, i8** %8
%46 = load i8*, i8** %9
%47 = call i64 @arm_part(i8* %45, i8* %46)
%48 = inttoptr i64 %47 to i8*
store i8* %48, i8** %16
%49 = load i8*, i8** %12
%50 = call i64 @arm_arch(i8* %49)
%51 = inttoptr i64 %50 to i8*
store i8* %51, i8** %17
%52 = load i8*, i8** %15
%53 = icmp ne i8* %52, null
br i1 %53, label %57, label %54
54: ; preds = %37
%55 = load i8*, i8** %16
%56 = icmp ne i8* %55, null
br i1 %56, label %57, label %106
57: ; preds = %54, %37
%58 = load i8*, i8** %17
%59 = load i8*, i8** %12
%60 = icmp ne i8* %58, %59
br i1 %60, label %61, label %83
61: ; preds = %57
%62 = load i8*, i8** %14
%63 = load i8*, i8** %15
%64 = icmp ne i8* %63, null
br i1 %64, label %65, label %67
65: ; preds = %61
%66 = load i8*, i8** %15
br label %69
67: ; preds = %61
%68 = load i8*, i8** %8
br label %69
69: ; preds = %67, %65
%70 = phi i8* [ %66, %65 ], [ %68, %67 ]
%71 = load i8*, i8** %16
%72 = icmp ne i8* %71, null
br i1 %72, label %73, label %75
73: ; preds = %69
%74 = load i8*, i8** %16
br label %77
75: ; preds = %69
%76 = load i8*, i8** %9
br label %77
77: ; preds = %75, %73
%78 = phi i8* [ %74, %73 ], [ %76, %75 ]
%79 = load i32, i32* %18
%80 = load i32, i32* %19
%81 = load i8*, i8** %17
%82 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %62, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %70, i8* %78, i32 %79, i32 %80, i8* %81)
br label %105
83: ; preds = %57
%84 = load i8*, i8** %14
%85 = load i8*, i8** %15
%86 = icmp ne i8* %85, null
br i1 %86, label %87, label %89
87: ; preds = %83
%88 = load i8*, i8** %15
br label %91
89: ; preds = %83
%90 = load i8*, i8** %8
br label %91
91: ; preds = %89, %87
%92 = phi i8* [ %88, %87 ], [ %90, %89 ]
%93 = load i8*, i8** %16
%94 = icmp ne i8* %93, null
br i1 %94, label %95, label %97
95: ; preds = %91
%96 = load i8*, i8** %16
br label %99
97: ; preds = %91
%98 = load i8*, i8** %9
br label %99
99: ; preds = %97, %95
%100 = phi i8* [ %96, %95 ], [ %98, %97 ]
%101 = load i32, i32* %18
%102 = load i32, i32* %19
%103 = load i8*, i8** %12
%104 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %84, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* %92, i8* %100, i32 %101, i32 %102, i8* %103)
br label %105
105: ; preds = %99, %77
br label %129
106: ; preds = %54
%107 = load i8*, i8** %14
%108 = load i8*, i8** %13
%109 = load i8*, i8** %15
%110 = icmp ne i8* %109, null
br i1 %110, label %111, label %113
111: ; preds = %106
%112 = load i8*, i8** %15
br label %115
113: ; preds = %106
%114 = load i8*, i8** %8
br label %115
115: ; preds = %113, %111
%116 = phi i8* [ %112, %111 ], [ %114, %113 ]
%117 = load i8*, i8** %16
%118 = icmp ne i8* %117, null
br i1 %118, label %119, label %121
119: ; preds = %115
%120 = load i8*, i8** %16
br label %123
121: ; preds = %115
%122 = load i8*, i8** %9
br label %123
123: ; preds = %121, %119
%124 = phi i8* [ %120, %119 ], [ %122, %121 ]
%125 = load i32, i32* %18
%126 = load i32, i32* %19
%127 = load i8*, i8** %12
%128 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %107, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0), i8* %108, i8* %116, i8* %124, i32 %125, i32 %126, i8* %127)
br label %129
129: ; preds = %123, %105
br label %141
130: ; preds = %34, %31, %28, %23
%131 = load i8*, i8** %13
%132 = icmp ne i8* %131, null
br i1 %132, label %133, label %137
133: ; preds = %130
%134 = load i8*, i8** %14
%135 = load i8*, i8** %13
%136 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %134, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %135)
br label %140
137: ; preds = %130
%138 = load i8*, i8** %14
%139 = call i32 @free(i8* %138)
store i8* null, i8** %7
br label %144
140: ; preds = %133
br label %141
141: ; preds = %140, %129
br label %142
142: ; preds = %141, %6
%143 = load i8*, i8** %14
store i8* %143, i8** %7
br label %144
144: ; preds = %142, %137
%145 = load i8*, i8** %7
ret i8* %145
}

LLVM IR (-O2):
@.str = [18 x i8] c"%s %s r%dp%d (%s)\00"
@.str.1 = [23 x i8] c"%s %s r%dp%d (arch:%s)\00"
@.str.2 = [35 x i8] c"%s [imp:%s part:%s r%dp%d arch:%s]\00"
define i8* @arm_decoded_name(i8* %0, i8* %1, i8* nocapture %2, i8* %3, i8* %4, i8* %5) {
%7 = tail call dereferenceable_or_null(256) i8* @malloc(i32 256)
%8 = icmp eq i8* %7, null
br i1 %8, label %46, label %9
9: ; preds = %6
%10 = tail call i32 @memset(i8* %7, i32 0, i32 256)
%11 = icmp ne i8* %0, null
%12 = icmp ne i8* %4, null
%13 = and i1 %11, %12
%14 = icmp ne i8* %1, null
%15 = and i1 %14, %13
%16 = icmp ne i8* %3, null
%17 = and i1 %16, %15
br i1 %17, label %18, label %40
18: ; preds = %9
%19 = tail call i32 @strtol(i8* nocapture %2, i32* null, i32 0)
%20 = tail call i32 @strtol(i8* nocapture %3, i32* null, i32 0)
%21 = tail call i64 @arm_implementer(i8* %0)
%22 = tail call i64 @arm_part(i8* %0, i8* %1)
%23 = tail call i64 @arm_arch(i8* %4)
%24 = inttoptr i64 %23 to i8*
%25 = icmp ne i64 %21, 0
%26 = icmp ne i64 %22, 0
%27 = select i1 %25, i1 true, i1 %26
br i1 %27, label %28, label %38
28: ; preds = %18
%29 = inttoptr i64 %22 to i8*
%30 = inttoptr i64 %21 to i8*
%31 = icmp eq i8* %24, %4
%32 = select i1 %25, i8* %30, i8* %0
%33 = select i1 %26, i8* %29, i8* %1
br i1 %31, label %36, label %34
34: ; preds = %28
%35 = tail call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %7, i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %32, i8* %33, i32 %19, i32 %20, i8* %24)
br label %46
36: ; preds = %28
%37 = tail call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %7, i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* %32, i8* %33, i32 %19, i32 %20, i8* %4)
br label %46
38: ; preds = %18
%39 = tail call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %7, i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0), i8* %5, i8* %0, i8* %1, i32 %19, i32 %20, i8* %4)
br label %46
40: ; preds = %9
%41 = icmp eq i8* %5, null
br i1 %41, label %44, label %42
42: ; preds = %40
%43 = tail call i8* @strcpy(i8* %7, i8* %5)
br label %46
44: ; preds = %40
%45 = tail call i32 @free(i8* %7)
br label %46
46: ; preds = %6, %38, %36, %34, %42, %44
%47 = phi i8* [ null, %44 ], [ %7, %42 ], [ %7, %34 ], [ %7, %36 ], [ %7, %38 ], [ null, %6 ]
ret i8* %47
}