#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*/ exit(int);
int obtener_indice(unsigned int nblogico, int nivel_punteros) {
  if (nblogico < 12)
    return nblogico;
  else if (nblogico < ((int)(1024 / sizeof(unsigned int)) + 12))
    return (nblogico - 12);
  else if (nblogico < ((int)(1024 / sizeof(unsigned int)) *
                           (int)(1024 / sizeof(unsigned int)) +
                       ((int)(1024 / sizeof(unsigned int)) + 12))) {
    if (nivel_punteros == 2) {
      return (nblogico - ((int)(1024 / sizeof(unsigned int)) + 12)) /
             (int)(1024 / sizeof(unsigned int));
    } else if (nivel_punteros == 1) {
      return (nblogico - ((int)(1024 / sizeof(unsigned int)) + 12)) %
             (int)(1024 / sizeof(unsigned int));
    }
  } else if (nblogico < ((int)(1024 / sizeof(unsigned int)) *
                             (int)(1024 / sizeof(unsigned int)) *
                             (int)(1024 / sizeof(unsigned int)) +
                         ((int)(1024 / sizeof(unsigned int)) *
                              (int)(1024 / sizeof(unsigned int)) +
                          ((int)(1024 / sizeof(unsigned int)) + 12)))) {
    if (nivel_punteros == 3) {
      return (nblogico - ((int)(1024 / sizeof(unsigned int)) *
                              (int)(1024 / sizeof(unsigned int)) +
                          ((int)(1024 / sizeof(unsigned int)) + 12))) /
             ((int)(1024 / sizeof(unsigned int)) *
              (int)(1024 / sizeof(unsigned int)));
    } else if (nivel_punteros == 2) {
      return ((nblogico - ((int)(1024 / sizeof(unsigned int)) *
                               (int)(1024 / sizeof(unsigned int)) +
                           ((int)(1024 / sizeof(unsigned int)) + 12))) %
              ((int)(1024 / sizeof(unsigned int)) *
               (int)(1024 / sizeof(unsigned int)))) /
             (int)(1024 / sizeof(unsigned int));
    } else if (nivel_punteros == 1) {
      return ((nblogico - ((int)(1024 / sizeof(unsigned int)) *
                               (int)(1024 / sizeof(unsigned int)) +
                           ((int)(1024 / sizeof(unsigned int)) + 12))) %
              ((int)(1024 / sizeof(unsigned int)) *
               (int)(1024 / sizeof(unsigned int)))) %
             (int)(1024 / sizeof(unsigned int));
    }
  }
  exit(-1);
}


x86 assembly (clang, -O0):
<obtener_indice>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cmpl   $0xc,-0x8(%rbp)
jae    1133 <obtener_indice+0x23>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1239 <obtener_indice+0x129>
cmpl   $0x10c,-0x8(%rbp)
jae    114e <obtener_indice+0x3e>
mov    -0x8(%rbp),%eax
sub    $0xc,%eax
mov    %eax,-0x4(%rbp)
jmp    1239 <obtener_indice+0x129>
cmpl   $0x1010c,-0x8(%rbp)
jae    11a1 <obtener_indice+0x91>
cmpl   $0x2,-0xc(%rbp)
jne    1178 <obtener_indice+0x68>
mov    -0x8(%rbp),%eax
sub    $0x10c,%eax
shr    $0x8,%eax
mov    %eax,-0x4(%rbp)
jmp    1239 <obtener_indice+0x129>
cmpl   $0x1,-0xc(%rbp)
jne    1197 <obtener_indice+0x87>
mov    -0x8(%rbp),%eax
sub    $0x10c,%eax
and    $0xff,%eax
mov    %eax,-0x4(%rbp)
jmp    1239 <obtener_indice+0x129>
jmp    119c <obtener_indice+0x8c>
jmp    1225 <obtener_indice+0x115>
cmpl   $0x101010c,-0x8(%rbp)
jae    1220 <obtener_indice+0x110>
cmpl   $0x3,-0xc(%rbp)
jne    11cb <obtener_indice+0xbb>
mov    -0x8(%rbp),%eax
sub    $0x1010c,%eax
shr    $0x10,%eax
mov    %eax,-0x4(%rbp)
jmp    1239 <obtener_indice+0x129>
cmpl   $0x2,-0xc(%rbp)
jne    11ed <obtener_indice+0xdd>
mov    -0x8(%rbp),%eax
sub    $0x1010c,%eax
and    $0xffff,%eax
shr    $0x8,%eax
mov    %eax,-0x4(%rbp)
jmp    1239 <obtener_indice+0x129>
cmpl   $0x1,-0xc(%rbp)
jne    1211 <obtener_indice+0x101>
mov    -0x8(%rbp),%eax
sub    $0x1010c,%eax
and    $0xffff,%eax
and    $0xff,%eax
mov    %eax,-0x4(%rbp)
jmp    1239 <obtener_indice+0x129>
jmp    1216 <obtener_indice+0x106>
jmp    121b <obtener_indice+0x10b>
jmp    1220 <obtener_indice+0x110>
jmp    1225 <obtener_indice+0x115>
jmp    122a <obtener_indice+0x11a>
jmp    122f <obtener_indice+0x11f>
mov    $0xffffffff,%edi
call   1030 <exit@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<obtener_indice>:
mov    %edi,%eax
cmp    $0xc,%edi
jae    1118 <obtener_indice+0x8>
ret
cmp    $0x10b,%eax
ja     1123 <obtener_indice+0x13>
add    $0xfffffff4,%eax
ret
cmp    $0x1010b,%eax
ja     113d <obtener_indice+0x2d>
cmp    $0x1,%esi
je     115c <obtener_indice+0x4c>
cmp    $0x2,%esi
jne    116e <obtener_indice+0x5e>
add    $0xfffffef4,%eax
shr    $0x8,%eax
ret
cmp    $0x101010b,%eax
ja     116e <obtener_indice+0x5e>
cmp    $0x1,%esi
je     115c <obtener_indice+0x4c>
cmp    $0x2,%esi
je     1165 <obtener_indice+0x55>
cmp    $0x3,%esi
jne    116e <obtener_indice+0x5e>
add    $0xfffefef4,%eax
shr    $0x10,%eax
ret
add    $0xf4,%eax
movzbl %al,%eax
ret
add    $0xfef4,%eax
movzbl %ah,%eax
ret
push   %rax
mov    $0xffffffff,%edi
call   1030 <exit@plt>

