#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 *);
void ex8() {
  int n, maior = 0;
  while (n != -9999) {
    printf("Informe um numero [-9999 para encerrar]: ");
    scanf("%d", &n);
    if (n > maior)
      maior = n;
  }
  printf("O maior dentre os numeros informados e: %d", maior);
}


x86 assembly (clang, -O0):
<ex8>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x8(%rbp)
cmpl   $0xffffd8f1,-0x4(%rbp)
je     1171 <ex8+0x51>
lea    0xebd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf01(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x4(%rbp),%eax
cmp    -0x8(%rbp),%eax
jle    116c <ex8+0x4c>
mov    -0x4(%rbp),%eax
mov    %eax,-0x8(%rbp)
jmp    112f <ex8+0xf>
mov    -0x8(%rbp),%esi
lea    0xeaf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ex8>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
lea    0xed1(%rip),%r14
lea    0xf1c(%rip),%r15
lea    0x4(%rsp),%r12
xor    %ebx,%ebx
nopl   (%rax)
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1040 <scanf@plt>
mov    0x4(%rsp),%eax
cmp    %ebx,%eax
cmovg  %eax,%ebx
cmp    $0xffffd8f1,%eax
jne    1140 <ex8+0x20>
lea    0xebe(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [42 x i8] c"Informe um numero [-9999 para encerrar]: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [43 x i8] c"O maior dentre os numeros informados e: %d\00"
define void @ex8() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %2
br label %3
3: ; preds = %14, %0
%4 = load i32, i32* %1
%5 = icmp ne i32 %4, -9999
br i1 %5, label %6, label %15
6: ; preds = %3
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%9 = load i32, i32* %1
%10 = load i32, i32* %2
%11 = icmp sgt i32 %9, %10
br i1 %11, label %12, label %14
12: ; preds = %6
%13 = load i32, i32* %1
store i32 %13, i32* %2
br label %14
14: ; preds = %12, %6
br label %3
15: ; preds = %3
%16 = load i32, i32* %2
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0), i32 %16)
ret void
}

LLVM IR (-O2):
@.str = [42 x i8] c"Informe um numero [-9999 para encerrar]: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [43 x i8] c"O maior dentre os numeros informados e: %d\00"
define void @ex8() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
br label %3
3: ; preds = %0, %3
%4 = phi i32 [ %9, %3 ], [ 0, %0 ]
%5 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%7 = load i32, i32* %1
%8 = icmp sgt i32 %7, %4
%9 = select i1 %8, i32 %7, i32 %4
%10 = icmp eq i32 %7, -9999
br i1 %10, label %11, label %3
11: ; preds = %3
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0), i32 %9)
ret void
}