#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 */
typedef scalar_t__ u_int;
typedef int u_char;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
void dump_longlink_mfc(u_char *p, int len) {
  u_int i, n = *p++;
  --len;
  for (i = 0; i < n; i++) {
    if (len < 5) {
      printf("\tWrong length for long link MFC tuple\n");
      return;
    }
    printf("\tFunction %d: %s memory, address 0x%x\n", i,
           (*p ? "common" : "attribute"),
           ((*((p + 1) + 3) << 24) | (*((p + 1) + 2) << 16) |
            (*((p + 1) + 1) << 8) | *(p + 1)));
    p += 5;
    len -= 5;
  }
}


x86 assembly (clang, -O0):
<dump_longlink_mfc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x4,%rcx
mov    %rcx,-0x8(%rbp)
movslq (%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x20(%rbp),%rax
jge    11ed <dump_longlink_mfc+0xdd>
cmpl   $0x5,-0xc(%rbp)
jge    1171 <dump_longlink_mfc+0x61>
lea    0xe9b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11ed <dump_longlink_mfc+0xdd>
mov    -0x18(%rbp),%rsi
mov    -0x8(%rbp),%rax
mov    (%rax),%ecx
lea    0xed3(%rip),%rdx
lea    0xec5(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rdx
mov    -0x8(%rbp),%rax
mov    0x10(%rax),%ecx
shl    $0x18,%ecx
mov    -0x8(%rbp),%rax
mov    0xc(%rax),%eax
shl    $0x10,%eax
or     %eax,%ecx
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%eax
shl    $0x8,%eax
or     %eax,%ecx
mov    -0x8(%rbp),%rax
or     0x4(%rax),%ecx
lea    0xe67(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
add    $0x14,%rax
mov    %rax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
sub    $0x5,%eax
mov    %eax,-0xc(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1146 <dump_longlink_mfc+0x36>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dump_longlink_mfc>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
movslq (%rdi),%r12
test   %r12,%r12
jle    11ae <dump_longlink_mfc+0x8e>
mov    %esi,%r15d
mov    %rdi,%rbx
add    $0xffffffff,%r15d
add    $0x4,%rbx
lea    0xedf(%rip),%r13
lea    0xeb1(%rip),%r14
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
cmp    $0x4,%r15d
jle    11bd <dump_longlink_mfc+0x9d>
cmpl   $0x0,(%rbx)
mov    %r13,%rdx
lea    0xebb(%rip),%rax
cmove  %rax,%rdx
mov    0x10(%rbx),%eax
shl    $0x18,%eax
mov    0x8(%rbx),%ecx
mov    0xc(%rbx),%esi
shl    $0x10,%esi
or     %eax,%esi
shl    $0x8,%ecx
or     %esi,%ecx
or     0x4(%rbx),%ecx
mov    %r14,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0xfffffffb,%r15d
add    $0x1,%rbp
add    $0x14,%rbx
cmp    %rbp,%r12
jne    1160 <dump_longlink_mfc+0x40>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe74(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <puts@plt>

LLVM IR (-O0):
@.str = [39 x i8] c"\09Wrong length for long link MFC tuple\0A\00"
@.str.1 = [39 x i8] c"\09Function %d: %s memory, address 0x%x\0A\00"
@.str.2 = [7 x i8] c"common\00"
@.str.3 = [10 x i8] c"attribute\00"
define void @dump_longlink_mfc(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i64
%6 = alloca i64
store i32* %0, i32** %3
store i32 %1, i32* %4
%7 = load i32*, i32** %3
%8 = getelementptr inbounds i32, i32* %7, i32 1
store i32* %8, i32** %3
%9 = load i32, i32* %7
%10 = sext i32 %9 to i64
store i64 %10, i64* %6
%11 = load i32, i32* %4
%12 = add nsw i32 %11, -1
store i32 %12, i32* %4
store i64 0, i64* %5
br label %13
13: ; preds = %55, %2
%14 = load i64, i64* %5
%15 = load i64, i64* %6
%16 = icmp slt i64 %14, %15
br i1 %16, label %17, label %58
17: ; preds = %13
%18 = load i32, i32* %4
%19 = icmp slt i32 %18, 5
br i1 %19, label %20, label %22
20: ; preds = %17
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0))
br label %58
22: ; preds = %17
%23 = load i64, i64* %5
%24 = load i32*, i32** %3
%25 = load i32, i32* %24
%26 = icmp ne i32 %25, 0
%27 = zext i1 %26 to i64
%28 = select i1 %26, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0)
%29 = load i32*, i32** %3
%30 = getelementptr inbounds i32, i32* %29, i64 1
%31 = getelementptr inbounds i32, i32* %30, i64 3
%32 = load i32, i32* %31
%33 = shl i32 %32, 24
%34 = load i32*, i32** %3
%35 = getelementptr inbounds i32, i32* %34, i64 1
%36 = getelementptr inbounds i32, i32* %35, i64 2
%37 = load i32, i32* %36
%38 = shl i32 %37, 16
%39 = or i32 %33, %38
%40 = load i32*, i32** %3
%41 = getelementptr inbounds i32, i32* %40, i64 1
%42 = getelementptr inbounds i32, i32* %41, i64 1
%43 = load i32, i32* %42
%44 = shl i32 %43, 8
%45 = or i32 %39, %44
%46 = load i32*, i32** %3
%47 = getelementptr inbounds i32, i32* %46, i64 1
%48 = load i32, i32* %47
%49 = or i32 %45, %48
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0), i64 %23, i8* %28, i32 %49)
%51 = load i32*, i32** %3
%52 = getelementptr inbounds i32, i32* %51, i64 5
store i32* %52, i32** %3
%53 = load i32, i32* %4
%54 = sub nsw i32 %53, 5
store i32 %54, i32* %4
br label %55
55: ; preds = %22
%56 = load i64, i64* %5
%57 = add nsw i64 %56, 1
store i64 %57, i64* %5
br label %13
58: ; preds = %20, %13
ret void
}

