#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 OBJFILESTR {
  int dummy;
};
struct LABELSTR {
  int dummy;
};

/* Variables and functions */
int get32l(unsigned char *);
struct LABELSTR *symbolconv0(unsigned char *, struct OBJFILESTR *);
struct LABELSTR *symbolconv(unsigned char *p, unsigned char *s,
                            struct OBJFILESTR *obj) {
  unsigned char tmp[12], *n;
  if (s[0x10] == 0x02)
    obj = NULL;
  if (s[0x00] | s[0x01] | s[0x02] | s[0x03]) {
    int i;
    for (i = 0; i < 8; i++)
      tmp[i] = s[i];
    tmp[8] = '\0';
    n = tmp;
  } else
    n = p + get32l(&p[0x08]) + get32l(&p[0x0c]) * 0x12 + get32l(&s[0x04]);
  return symbolconv0(n, obj);
}


x86 assembly (clang, -O0):
<symbolconv>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movzbl 0x10(%rax),%eax
cmp    $0x2,%eax
jne    114d <symbolconv+0x2d>
movq   $0x0,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movzbl (%rax),%eax
mov    -0x10(%rbp),%rcx
movzbl 0x1(%rcx),%ecx
or     %ecx,%eax
mov    -0x10(%rbp),%rcx
movzbl 0x2(%rcx),%ecx
or     %ecx,%eax
mov    -0x10(%rbp),%rcx
movzbl 0x3(%rcx),%ecx
or     %ecx,%eax
cmp    $0x0,%eax
je     11be <symbolconv+0x9e>
movl   $0x0,-0x34(%rbp)
cmpl   $0x8,-0x34(%rbp)
jge    11ad <symbolconv+0x8d>
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,1),%cl
movslq -0x34(%rbp),%rax
mov    %cl,-0x24(%rbp,%rax,1)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1182 <symbolconv+0x62>
movb   $0x0,-0x1c(%rbp)
lea    -0x24(%rbp),%rax
mov    %rax,-0x30(%rbp)
jmp    1220 <symbolconv+0x100>
mov    -0x8(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x8(%rbp),%rdi
add    $0x8,%rdi
call   1030 <get32l@plt>
mov    %eax,%ecx
mov    -0x50(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x48(%rbp)
mov    -0x8(%rbp),%rdi
add    $0xc,%rdi
call   1030 <get32l@plt>
mov    %eax,%ecx
mov    -0x48(%rbp),%rax
imul   $0x12,%ecx,%ecx
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x40(%rbp)
mov    -0x10(%rbp),%rdi
add    $0x4,%rdi
call   1030 <get32l@plt>
mov    %eax,%ecx
mov    -0x40(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <symbolconv0@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<symbolconv>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdx,%r14
mov    %rsi,%rbx
mov    0x10(%rsi),%r12b
cmpl   $0x0,(%rsi)
je     1151 <symbolconv+0x31>
lea    0x8(%rsp),%rdi
mov    (%rbx),%rax
mov    %rax,0x8(%rsp)
movb   $0x0,0x10(%rsp)
jmp    118c <symbolconv+0x6c>
mov    %rdi,%r15
add    $0x8,%rdi
call   1030 <get32l@plt>
movslq %eax,%r13
add    %r15,%r13
add    $0xc,%r15
mov    %r15,%rdi
call   1030 <get32l@plt>
add    %eax,%eax
lea    (%rax,%rax,8),%eax
movslq %eax,%rbp
add    %r13,%rbp
add    $0x4,%rbx
mov    %rbx,%rdi
call   1030 <get32l@plt>
movslq %eax,%rdi
add    %rbp,%rdi
xor    %eax,%eax
cmp    $0x2,%r12b
cmove  %rax,%r14
mov    %r14,%rsi
call   1040 <symbolconv0@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.LABELSTR = type { i32 }
%struct.OBJFILESTR = type { i32 }
define %struct.LABELSTR* @symbolconv(i8* %0, i8* %1, %struct.OBJFILESTR* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca %struct.OBJFILESTR*
%7 = alloca [12 x i8]
%8 = alloca i8*
%9 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store %struct.OBJFILESTR* %2, %struct.OBJFILESTR** %6
%10 = load i8*, i8** %5
%11 = getelementptr inbounds i8, i8* %10, i64 16
%12 = load i8, i8* %11
%13 = zext i8 %12 to i32
%14 = icmp eq i32 %13, 2
br i1 %14, label %15, label %16
15: ; preds = %3
store %struct.OBJFILESTR* null, %struct.OBJFILESTR** %6
br label %16
16: ; preds = %15, %3
%17 = load i8*, i8** %5
%18 = getelementptr inbounds i8, i8* %17, i64 0
%19 = load i8, i8* %18
%20 = zext i8 %19 to i32
%21 = load i8*, i8** %5
%22 = getelementptr inbounds i8, i8* %21, i64 1
%23 = load i8, i8* %22
%24 = zext i8 %23 to i32
%25 = or i32 %20, %24
%26 = load i8*, i8** %5
%27 = getelementptr inbounds i8, i8* %26, i64 2
%28 = load i8, i8* %27
%29 = zext i8 %28 to i32
%30 = or i32 %25, %29
%31 = load i8*, i8** %5
%32 = getelementptr inbounds i8, i8* %31, i64 3
%33 = load i8, i8* %32
%34 = zext i8 %33 to i32
%35 = or i32 %30, %34
%36 = icmp ne i32 %35, 0
br i1 %36, label %37, label %56
37: ; preds = %16
store i32 0, i32* %9
br label %38
38: ; preds = %50, %37
%39 = load i32, i32* %9
%40 = icmp slt i32 %39, 8
br i1 %40, label %41, label %53
41: ; preds = %38
%42 = load i8*, i8** %5
%43 = load i32, i32* %9
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds i8, i8* %42, i64 %44
%46 = load i8, i8* %45
%47 = load i32, i32* %9
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds [12 x i8], [12 x i8]* %7, i64 0, i64 %48
store i8 %46, i8* %49
br label %50
50: ; preds = %41
%51 = load i32, i32* %9
%52 = add nsw i32 %51, 1
store i32 %52, i32* %9
br label %38
53: ; preds = %38
%54 = getelementptr inbounds [12 x i8], [12 x i8]* %7, i64 0, i64 8
store i8 0, i8* %54
%55 = getelementptr inbounds [12 x i8], [12 x i8]* %7, i64 0, i64 0
store i8* %55, i8** %8
br label %74
56: ; preds = %16
%57 = load i8*, i8** %4
%58 = load i8*, i8** %4
%59 = getelementptr inbounds i8, i8* %58, i64 8
%60 = call i32 @get32l(i8* %59)
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds i8, i8* %57, i64 %61
%63 = load i8*, i8** %4
%64 = getelementptr inbounds i8, i8* %63, i64 12
%65 = call i32 @get32l(i8* %64)
%66 = mul nsw i32 %65, 18
%67 = sext i32 %66 to i64
%68 = getelementptr inbounds i8, i8* %62, i64 %67
%69 = load i8*, i8** %5
%70 = getelementptr inbounds i8, i8* %69, i64 4
%71 = call i32 @get32l(i8* %70)
%72 = sext i32 %71 to i64
%73 = getelementptr inbounds i8, i8* %68, i64 %72
store i8* %73, i8** %8
br label %74
74: ; preds = %56, %53
%75 = load i8*, i8** %8
%76 = load %struct.OBJFILESTR*, %struct.OBJFILESTR** %6
%77 = call %struct.LABELSTR* @symbolconv0(i8* %75, %struct.OBJFILESTR* %76)
ret %struct.LABELSTR* %77
}

LLVM IR (-O2):
%struct.LABELSTR = type { i32 }
%struct.OBJFILESTR = type { i32 }
define %struct.LABELSTR* @symbolconv(i8* %0, i8* %1, %struct.OBJFILESTR* %2) {
%4 = alloca [12 x i8]
%5 = getelementptr inbounds [12 x i8], [12 x i8]* %4, i64 0, i64 0
%6 = getelementptr inbounds i8, i8* %1, i64 16
%7 = load i8, i8* %6
%8 = bitcast i8* %1 to <4 x i8>*
%9 = load <4 x i8>, <4 x i8>* %8
%10 = call i8 @llvm.vector.reduce.or.v4i8(<4 x i8> %9)
%11 = icmp eq i8 %10, 0
br i1 %11, label %17, label %12
12: ; preds = %3
%13 = bitcast i8* %1 to i64*
%14 = bitcast [12 x i8]* %4 to i64*
%15 = load i64, i64* %13
store i64 %15, i64* %14
%16 = getelementptr inbounds [12 x i8], [12 x i8]* %4, i64 0, i64 8
store i8 0, i8* %16
br label %31
17: ; preds = %3
%18 = getelementptr inbounds i8, i8* %0, i64 8
%19 = tail call i32 @get32l(i8* %18)
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8, i8* %0, i64 %20
%22 = getelementptr inbounds i8, i8* %0, i64 12
%23 = tail call i32 @get32l(i8* %22)
%24 = mul nsw i32 %23, 18
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %21, i64 %25
%27 = getelementptr inbounds i8, i8* %1, i64 4
%28 = tail call i32 @get32l(i8* %27)
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8, i8* %26, i64 %29
br label %31
31: ; preds = %17, %12
%32 = phi i8* [ %5, %12 ], [ %30, %17 ]
%33 = icmp eq i8 %7, 2
%34 = select i1 %33, %struct.OBJFILESTR* null, %struct.OBJFILESTR* %2
%35 = call %struct.LABELSTR* @symbolconv0(i8* %32, %struct.OBJFILESTR* %34)
ret %struct.LABELSTR* %35
}