#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 /*<<< orphan*/ printf(char *, int, int);
int main() {
  int a[10] = {3, 5, 12, 8, 7, 22, 14, 4, 7, 11};
  int max = 0;
  int min = 0;
  int posMax;
  int posMin;
  int i;
  int j;
  int *ptr_max;
  int *ptr_min;
  int *ptr_pMax;
  int *ptr_pMin;
  ptr_max = &max;
  ptr_min = &min;
  ptr_pMax = &posMax;
  ptr_pMin = &posMin;
  *ptr_max = a[0];
  *ptr_min = a[0];
  *ptr_pMax = 0;
  *ptr_pMin = 0;
  for (i = 0; i < 10; i++) {
    if (a[i] > *ptr_max) {
      *ptr_max = a[i];
      *ptr_pMax = i;
    }
  }
  for (j = 0; i < 10; i++) {
    if (a[j] < *ptr_min) {
      *ptr_min = a[j];
      *ptr_pMin = j;
    }
  }
  printf("El valor maximo es %d y esta en la posicion %d del array\n", *ptr_max,
         *ptr_pMax);
  printf("El valor minimo es %d y esta en la posicion %d del array\n", *ptr_min,
         *ptr_pMin);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x30(%rbp),%rdi
lea    0xec6(%rip),%rsi
mov    $0x28,%edx
call   1040 <memcpy@plt>
movl   $0x0,-0x34(%rbp)
movl   $0x0,-0x38(%rbp)
lea    -0x34(%rbp),%rax
mov    %rax,-0x50(%rbp)
lea    -0x38(%rbp),%rax
mov    %rax,-0x58(%rbp)
lea    -0x3c(%rbp),%rax
mov    %rax,-0x60(%rbp)
lea    -0x40(%rbp),%rax
mov    %rax,-0x68(%rbp)
mov    -0x30(%rbp),%ecx
mov    -0x50(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x30(%rbp),%ecx
mov    -0x58(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x60(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x68(%rbp),%rax
movl   $0x0,(%rax)
movl   $0x0,-0x44(%rbp)
cmpl   $0xa,-0x44(%rbp)
jge    11e7 <main+0xc7>
movslq -0x44(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%eax
mov    -0x50(%rbp),%rcx
cmp    (%rcx),%eax
jle    11d4 <main+0xb4>
movslq -0x44(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%ecx
mov    -0x50(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x44(%rbp),%ecx
mov    -0x60(%rbp),%rax
mov    %ecx,(%rax)
jmp    11d9 <main+0xb9>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    119f <main+0x7f>
movl   $0x0,-0x48(%rbp)
cmpl   $0xa,-0x44(%rbp)
jge    1236 <main+0x116>
movslq -0x48(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%eax
mov    -0x58(%rbp),%rcx
cmp    (%rcx),%eax
jge    1223 <main+0x103>
movslq -0x48(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%ecx
mov    -0x58(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x48(%rbp),%ecx
mov    -0x68(%rbp),%rax
mov    %ecx,(%rax)
jmp    1228 <main+0x108>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    11ee <main+0xce>
mov    -0x50(%rbp),%rax
mov    (%rax),%esi
mov    -0x60(%rbp),%rax
mov    (%rax),%edx
lea    0xddf(%rip),%rdi
call   1030 <printf@plt>
mov    -0x58(%rbp),%rax
mov    (%rax),%esi
mov    -0x68(%rbp),%rax
mov    (%rax),%edx
lea    0xe01(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

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

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

LLVM IR (-O2):
@.str = [58 x i8] c"El valor maximo es %d y esta en la posicion %d del array\0A\00"
@.str.1 = [58 x i8] c"El valor minimo es %d y esta en la posicion %d del array\0A\00"
define i32 @main() {
%1 = tail call i32 @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str, i64 0, i64 0), i32 22, i32 5)
%2 = tail call i32 @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.1, i64 0, i64 0), i32 3, i32 0)
ret i32 0
}