LLVM IR (-O2):
@.str.1 = [39 x i8] c"\09Function %d: %s memory, address 0x%x\0A\00"
@.str.2 = [7 x i8] c"common\00"
@.str.3 = [10 x i8] c"attribute\00"
@str = [38 x i8] c"\09Wrong length for long link MFC tuple\00"
define void @dump_longlink_mfc(i32* nocapture %0, i32 %1) {
%3 = load i32, i32* %0
%4 = sext i32 %3 to i64
%5 = icmp sgt i32 %3, 0
br i1 %5, label %6, label %39
6: ; preds = %2
%7 = add nsw i32 %1, -1
%8 = getelementptr inbounds i32, i32* %0, i64 1
br label %9
9: ; preds = %6, %16
%10 = phi i32* [ %35, %16 ], [ %8, %6 ]
%11 = phi i64 [ %37, %16 ], [ 0, %6 ]
%12 = phi i32 [ %36, %16 ], [ %7, %6 ]
%13 = icmp slt i32 %12, 5
br i1 %13, label %14, label %16
14: ; preds = %9
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str, i64 0, i64 0))
br label %39
16: ; preds = %9
%17 = load i32, i32* %10
%18 = icmp eq i32 %17, 0
%19 = select i1 %18, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0)
%20 = getelementptr inbounds i32, i32* %10, i64 1
%21 = getelementptr inbounds i32, i32* %10, i64 4
%22 = load i32, i32* %21
%23 = shl i32 %22, 24
%24 = getelementptr inbounds i32, i32* %10, i64 3
%25 = load i32, i32* %24
%26 = shl i32 %25, 16
%27 = or i32 %26, %23
%28 = getelementptr inbounds i32, i32* %10, i64 2
%29 = load i32, i32* %28
%30 = shl i32 %29, 8
%31 = or i32 %27, %30
%32 = load i32, i32* %20
%33 = or i32 %31, %32
%34 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0), i64 %11, i8* %19, i32 %33)
%35 = getelementptr inbounds i32, i32* %10, i64 5
%36 = add nsw i32 %12, -5
%37 = add nuw nsw i64 %11, 1
%38 = icmp eq i64 %37, %4
br i1 %38, label %39, label %9
39: ; preds = %16, %2, %14
ret void
}