LLVM IR (-O0):
define i32 @obtener_indice(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
%6 = load i32, i32* %4
%7 = icmp ult i32 %6, 12
br i1 %7, label %8, label %10
8: ; preds = %2
%9 = load i32, i32* %4
store i32 %9, i32* %3
br label %69
10: ; preds = %2
%11 = load i32, i32* %4
%12 = icmp ult i32 %11, 268
br i1 %12, label %13, label %16
13: ; preds = %10
%14 = load i32, i32* %4
%15 = sub i32 %14, 12
store i32 %15, i32* %3
br label %69
16: ; preds = %10
%17 = load i32, i32* %4
%18 = icmp ult i32 %17, 65804
br i1 %18, label %19, label %35
19: ; preds = %16
%20 = load i32, i32* %5
%21 = icmp eq i32 %20, 2
br i1 %21, label %22, label %26
22: ; preds = %19
%23 = load i32, i32* %4
%24 = sub i32 %23, 268
%25 = udiv i32 %24, 256
store i32 %25, i32* %3
br label %69
26: ; preds = %19
%27 = load i32, i32* %5
%28 = icmp eq i32 %27, 1
br i1 %28, label %29, label %33
29: ; preds = %26
%30 = load i32, i32* %4
%31 = sub i32 %30, 268
%32 = urem i32 %31, 256
store i32 %32, i32* %3
br label %69
33: ; preds = %26
br label %34
34: ; preds = %33
br label %65
35: ; preds = %16
%36 = load i32, i32* %4
%37 = icmp ult i32 %36, 16843020
br i1 %37, label %38, label %64
38: ; preds = %35
%39 = load i32, i32* %5
%40 = icmp eq i32 %39, 3
br i1 %40, label %41, label %45
41: ; preds = %38
%42 = load i32, i32* %4
%43 = sub i32 %42, 65804
%44 = udiv i32 %43, 65536
store i32 %44, i32* %3
br label %69
45: ; preds = %38
%46 = load i32, i32* %5
%47 = icmp eq i32 %46, 2
br i1 %47, label %48, label %53
48: ; preds = %45
%49 = load i32, i32* %4
%50 = sub i32 %49, 65804
%51 = urem i32 %50, 65536
%52 = udiv i32 %51, 256
store i32 %52, i32* %3
br label %69
53: ; preds = %45
%54 = load i32, i32* %5
%55 = icmp eq i32 %54, 1
br i1 %55, label %56, label %61
56: ; preds = %53
%57 = load i32, i32* %4
%58 = sub i32 %57, 65804
%59 = urem i32 %58, 65536
%60 = urem i32 %59, 256
store i32 %60, i32* %3
br label %69
61: ; preds = %53
br label %62
62: ; preds = %61
br label %63
63: ; preds = %62
br label %64
64: ; preds = %63, %35
br label %65
65: ; preds = %64, %34
br label %66
66: ; preds = %65
br label %67
67: ; preds = %66
%68 = call i32 @exit(i32 -1)
unreachable
69: ; preds = %56, %48, %41, %29, %22, %13, %8
%70 = load i32, i32* %3
ret i32 %70
}

LLVM IR (-O2):
define i32 @obtener_indice(i32 %0, i32 %1) {
%3 = icmp ult i32 %0, 12
br i1 %3, label %32, label %4
4: ; preds = %2
%5 = icmp ult i32 %0, 268
br i1 %5, label %6, label %8
6: ; preds = %4
%7 = add nsw i32 %0, -12
br label %32
8: ; preds = %4
%9 = icmp ult i32 %0, 65804
br i1 %9, label %10, label %17
10: ; preds = %8
switch i32 %1, label %30 [
i32 2, label %11
i32 1, label %14
]
11: ; preds = %10
%12 = add nsw i32 %0, -268
%13 = lshr i32 %12, 8
br label %32
14: ; preds = %10
%15 = add nuw nsw i32 %0, 244
%16 = and i32 %15, 255
br label %32
17: ; preds = %8
%18 = icmp ult i32 %0, 16843020
br i1 %18, label %19, label %30
19: ; preds = %17
switch i32 %1, label %30 [
i32 3, label %20
i32 2, label %23
i32 1, label %27
]
20: ; preds = %19
%21 = add nsw i32 %0, -65804
%22 = lshr i32 %21, 16
br label %32
23: ; preds = %19
%24 = add nuw nsw i32 %0, 65268
%25 = lshr i32 %24, 8
%26 = and i32 %25, 255
br label %32
27: ; preds = %19
%28 = add nuw nsw i32 %0, 244
%29 = and i32 %28, 255
br label %32
30: ; preds = %19, %10, %17
%31 = tail call i32 @exit(i32 -1)
unreachable
32: ; preds = %2, %27, %23, %20, %14, %11, %6
%33 = phi i32 [ %7, %6 ], [ %13, %11 ], [ %16, %14 ], [ %22, %20 ], [ %26, %23 ], [ %29, %27 ], [ %0, %2 ]
ret i32 %33
}