#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*/ error_abort();
int /*<<< orphan*/ error_report();
int /*<<< orphan*/ error_signal(char *, int, char *, int, int, int);
int edg_get(int md, int i, int x, const int *hx, const int *hy) {
  int d;
  i *= md;
  d = 0;
  while (hx[i] != x) {
    i++;
    d++;
    if (d >= md)
      do {
        error_signal("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                     "outputs/2022-01-22/02-19-57/repos/slitvinov/uDeviceX/"
                     "refs/heads/master/src/algo/edg/imp/main.h",
                     28, "invalid edg_get call: %d/%d/%d", md, i, x);
        error_report();
        error_abort();
      } while (0);
  }
  return hy[i];
}


x86 assembly (clang, -O0):
<edg_get>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
mov    -0x4(%rbp),%eax
imul   -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x8(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
cmp    -0xc(%rbp),%eax
je     11cc <edg_get+0x9c>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x4(%rbp),%eax
jl     11c7 <edg_get+0x97>
jmp    1191 <edg_get+0x61>
mov    -0x4(%rbp),%ecx
mov    -0x8(%rbp),%r8d
mov    -0xc(%rbp),%r9d
lea    0xe5d(%rip),%rdi
mov    $0x1c,%esi
lea    0xee8(%rip),%rdx
call   1040 <error_signal@plt>
mov    $0x0,%al
call   1030 <error_report@plt>
mov    $0x0,%al
call   1050 <error_abort@plt>
jmp    11c7 <edg_get+0x97>
jmp    115a <edg_get+0x2a>
mov    -0x20(%rbp),%rax
movslq -0x8(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<edg_get>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8,(%rsp)
mov    %esi,%r15d
imul   %edi,%r15d
movslq %r15d,%r13
cmp    %edx,(%rcx,%r13,4)
jne    1168 <edg_get+0x38>
mov    %r13,%rax
mov    (%rsp),%rcx
mov    (%rcx,%rax,4),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %rcx,%r12
mov    %edx,%ebp
mov    %edi,%ebx
mov    $0x1,%r14d
jmp    1192 <edg_get+0x62>
nopw   0x0(%rax,%rax,1)
add    $0x1,%r14d
lea    0x1(%r13),%rax
cmp    %ebp,0x4(%r12,%r13,4)
mov    %rax,%r13
je     1152 <edg_get+0x22>
cmp    %ebx,%r14d
jl     1180 <edg_get+0x50>
lea    (%r15,%r14,1),%r8d
lea    0xe5e(%rip),%rdi
mov    $0x1c,%esi
lea    0xee9(%rip),%rdx
mov    %ebx,%ecx
mov    %ebp,%r9d
call   1040 <error_signal@plt>
xor    %eax,%eax
call   1030 <error_report@plt>
xor    %eax,%eax
call   1050 <error_abort@plt>
jmp    1180 <edg_get+0x50>

LLVM IR (-O0):
@.str = [151 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/slitvinov/uDeviceX/refs/heads/master/src/algo/edg/imp/main.h\00"
@.str.1 = [31 x i8] c"invalid edg_get call: %d/%d/%d\00"
define i32 @edg_get(i32 %0, i32 %1, i32 %2, i32* %3, i32* %4) {
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32*
%10 = alloca i32*
%11 = alloca i32
store i32 %0, i32* %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32* %3, i32** %9
store i32* %4, i32** %10
%12 = load i32, i32* %6
%13 = load i32, i32* %7
%14 = mul nsw i32 %13, %12
store i32 %14, i32* %7
store i32 0, i32* %11
br label %15
15: ; preds = %40, %5
%16 = load i32*, i32** %9
%17 = load i32, i32* %7
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i32, i32* %16, i64 %18
%20 = load i32, i32* %19
%21 = load i32, i32* %8
%22 = icmp ne i32 %20, %21
br i1 %22, label %23, label %41
23: ; preds = %15
%24 = load i32, i32* %7
%25 = add nsw i32 %24, 1
store i32 %25, i32* %7
%26 = load i32, i32* %11
%27 = add nsw i32 %26, 1
store i32 %27, i32* %11
%28 = load i32, i32* %11
%29 = load i32, i32* %6
%30 = icmp sge i32 %28, %29
br i1 %30, label %31, label %40
31: ; preds = %23
br label %32
32: ; preds = %31
%33 = load i32, i32* %6
%34 = load i32, i32* %7
%35 = load i32, i32* %8
%36 = call i32 @error_signal(i8* getelementptr inbounds ([151 x i8], [151 x i8]* @.str, i64 0, i64 0), i32 28, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i32 %33, i32 %34, i32 %35)
%37 = call i32 (...) @error_report()
%38 = call i32 (...) @error_abort()
br label %39
39: ; preds = %32
br label %40
40: ; preds = %39, %23
br label %15
41: ; preds = %15
%42 = load i32*, i32** %10
%43 = load i32, i32* %7
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds i32, i32* %42, i64 %44
%46 = load i32, i32* %45
ret i32 %46
}

LLVM IR (-O2):
@.str = [151 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/slitvinov/uDeviceX/refs/heads/master/src/algo/edg/imp/main.h\00"
@.str.1 = [31 x i8] c"invalid edg_get call: %d/%d/%d\00"
define i32 @edg_get(i32 %0, i32 %1, i32 %2, i32* nocapture %3, i32* nocapture %4) {
%6 = mul nsw i32 %1, %0
%7 = sext i32 %6 to i64
%8 = getelementptr inbounds i32, i32* %3, i64 %7
%9 = load i32, i32* %8
%10 = icmp eq i32 %9, %2
br i1 %10, label %26, label %11
11: ; preds = %5, %22
%12 = phi i64 [ %14, %22 ], [ %7, %5 ]
%13 = phi i32 [ %15, %22 ], [ 0, %5 ]
%14 = add i64 %12, 1
%15 = add nuw nsw i32 %13, 1
%16 = icmp slt i32 %15, %0
br i1 %16, label %22, label %17
17: ; preds = %11
%18 = trunc i64 %14 to i32
%19 = tail call i32 @error_signal(i8* getelementptr inbounds ([151 x i8], [151 x i8]* @.str, i64 0, i64 0), i32 28, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i32 %0, i32 %18, i32 %2)
%20 = tail call i32 (...) @error_report()
%21 = tail call i32 (...) @error_abort()
br label %22
22: ; preds = %17, %11
%23 = getelementptr inbounds i32, i32* %3, i64 %14
%24 = load i32, i32* %23
%25 = icmp eq i32 %24, %2
br i1 %25, label %26, label %11
26: ; preds = %22, %5
%27 = phi i64 [ %7, %5 ], [ %14, %22 ]
%28 = getelementptr inbounds i32, i32* %4, i64 %27
%29 = load i32, i32* %28
ret i32 %29
}