#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 EX_OK;
int /*<<< orphan*/ printf(char *, ...);
int rand();
int /*<<< orphan*/ srand(unsigned int);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(void) {
  int result = -1;
  unsigned seed = (unsigned)time(NULL);
  int count = 10;
  int limit = 4;
  int values[count];
  int index;
  printf("Seed: %u\n", seed);
  srand(seed);
  printf("Input:\n");
  for (index = 0; index < count; index++) {
    values[index] = rand() % limit;
    printf("%8d: %d\n", index, values[index]);
  }
  for (index = 0; index < count; index++) {
    if (((index == 0) || (values[index] >= values[index - 1])) &&
        ((index == count - 1) || (values[index] >= values[index + 1]))) {
      result = index;
      break;
    }
  }
  if (result != -1) {
    printf("Peak found at index %d: %d\n", result, values[result]);
  } else {
    printf("No peak found\n");
  }
  return EX_OK;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0xffffffff,-0x8(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1050 <time@plt>
mov    %eax,-0xc(%rbp)
movl   $0xa,-0x10(%rbp)
movl   $0x4,-0x14(%rbp)
mov    -0x10(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x20(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x38(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x28(%rbp)
mov    -0xc(%rbp),%esi
lea    0xe5f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%edi
call   1040 <srand@plt>
lea    0xe53(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    120d <main+0xcd>
mov    $0x0,%al
call   1060 <rand@plt>
cltd
idivl  -0x14(%rbp)
mov    -0x38(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x2c(%rbp),%esi
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
lea    0xe1a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    11c5 <main+0x85>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    1293 <main+0x153>
cmpl   $0x0,-0x2c(%rbp)
je     1247 <main+0x107>
mov    -0x38(%rbp),%rcx
movslq -0x2c(%rbp),%rax
mov    (%rcx,%rax,4),%eax
mov    -0x2c(%rbp),%edx
sub    $0x1,%edx
movslq %edx,%rdx
cmp    (%rcx,%rdx,4),%eax
jl     1280 <main+0x140>
mov    -0x2c(%rbp),%eax
mov    -0x10(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
je     1275 <main+0x135>
mov    -0x38(%rbp),%rcx
movslq -0x2c(%rbp),%rax
mov    (%rcx,%rax,4),%eax
mov    -0x2c(%rbp),%edx
add    $0x1,%edx
movslq %edx,%rdx
cmp    (%rcx,%rdx,4),%eax
jl     1280 <main+0x140>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x8(%rbp)
jmp    1293 <main+0x153>
jmp    1285 <main+0x145>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1214 <main+0xd4>
cmpl   $0xffffffff,-0x8(%rbp)
je     12be <main+0x17e>
mov    -0x38(%rbp),%rax
mov    -0x8(%rbp),%esi
movslq -0x8(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
lea    0xd69(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12cc <main+0x18c>
lea    0xd72(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2d0d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,%ebx
lea    0xe92(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebx,%edi
call   1050 <srand@plt>
lea    0xeaa(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1070 <rand@plt>
mov    %eax,%edx
lea    0x3(%rdx),%eax
test   %edx,%edx
cmovns %edx,%eax
and    $0xfffffffc,%eax
sub    %eax,%edx
mov    %rdx,0x40(%rsp)
mov    %edx,0x10(%rsp)
lea    0xe5a(%rip),%rbp
mov    %rbp,%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1070 <rand@plt>
mov    %eax,%edx
lea    0x3(%rdx),%eax
test   %edx,%edx
cmovns %edx,%eax
and    $0xfffffffc,%eax
sub    %eax,%edx
mov    %rdx,0x38(%rsp)
mov    %edx,0x14(%rsp)
mov    %rbp,%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1070 <rand@plt>
mov    %eax,%edx
lea    0x3(%rdx),%eax
test   %edx,%edx
cmovns %edx,%eax
and    $0xfffffffc,%eax
sub    %eax,%edx
mov    %edx,0x18(%rsp)
mov    %rbp,%rdi
mov    $0x2,%esi
mov    %rdx,0x8(%rsp)
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1070 <rand@plt>
mov    %eax,%edx
lea    0x3(%rdx),%eax
test   %edx,%edx
cmovns %edx,%eax
and    $0xfffffffc,%eax
sub    %eax,%edx
mov    %edx,0x1c(%rsp)
mov    %rbp,%rdi
mov    $0x3,%esi
mov    %rdx,(%rsp)
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1070 <rand@plt>
mov    %eax,%r14d
lea    0x3(%r14),%eax
test   %r14d,%r14d
cmovns %r14d,%eax
and    $0xfffffffc,%eax
sub    %eax,%r14d
mov    %r14d,0x20(%rsp)
mov    %rbp,%rdi
mov    $0x4,%esi
mov    %r14d,%edx
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1070 <rand@plt>
mov    %eax,%r12d
lea    0x3(%r12),%eax
test   %r12d,%r12d
cmovns %r12d,%eax
and    $0xfffffffc,%eax
sub    %eax,%r12d
mov    %r12d,0x24(%rsp)
mov    %rbp,%rdi
mov    $0x5,%esi
mov    %r12d,%edx
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1070 <rand@plt>
mov    %eax,%r15d
lea    0x3(%r15),%eax
test   %r15d,%r15d
cmovns %r15d,%eax
and    $0xfffffffc,%eax
sub    %eax,%r15d
mov    %r15d,0x28(%rsp)
mov    %rbp,%rdi
mov    $0x6,%esi
mov    %r15d,%edx
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1070 <rand@plt>
mov    %eax,%r13d
lea    0x3(%r13),%eax
test   %r13d,%r13d
cmovns %r13d,%eax
and    $0xfffffffc,%eax
sub    %eax,%r13d
mov    %r13d,0x2c(%rsp)
mov    %rbp,%rdi
mov    $0x7,%esi
mov    %r13d,%edx
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1070 <rand@plt>
mov    %eax,%ebx
lea    0x3(%rbx),%eax
test   %ebx,%ebx
cmovns %ebx,%eax
and    $0xfffffffc,%eax
sub    %eax,%ebx
mov    %ebx,0x30(%rsp)
mov    %rbp,%rdi
mov    $0x8,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1070 <rand@plt>
mov    %eax,%ebp
lea    0x3(%rbp),%eax
test   %ebp,%ebp
cmovns %ebp,%eax
and    $0xfffffffc,%eax
sub    %eax,%ebp
mov    %ebp,0x34(%rsp)
lea    0xcb0(%rip),%rdi
mov    $0x9,%esi
mov    %ebp,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x38(%rsp),%rax
xor    %esi,%esi
cmp    %eax,0x40(%rsp)
jge    13cd <main+0x27d>
mov    $0x1,%esi
cmp    0x8(%rsp),%eax
jge    13cd <main+0x27d>
mov    $0x2,%esi
mov    (%rsp),%rax
cmp    %eax,0x8(%rsp)
jge    13cd <main+0x27d>
mov    $0x3,%esi
cmp    %r14d,(%rsp)
jge    13cd <main+0x27d>
mov    $0x4,%esi
cmp    %r12d,%r14d
jge    13cd <main+0x27d>
mov    $0x5,%esi
cmp    %r15d,%r12d
jge    13cd <main+0x27d>
mov    $0x6,%esi
cmp    %r13d,%r15d
jge    13cd <main+0x27d>
mov    $0x7,%esi
cmp    %ebx,%r13d
jge    13cd <main+0x27d>
xor    %esi,%esi
cmp    %ebp,%ebx
setl   %sil
or     $0x8,%esi
mov    %esi,%eax
mov    0x10(%rsp,%rax,4),%edx
lea    0xc39(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2bf8(%rip),%rax
mov    (%rax),%eax
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [10 x i8] c"Seed: %u\0A\00"
@.str.1 = [8 x i8] c"Input:\0A\00"
@.str.2 = [9 x i8] c"%8d: %d\0A\00"
@.str.3 = [28 x i8] c"Peak found at index %d: %d\0A\00"
@.str.4 = [15 x i8] c"No peak found\0A\00"
@EX_OK = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i32
store i32 0, i32* %1
store i32 -1, i32* %2
%9 = call i32 @time(i32* null)
store i32 %9, i32* %3
store i32 10, i32* %4
store i32 4, i32* %5
%10 = load i32, i32* %4
%11 = zext i32 %10 to i64
%12 = call i8* @llvm.stacksave()
store i8* %12, i8** %6
%13 = alloca i32, i64 %11
store i64 %11, i64* %7
%14 = load i32, i32* %3
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %14)
%16 = load i32, i32* %3
%17 = call i32 @srand(i32 %16)
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %8
br label %19
19: ; preds = %36, %0
%20 = load i32, i32* %8
%21 = load i32, i32* %4
%22 = icmp slt i32 %20, %21
br i1 %22, label %23, label %39
23: ; preds = %19
%24 = call i32 (...) @rand()
%25 = load i32, i32* %5
%26 = srem i32 %24, %25
%27 = load i32, i32* %8
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i32, i32* %13, i64 %28
store i32 %26, i32* %29
%30 = load i32, i32* %8
%31 = load i32, i32* %8
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i32, i32* %13, i64 %32
%34 = load i32, i32* %33
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %30, i32 %34)
br label %36
36: ; preds = %23
%37 = load i32, i32* %8
%38 = add nsw i32 %37, 1
store i32 %38, i32* %8
br label %19
39: ; preds = %19
store i32 0, i32* %8
br label %40
40: ; preds = %77, %39
%41 = load i32, i32* %8
%42 = load i32, i32* %4
%43 = icmp slt i32 %41, %42
br i1 %43, label %44, label %80
44: ; preds = %40
%45 = load i32, i32* %8
%46 = icmp eq i32 %45, 0
br i1 %46, label %58, label %47
47: ; preds = %44
%48 = load i32, i32* %8
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds i32, i32* %13, i64 %49
%51 = load i32, i32* %50
%52 = load i32, i32* %8
%53 = sub nsw i32 %52, 1
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds i32, i32* %13, i64 %54
%56 = load i32, i32* %55
%57 = icmp sge i32 %51, %56
br i1 %57, label %58, label %76
58: ; preds = %47, %44
%59 = load i32, i32* %8
%60 = load i32, i32* %4
%61 = sub nsw i32 %60, 1
%62 = icmp eq i32 %59, %61
br i1 %62, label %74, label %63
63: ; preds = %58
%64 = load i32, i32* %8
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds i32, i32* %13, i64 %65
%67 = load i32, i32* %66
%68 = load i32, i32* %8
%69 = add nsw i32 %68, 1
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds i32, i32* %13, i64 %70
%72 = load i32, i32* %71
%73 = icmp sge i32 %67, %72
br i1 %73, label %74, label %76
74: ; preds = %63, %58
%75 = load i32, i32* %8
store i32 %75, i32* %2
br label %80
76: ; preds = %63, %47
br label %77
77: ; preds = %76
%78 = load i32, i32* %8
%79 = add nsw i32 %78, 1
store i32 %79, i32* %8
br label %40
80: ; preds = %74, %40
%81 = load i32, i32* %2
%82 = icmp ne i32 %81, -1
br i1 %82, label %83, label %90
83: ; preds = %80
%84 = load i32, i32* %2
%85 = load i32, i32* %2
%86 = sext i32 %85 to i64
%87 = getelementptr inbounds i32, i32* %13, i64 %86
%88 = load i32, i32* %87
%89 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i32 %84, i32 %88)
br label %92
90: ; preds = %80
%91 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
br label %92
92: ; preds = %90, %83
%93 = load i32, i32* @EX_OK
store i32 %93, i32* %1
%94 = load i8*, i8** %6
%95 = load i32, i32* %1
ret i32 %95
}

LLVM IR (-O2):
@.str = [10 x i8] c"Seed: %u\0A\00"
@.str.2 = [9 x i8] c"%8d: %d\0A\00"
@.str.3 = [28 x i8] c"Peak found at index %d: %d\0A\00"
@EX_OK = global i32 0
@str = [7 x i8] c"Input:\00"
define i32 @main() {
%1 = tail call i32 @time(i32* null)
%2 = alloca [10 x i32]
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %1)
%4 = tail call i32 @srand(i32 %1)
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str, i64 0, i64 0))
%6 = tail call i32 (...) @rand()
%7 = srem i32 %6, 4
%8 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 0
store i32 %7, i32* %8
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 0, i32 %7)
%10 = tail call i32 (...) @rand()
%11 = srem i32 %10, 4
%12 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 1
store i32 %11, i32* %12
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 1, i32 %11)
%14 = tail call i32 (...) @rand()
%15 = srem i32 %14, 4
%16 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 2
store i32 %15, i32* %16
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 2, i32 %15)
%18 = tail call i32 (...) @rand()
%19 = srem i32 %18, 4
%20 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 3
store i32 %19, i32* %20
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 3, i32 %19)
%22 = tail call i32 (...) @rand()
%23 = srem i32 %22, 4
%24 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 4
store i32 %23, i32* %24
%25 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 4, i32 %23)
%26 = tail call i32 (...) @rand()
%27 = srem i32 %26, 4
%28 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 5
store i32 %27, i32* %28
%29 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 5, i32 %27)
%30 = tail call i32 (...) @rand()
%31 = srem i32 %30, 4
%32 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 6
store i32 %31, i32* %32
%33 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 6, i32 %31)
%34 = tail call i32 (...) @rand()
%35 = srem i32 %34, 4
%36 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 7
store i32 %35, i32* %36
%37 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 7, i32 %35)
%38 = tail call i32 (...) @rand()
%39 = srem i32 %38, 4
%40 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 8
store i32 %39, i32* %40
%41 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 8, i32 %39)
%42 = tail call i32 (...) @rand()
%43 = srem i32 %42, 4
%44 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 9
store i32 %43, i32* %44
%45 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 9, i32 %43)
%46 = icmp slt i32 %7, %11
br i1 %46, label %47, label %64
47: ; preds = %0
%48 = icmp slt i32 %11, %15
br i1 %48, label %49, label %64
49: ; preds = %47
%50 = icmp slt i32 %15, %19
br i1 %50, label %51, label %64
51: ; preds = %49
%52 = icmp slt i32 %19, %23
br i1 %52, label %53, label %64
53: ; preds = %51
%54 = icmp slt i32 %23, %27
br i1 %54, label %55, label %64
55: ; preds = %53
%56 = icmp slt i32 %27, %31
br i1 %56, label %57, label %64
57: ; preds = %55
%58 = icmp slt i32 %31, %35
br i1 %58, label %59, label %64
59: ; preds = %57
%60 = icmp slt i32 %35, %39
br i1 %60, label %61, label %64
61: ; preds = %59
%62 = icmp slt i32 %39, %43
%63 = select i1 %62, i32 9, i32 8
br label %64
64: ; preds = %61, %0, %47, %49, %51, %53, %55, %57, %59
%65 = phi i32 [ 0, %0 ], [ 1, %47 ], [ 2, %49 ], [ 3, %51 ], [ 4, %53 ], [ 5, %55 ], [ 6, %57 ], [ 7, %59 ], [ %63, %61 ]
%66 = zext i32 %65 to i64
%67 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 %66
%68 = load i32, i32* %67
%69 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i32 %65, i32 %68)
%70 = load i32, i32* @EX_OK
ret i32 %70
}