#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 */
struct connection_domain {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ rnn_get_connection(int, struct connection_domain *, int *);
int /*<<< orphan*/ rnn_set_connection(int, struct connection_domain *, int *);
void rnn_delete_connection(int size, struct connection_domain *connection,
                           int begin, int end) {
  int has_connection[size];
  rnn_get_connection(size, connection, has_connection);
  for (int i = begin; i < end; i++) {
    has_connection[i] = 0;
  }
  rnn_set_connection(size, connection, has_connection);
}


x86 assembly (clang, -O0):
<rnn_delete_connection>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    -0x4(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x20(%rbp)
lea    0xf(,%rax,4),%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdx
sub    %rcx,%rdx
mov    %rdx,-0x38(%rbp)
mov    %rdx,%rsp
mov    %rax,-0x28(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1030 <rnn_get_connection@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    1197 <rnn_delete_connection+0x77>
mov    -0x38(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movl   $0x0,(%rax,%rcx,4)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    116e <rnn_delete_connection+0x4e>
mov    -0x38(%rbp),%rdx
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1040 <rnn_set_connection@plt>
mov    -0x20(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rnn_delete_connection>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %ecx,%r13d
mov    %edx,%r12d
mov    %rsi,%r14
mov    %edi,%r15d
mov    %edi,%eax
mov    %rsp,%rbx
lea    0xf(,%rax,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
mov    %rbx,%rdx
call   1040 <rnn_get_connection@plt>
cmp    %r13d,%r12d
jge    118a <rnn_delete_connection+0x5a>
movslq %r12d,%rax
lea    (%rbx,%rax,4),%rdi
not    %r12d
add    %r13d,%r12d
lea    0x4(,%r12,4),%rdx
xor    %esi,%esi
call   1030 <memset@plt>
mov    %r15d,%edi
mov    %r14,%rsi
mov    %rbx,%rdx
call   1050 <rnn_set_connection@plt>
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.connection_domain = type { i32 }
define void @rnn_delete_connection(i32 %0, %struct.connection_domain* %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca %struct.connection_domain*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i64
%11 = alloca i32
store i32 %0, i32* %5
store %struct.connection_domain* %1, %struct.connection_domain** %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%12 = load i32, i32* %5
%13 = zext i32 %12 to i64
%14 = call i8* @llvm.stacksave()
store i8* %14, i8** %9
%15 = alloca i32, i64 %13
store i64 %13, i64* %10
%16 = load i32, i32* %5
%17 = load %struct.connection_domain*, %struct.connection_domain** %6
%18 = call i32 @rnn_get_connection(i32 %16, %struct.connection_domain* %17, i32* %15)
%19 = load i32, i32* %7
store i32 %19, i32* %11
br label %20
20: ; preds = %28, %4
%21 = load i32, i32* %11
%22 = load i32, i32* %8
%23 = icmp slt i32 %21, %22
br i1 %23, label %24, label %31
24: ; preds = %20
%25 = load i32, i32* %11
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i32, i32* %15, i64 %26
store i32 0, i32* %27
br label %28
28: ; preds = %24
%29 = load i32, i32* %11
%30 = add nsw i32 %29, 1
store i32 %30, i32* %11
br label %20
31: ; preds = %20
%32 = load i32, i32* %5
%33 = load %struct.connection_domain*, %struct.connection_domain** %6
%34 = call i32 @rnn_set_connection(i32 %32, %struct.connection_domain* %33, i32* %15)
%35 = load i8*, i8** %9
ret void
}

LLVM IR (-O2):
%struct.connection_domain = type { i32 }
define void @rnn_delete_connection(i32 %0, %struct.connection_domain* %1, i32 %2, i32 %3) {
%5 = zext i32 %0 to i64
%6 = alloca i32, i64 %5
%7 = call i32 @rnn_get_connection(i32 %0, %struct.connection_domain* %1, i32* %6)
%8 = icmp slt i32 %2, %3
br i1 %8, label %9, label %18
9: ; preds = %4
%10 = sext i32 %2 to i64
%11 = getelementptr i32, i32* %6, i64 %10
%12 = bitcast i32* %11 to i8*
%13 = xor i32 %2, -1
%14 = add i32 %13, %3
%15 = zext i32 %14 to i64
%16 = shl nuw nsw i64 %15, 2
%17 = add nuw nsw i64 %16, 4
br label %18
18: ; preds = %9, %4
%19 = call i32 @rnn_set_connection(i32 %0, %struct.connection_domain* %1, i32* %6)
ret void
}