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

/* Variables and functions */
int /*<<< orphan*/ printf(char *, int, int);
int main(int argc, char *argv[]) {
  int a[] = {10, 11, 7, 10, 6};
  int size = sizeof(a) / sizeof(a[0]);
  int i = 0, max = a[1] - a[0], l = 2;
  for (int j = i + l; j < size; j++) {
    if (a[j] - a[i] > max)
      max = a[j] - a[i];
    if (a[j] < a[i])
      i = j - 1;
  }
  printf("When to buy, %d Day at price %d\n", i, a[i]);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0xed3(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xed0(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0xece(%rip),%eax
mov    %eax,-0x20(%rbp)
movl   $0x5,-0x34(%rbp)
movl   $0x0,-0x38(%rbp)
mov    -0x2c(%rbp),%eax
sub    -0x30(%rbp),%eax
mov    %eax,-0x3c(%rbp)
movl   $0x2,-0x40(%rbp)
mov    -0x38(%rbp),%eax
add    -0x40(%rbp),%eax
mov    %eax,-0x44(%rbp)
mov    -0x44(%rbp),%eax
cmp    -0x34(%rbp),%eax
jge    11d6 <main+0xc6>
movslq -0x44(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%eax
movslq -0x38(%rbp),%rcx
sub    -0x30(%rbp,%rcx,4),%eax
cmp    -0x3c(%rbp),%eax
jle    11a4 <main+0x94>
movslq -0x44(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%eax
movslq -0x38(%rbp),%rcx
sub    -0x30(%rbp,%rcx,4),%eax
mov    %eax,-0x3c(%rbp)
movslq -0x44(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%eax
movslq -0x38(%rbp),%rcx
cmp    -0x30(%rbp,%rcx,4),%eax
jge    11c3 <main+0xb3>
mov    -0x44(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    11c8 <main+0xb8>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    116c <main+0x5c>
mov    -0x38(%rbp),%esi
movslq -0x38(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%edx
lea    0xe2c(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xee8(%rip),%rdi
mov    $0x3,%esi
mov    $0xa,%edx
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

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

LLVM IR (-O2):
@.str = [33 x i8] c"When to buy, %d Day at price %d\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i32 3, i32 10)
ret i32 0
}