#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 /*<<< orphan*/ scanf(char *, int *);
int main() {
  int i, cds, maior = 0, melhor_dia, maior_venda;
  printf("\nMarço - Maiores Vendas: \n");
  for (i = 1; i <= 31; i++) {
    printf("Dia %d: ", i);
    scanf("%d", &cds);
    if (cds > maior) {
      melhor_dia = i;
      maior_venda = cds;
      maior = cds;
    }
  }
  printf("Dia: %d\n", melhor_dia);
  printf("Discos Vendidos: %d\n", maior_venda);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x10(%rbp)
lea    0xec3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x8(%rbp)
cmpl   $0x1f,-0x8(%rbp)
jg     11a7 <main+0x87>
mov    -0x8(%rbp),%esi
lea    0xebd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb8(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jle    1194 <main+0x74>
mov    -0x8(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
jmp    1199 <main+0x79>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    114b <main+0x2b>
mov    -0x14(%rbp),%esi
lea    0xe77(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%esi
lea    0xe6f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xee8(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%ebx
lea    0xeb6(%rip),%r12
lea    0x4(%rsp),%r13
xor    %r15d,%r15d
nopl   0x0(%rax,%rax,1)
lea    0xe99(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
mov    %r13,%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%eax
cmp    %r15d,%eax
cmovg  %eax,%r15d
cmovg  %ebx,%ebp
cmovg  %eax,%r14d
add    $0x1,%ebx
cmp    $0x20,%ebx
jne    1160 <main+0x30>
lea    0xe70(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe69(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [28 x i8] c"\0AMar\C3\A7o - Maiores Vendas: \0A\00"
@.str.1 = [9 x i8] c"Dia %d: \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [9 x i8] c"Dia: %d\0A\00"
@.str.4 = [21 x i8] c"Discos Vendidos: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %4
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %2
br label %8
8: ; preds = %23, %0
%9 = load i32, i32* %2
%10 = icmp sle i32 %9, 31
br i1 %10, label %11, label %26
11: ; preds = %8
%12 = load i32, i32* %2
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %12)
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %3)
%15 = load i32, i32* %3
%16 = load i32, i32* %4
%17 = icmp sgt i32 %15, %16
br i1 %17, label %18, label %22
18: ; preds = %11
%19 = load i32, i32* %2
store i32 %19, i32* %5
%20 = load i32, i32* %3
store i32 %20, i32* %6
%21 = load i32, i32* %3
store i32 %21, i32* %4
br label %22
22: ; preds = %18, %11
br label %23
23: ; preds = %22
%24 = load i32, i32* %2
%25 = add nsw i32 %24, 1
store i32 %25, i32* %2
br label %8
26: ; preds = %8
%27 = load i32, i32* %5
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32 %27)
%29 = load i32, i32* %6
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i32 %29)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [9 x i8] c"Dia %d: \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [9 x i8] c"Dia: %d\0A\00"
@.str.4 = [21 x i8] c"Discos Vendidos: %d\0A\00"
@str = [27 x i8] c"\0AMar\C3\A7o - Maiores Vendas: \00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str, i64 0, i64 0))
br label %4
4: ; preds = %0, %4
%5 = phi i32 [ undef, %0 ], [ %15, %4 ]
%6 = phi i32 [ undef, %0 ], [ %14, %4 ]
%7 = phi i32 [ 0, %0 ], [ %13, %4 ]
%8 = phi i32 [ 1, %0 ], [ %16, %4 ]
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %8)
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%11 = load i32, i32* %1
%12 = icmp sgt i32 %11, %7
%13 = select i1 %12, i32 %11, i32 %7
%14 = select i1 %12, i32 %8, i32 %6
%15 = select i1 %12, i32 %11, i32 %5
%16 = add nuw nsw i32 %8, 1
%17 = icmp eq i32 %16, 32
br i1 %17, label %18, label %4
18: ; preds = %4
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32 %14)
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i32 %15)
ret i32 0
}