#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 main(int argc, char *argv[]) {
  int a[] = {10, 11, 7, 10, 6};
  int size = sizeof(a) / sizeof(a[0]);
  printf("\n");
  int i = 0, max = a[1] - a[0];
  for (int j = 1; j < size; j++) {
    if ((a[j] - a[i]) > max)
      max = a[j] - a[i];
    if (a[j] < a[i])
      i = j;
  }
  printf("\n[When to buy] Day i is %d, price is %d\n", i, a[i]);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%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)
lea    0xee8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x38(%rbp)
mov    -0x2c(%rbp),%eax
sub    -0x30(%rbp),%eax
mov    %eax,-0x3c(%rbp)
movl   $0x1,-0x40(%rbp)
mov    -0x40(%rbp),%eax
cmp    -0x34(%rbp),%eax
jge    11d8 <main+0xc8>
movslq -0x40(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%eax
movslq -0x38(%rbp),%rcx
sub    -0x30(%rbp,%rcx,4),%eax
cmp    -0x3c(%rbp),%eax
jle    11a9 <main+0x99>
movslq -0x40(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%eax
movslq -0x38(%rbp),%rcx
sub    -0x30(%rbp,%rcx,4),%eax
mov    %eax,-0x3c(%rbp)
movslq -0x40(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%eax
movslq -0x38(%rbp),%rcx
cmp    -0x30(%rbp,%rcx,4),%eax
jge    11c5 <main+0xb5>
mov    -0x40(%rbp),%eax
mov    %eax,-0x38(%rbp)
jmp    11ca <main+0xba>
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    1171 <main+0x61>
mov    -0x38(%rbp),%esi
movslq -0x38(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%edx
lea    0xe2a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xece(%rip),%rdi
mov    $0x4,%esi
mov    $0x6,%edx
xor    %eax,%eax
call   1040 <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 = [2 x i8] c"\0A\00"
@.str.1 = [41 x i8] c"\0A[When to buy] Day i is %d, price is %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
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = bitcast [5 x i32]* %6 to i8*
store i32 5, i32* %7
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
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 1, i32* %10
br label %18
18: ; preds = %57, %2
%19 = load i32, i32* %10
%20 = load i32, i32* %7
%21 = icmp slt i32 %19, %20
br i1 %21, label %22, label %60
22: ; preds = %18
%23 = load i32, i32* %10
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [5 x i32], [5 x i32]* %6, i64 0, i64 %24
%26 = load i32, i32* %25
%27 = load i32, i32* %8
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [5 x i32], [5 x i32]* %6, i64 0, i64 %28
%30 = load i32, i32* %29
%31 = sub nsw i32 %26, %30
%32 = load i32, i32* %9
%33 = icmp sgt i32 %31, %32
br i1 %33, label %34, label %44
34: ; preds = %22
%35 = load i32, i32* %10
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [5 x i32], [5 x i32]* %6, i64 0, i64 %36
%38 = load i32, i32* %37
%39 = load i32, i32* %8
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds [5 x i32], [5 x i32]* %6, i64 0, i64 %40
%42 = load i32, i32* %41
%43 = sub nsw i32 %38, %42
store i32 %43, i32* %9
br label %44
44: ; preds = %34, %22
%45 = load i32, i32* %10
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds [5 x i32], [5 x i32]* %6, i64 0, i64 %46
%48 = load i32, i32* %47
%49 = load i32, i32* %8
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds [5 x i32], [5 x i32]* %6, i64 0, i64 %50
%52 = load i32, i32* %51
%53 = icmp slt i32 %48, %52
br i1 %53, label %54, label %56
54: ; preds = %44
%55 = load i32, i32* %10
store i32 %55, i32* %8
br label %56
56: ; preds = %54, %44
br label %57
57: ; preds = %56
%58 = load i32, i32* %10
%59 = add nsw i32 %58, 1
store i32 %59, i32* %10
br label %18
60: ; preds = %18
%61 = load i32, i32* %8
%62 = load i32, i32* %8
%63 = sext i32 %62 to i64
%64 = getelementptr inbounds [5 x i32], [5 x i32]* %6, i64 0, i64 %63
%65 = load i32, i32* %64
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0), i32 %61, i32 %65)
ret i32 0
}

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