getloc(sym) char *sym;
{
  int t;
  t = (sym[12] & 255) + ((sym[12 + 1] & 255) << 8);
  if (sym[12 + 1] & 0x80)
    t = t | 0xffff0000;
  ot("leal");
  tab();
  outdec(t);
  outasm("(%ebp), %eax");
  nl();
}


x86 assembly (clang, -O0):
<getloc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl 0xc(%rax),%eax
and    $0xff,%eax
mov    -0x10(%rbp),%rcx
movsbl 0xd(%rcx),%ecx
and    $0xff,%ecx
shl    $0x8,%ecx
add    %ecx,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
movsbl 0xd(%rax),%eax
and    $0x80,%eax
cmp    $0x0,%eax
je     11a0 <getloc+0x50>
mov    -0x14(%rbp),%eax
or     $0xffff0000,%eax
mov    %eax,-0x14(%rbp)
lea    0xe59(%rip),%rdi
mov    $0x0,%al
call   1060 <ot@plt>
mov    $0x0,%al
call   1070 <tab@plt>
mov    -0x14(%rbp),%edi
mov    $0x0,%al
call   1050 <outdec@plt>
lea    0xe3f(%rip),%rdi
mov    $0x0,%al
call   1040 <outasm@plt>
mov    $0x0,%al
call   1030 <nl@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getloc>:
push   %rbx
movzbl 0xc(%rdi),%eax
movsbl 0xd(%rdi),%ecx
mov    %ecx,%edx
shl    $0x8,%edx
movzwl %dx,%edx
lea    (%rdx,%rax,1),%esi
test   $0x80,%cl
lea    -0x10000(%rdx,%rax,1),%ebx
cmove  %esi,%ebx
lea    0xe88(%rip),%rdi
xor    %eax,%eax
call   1060 <ot@plt>
xor    %eax,%eax
call   1070 <tab@plt>
mov    %ebx,%edi
xor    %eax,%eax
call   1050 <outdec@plt>
lea    0xe6f(%rip),%rdi
xor    %eax,%eax
call   1040 <outasm@plt>
xor    %eax,%eax
pop    %rbx
jmp    1030 <nl@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"leal\00"
@.str.1 = [13 x i8] c"(%ebp), %eax\00"
define i32 @getloc(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = getelementptr inbounds i8, i8* %5, i64 12
%7 = load i8, i8* %6
%8 = sext i8 %7 to i32
%9 = and i32 %8, 255
%10 = load i8*, i8** %3
%11 = getelementptr inbounds i8, i8* %10, i64 13
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = and i32 %13, 255
%15 = shl i32 %14, 8
%16 = add nsw i32 %9, %15
store i32 %16, i32* %4
%17 = load i8*, i8** %3
%18 = getelementptr inbounds i8, i8* %17, i64 13
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = and i32 %20, 128
%22 = icmp ne i32 %21, 0
br i1 %22, label %23, label %26
23: ; preds = %1
%24 = load i32, i32* %4
%25 = or i32 %24, -65536
store i32 %25, i32* %4
br label %26
26: ; preds = %23, %1
%27 = call i32 (i8*, ...) bitcast (i32 (...)* @ot to i32 (i8*, ...)*)(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%28 = call i32 (...) @tab()
%29 = load i32, i32* %4
%30 = call i32 (i32, ...) bitcast (i32 (...)* @outdec to i32 (i32, ...)*)(i32 %29)
%31 = call i32 (i8*, ...) bitcast (i32 (...)* @outasm to i32 (i8*, ...)*)(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
%32 = call i32 (...) @nl()
%33 = load i32, i32* %2
ret i32 %33
}

LLVM IR (-O2):
@.str = [5 x i8] c"leal\00"
@.str.1 = [13 x i8] c"(%ebp), %eax\00"
define i32 @getloc(i8* nocapture %0) {
%2 = getelementptr inbounds i8, i8* %0, i64 12
%3 = load i8, i8* %2
%4 = zext i8 %3 to i32
%5 = getelementptr inbounds i8, i8* %0, i64 13
%6 = load i8, i8* %5
%7 = sext i8 %6 to i32
%8 = shl nsw i32 %7, 8
%9 = and i32 %8, 65280
%10 = or i32 %9, %4
%11 = and i32 %7, 128
%12 = icmp eq i32 %11, 0
%13 = or i32 %10, -65536
%14 = select i1 %12, i32 %10, i32 %13
%15 = tail call i32 (i8*, ...) bitcast (i32 (...)* @ot to i32 (i8*, ...)*)(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%16 = tail call i32 (...) @tab()
%17 = tail call i32 (i32, ...) bitcast (i32 (...)* @outdec to i32 (i32, ...)*)(i32 %14)
%18 = tail call i32 (i8*, ...) bitcast (i32 (...)* @outasm to i32 (i8*, ...)*)(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
%19 = tail call i32 (...) @nl()
ret i32 undef
}