#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 get_array(int *);
int max_index(int *, int *, int);
int max_value(int *, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ put_array(int *, int);
int main() {
  int array[1010], size;
  int index[1010], idx_size;
  size = get_array(array);
  idx_size = max_index(index, array, size);
  printf("maximum number is %d, ", max_value(array, size));
  printf("whose positions are:");
  put_array(index, idx_size);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1fb0,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0xfd0(%rbp),%rdi
call   1060 <get_array@plt>
mov    %eax,-0xfd4(%rbp)
lea    -0x1fa0(%rbp),%rdi
lea    -0xfd0(%rbp),%rsi
mov    -0xfd4(%rbp),%edx
call   1070 <max_index@plt>
mov    %eax,-0x1fa4(%rbp)
lea    -0xfd0(%rbp),%rdi
mov    -0xfd4(%rbp),%esi
call   1040 <max_value@plt>
mov    %eax,%esi
lea    0xe52(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe5b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x1fa0(%rbp),%rdi
mov    -0x1fa4(%rbp),%esi
call   1050 <put_array@plt>
xor    %eax,%eax
add    $0x1fb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x1f98,%rsp
lea    0xfd0(%rsp),%rbx
mov    %rbx,%rdi
call   1060 <get_array@plt>
mov    %eax,%ebp
mov    %rsp,%r14
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1070 <max_index@plt>
mov    %eax,%r15d
mov    %rbx,%rdi
mov    %ebp,%esi
call   1040 <max_value@plt>
lea    0xe6d(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe74(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r14,%rdi
mov    %r15d,%esi
call   1050 <put_array@plt>
xor    %eax,%eax
add    $0x1f98,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [23 x i8] c"maximum number is %d, \00"
@.str.1 = [21 x i8] c"whose positions are:\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [1010 x i32]
%3 = alloca i32
%4 = alloca [1010 x i32]
%5 = alloca i32
store i32 0, i32* %1
%6 = getelementptr inbounds [1010 x i32], [1010 x i32]* %2, i64 0, i64 0
%7 = call i32 @get_array(i32* %6)
store i32 %7, i32* %3
%8 = getelementptr inbounds [1010 x i32], [1010 x i32]* %4, i64 0, i64 0
%9 = getelementptr inbounds [1010 x i32], [1010 x i32]* %2, i64 0, i64 0
%10 = load i32, i32* %3
%11 = call i32 @max_index(i32* %8, i32* %9, i32 %10)
store i32 %11, i32* %5
%12 = getelementptr inbounds [1010 x i32], [1010 x i32]* %2, i64 0, i64 0
%13 = load i32, i32* %3
%14 = call i32 @max_value(i32* %12, i32 %13)
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %14)
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
%17 = getelementptr inbounds [1010 x i32], [1010 x i32]* %4, i64 0, i64 0
%18 = load i32, i32* %5
%19 = call i32 @put_array(i32* %17, i32 %18)
ret i32 0
}

LLVM IR (-O2):
@.str = [23 x i8] c"maximum number is %d, \00"
@.str.1 = [21 x i8] c"whose positions are:\00"
define i32 @main() {
%1 = alloca [1010 x i32]
%2 = alloca [1010 x i32]
%3 = bitcast [1010 x i32]* %1 to i8*
%4 = bitcast [1010 x i32]* %2 to i8*
%5 = getelementptr inbounds [1010 x i32], [1010 x i32]* %1, i64 0, i64 0
%6 = call i32 @get_array(i32* %5)
%7 = getelementptr inbounds [1010 x i32], [1010 x i32]* %2, i64 0, i64 0
%8 = call i32 @max_index(i32* %7, i32* %5, i32 %6)
%9 = call i32 @max_value(i32* %5, i32 %6)
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %9)
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
%12 = call i32 @put_array(i32* %7, i32 %8)
ret i32 0
}