#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 */
int /*<<< orphan*/ lineprint3(char *, long, unsigned char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, char *, unsigned char,
                           unsigned long);
void pseudorel(char *outf, long ctr, unsigned char *op, char *str) {
  char buf[256];
  long newadd;
  int offset = (int)*(op + 2);
  if (offset >= 128)
    offset -= 256;
  newadd = (ctr + 3) + offset;
  sprintf(buf, "%-4s $%02X, $%04lX", str, *(op + 1), (unsigned long)newadd);
  lineprint3(outf, ctr, op, buf);
}


x86 assembly (clang, -O0):
<pseudorel>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x18(%rbp),%rax
movzbl 0x2(%rax),%eax
mov    %eax,-0x12c(%rbp)
cmpl   $0x80,-0x12c(%rbp)
jl     116a <pseudorel+0x4a>
mov    -0x12c(%rbp),%eax
sub    $0x100,%eax
mov    %eax,-0x12c(%rbp)
mov    -0x10(%rbp),%rax
add    $0x3,%rax
movslq -0x12c(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x128(%rbp)
lea    -0x120(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    -0x18(%rbp),%rax
mov    0x1(%rax),%al
mov    -0x128(%rbp),%r8
lea    0xe5d(%rip),%rsi
movzbl %al,%ecx
call   1040 <sprintf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
lea    -0x120(%rbp),%rcx
call   1030 <lineprint3@plt>
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pseudorel>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x108,%rsp
mov    %rdx,%rbx
movzbl 0x2(%rdx),%eax
lea    -0x100(%rax),%edx
test   %al,%al
cmovns %eax,%edx
mov    %rsi,%r14
mov    %rdi,%r15
movslq %edx,%rax
lea    (%rsi,%rax,1),%r8
add    $0x3,%r8
movzbl 0x1(%rbx),%eax
lea    0xea4(%rip),%rsi
mov    %rsp,%r12
mov    %r12,%rdi
mov    %rcx,%rdx
mov    %eax,%ecx
call   1040 <sprintf@plt>
mov    %r15,%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
mov    %r12,%rcx
call   1030 <lineprint3@plt>
add    $0x108,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [19 x i8] c"%-4s $%02X, $%04lX\00"
define void @pseudorel(i8* %0, i64 %1, i8* %2, i8* %3) {
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca [256 x i8]
%10 = alloca i64
%11 = alloca i32
store i8* %0, i8** %5
store i64 %1, i64* %6
store i8* %2, i8** %7
store i8* %3, i8** %8
%12 = load i8*, i8** %7
%13 = getelementptr inbounds i8, i8* %12, i64 2
%14 = load i8, i8* %13
%15 = zext i8 %14 to i32
store i32 %15, i32* %11
%16 = load i32, i32* %11
%17 = icmp sge i32 %16, 128
br i1 %17, label %18, label %21
18: ; preds = %4
%19 = load i32, i32* %11
%20 = sub nsw i32 %19, 256
store i32 %20, i32* %11
br label %21
21: ; preds = %18, %4
%22 = load i64, i64* %6
%23 = add nsw i64 %22, 3
%24 = load i32, i32* %11
%25 = sext i32 %24 to i64
%26 = add nsw i64 %23, %25
store i64 %26, i64* %10
%27 = getelementptr inbounds [256 x i8], [256 x i8]* %9, i64 0, i64 0
%28 = load i8*, i8** %8
%29 = load i8*, i8** %7
%30 = getelementptr inbounds i8, i8* %29, i64 1
%31 = load i8, i8* %30
%32 = load i64, i64* %10
%33 = call i32 @sprintf(i8* %27, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* %28, i8 zeroext %31, i64 %32)
%34 = load i8*, i8** %5
%35 = load i64, i64* %6
%36 = load i8*, i8** %7
%37 = getelementptr inbounds [256 x i8], [256 x i8]* %9, i64 0, i64 0
%38 = call i32 @lineprint3(i8* %34, i64 %35, i8* %36, i8* %37)
ret void
}

LLVM IR (-O2):
@.str = [19 x i8] c"%-4s $%02X, $%04lX\00"
define void @pseudorel(i8* %0, i64 %1, i8* %2, i8* %3) {
%5 = alloca [256 x i8]
%6 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%7 = getelementptr inbounds i8, i8* %2, i64 2
%8 = load i8, i8* %7
%9 = zext i8 %8 to i32
%10 = icmp slt i8 %8, 0
%11 = or i32 %9, -256
%12 = select i1 %10, i32 %11, i32 %9
%13 = add nsw i64 %1, 3
%14 = sext i32 %12 to i64
%15 = add nsw i64 %13, %14
%16 = getelementptr inbounds i8, i8* %2, i64 1
%17 = load i8, i8* %16
%18 = call i32 @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* %3, i8 zeroext %17, i64 %15)
%19 = call i32 @lineprint3(i8* %0, i64 %1, i8* %2, i8* %6)
ret void
}