#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 */
typedef struct TYPE_2__ TYPE_1__;

/* Type definitions */
struct fiemap {
  int fm_mapped_extents;
  TYPE_1__ *fm_extents;
};
struct TYPE_2__ {
  int fe_logical;
  int fe_physical;
  int fe_length;
  int /*<<< orphan*/ fe_flags;
};

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
void dump_fiemap(struct fiemap *fiemap, char *filename) {
  int i;
  printf("File %s has %d extents:\n", filename, fiemap->fm_mapped_extents);
  printf("#\tLogical          Physical         Length           Flags\n");
  for (i = 0; i < fiemap->fm_mapped_extents; i++) {
    printf("%d:\t%-16.16llx %-16.16llx %-16.16llx %-4.4x\n", i,
           fiemap->fm_extents[i].fe_logical, fiemap->fm_extents[i].fe_physical,
           fiemap->fm_extents[i].fe_length, fiemap->fm_extents[i].fe_flags);
  }
  printf("\n Now, let's look at them in MB");
  for (i = 0; i < fiemap->fm_mapped_extents; i++) {
    printf("%d:\t%lld MB %lld MB %-16.16lld %-4.4x\n", i,
           fiemap->fm_extents[i].fe_logical >> 20,
           fiemap->fm_extents[i].fe_physical >> 20,
           fiemap->fm_extents[i].fe_length >> 10,
           fiemap->fm_extents[i].fe_flags);
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<dump_fiemap>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
mov    -0x8(%rbp),%rax
mov    (%rax),%edx
lea    0xecf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeda(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    -0x8(%rbp),%rcx
cmp    (%rcx),%eax
jge    11d4 <dump_fiemap+0xc4>
mov    -0x14(%rbp),%esi
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
movslq -0x14(%rbp),%rcx
shl    $0x4,%rcx
add    %rcx,%rax
mov    (%rax),%edx
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
movslq -0x14(%rbp),%rcx
shl    $0x4,%rcx
add    %rcx,%rax
mov    0x4(%rax),%ecx
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
movslq -0x14(%rbp),%rdi
shl    $0x4,%rdi
add    %rdi,%rax
mov    0x8(%rax),%r8d
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
movslq -0x14(%rbp),%rdi
shl    $0x4,%rdi
add    %rdi,%rax
mov    0xc(%rax),%r9d
lea    0xe96(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    114d <dump_fiemap+0x3d>
lea    0xea7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    -0x8(%rbp),%rcx
cmp    (%rcx),%eax
jge    127a <dump_fiemap+0x16a>
mov    -0x14(%rbp),%esi
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
movslq -0x14(%rbp),%rcx
shl    $0x4,%rcx
add    %rcx,%rax
mov    (%rax),%edx
sar    $0x14,%edx
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
movslq -0x14(%rbp),%rcx
shl    $0x4,%rcx
add    %rcx,%rax
mov    0x4(%rax),%ecx
sar    $0x14,%ecx
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
movslq -0x14(%rbp),%rdi
shl    $0x4,%rdi
add    %rdi,%rax
mov    0x8(%rax),%r8d
sar    $0xa,%r8d
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
movslq -0x14(%rbp),%rdi
shl    $0x4,%rdi
add    %rdi,%rax
mov    0xc(%rax),%r9d
lea    0xe3d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11e9 <dump_fiemap+0xd9>
lea    0xd96(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dump_fiemap>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r15
mov    (%rdi),%edx
lea    0xebc(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xf3b(%rip),%rdi
call   1040 <puts@plt>
cmpl   $0x0,(%r15)
jle    11a2 <dump_fiemap+0x72>
mov    $0xc,%ebx
lea    0xeb0(%rip),%r14
xor    %r12d,%r12d
nopl   0x0(%rax)
mov    0x8(%r15),%rax
mov    -0xc(%rax,%rbx,1),%edx
mov    -0x8(%rax,%rbx,1),%ecx
mov    -0x4(%rax,%rbx,1),%r8d
mov    (%rax,%rbx,1),%r9d
mov    %r14,%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%r12
movslq (%r15),%rax
add    $0x10,%rbx
cmp    %rax,%r12
jl     1170 <dump_fiemap+0x40>
lea    0xe9d(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
cmpl   $0x0,(%r15)
jle    120c <dump_fiemap+0xdc>
mov    $0xc,%ebx
lea    0xea4(%rip),%r14
xor    %r12d,%r12d
cs nopw 0x0(%rax,%rax,1)
nop
mov    0x8(%r15),%rax
mov    -0xc(%rax,%rbx,1),%edx
mov    -0x8(%rax,%rbx,1),%ecx
sar    $0x14,%edx
sar    $0x14,%ecx
mov    -0x4(%rax,%rbx,1),%r8d
sar    $0xa,%r8d
mov    (%rax,%rbx,1),%r9d
mov    %r14,%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%r12
movslq (%r15),%rax
add    $0x10,%rbx
cmp    %rax,%r12
jl     11d0 <dump_fiemap+0xa0>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1030 <putchar@plt>

LLVM IR (-O0):
%struct.fiemap = type { i32, %struct.TYPE_2__* }
%struct.TYPE_2__ = type { i32, i32, i32, i32 }
@.str = [25 x i8] c"File %s has %d extents:\0A\00"
@.str.1 = [60 x i8] c"#\09Logical Physical Length Flags\0A\00"
@.str.2 = [45 x i8] c"%d:\09%-16.16llx %-16.16llx %-16.16llx %-4.4x\0A\00"
@.str.3 = [32 x i8] c"\0A Now, let's look at them in MB\00"
@.str.4 = [39 x i8] c"%d:\09%lld MB %lld MB %-16.16lld %-4.4x\0A\00"
@.str.5 = [2 x i8] c"\0A\00"
define void @dump_fiemap(%struct.fiemap* %0, i8* %1) {
%3 = alloca %struct.fiemap*
%4 = alloca i8*
%5 = alloca i32
store %struct.fiemap* %0, %struct.fiemap** %3
store i8* %1, i8** %4
%6 = load i8*, i8** %4
%7 = load %struct.fiemap*, %struct.fiemap** %3
%8 = getelementptr inbounds %struct.fiemap, %struct.fiemap* %7, i32 0, i32 0
%9 = load i32, i32* %8
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %6, i32 %9)
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %5
br label %12
12: ; preds = %53, %2
%13 = load i32, i32* %5
%14 = load %struct.fiemap*, %struct.fiemap** %3
%15 = getelementptr inbounds %struct.fiemap, %struct.fiemap* %14, i32 0, i32 0
%16 = load i32, i32* %15
%17 = icmp slt i32 %13, %16
br i1 %17, label %18, label %56
18: ; preds = %12
%19 = load i32, i32* %5
%20 = load %struct.fiemap*, %struct.fiemap** %3
%21 = getelementptr inbounds %struct.fiemap, %struct.fiemap* %20, i32 0, i32 1
%22 = load %struct.TYPE_2__*, %struct.TYPE_2__** %21
%23 = load i32, i32* %5
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %22, i64 %24
%26 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %25, i32 0, i32 0
%27 = load i32, i32* %26
%28 = load %struct.fiemap*, %struct.fiemap** %3
%29 = getelementptr inbounds %struct.fiemap, %struct.fiemap* %28, i32 0, i32 1
%30 = load %struct.TYPE_2__*, %struct.TYPE_2__** %29
%31 = load i32, i32* %5
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %30, i64 %32
%34 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %33, i32 0, i32 1
%35 = load i32, i32* %34
%36 = load %struct.fiemap*, %struct.fiemap** %3
%37 = getelementptr inbounds %struct.fiemap, %struct.fiemap* %36, i32 0, i32 1
%38 = load %struct.TYPE_2__*, %struct.TYPE_2__** %37
%39 = load i32, i32* %5
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %38, i64 %40
%42 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %41, i32 0, i32 2
%43 = load i32, i32* %42
%44 = load %struct.fiemap*, %struct.fiemap** %3
%45 = getelementptr inbounds %struct.fiemap, %struct.fiemap* %44, i32 0, i32 1
%46 = load %struct.TYPE_2__*, %struct.TYPE_2__** %45
%47 = load i32, i32* %5
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %46, i64 %48
%50 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %49, i32 0, i32 3
%51 = load i32, i32* %50
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.2, i64 0, i64 0), i32 %19, i32 %27, i32 %35, i32 %43, i32 %51)
br label %53
53: ; preds = %18
%54 = load i32, i32* %5
%55 = add nsw i32 %54, 1
store i32 %55, i32* %5
br label %12
56: ; preds = %12
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %5
br label %58
58: ; preds = %102, %56
%59 = load i32, i32* %5
%60 = load %struct.fiemap*, %struct.fiemap** %3
%61 = getelementptr inbounds %struct.fiemap, %struct.fiemap* %60, i32 0, i32 0
%62 = load i32, i32* %61
%63 = icmp slt i32 %59, %62
br i1 %63, label %64, label %105
64: ; preds = %58
%65 = load i32, i32* %5
%66 = load %struct.fiemap*, %struct.fiemap** %3
%67 = getelementptr inbounds %struct.fiemap, %struct.fiemap* %66, i32 0, i32 1
%68 = load %struct.TYPE_2__*, %struct.TYPE_2__** %67
%69 = load i32, i32* %5
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %68, i64 %70
%72 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %71, i32 0, i32 0
%73 = load i32, i32* %72
%74 = ashr i32 %73, 20
%75 = load %struct.fiemap*, %struct.fiemap** %3
%76 = getelementptr inbounds %struct.fiemap, %struct.fiemap* %75, i32 0, i32 1
%77 = load %struct.TYPE_2__*, %struct.TYPE_2__** %76
%78 = load i32, i32* %5
%79 = sext i32 %78 to i64
%80 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %77, i64 %79
%81 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %80, i32 0, i32 1
%82 = load i32, i32* %81
%83 = ashr i32 %82, 20
%84 = load %struct.fiemap*, %struct.fiemap** %3
%85 = getelementptr inbounds %struct.fiemap, %struct.fiemap* %84, i32 0, i32 1
%86 = load %struct.TYPE_2__*, %struct.TYPE_2__** %85
%87 = load i32, i32* %5
%88 = sext i32 %87 to i64
%89 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %86, i64 %88
%90 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %89, i32 0, i32 2
%91 = load i32, i32* %90
%92 = ashr i32 %91, 10
%93 = load %struct.fiemap*, %struct.fiemap** %3
%94 = getelementptr inbounds %struct.fiemap, %struct.fiemap* %93, i32 0, i32 1
%95 = load %struct.TYPE_2__*, %struct.TYPE_2__** %94
%96 = load i32, i32* %5
%97 = sext i32 %96 to i64
%98 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %95, i64 %97
%99 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %98, i32 0, i32 3
%100 = load i32, i32* %99
%101 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.4, i64 0, i64 0), i32 %65, i32 %74, i32 %83, i32 %92, i32 %100)
br label %102
102: ; preds = %64
%103 = load i32, i32* %5
%104 = add nsw i32 %103, 1
store i32 %104, i32* %5
br label %58
105: ; preds = %58
%106 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
%struct.fiemap = type { i32, %struct.TYPE_2__* }
%struct.TYPE_2__ = type { i32, i32, i32, i32 }
@.str = [25 x i8] c"File %s has %d extents:\0A\00"
@.str.2 = [45 x i8] c"%d:\09%-16.16llx %-16.16llx %-16.16llx %-4.4x\0A\00"
@.str.3 = [32 x i8] c"\0A Now, let's look at them in MB\00"
@.str.4 = [39 x i8] c"%d:\09%lld MB %lld MB %-16.16lld %-4.4x\0A\00"
@str = [59 x i8] c"#\09Logical Physical Length Flags\00"
define void @dump_fiemap(%struct.fiemap* nocapture %0, i8* %1) {
%3 = getelementptr inbounds %struct.fiemap, %struct.fiemap* %0, i64 0, i32 0
%4 = load i32, i32* %3
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %1, i32 %4)
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([59 x i8], [59 x i8]* @str, i64 0, i64 0))
%7 = load i32, i32* %3
%8 = icmp sgt i32 %7, 0
br i1 %8, label %9, label %28
9: ; preds = %2
%10 = getelementptr inbounds %struct.fiemap, %struct.fiemap* %0, i64 0, i32 1
br label %11
11: ; preds = %9, %11
%12 = phi i64 [ 0, %9 ], [ %24, %11 ]
%13 = load %struct.TYPE_2__*, %struct.TYPE_2__** %10
%14 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %13, i64 %12, i32 0
%15 = load i32, i32* %14
%16 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %13, i64 %12, i32 1
%17 = load i32, i32* %16
%18 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %13, i64 %12, i32 2
%19 = load i32, i32* %18
%20 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %13, i64 %12, i32 3
%21 = load i32, i32* %20
%22 = trunc i64 %12 to i32
%23 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.2, i64 0, i64 0), i32 %22, i32 %15, i32 %17, i32 %19, i32 %21)
%24 = add nuw nsw i64 %12, 1
%25 = load i32, i32* %3
%26 = sext i32 %25 to i64
%27 = icmp slt i64 %24, %26
br i1 %27, label %11, label %28
28: ; preds = %11, %2
%29 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0))
%30 = load i32, i32* %3
%31 = icmp sgt i32 %30, 0
br i1 %31, label %32, label %54
32: ; preds = %28
%33 = getelementptr inbounds %struct.fiemap, %struct.fiemap* %0, i64 0, i32 1
br label %34
34: ; preds = %32, %34
%35 = phi i64 [ 0, %32 ], [ %50, %34 ]
%36 = load %struct.TYPE_2__*, %struct.TYPE_2__** %33
%37 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %36, i64 %35, i32 0
%38 = load i32, i32* %37
%39 = ashr i32 %38, 20
%40 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %36, i64 %35, i32 1
%41 = load i32, i32* %40
%42 = ashr i32 %41, 20
%43 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %36, i64 %35, i32 2
%44 = load i32, i32* %43
%45 = ashr i32 %44, 10
%46 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %36, i64 %35, i32 3
%47 = load i32, i32* %46
%48 = trunc i64 %35 to i32
%49 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.4, i64 0, i64 0), i32 %48, i32 %39, i32 %42, i32 %45, i32 %47)
%50 = add nuw nsw i64 %35, 1
%51 = load i32, i32* %3
%52 = sext i32 %51 to i64
%53 = icmp slt i64 %50, %52
br i1 %53, label %34, label %54
54: ; preds = %34, %28
%55 = tail call i32 @putchar(i32 10)
ret void
}