#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*/ printf(char *, int, ...);
int rand();
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(void) {
  int randomVal, maxRepeat = 4, idx, prevVal = -1, go = 1, execCnt = 0;
  int testCnt;
  int randArray[4] = {0};
  srand(time(NULL));
  for (testCnt = 0; testCnt < 100; testCnt++) {
    while (go == 1) {
      printf("execCnt:%d\n", ++execCnt);
      prevVal = -1;
      for (idx = 0; idx < maxRepeat; idx++) {
        while (1) {
          randomVal = rand() % 256;
          printf("(%d)", randomVal);
          if ((256 - randomVal) < (4 - idx)) {
            printf("%d < %d ? , skip...\n", 256 - randomVal, 4 - idx);
            goto skip;
          }
          if (randomVal > prevVal) {
            prevVal = randArray[idx] = randomVal;
            printf("randArray[%d]=%d\n", idx, randArray[idx]);
            break;
          }
        }
      }
    skip:
      printf("idx=%d\n", idx);
      if (idx >= 4)
        go = 0;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x4,-0xc(%rbp)
movl   $0xffffffff,-0x14(%rbp)
movl   $0x1,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1040 <memset@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
movl   $0x0,-0x20(%rbp)
cmpl   $0x64,-0x20(%rbp)
jge    12de <main+0x18e>
jmp    11b1 <main+0x61>
cmpl   $0x1,-0x18(%rbp)
jne    12cb <main+0x17b>
mov    -0x1c(%rbp),%esi
add    $0x1,%esi
mov    %esi,-0x1c(%rbp)
lea    0xe35(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0xffffffff,-0x14(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    129f <main+0x14f>
jmp    11f1 <main+0xa1>
mov    $0x0,%al
call   1070 <rand@plt>
mov    $0x100,%ecx
cltd
idiv   %ecx
mov    %edx,-0x8(%rbp)
mov    -0x8(%rbp),%esi
lea    0xdff(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x100,%eax
sub    -0x8(%rbp),%eax
mov    $0x4,%ecx
sub    -0x10(%rbp),%ecx
cmp    %ecx,%eax
jge    124f <main+0xff>
mov    $0x100,%esi
sub    -0x8(%rbp),%esi
mov    $0x4,%edx
sub    -0x10(%rbp),%edx
lea    0xdce(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12a4 <main+0x154>
mov    -0x8(%rbp),%eax
cmp    -0x14(%rbp),%eax
jle    1287 <main+0x137>
mov    -0x8(%rbp),%eax
movslq -0x10(%rbp),%rcx
mov    %eax,-0x30(%rbp,%rcx,4)
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%esi
movslq -0x10(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%edx
lea    0xdab(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    128c <main+0x13c>
jmp    11f1 <main+0xa1>
jmp    1291 <main+0x141>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11e0 <main+0x90>
jmp    12a4 <main+0x154>
mov    -0x10(%rbp),%esi
lea    0xd8a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x4,-0x10(%rbp)
jl     12c6 <main+0x176>
movl   $0x0,-0x18(%rbp)
jmp    11b1 <main+0x61>
jmp    12d0 <main+0x180>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11a2 <main+0x52>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %edi,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
mov    $0x1,%al
lea    0xe9e(%rip),%rbx
lea    0xea3(%rip),%r12
lea    0xec8(%rip),%r15
xor    %ecx,%ecx
xor    %r14d,%r14d
jmp    1192 <main+0x52>
nopw   0x0(%rax,%rax,1)
mov    0x4(%rsp),%ecx
add    $0x1,%ecx
xor    %eax,%eax
cmp    $0x64,%ecx
je     13a2 <main+0x262>
mov    %ecx,0x4(%rsp)
test   $0x1,%al
jne    11bf <main+0x7f>
jmp    1180 <main+0x40>
nopl   0x0(%rax)
mov    $0x4,%edx
lea    0xe65(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x1,%r14d
mov    %rbx,%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %ebp,%ebp
xor    %eax,%eax
call   1060 <rand@plt>
mov    %eax,%r13d
lea    0xff(%r13),%eax
test   %r13d,%r13d
cmovns %r13d,%eax
and    $0xffffff00,%eax
sub    %eax,%r13d
mov    %r12,%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x100,%esi
sub    %r13d,%esi
cmp    $0x4,%esi
jb     11a0 <main+0x60>
test   %r13d,%r13d
js     11d0 <main+0x90>
lea    0xe0e(%rip),%rdi
xor    %esi,%esi
mov    %r13d,%edx
xor    %eax,%eax
call   1030 <printf@plt>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
xor    %eax,%eax
call   1060 <rand@plt>
mov    %eax,%r15d
lea    0xff(%r15),%eax
test   %r15d,%r15d
cmovns %r15d,%eax
and    $0xffffff00,%eax
sub    %eax,%r15d
mov    %r12,%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x100,%esi
sub    %r15d,%esi
cmp    $0x3,%esi
jb     12e0 <main+0x1a0>
cmp    %r13d,%r15d
jle    1230 <main+0xf0>
lea    0xdb0(%rip),%rdi
mov    $0x1,%esi
mov    %r15d,%edx
xor    %eax,%eax
call   1030 <printf@plt>
cs nopw 0x0(%rax,%rax,1)
nop
xor    %eax,%eax
call   1060 <rand@plt>
mov    %eax,%r13d
lea    0xff(%r13),%ebx
test   %eax,%eax
cmovns %eax,%ebx
and    $0xffffff00,%ebx
mov    %eax,%ebp
sub    %ebx,%ebp
mov    %r12,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1030 <printf@plt>
neg    %ebx
lea    (%rbx,%r13,1),%eax
add    $0xffffff01,%eax
cmp    $0x2,%eax
jb     12f6 <main+0x1b6>
cmp    %r15d,%ebp
jle    1290 <main+0x150>
jmp    1320 <main+0x1e0>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    $0x3,%edx
mov    $0x1,%ebp
lea    0xd47(%rip),%r15
jmp    11a5 <main+0x65>
mov    $0x1,%esi
mov    $0x2,%ebp
mov    $0x2,%edx
lea    0xcf4(%rip),%rbx
lea    0xd25(%rip),%r15
jmp    11a5 <main+0x65>
nopl   0x0(%rax,%rax,1)
lea    0xcff(%rip),%rdi
mov    $0x2,%esi
mov    %ebp,%edx
xor    %eax,%eax
call   1030 <printf@plt>
cs nopw 0x0(%rax,%rax,1)
nop
xor    %eax,%eax
call   1060 <rand@plt>
mov    %eax,%ebx
lea    0xff(%rbx),%eax
test   %ebx,%ebx
cmovns %ebx,%eax
and    $0xffffff00,%eax
sub    %eax,%ebx
mov    %r12,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
cmp    %ebp,%ebx
jle    1340 <main+0x200>
lea    0xcb4(%rip),%rdi
mov    $0x3,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xcb1(%rip),%r15
mov    %r15,%rdi
mov    $0x4,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xc63(%rip),%rbx
jmp    1180 <main+0x40>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [12 x i8] c"execCnt:%d\0A\00"
@.str.1 = [5 x i8] c"(%d)\00"
@.str.2 = [21 x i8] c"%d < %d ? , skip...\0A\00"
@.str.3 = [18 x i8] c"randArray[%d]=%d\0A\00"
@.str.4 = [8 x i8] c"idx=%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca [4 x i32]
store i32 0, i32* %1
store i32 4, i32* %3
store i32 -1, i32* %5
store i32 1, i32* %6
store i32 0, i32* %7
%10 = bitcast [4 x i32]* %9 to i8*
%11 = call i32 @time(i32* null)
%12 = call i32 @srand(i32 %11)
store i32 0, i32* %8
br label %13
13: ; preds = %74, %0
%14 = load i32, i32* %8
%15 = icmp slt i32 %14, 100
br i1 %15, label %16, label %77
16: ; preds = %13
br label %17
17: ; preds = %72, %16
%18 = load i32, i32* %6
%19 = icmp eq i32 %18, 1
br i1 %19, label %20, label %73
20: ; preds = %17
%21 = load i32, i32* %7
%22 = add nsw i32 %21, 1
store i32 %22, i32* %7
%23 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %22)
store i32 -1, i32* %5
store i32 0, i32* %4
br label %24
24: ; preds = %62, %20
%25 = load i32, i32* %4
%26 = load i32, i32* %3
%27 = icmp slt i32 %25, %26
br i1 %27, label %28, label %65
28: ; preds = %24
br label %29
29: ; preds = %28, %60
%30 = call i32 (...) @rand()
%31 = srem i32 %30, 256
store i32 %31, i32* %2
%32 = load i32, i32* %2
%33 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %32)
%34 = load i32, i32* %2
%35 = sub nsw i32 256, %34
%36 = load i32, i32* %4
%37 = sub nsw i32 4, %36
%38 = icmp slt i32 %35, %37
br i1 %38, label %39, label %45
39: ; preds = %29
%40 = load i32, i32* %2
%41 = sub nsw i32 256, %40
%42 = load i32, i32* %4
%43 = sub nsw i32 4, %42
%44 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i32 %41, i32 %43)
br label %66
45: ; preds = %29
%46 = load i32, i32* %2
%47 = load i32, i32* %5
%48 = icmp sgt i32 %46, %47
br i1 %48, label %49, label %60
49: ; preds = %45
%50 = load i32, i32* %2
%51 = load i32, i32* %4
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds [4 x i32], [4 x i32]* %9, i64 0, i64 %52
store i32 %50, i32* %53
store i32 %50, i32* %5
%54 = load i32, i32* %4
%55 = load i32, i32* %4
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds [4 x i32], [4 x i32]* %9, i64 0, i64 %56
%58 = load i32, i32* %57
%59 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i32 %54, i32 %58)
br label %61
60: ; preds = %45
br label %29
61: ; preds = %49
br label %62
62: ; preds = %61
%63 = load i32, i32* %4
%64 = add nsw i32 %63, 1
store i32 %64, i32* %4
br label %24
65: ; preds = %24
br label %66
66: ; preds = %65, %39
%67 = load i32, i32* %4
%68 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i32 %67)
%69 = load i32, i32* %4
%70 = icmp sge i32 %69, 4
br i1 %70, label %71, label %72
71: ; preds = %66
store i32 0, i32* %6
br label %72
72: ; preds = %71, %66
br label %17
73: ; preds = %17
br label %74
74: ; preds = %73
%75 = load i32, i32* %8
%76 = add nsw i32 %75, 1
store i32 %76, i32* %8
br label %13
77: ; preds = %13
ret i32 0
}

LLVM IR (-O2):
@.str = [12 x i8] c"execCnt:%d\0A\00"
@.str.1 = [5 x i8] c"(%d)\00"
@.str.2 = [21 x i8] c"%d < %d ? , skip...\0A\00"
@.str.3 = [18 x i8] c"randArray[%d]=%d\0A\00"
@.str.4 = [8 x i8] c"idx=%d\0A\00"
define i32 @main() {
%1 = tail call i32 @time(i32* null)
%2 = tail call i32 @srand(i32 %1)
br label %3
3: ; preds = %0, %55
%4 = phi i32 [ 0, %0 ], [ %57, %55 ]
%5 = phi i32 [ 0, %0 ], [ %56, %55 ]
%6 = phi i1 [ true, %0 ], [ false, %55 ]
br i1 %6, label %13, label %55
7: ; preds = %17, %27, %37
%8 = phi i32 [ 2, %37 ], [ 1, %27 ], [ 0, %17 ]
%9 = phi i32 [ 2, %37 ], [ 3, %27 ], [ 4, %17 ]
%10 = phi i32 [ 1, %37 ], [ %31, %27 ], [ %21, %17 ]
%11 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i32 %10, i32 %9)
%12 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i32 %8)
br label %13
13: ; preds = %3, %7
%14 = phi i32 [ %15, %7 ], [ %5, %3 ]
%15 = add nsw i32 %14, 1
%16 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %15)
br label %17
17: ; preds = %13, %23
%18 = tail call i32 (...) @rand()
%19 = srem i32 %18, 256
%20 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %19)
%21 = sub nsw i32 256, %19
%22 = icmp ult i32 %21, 4
br i1 %22, label %7, label %23
23: ; preds = %17
%24 = icmp sgt i32 %19, -1
br i1 %24, label %25, label %17
25: ; preds = %23
%26 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i32 0, i32 %19)
br label %27
27: ; preds = %33, %25
%28 = tail call i32 (...) @rand()
%29 = srem i32 %28, 256
%30 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %29)
%31 = sub nsw i32 256, %29
%32 = icmp ult i32 %31, 3
br i1 %32, label %7, label %33
33: ; preds = %27
%34 = icmp sgt i32 %29, %19
br i1 %34, label %35, label %27
35: ; preds = %33
%36 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i32 1, i32 %29)
br label %37
37: ; preds = %43, %35
%38 = tail call i32 (...) @rand()
%39 = srem i32 %38, 256
%40 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %39)
%41 = add nsw i32 %39, -255
%42 = icmp ult i32 %41, 2
br i1 %42, label %7, label %43
43: ; preds = %37
%44 = icmp sgt i32 %39, %29
br i1 %44, label %45, label %37
45: ; preds = %43
%46 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i32 2, i32 %39)
br label %47
47: ; preds = %45, %47
%48 = tail call i32 (...) @rand()
%49 = srem i32 %48, 256
%50 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %49)
%51 = icmp sgt i32 %49, %39
br i1 %51, label %52, label %47
52: ; preds = %47
%53 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i32 3, i32 %49)
%54 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i32 4)
br label %55
55: ; preds = %52, %3
%56 = phi i32 [ %5, %3 ], [ %15, %52 ]
%57 = add nuw nsw i32 %4, 1
%58 = icmp eq i32 %57, 100
br i1 %58, label %59, label %3
59: ; preds = %55
ret i32 0
}