#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 /*<<< orphan*/ scanf(char *, int *);
void ex4() {
  int tm[12], menor = 0, maior = 0, f = 0;
  for (int i = 0; i < 12; i++) {
    printf("Informe a temperatura do mes n%d: ", i + 1);
    scanf("%d", &tm[i]);
    if (tm[i] > tm[maior])
      maior = i;
    if (!f++ || tm[i] < tm[menor])
      menor = i;
  }
  for (int i = 0; i < 12; i++)
    printf("Temperatura mes n%d=%d\n", i + 1, tm[i]);
  printf("Maior temperatura:\n\tmes=%d\n\ttemp=%d\n", maior + 1, tm[maior]);
  printf("Menor temperatura:\n\tmes=%d\n\ttemp=%d\n", menor + 1, tm[menor]);
}


x86 assembly (clang, -O0):
<ex4>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x34(%rbp)
movl   $0x0,-0x38(%rbp)
movl   $0x0,-0x3c(%rbp)
movl   $0x0,-0x40(%rbp)
cmpl   $0xc,-0x40(%rbp)
jge    11dc <ex4+0xbc>
mov    -0x40(%rbp),%esi
add    $0x1,%esi
lea    0xea5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movslq -0x40(%rbp),%rax
lea    -0x30(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xeab(%rip),%rdi
call   1040 <scanf@plt>
movslq -0x40(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%eax
movslq -0x38(%rbp),%rcx
cmp    -0x30(%rbp,%rcx,4),%eax
jle    1199 <ex4+0x79>
mov    -0x40(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    -0x3c(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x3c(%rbp)
cmp    $0x0,%eax
je     11c3 <ex4+0xa3>
movslq -0x40(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%eax
movslq -0x34(%rbp),%rcx
cmp    -0x30(%rbp,%rcx,4),%eax
jge    11c9 <ex4+0xa9>
mov    -0x40(%rbp),%eax
mov    %eax,-0x34(%rbp)
jmp    11ce <ex4+0xae>
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    1144 <ex4+0x24>
movl   $0x0,-0x44(%rbp)
cmpl   $0xc,-0x44(%rbp)
jge    1217 <ex4+0xf7>
mov    -0x44(%rbp),%esi
add    $0x1,%esi
movslq -0x44(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%edx
lea    0xe24(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    11e3 <ex4+0xc3>
mov    -0x38(%rbp),%esi
add    $0x1,%esi
movslq -0x38(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%edx
lea    0xe12(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x34(%rbp),%esi
add    $0x1,%esi
movslq -0x34(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%edx
lea    0xe1b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ex4>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
lea    0xecb(%rip),%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xedb(%rip),%rdi
mov    %rsp,%rsi
call   1040 <scanf@plt>
lea    0x4(%rsp),%rbp
mov    $0x1,%r14d
mov    $0x2,%ebx
xor    %r12d,%r12d
xor    %r13d,%r13d
jmp    1186 <ex4+0x66>
nopl   0x0(%rax,%rax,1)
mov    %r14d,%r13d
add    $0x4,%rbp
add    $0x1,%ebx
mov    %rax,%r14
mov    %r15d,%r12d
cmp    $0xc,%rax
je     11ca <ex4+0xaa>
lea    0xe73(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe86(%rip),%rdi
mov    %rbp,%rsi
call   1040 <scanf@plt>
mov    0x0(%rbp),%ecx
movslq %r12d,%rax
mov    %r14d,%r15d
cmp    (%rsp,%rax,4),%ecx
jg     11b6 <ex4+0x96>
mov    %r12d,%r15d
mov    %r14,%rax
add    $0x1,%rax
movslq %r13d,%rdx
cmp    (%rsp,%rdx,4),%ecx
jl     1170 <ex4+0x50>
mov    %r13d,%r14d
jmp    1170 <ex4+0x50>
mov    (%rsp),%edx
lea    0xe52(%rip),%r14
mov    %r14,%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x4(%rsp),%edx
mov    %r14,%rdi
mov    $0x2,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x8(%rsp),%edx
mov    %r14,%rdi
mov    $0x3,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0xc(%rsp),%edx
mov    %r14,%rdi
mov    $0x4,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x10(%rsp),%edx
mov    %r14,%rdi
mov    $0x5,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x14(%rsp),%edx
mov    %r14,%rdi
mov    $0x6,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x18(%rsp),%edx
mov    %r14,%rdi
mov    $0x7,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x1c(%rsp),%edx
mov    %r14,%rdi
mov    $0x8,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x20(%rsp),%edx
mov    %r14,%rdi
mov    $0x9,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x24(%rsp),%edx
mov    %r14,%rdi
mov    $0xa,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x28(%rsp),%edx
mov    %r14,%rdi
mov    $0xb,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x2c(%rsp),%edx
mov    %r14,%rdi
mov    $0xc,%esi
xor    %eax,%eax
call   1030 <printf@plt>
movslq %r15d,%rax
add    $0x1,%r15d
mov    (%rsp,%rax,4),%edx
lea    0xd79(%rip),%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1030 <printf@plt>
movslq %r13d,%rax
add    $0x1,%r13d
mov    (%rsp,%rax,4),%edx
lea    0xd83(%rip),%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [35 x i8] c"Informe a temperatura do mes n%d: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [24 x i8] c"Temperatura mes n%d=%d\0A\00"
@.str.3 = [37 x i8] c"Maior temperatura:\0A\09mes=%d\0A\09temp=%d\0A\00"
@.str.4 = [37 x i8] c"Menor temperatura:\0A\09mes=%d\0A\09temp=%d\0A\00"
define void @ex4() {
%1 = alloca [12 x i32]
%2 = bitcast [12 x i32]* %1 to i8*
%3 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i32 1)
%4 = getelementptr inbounds [12 x i32], [12 x i32]* %1, i64 0, i64 0
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
br label %52
6: ; preds = %52
%7 = load i32, i32* %4
%8 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i32 1, i32 %7)
%9 = getelementptr inbounds [12 x i32], [12 x i32]* %1, i64 0, i64 1
%10 = load i32, i32* %9
%11 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i32 2, i32 %10)
%12 = getelementptr inbounds [12 x i32], [12 x i32]* %1, i64 0, i64 2
%13 = load i32, i32* %12
%14 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i32 3, i32 %13)
%15 = getelementptr inbounds [12 x i32], [12 x i32]* %1, i64 0, i64 3
%16 = load i32, i32* %15
%17 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i32 4, i32 %16)
%18 = getelementptr inbounds [12 x i32], [12 x i32]* %1, i64 0, i64 4
%19 = load i32, i32* %18
%20 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i32 5, i32 %19)
%21 = getelementptr inbounds [12 x i32], [12 x i32]* %1, i64 0, i64 5
%22 = load i32, i32* %21
%23 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i32 6, i32 %22)
%24 = getelementptr inbounds [12 x i32], [12 x i32]* %1, i64 0, i64 6
%25 = load i32, i32* %24
%26 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i32 7, i32 %25)
%27 = getelementptr inbounds [12 x i32], [12 x i32]* %1, i64 0, i64 7
%28 = load i32, i32* %27
%29 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i32 8, i32 %28)
%30 = getelementptr inbounds [12 x i32], [12 x i32]* %1, i64 0, i64 8
%31 = load i32, i32* %30
%32 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i32 9, i32 %31)
%33 = getelementptr inbounds [12 x i32], [12 x i32]* %1, i64 0, i64 9
%34 = load i32, i32* %33
%35 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i32 10, i32 %34)
%36 = getelementptr inbounds [12 x i32], [12 x i32]* %1, i64 0, i64 10
%37 = load i32, i32* %36
%38 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i32 11, i32 %37)
%39 = getelementptr inbounds [12 x i32], [12 x i32]* %1, i64 0, i64 11
%40 = load i32, i32* %39
%41 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i32 12, i32 %40)
%42 = add nsw i32 %67, 1
%43 = sext i32 %67 to i64
%44 = getelementptr inbounds [12 x i32], [12 x i32]* %1, i64 0, i64 %43
%45 = load i32, i32* %44
%46 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0), i32 %42, i32 %45)
%47 = add nsw i32 %72, 1
%48 = sext i32 %72 to i64
%49 = getelementptr inbounds [12 x i32], [12 x i32]* %1, i64 0, i64 %48
%50 = load i32, i32* %49
%51 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0), i32 %47, i32 %50)
ret void
52: ; preds = %52, %0
%53 = phi i64 [ 1, %0 ], [ %56, %52 ]
%54 = phi i32 [ 0, %0 ], [ %67, %52 ]
%55 = phi i32 [ 0, %0 ], [ %72, %52 ]
%56 = add nuw nsw i64 %53, 1
%57 = trunc i64 %56 to i32
%58 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i32 %57)
%59 = getelementptr inbounds [12 x i32], [12 x i32]* %1, i64 0, i64 %53
%60 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %59)
%61 = load i32, i32* %59
%62 = sext i32 %54 to i64
%63 = getelementptr inbounds [12 x i32], [12 x i32]* %1, i64 0, i64 %62
%64 = load i32, i32* %63
%65 = icmp sgt i32 %61, %64
%66 = trunc i64 %53 to i32
%67 = select i1 %65, i32 %66, i32 %54
%68 = sext i32 %55 to i64
%69 = getelementptr inbounds [12 x i32], [12 x i32]* %1, i64 0, i64 %68
%70 = load i32, i32* %69
%71 = icmp slt i32 %61, %70
%72 = select i1 %71, i32 %66, i32 %55
%73 = icmp eq i64 %56, 12
br i1 %73, label %6, label %52
}