#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 *, ...);
void minmax(int a[], int len, int *max, int *min) {
  int i;
  printf("minmax a=%p\n", a);
  printf("minmax sizeof(a)=%lu\n", sizeof(a));
  a[0] = 1000;
  *min = *max = a[0];
  for (i = 1; i < len; i++) {
    if (a[i] < *min) {
      *min = a[i];
    }
    if (a[i] > *max) {
      *max = a[i];
    }
  }
}


x86 assembly (clang, -O0):
<minmax>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xece(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xecd(%rip),%rdi
mov    $0x8,%esi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
movl   $0x3e8,(%rax)
mov    -0x8(%rbp),%rax
mov    (%rax),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x1,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11de <minmax+0xce>
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    -0x20(%rbp),%rcx
cmp    (%rcx),%eax
jge    11a3 <minmax+0x93>
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,4),%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    -0x18(%rbp),%rcx
cmp    (%rcx),%eax
jle    11cb <minmax+0xbb>
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,4),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
jmp    11d0 <minmax+0xc0>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    116f <minmax+0x5f>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<minmax>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rcx,%r14
mov    %rdx,%r15
mov    %esi,%ebp
mov    %rdi,%rbx
lea    0xed7(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xed3(%rip),%rdi
mov    $0x8,%esi
xor    %eax,%eax
call   1030 <printf@plt>
movl   $0x3e8,(%rbx)
movl   $0x3e8,(%r15)
movl   $0x3e8,(%r14)
cmp    $0x2,%ebp
jl     11ad <minmax+0x9d>
mov    %ebp,%eax
add    $0xfffffffffffffffe,%rax
mov    $0x3e8,%esi
xor    %ecx,%ecx
nopl   0x0(%rax)
mov    0x4(%rbx,%rcx,4),%edx
cmp    %esi,%edx
jl     1190 <minmax+0x80>
cmp    (%r15),%edx
jg     119c <minmax+0x8c>
cmp    %rcx,%rax
jne    11a4 <minmax+0x94>
jmp    11ad <minmax+0x9d>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %edx,(%r14)
mov    0x4(%rbx,%rcx,4),%edx
cmp    (%r15),%edx
jle    117d <minmax+0x6d>
mov    %edx,(%r15)
cmp    %rcx,%rax
je     11ad <minmax+0x9d>
mov    (%r14),%esi
add    $0x1,%rcx
jmp    1170 <minmax+0x60>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [13 x i8] c"minmax a=%p\0A\00"
@.str.1 = [22 x i8] c"minmax sizeof(a)=%lu\0A\00"
define void @minmax(i32* %0, i32 %1, i32* nocapture %2, i32* nocapture %3) {
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32* %0)
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i64 8)
store i32 1000, i32* %0
store i32 1000, i32* %2
store i32 1000, i32* %3
%7 = icmp sgt i32 %1, 1
br i1 %7, label %8, label %28
8: ; preds = %4
%9 = zext i32 %1 to i64
br label %10
10: ; preds = %26, %8
%11 = phi i32 [ 1000, %8 ], [ %27, %26 ]
%12 = phi i64 [ 1, %8 ], [ %24, %26 ]
%13 = getelementptr inbounds i32, i32* %0, i64 %12
%14 = load i32, i32* %13
%15 = icmp slt i32 %14, %11
br i1 %15, label %16, label %18
16: ; preds = %10
store i32 %14, i32* %3
%17 = load i32, i32* %13
br label %18
18: ; preds = %16, %10
%19 = phi i32 [ %17, %16 ], [ %14, %10 ]
%20 = load i32, i32* %2
%21 = icmp sgt i32 %19, %20
br i1 %21, label %22, label %23
22: ; preds = %18
store i32 %19, i32* %2
br label %23
23: ; preds = %18, %22
%24 = add nuw nsw i64 %12, 1
%25 = icmp eq i64 %24, %9
br i1 %25, label %28, label %26
26: ; preds = %23
%27 = load i32, i32* %3
br label %10
28: ; preds = %23, %4
ret void
}