#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*/ arr;

/* Variables and functions */
int _check_duplicate(int *, int, int, int);
void main() {
  int arr[] = {1, 2, 3, 4, 1, 2, 3, 4};
  int i = 0, prev_sum = 0, k = 3, ret = 0;
  for (i = 0; (i + k) < sizeof(arr) / sizeof(arr[0]); i++) {
    ret = _check_duplicate(arr, i, k, prev_sum);
    if (ret == 0) {
      break;
    }
    prev_sum = ret;
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    0xee1(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xede(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xedb(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    0xed8(%rip),%rax
mov    %rax,-0x8(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
movl   $0x3,-0x2c(%rbp)
movl   $0x0,-0x30(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
add    -0x2c(%rbp),%eax
cltq
cmp    $0x8,%rax
jae    11b1 <main+0xa1>
lea    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%esi
mov    -0x2c(%rbp),%edx
mov    -0x28(%rbp),%ecx
call   1030 <_check_duplicate@plt>
mov    %eax,-0x30(%rbp)
cmpl   $0x0,-0x30(%rbp)
jne    119d <main+0x8d>
jmp    11b1 <main+0xa1>
mov    -0x30(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1167 <main+0x57>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x28,%rsp
movaps 0xef5(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xed9(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%rdi
xor    %esi,%esi
mov    $0x3,%edx
xor    %ecx,%ecx
call   1030 <_check_duplicate@plt>
test   %eax,%eax
je     119c <main+0x8c>
mov    %rsp,%rdi
mov    $0x1,%esi
mov    $0x3,%edx
mov    %eax,%ecx
call   1030 <_check_duplicate@plt>
test   %eax,%eax
je     119c <main+0x8c>
mov    %rsp,%rdi
mov    $0x2,%esi
mov    $0x3,%edx
mov    %eax,%ecx
call   1030 <_check_duplicate@plt>
test   %eax,%eax
je     119c <main+0x8c>
mov    %rsp,%rdi
mov    $0x3,%esi
mov    $0x3,%edx
mov    %eax,%ecx
call   1030 <_check_duplicate@plt>
test   %eax,%eax
je     119c <main+0x8c>
mov    %rsp,%rdi
mov    $0x4,%esi
mov    $0x3,%edx
mov    %eax,%ecx
call   1030 <_check_duplicate@plt>
add    $0x28,%rsp
ret

LLVM IR (-O0):
@__const.main.arr = [8 x i32] [i32 1, i32 2, i32 3, i32 4, i32 1, i32 2, i32 3, i32 4]
define void @main() {
%1 = alloca [8 x i32]
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = bitcast [8 x i32]* %1 to i8*
store i32 0, i32* %2
store i32 0, i32* %3
store i32 3, i32* %4
store i32 0, i32* %5
store i32 0, i32* %2
br label %7
7: ; preds = %24, %0
%8 = load i32, i32* %2
%9 = load i32, i32* %4
%10 = add nsw i32 %8, %9
%11 = sext i32 %10 to i64
%12 = icmp ult i64 %11, 8
br i1 %12, label %13, label %27
13: ; preds = %7
%14 = getelementptr inbounds [8 x i32], [8 x i32]* %1, i64 0, i64 0
%15 = load i32, i32* %2
%16 = load i32, i32* %4
%17 = load i32, i32* %3
%18 = call i32 @_check_duplicate(i32* %14, i32 %15, i32 %16, i32 %17)
store i32 %18, i32* %5
%19 = load i32, i32* %5
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %22
21: ; preds = %13
br label %27
22: ; preds = %13
%23 = load i32, i32* %5
store i32 %23, i32* %3
br label %24
24: ; preds = %22
%25 = load i32, i32* %2
%26 = add nsw i32 %25, 1
store i32 %26, i32* %2
br label %7
27: ; preds = %21, %7
ret void
}

LLVM IR (-O2):
@__const.main.arr = [8 x i32] [i32 1, i32 2, i32 3, i32 4, i32 1, i32 2, i32 3, i32 4]
define void @main() {
%1 = alloca [8 x i32]
%2 = bitcast [8 x i32]* %1 to i8*
%3 = getelementptr inbounds [8 x i32], [8 x i32]* %1, i64 0, i64 0
%4 = call i32 @_check_duplicate(i32* %3, i32 0, i32 3, i32 0)
%5 = icmp eq i32 %4, 0
br i1 %5, label %17, label %6
6: ; preds = %0
%7 = call i32 @_check_duplicate(i32* %3, i32 1, i32 3, i32 %4)
%8 = icmp eq i32 %7, 0
br i1 %8, label %17, label %9
9: ; preds = %6
%10 = call i32 @_check_duplicate(i32* %3, i32 2, i32 3, i32 %7)
%11 = icmp eq i32 %10, 0
br i1 %11, label %17, label %12
12: ; preds = %9
%13 = call i32 @_check_duplicate(i32* %3, i32 3, i32 3, i32 %10)
%14 = icmp eq i32 %13, 0
br i1 %14, label %17, label %15
15: ; preds = %12
%16 = call i32 @_check_duplicate(i32* %3, i32 4, i32 3, i32 %13)
br label %17
17: ; preds = %15, %12, %9, %6, %0
ret void
}