#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, int);
void edg_set(int md, int f, int x, int y, int *hx, int *hy) {
  int d, j;
  j = f * md;
  d = 0;
  while (hx[j] != -1) {
    j++;
    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",
                     18, "invalid edg_set call: %d/%d/%d/%d/%d", md, f, x, y,
                     j);
        error_report();
        error_abort();
      } while (0);
  }
  hx[j] = x;
  hy[j] = y;
}


x86 assembly (clang, -O0):
<edg_set>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    %r8,-0x18(%rbp)
mov    %r9,-0x20(%rbp)
mov    -0x8(%rbp),%eax
imul   -0x4(%rbp),%eax
mov    %eax,-0x28(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x28(%rbp),%rcx
cmpl   $0xffffffff,(%rax,%rcx,4)
je     11dc <edg_set+0xac>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x4(%rbp),%eax
jl     11d7 <edg_set+0xa7>
jmp    1192 <edg_set+0x62>
mov    -0x4(%rbp),%ecx
mov    -0x8(%rbp),%r8d
mov    -0xc(%rbp),%r9d
mov    -0x10(%rbp),%r10d
mov    -0x28(%rbp),%eax
lea    0xe55(%rip),%rdi
mov    $0x12,%esi
lea    0xee0(%rip),%rdx
mov    %r10d,(%rsp)
mov    %eax,0x8(%rsp)
call   1040 <error_signal@plt>
mov    $0x0,%al
call   1030 <error_report@plt>
mov    $0x0,%al
call   1050 <error_abort@plt>
jmp    11d7 <edg_set+0xa7>
jmp    115d <edg_set+0x2d>
mov    -0xc(%rbp),%edx
mov    -0x18(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x10(%rbp),%edx
mov    -0x20(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<edg_set>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r9,0x10(%rsp)
mov    %r8,%rbx
mov    %rcx,0x8(%rsp)
mov    %edx,0x4(%rsp)
mov    %esi,%r14d
imul   %edi,%r14d
movslq %r14d,%r15
cmpl   $0xffffffff,(%r8,%r15,4)
je     11c7 <edg_set+0x97>
mov    %esi,%r13d
mov    %edi,%ebp
mov    $0x1,%r12d
jmp    1183 <edg_set+0x53>
nopl   (%rax)
add    $0x1,%r12d
lea    0x1(%r15),%rax
cmpl   $0xffffffff,0x4(%rbx,%r15,4)
mov    %rax,%r15
je     11ca <edg_set+0x9a>
cmp    %ebp,%r12d
jl     1170 <edg_set+0x40>
lea    (%r14,%r12,1),%eax
lea    0xe6d(%rip),%rdi
mov    $0x12,%esi
lea    0xef8(%rip),%rdx
mov    %ebp,%ecx
mov    %r13d,%r8d
mov    0x4(%rsp),%r9d
push   %rax
push   0x10(%rsp)
call   1040 <error_signal@plt>
add    $0x10,%rsp
xor    %eax,%eax
call   1030 <error_report@plt>
xor    %eax,%eax
call   1050 <error_abort@plt>
jmp    1170 <edg_set+0x40>
mov    %r15,%rax
mov    0x4(%rsp),%ecx
mov    %ecx,(%rbx,%rax,4)
mov    0x10(%rsp),%rcx
mov    0x8(%rsp),%rdx
mov    %edx,(%rcx,%rax,4)
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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 = [37 x i8] c"invalid edg_set call: %d/%d/%d/%d/%d\00"
define void @edg_set(i32 %0, i32 %1, i32 %2, i32 %3, i32* %4, i32* %5) {
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32*
%12 = alloca i32*
%13 = alloca i32
%14 = alloca i32
store i32 %0, i32* %7
store i32 %1, i32* %8
store i32 %2, i32* %9
store i32 %3, i32* %10
store i32* %4, i32** %11
store i32* %5, i32** %12
%15 = load i32, i32* %8
%16 = load i32, i32* %7
%17 = mul nsw i32 %15, %16
store i32 %17, i32* %14
store i32 0, i32* %13
br label %18
18: ; preds = %44, %6
%19 = load i32*, i32** %11
%20 = load i32, i32* %14
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i32, i32* %19, i64 %21
%23 = load i32, i32* %22
%24 = icmp ne i32 %23, -1
br i1 %24, label %25, label %45
25: ; preds = %18
%26 = load i32, i32* %14
%27 = add nsw i32 %26, 1
store i32 %27, i32* %14
%28 = load i32, i32* %13
%29 = add nsw i32 %28, 1
store i32 %29, i32* %13
%30 = load i32, i32* %13
%31 = load i32, i32* %7
%32 = icmp sge i32 %30, %31
br i1 %32, label %33, label %44
33: ; preds = %25
br label %34
34: ; preds = %33
%35 = load i32, i32* %7
%36 = load i32, i32* %8
%37 = load i32, i32* %9
%38 = load i32, i32* %10
%39 = load i32, i32* %14
%40 = call i32 @error_signal(i8* getelementptr inbounds ([151 x i8], [151 x i8]* @.str, i64 0, i64 0), i32 18, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i32 %35, i32 %36, i32 %37, i32 %38, i32 %39)
%41 = call i32 (...) @error_report()
%42 = call i32 (...) @error_abort()
br label %43
43: ; preds = %34
br label %44
44: ; preds = %43, %25
br label %18
45: ; preds = %18
%46 = load i32, i32* %9
%47 = load i32*, i32** %11
%48 = load i32, i32* %14
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds i32, i32* %47, i64 %49
store i32 %46, i32* %50
%51 = load i32, i32* %10
%52 = load i32*, i32** %12
%53 = load i32, i32* %14
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds i32, i32* %52, i64 %54
store i32 %51, i32* %55
ret void
}

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 = [37 x i8] c"invalid edg_set call: %d/%d/%d/%d/%d\00"
define void @edg_set(i32 %0, i32 %1, i32 %2, i32 %3, i32* nocapture %4, i32* nocapture writeonly %5) {
%7 = mul nsw i32 %1, %0
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds i32, i32* %4, i64 %8
%10 = load i32, i32* %9
%11 = icmp eq i32 %10, -1
br i1 %11, label %27, label %12
12: ; preds = %6, %23
%13 = phi i64 [ %15, %23 ], [ %8, %6 ]
%14 = phi i32 [ %16, %23 ], [ 0, %6 ]
%15 = add i64 %13, 1
%16 = add nuw nsw i32 %14, 1
%17 = icmp slt i32 %16, %0
br i1 %17, label %23, label %18
18: ; preds = %12
%19 = trunc i64 %15 to i32
%20 = tail call i32 @error_signal(i8* getelementptr inbounds ([151 x i8], [151 x i8]* @.str, i64 0, i64 0), i32 18, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i32 %0, i32 %1, i32 %2, i32 %3, i32 %19)
%21 = tail call i32 (...) @error_report()
%22 = tail call i32 (...) @error_abort()
br label %23
23: ; preds = %18, %12
%24 = getelementptr inbounds i32, i32* %4, i64 %15
%25 = load i32, i32* %24
%26 = icmp eq i32 %25, -1
br i1 %26, label %27, label %12
27: ; preds = %23, %6
%28 = phi i64 [ %8, %6 ], [ %15, %23 ]
%29 = getelementptr inbounds i32, i32* %4, i64 %28
store i32 %2, i32* %29
%30 = getelementptr inbounds i32, i32* %5, i64 %28
store i32 %3, i32* %30
ret void
}