#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("Digite um numero: ");
    scanf("%d", &n);
    maior == 0 ? maior = n : n > maior &&n != -9999 ? maior = n : maior;
  }
  printf("Maior = %d", maior);
}


x86 assembly (clang, -O0):
<ex8>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x8(%rbp)
cmpl   $0xffffd8f1,-0x4(%rbp)
je     11a4 <ex8+0x84>
lea    0xebd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeca(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x0,-0x8(%rbp)
jne    116f <ex8+0x4f>
mov    -0x4(%rbp),%eax
mov    %eax,-0x8(%rbp)
jmp    119f <ex8+0x7f>
mov    -0x4(%rbp),%eax
cmp    -0x8(%rbp),%eax
jle    1196 <ex8+0x76>
cmpl   $0xffffd8f1,-0x4(%rbp)
je     1196 <ex8+0x76>
mov    -0x4(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    %eax,-0xc(%rbp)
jmp    119c <ex8+0x7c>
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
jmp    112f <ex8+0xf>
mov    -0x8(%rbp),%esi
lea    0xe65(%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    0xee5(%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    $0xffffd8f1,%eax
mov    %ebx,%ecx
cmovne %eax,%ecx
cmp    %ebx,%eax
cmovle %ebx,%ecx
test   %ebx,%ebx
mov    %ecx,%ebx
cmove  %eax,%ebx
cmp    $0xffffd8f1,%eax
jne    1140 <ex8+0x20>
lea    0xe96(%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 = [19 x i8] c"Digite um numero: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [11 x i8] c"Maior = %d\00"
define void @ex8() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %2
br label %3
3: ; preds = %26, %0
%4 = load i32, i32* %1
%5 = icmp ne i32 %4, -9999
br i1 %5, label %6, label %28
6: ; preds = %3
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 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* %2
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %6
%12 = load i32, i32* %1
store i32 %12, i32* %2
br label %26
13: ; preds = %6
%14 = load i32, i32* %1
%15 = load i32, i32* %2
%16 = icmp sgt i32 %14, %15
br i1 %16, label %17, label %22
17: ; preds = %13
%18 = load i32, i32* %1
%19 = icmp ne i32 %18, -9999
br i1 %19, label %20, label %22
20: ; preds = %17
%21 = load i32, i32* %1
store i32 %21, i32* %2
br label %24
22: ; preds = %17, %13
%23 = load i32, i32* %2
br label %24
24: ; preds = %22, %20
%25 = phi i32 [ %21, %20 ], [ %23, %22 ]
br label %26
26: ; preds = %24, %11
%27 = phi i32 [ %12, %11 ], [ %25, %24 ]
br label %3
28: ; preds = %3
%29 = load i32, i32* %2
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %29)
ret void
}

LLVM IR (-O2):
@.str = [19 x i8] c"Digite um numero: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [11 x i8] c"Maior = %d\00"
define void @ex8() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
br label %3
3: ; preds = %0, %3
%4 = phi i32 [ %13, %3 ], [ 0, %0 ]
%5 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 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 = icmp eq i32 %4, 0
%8 = load i32, i32* %1
%9 = icmp sgt i32 %8, %4
%10 = icmp ne i32 %8, -9999
%11 = and i1 %9, %10
%12 = select i1 %7, i1 true, i1 %11
%13 = select i1 %12, i32 %8, i32 %4
%14 = icmp eq i32 %8, -9999
br i1 %14, label %15, label %3
15: ; preds = %3
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %13)
ret void
}