#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*/ free(char *);
scalar_t__ malloc(unsigned long);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, unsigned long);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, long *);
void ProcessSet(unsigned long ulSetValues) {
  unsigned long fValid = 1;
  unsigned long ulCurrentValue = 0;
  long lLastValue = 0;
  char *pSet = (char *)malloc(ulSetValues);
  memset(pSet, 0, ulSetValues);
  scanf("%ld", &lLastValue);
  for (ulCurrentValue = 1; ulCurrentValue < ulSetValues; ulCurrentValue++) {
    unsigned long ulDiff = 0;
    long lReadValue = 0;
    scanf("%ld", &lReadValue);
    if (lLastValue < lReadValue) {
      ulDiff = lReadValue - lLastValue;
    } else {
      ulDiff = lLastValue - lReadValue;
    }
    if (ulDiff == 0 || ulDiff >= ulSetValues || pSet[ulDiff] == 1) {
      fValid = 0;
    } else {
      pSet[ulDiff] = 1;
    }
    lLastValue = lReadValue;
  }
  if (fValid) {
    printf("Jolly\n");
  } else {
    printf("Not jolly\n");
  }
  free(pSet);
}


x86 assembly (clang, -O0):
<ProcessSet>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x1,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x8(%rbp),%rdx
xor    %esi,%esi
call   1050 <memset@plt>
lea    0xe69(%rip),%rdi
lea    -0x20(%rbp),%rsi
call   1070 <scanf@plt>
movq   $0x1,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x8(%rbp),%rax
jae    1261 <ProcessSet+0x111>
movq   $0x0,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
lea    0xe33(%rip),%rdi
lea    -0x38(%rbp),%rsi
call   1070 <scanf@plt>
mov    -0x20(%rbp),%rax
cmp    -0x38(%rbp),%rax
jge    11f5 <ProcessSet+0xa5>
mov    -0x38(%rbp),%rax
sub    -0x20(%rbp),%rax
mov    %rax,-0x30(%rbp)
jmp    1201 <ProcessSet+0xb1>
mov    -0x20(%rbp),%rax
sub    -0x38(%rbp),%rax
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
je     122f <ProcessSet+0xdf>
mov    -0x30(%rbp),%rax
cmp    -0x8(%rbp),%rax
jae    122f <ProcessSet+0xdf>
mov    -0x28(%rbp),%rax
mov    -0x30(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x1,%eax
jne    123c <ProcessSet+0xec>
movq   $0x0,-0x10(%rbp)
jmp    1248 <ProcessSet+0xf8>
mov    -0x28(%rbp),%rax
mov    -0x30(%rbp),%rcx
movb   $0x1,(%rax,%rcx,1)
mov    -0x38(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    11a8 <ProcessSet+0x58>
cmpq   $0x0,-0x10(%rbp)
je     127d <ProcessSet+0x12d>
lea    0xd91(%rip),%rdi
call   1040 <printf@plt>
jmp    1289 <ProcessSet+0x139>
lea    0xd87(%rip),%rdi
call   1040 <printf@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ProcessSet>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%r13
movq   $0x0,0x10(%rsp)
call   1060 <malloc@plt>
mov    %rax,%r14
mov    %rax,%rdi
xor    %esi,%esi
mov    %r13,%rdx
call   1050 <memset@plt>
lea    0xe7a(%rip),%rdi
lea    0x10(%rsp),%rsi
call   1070 <scanf@plt>
cmp    $0x2,%r13
jb     120b <ProcessSet+0xbb>
mov    $0x1,%ebp
lea    0xe5e(%rip),%r15
lea    0x8(%rsp),%r12
mov    $0x1,%ebx
jmp    11c0 <ProcessSet+0x70>
xchg   %ax,%ax
xor    %ebp,%ebp
mov    %rax,0x10(%rsp)
add    $0x1,%rbx
cmp    %rbx,%r13
je     1214 <ProcessSet+0xc4>
movq   $0x0,0x8(%rsp)
mov    %r15,%rdi
mov    %r12,%rsi
call   1070 <scanf@plt>
mov    0x10(%rsp),%rcx
mov    0x8(%rsp),%rax
mov    %rcx,%rdx
sub    %rax,%rdx
neg    %rdx
sub    %rax,%rcx
cmovl  %rdx,%rcx
test   %rcx,%rcx
je     11b0 <ProcessSet+0x60>
cmp    %r13,%rcx
jae    11b0 <ProcessSet+0x60>
cmpb   $0x1,(%r14,%rcx,1)
je     11b0 <ProcessSet+0x60>
movb   $0x1,(%r14,%rcx,1)
mov    0x8(%rsp),%rax
jmp    11b2 <ProcessSet+0x62>
lea    0xdfc(%rip),%rdi
jmp    1229 <ProcessSet+0xd9>
test   %rbp,%rbp
lea    0xde6(%rip),%rax
lea    0xde9(%rip),%rdi
cmove  %rax,%rdi
call   1040 <puts@plt>
mov    %r14,%rdi
call   1030 <free@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%ld\00"
@.str.1 = [7 x i8] c"Jolly\0A\00"
@.str.2 = [11 x i8] c"Not jolly\0A\00"
define void @ProcessSet(i64 %0) {
%2 = alloca i64
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i64
store i64 %0, i64* %2
store i64 1, i64* %3
store i64 0, i64* %4
store i64 0, i64* %5
%9 = load i64, i64* %2
%10 = call i64 @malloc(i64 %9)
%11 = inttoptr i64 %10 to i8*
store i8* %11, i8** %6
%12 = load i8*, i8** %6
%13 = load i64, i64* %2
%14 = call i32 @memset(i8* %12, i32 0, i64 %13)
%15 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64* %5)
store i64 1, i64* %4
br label %16
16: ; preds = %54, %1
%17 = load i64, i64* %4
%18 = load i64, i64* %2
%19 = icmp ult i64 %17, %18
br i1 %19, label %20, label %57
20: ; preds = %16
store i64 0, i64* %7
store i64 0, i64* %8
%21 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64* %8)
%22 = load i64, i64* %5
%23 = load i64, i64* %8
%24 = icmp slt i64 %22, %23
br i1 %24, label %25, label %29
25: ; preds = %20
%26 = load i64, i64* %8
%27 = load i64, i64* %5
%28 = sub nsw i64 %26, %27
store i64 %28, i64* %7
br label %33
29: ; preds = %20
%30 = load i64, i64* %5
%31 = load i64, i64* %8
%32 = sub nsw i64 %30, %31
store i64 %32, i64* %7
br label %33
33: ; preds = %29, %25
%34 = load i64, i64* %7
%35 = icmp eq i64 %34, 0
br i1 %35, label %47, label %36
36: ; preds = %33
%37 = load i64, i64* %7
%38 = load i64, i64* %2
%39 = icmp uge i64 %37, %38
br i1 %39, label %47, label %40
40: ; preds = %36
%41 = load i8*, i8** %6
%42 = load i64, i64* %7
%43 = getelementptr inbounds i8, i8* %41, i64 %42
%44 = load i8, i8* %43
%45 = sext i8 %44 to i32
%46 = icmp eq i32 %45, 1
br i1 %46, label %47, label %48
47: ; preds = %40, %36, %33
store i64 0, i64* %3
br label %52
48: ; preds = %40
%49 = load i8*, i8** %6
%50 = load i64, i64* %7
%51 = getelementptr inbounds i8, i8* %49, i64 %50
store i8 1, i8* %51
br label %52
52: ; preds = %48, %47
%53 = load i64, i64* %8
store i64 %53, i64* %5
br label %54
54: ; preds = %52
%55 = load i64, i64* %4
%56 = add i64 %55, 1
store i64 %56, i64* %4
br label %16
57: ; preds = %16
%58 = load i64, i64* %3
%59 = icmp ne i64 %58, 0
br i1 %59, label %60, label %62
60: ; preds = %57
%61 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
br label %64
62: ; preds = %57
%63 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
br label %64
64: ; preds = %62, %60
%65 = load i8*, i8** %6
%66 = call i32 @free(i8* %65)
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"%ld\00"
@str = [10 x i8] c"Not jolly\00"
@str.3 = [6 x i8] c"Jolly\00"
define void @ProcessSet(i64 %0) {
%2 = alloca i64
%3 = alloca i64
%4 = bitcast i64* %2 to i8*
store i64 0, i64* %2
%5 = tail call i64 @malloc(i64 %0)
%6 = inttoptr i64 %5 to i8*
%7 = tail call i32 @memset(i8* %6, i32 0, i64 %0)
%8 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64* %2)
%9 = icmp ugt i64 %0, 1
br i1 %9, label %10, label %39
10: ; preds = %1
%11 = bitcast i64* %3 to i8*
br label %12
12: ; preds = %10, %31
%13 = phi i64 [ 1, %10 ], [ %33, %31 ]
%14 = phi i64 [ 1, %10 ], [ %34, %31 ]
store i64 0, i64* %3
%15 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64* %3)
%16 = load i64, i64* %2
%17 = load i64, i64* %3
%18 = icmp slt i64 %16, %17
%19 = sub nsw i64 %17, %16
%20 = sub nsw i64 %16, %17
%21 = select i1 %18, i64 %19, i64 %20
%22 = icmp ne i64 %21, 0
%23 = icmp ult i64 %21, %0
%24 = and i1 %22, %23
br i1 %24, label %25, label %31
25: ; preds = %12
%26 = getelementptr inbounds i8, i8* %6, i64 %21
%27 = load i8, i8* %26
%28 = icmp eq i8 %27, 1
br i1 %28, label %31, label %29
29: ; preds = %25
store i8 1, i8* %26
%30 = load i64, i64* %3
br label %31
31: ; preds = %12, %25, %29
%32 = phi i64 [ %30, %29 ], [ %17, %25 ], [ %17, %12 ]
%33 = phi i64 [ %13, %29 ], [ 0, %25 ], [ 0, %12 ]
store i64 %32, i64* %2
%34 = add nuw i64 %14, 1
%35 = icmp eq i64 %34, %0
br i1 %35, label %36, label %12
36: ; preds = %31
%37 = icmp eq i64 %33, 0
%38 = select i1 %37, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @str.3, i64 0, i64 0)
br label %39
39: ; preds = %36, %1
%40 = phi i8* [ getelementptr inbounds ([6 x i8], [6 x i8]* @str.3, i64 0, i64 0), %1 ], [ %38, %36 ]
%41 = call i32 @puts(i8* dereferenceable(1) %40)
%42 = call i32 @free(i8* %6)
ret void
}