#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*/ snprintf(char *, int, char *, char *, char *, int);
int nut_disassemble_long_branch(int op1, int op2, char *buf, int len) {
  int cond, type, target;
  target = (op1 >> 2) | ((op2 & 0x3fc) << 6);
  cond = op2 & 0x001;
  type = op2 & 0x002;
  snprintf(buf, len, "?%s %s %05o", cond ? "c " : "nc", type ? "goto" : "call",
           target);
  return (2);
}


x86 assembly (clang, -O0):
<nut_disassemble_long_branch>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    -0x4(%rbp),%eax
sar    $0x2,%eax
mov    -0x8(%rbp),%ecx
and    $0x3fc,%ecx
shl    $0x6,%ecx
or     %ecx,%eax
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%eax
and    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%eax
and    $0x2,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
lea    0xeb0(%rip),%rcx
lea    0xea6(%rip),%rax
cmp    $0x0,%edx
cmovne %rax,%rcx
mov    -0x1c(%rbp),%edx
lea    0xea0(%rip),%r8
lea    0xe94(%rip),%rax
cmp    $0x0,%edx
cmovne %rax,%r8
mov    -0x20(%rbp),%r9d
lea    0xe70(%rip),%rdx
call   1030 <snprintf@plt>
mov    $0x2,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nut_disassemble_long_branch>:
push   %rax
mov    %rdx,%r10
sar    $0x2,%edi
mov    %esi,%r9d
shl    $0x6,%r9d
and    $0xff00,%r9d
or     %edi,%r9d
test   $0x1,%sil
lea    0xedc(%rip),%rdx
lea    0xed2(%rip),%rax
cmove  %rdx,%rax
test   $0x2,%sil
lea    0xece(%rip),%rdx
lea    0xec2(%rip),%r8
cmove  %rdx,%r8
lea    0xea5(%rip),%rdx
mov    %r10,%rdi
mov    %ecx,%esi
mov    %rax,%rcx
call   1030 <snprintf@plt>
mov    $0x2,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [12 x i8] c"?%s %s %05o\00"
@.str.1 = [3 x i8] c"c \00"
@.str.2 = [3 x i8] c"nc\00"
@.str.3 = [5 x i8] c"goto\00"
@.str.4 = [5 x i8] c"call\00"
define i32 @nut_disassemble_long_branch(i32 %0, i32 %1, i8* %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i8* %2, i8** %7
store i32 %3, i32* %8
%12 = load i32, i32* %5
%13 = ashr i32 %12, 2
%14 = load i32, i32* %6
%15 = and i32 %14, 1020
%16 = shl i32 %15, 6
%17 = or i32 %13, %16
store i32 %17, i32* %11
%18 = load i32, i32* %6
%19 = and i32 %18, 1
store i32 %19, i32* %9
%20 = load i32, i32* %6
%21 = and i32 %20, 2
store i32 %21, i32* %10
%22 = load i8*, i8** %7
%23 = load i32, i32* %8
%24 = load i32, i32* %9
%25 = icmp ne i32 %24, 0
%26 = zext i1 %25 to i64
%27 = select i1 %25, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0)
%28 = load i32, i32* %10
%29 = icmp ne i32 %28, 0
%30 = zext i1 %29 to i64
%31 = select i1 %29, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0)
%32 = load i32, i32* %11
%33 = call i32 @snprintf(i8* %22, i32 %23, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %27, i8* %31, i32 %32)
ret i32 2
}

LLVM IR (-O2):
@.str = [12 x i8] c"?%s %s %05o\00"
@.str.1 = [3 x i8] c"c \00"
@.str.2 = [3 x i8] c"nc\00"
@.str.3 = [5 x i8] c"goto\00"
@.str.4 = [5 x i8] c"call\00"
define i32 @nut_disassemble_long_branch(i32 %0, i32 %1, i8* %2, i32 %3) {
%5 = ashr i32 %0, 2
%6 = shl i32 %1, 6
%7 = and i32 %6, 65280
%8 = or i32 %7, %5
%9 = and i32 %1, 1
%10 = and i32 %1, 2
%11 = icmp eq i32 %9, 0
%12 = select i1 %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0)
%13 = icmp eq i32 %10, 0
%14 = select i1 %13, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0)
%15 = tail call i32 @snprintf(i8* %2, i32 %3, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %12, i8* %14, i32 %8)
ret i32 2
}