#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 int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, int, ...);
int read_integer(int /*<<< orphan*/ *, int *);
int read_mappings(FILE *fptr) {
  int tot_ele;
  int cur_ele;
  int ret;
  ret = read_integer(fptr, &tot_ele);
  if (ret >= 0)
    printf("MAP LIST: %d elements\n", tot_ele);
  cur_ele = 1;
  while ((cur_ele <= tot_ele) && (ret >= 0)) {
    int ovl_ino;
    int dev;
    int ino;
    ret = read_integer(fptr, &dev);
    if (ret >= 0) {
      ret = read_integer(fptr, &ino);
      if (ret >= 0) {
        ret = read_integer(fptr, &ovl_ino);
        if (ret >= 0) {
          printf("\tDEVICE %d  INODE %d:  OVL INO %d\n", dev, ino, ovl_ino);
        }
      }
    }
    cur_ele++;
  }
  return ret;
}


x86 assembly (clang, -O0):
<read_mappings>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <read_integer@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jl     1157 <read_mappings+0x37>
mov    -0xc(%rbp),%esi
lea    0xeb0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x10(%rbp)
mov    -0x10(%rbp),%ecx
xor    %eax,%eax
cmp    -0xc(%rbp),%ecx
mov    %al,-0x21(%rbp)
jg     1179 <read_mappings+0x59>
cmpl   $0x0,-0x14(%rbp)
setge  %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    1189 <read_mappings+0x69>
jmp    1206 <read_mappings+0xe6>
mov    -0x8(%rbp),%rdi
lea    -0x1c(%rbp),%rsi
call   1040 <read_integer@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jl     11f8 <read_mappings+0xd8>
mov    -0x8(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1040 <read_integer@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jl     11f3 <read_mappings+0xd3>
mov    -0x8(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1040 <read_integer@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jl     11ee <read_mappings+0xce>
mov    -0x1c(%rbp),%esi
mov    -0x20(%rbp),%edx
mov    -0x18(%rbp),%ecx
lea    0xe30(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11f3 <read_mappings+0xd3>
jmp    11f8 <read_mappings+0xd8>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    115e <read_mappings+0x3e>
mov    -0x14(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_mappings>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%rbx
lea    0x8(%rsp),%rsi
call   1040 <read_integer@plt>
mov    %eax,%ebp
test   %eax,%eax
js     11d8 <read_mappings+0xb8>
mov    0x8(%rsp),%esi
lea    0xeb0(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
cmpl   $0x0,0x8(%rsp)
jle    11d8 <read_mappings+0xb8>
test   %ebp,%ebp
js     11d8 <read_mappings+0xb8>
lea    0x10(%rsp),%r14
lea    0xc(%rsp),%r15
lea    0x14(%rsp),%r12
xor    %r13d,%r13d
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <read_integer@plt>
test   %eax,%eax
js     11d6 <read_mappings+0xb6>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <read_integer@plt>
test   %eax,%eax
js     11d6 <read_mappings+0xb6>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1040 <read_integer@plt>
mov    %eax,%ebp
test   %eax,%eax
js     11d8 <read_mappings+0xb8>
mov    0x10(%rsp),%esi
mov    0xc(%rsp),%edx
mov    0x14(%rsp),%ecx
lea    0xe55(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x1,%r13d
cmp    0x8(%rsp),%r13d
jl     1180 <read_mappings+0x60>
jmp    11d8 <read_mappings+0xb8>
mov    %eax,%ebp
mov    %ebp,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [23 x i8] c"MAP LIST: %d elements\0A\00"
@.str.1 = [35 x i8] c"\09DEVICE %d INODE %d: OVL INO %d\0A\00"
define i32 @read_mappings(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32* %0, i32** %2
%9 = load i32*, i32** %2
%10 = call i32 @read_integer(i32* %9, i32* %3)
store i32 %10, i32* %5
%11 = load i32, i32* %5
%12 = icmp sge i32 %11, 0
br i1 %12, label %13, label %16
13: ; preds = %1
%14 = load i32, i32* %3
%15 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %14)
br label %16
16: ; preds = %13, %1
store i32 1, i32* %4
br label %17
17: ; preds = %48, %16
%18 = load i32, i32* %4
%19 = load i32, i32* %3
%20 = icmp sle i32 %18, %19
br i1 %20, label %21, label %24
21: ; preds = %17
%22 = load i32, i32* %5
%23 = icmp sge i32 %22, 0
br label %24
24: ; preds = %21, %17
%25 = phi i1 [ false, %17 ], [ %23, %21 ]
br i1 %25, label %26, label %51
26: ; preds = %24
%27 = load i32*, i32** %2
%28 = call i32 @read_integer(i32* %27, i32* %7)
store i32 %28, i32* %5
%29 = load i32, i32* %5
%30 = icmp sge i32 %29, 0
br i1 %30, label %31, label %48
31: ; preds = %26
%32 = load i32*, i32** %2
%33 = call i32 @read_integer(i32* %32, i32* %8)
store i32 %33, i32* %5
%34 = load i32, i32* %5
%35 = icmp sge i32 %34, 0
br i1 %35, label %36, label %47
36: ; preds = %31
%37 = load i32*, i32** %2
%38 = call i32 @read_integer(i32* %37, i32* %6)
store i32 %38, i32* %5
%39 = load i32, i32* %5
%40 = icmp sge i32 %39, 0
br i1 %40, label %41, label %46
41: ; preds = %36
%42 = load i32, i32* %7
%43 = load i32, i32* %8
%44 = load i32, i32* %6
%45 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), i32 %42, i32 %43, i32 %44)
br label %46
46: ; preds = %41, %36
br label %47
47: ; preds = %46, %31
br label %48
48: ; preds = %47, %26
%49 = load i32, i32* %4
%50 = add nsw i32 %49, 1
store i32 %50, i32* %4
br label %17
51: ; preds = %24
%52 = load i32, i32* %5
ret i32 %52
}

LLVM IR (-O2):
@.str = [23 x i8] c"MAP LIST: %d elements\0A\00"
@.str.1 = [35 x i8] c"\09DEVICE %d INODE %d: OVL INO %d\0A\00"
define i32 @read_mappings(i32* %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = bitcast i32* %2 to i8*
%7 = call i32 @read_integer(i32* %0, i32* %2)
%8 = icmp sgt i32 %7, -1
br i1 %8, label %9, label %39
9: ; preds = %1
%10 = load i32, i32* %2
%11 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %10)
%12 = load i32, i32* %2
%13 = icmp sgt i32 %12, 0
%14 = select i1 %13, i1 %8, i1 false
br i1 %14, label %15, label %39
15: ; preds = %9
%16 = bitcast i32* %3 to i8*
%17 = bitcast i32* %4 to i8*
%18 = bitcast i32* %5 to i8*
br label %19
19: ; preds = %15, %31
%20 = phi i32 [ 1, %15 ], [ %36, %31 ]
%21 = call i32 @read_integer(i32* %0, i32* %4)
%22 = icmp sgt i32 %21, -1
br i1 %22, label %23, label %29
23: ; preds = %19
%24 = call i32 @read_integer(i32* %0, i32* %5)
%25 = icmp sgt i32 %24, -1
br i1 %25, label %26, label %29
26: ; preds = %23
%27 = call i32 @read_integer(i32* %0, i32* %3)
%28 = icmp sgt i32 %27, -1
br i1 %28, label %31, label %29
29: ; preds = %26, %23, %19
%30 = phi i32 [ %21, %19 ], [ %24, %23 ], [ %27, %26 ]
br label %39
31: ; preds = %26
%32 = load i32, i32* %4
%33 = load i32, i32* %5
%34 = load i32, i32* %3
%35 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), i32 %32, i32 %33, i32 %34)
%36 = add nuw nsw i32 %20, 1
%37 = load i32, i32* %2
%38 = icmp slt i32 %20, %37
br i1 %38, label %19, label %39
39: ; preds = %31, %1, %29, %9
%40 = phi i32 [ %7, %9 ], [ %30, %29 ], [ %7, %1 ], [ %27, %31 ]
ret i32 %40
}