#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 max, min;
  int num;
  int init = 0;
  printf("Escriba 0 cuando desee imprimir el maximo y minimo\n\n");
  printf("Ingrese un numero: ");
  scanf("%d", &num);
  while (num != 0) {
    if (!init) {
      max = min = num;
      init = 1;
    }
    max = (num > max) ? num : max;
    min = (num < min) ? num : min;
    printf("Ingrese un numero: ");
    scanf("%d", &num);
  }
  if (init) {
    printf("Numero maximo: %d\n", max);
    printf("Numero minimo: %d\n", min);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x14(%rbp)
lea    0xec3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeea(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xef0(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x0,-0x10(%rbp)
je     11ef <main+0xcf>
cmpl   $0x0,-0x14(%rbp)
jne    1186 <main+0x66>
mov    -0x10(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    %eax,-0x8(%rbp)
movl   $0x1,-0x14(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jle    119d <main+0x7d>
mov    -0x10(%rbp),%eax
mov    %eax,-0x18(%rbp)
jmp    11a3 <main+0x83>
mov    -0x8(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11c0 <main+0xa0>
mov    -0x10(%rbp),%eax
mov    %eax,-0x1c(%rbp)
jmp    11c6 <main+0xa6>
mov    -0xc(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0xc(%rbp)
lea    0xe62(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe68(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
jmp    1162 <main+0x42>
cmpl   $0x0,-0x14(%rbp)
je     121b <main+0xfb>
mov    -0x8(%rbp),%esi
lea    0xe49(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%esi
lea    0xe4b(%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    0xefb(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb2(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeb8(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%r13d
test   %r13d,%r13d
je     1214 <main+0xe4>
lea    0xe85(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe8b(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%eax
test   %eax,%eax
je     11ee <main+0xbe>
lea    0xe5e(%rip),%r14
lea    0xe6b(%rip),%r15
lea    0x4(%rsp),%r12
mov    %r13d,%ebx
mov    %r13d,%ebp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
cmp    %ebp,%eax
cmovg  %eax,%ebp
cmp    %ebx,%eax
cmovl  %eax,%ebx
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%eax
test   %eax,%eax
jne    11c0 <main+0x90>
test   %r13d,%r13d
jne    11f4 <main+0xc4>
jmp    1214 <main+0xe4>
mov    %r13d,%ebx
mov    %r13d,%ebp
lea    0xe1c(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe1f(%rip),%rdi
mov    %ebx,%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 = [53 x i8] c"Escriba 0 cuando desee imprimir el maximo y minimo\0A\0A\00"
@.str.1 = [20 x i8] c"Ingrese un numero: \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [19 x i8] c"Numero maximo: %d\0A\00"
@.str.4 = [19 x i8] c"Numero minimo: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %5
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str, i64 0, i64 0))
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %4)
br label %9
9: ; preds = %34, %0
%10 = load i32, i32* %4
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %38
12: ; preds = %9
%13 = load i32, i32* %5
%14 = icmp ne i32 %13, 0
br i1 %14, label %17, label %15
15: ; preds = %12
%16 = load i32, i32* %4
store i32 %16, i32* %3
store i32 %16, i32* %2
store i32 1, i32* %5
br label %17
17: ; preds = %15, %12
%18 = load i32, i32* %4
%19 = load i32, i32* %2
%20 = icmp sgt i32 %18, %19
br i1 %20, label %21, label %23
21: ; preds = %17
%22 = load i32, i32* %4
br label %25
23: ; preds = %17
%24 = load i32, i32* %2
br label %25
25: ; preds = %23, %21
%26 = phi i32 [ %22, %21 ], [ %24, %23 ]
store i32 %26, i32* %2
%27 = load i32, i32* %4
%28 = load i32, i32* %3
%29 = icmp slt i32 %27, %28
br i1 %29, label %30, label %32
30: ; preds = %25
%31 = load i32, i32* %4
br label %34
32: ; preds = %25
%33 = load i32, i32* %3
br label %34
34: ; preds = %32, %30
%35 = phi i32 [ %31, %30 ], [ %33, %32 ]
store i32 %35, i32* %3
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
%37 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %4)
br label %9
38: ; preds = %9
%39 = load i32, i32* %5
%40 = icmp ne i32 %39, 0
br i1 %40, label %41, label %46
41: ; preds = %38
%42 = load i32, i32* %2
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i32 %42)
%44 = load i32, i32* %3
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i32 %44)
br label %46
46: ; preds = %41, %38
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [20 x i8] c"Ingrese un numero: \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [19 x i8] c"Numero maximo: %d\0A\00"
@.str.4 = [19 x i8] c"Numero minimo: %d\0A\00"
@str = [52 x i8] c"Escriba 0 cuando desee imprimir el maximo y minimo\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%6 = load i32, i32* %1
%7 = icmp eq i32 %6, 0
br i1 %7, label %31, label %8
8: ; preds = %0
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
%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 eq i32 %11, 0
br i1 %12, label %26, label %13
13: ; preds = %8, %13
%14 = phi i32 [ %23, %13 ], [ %11, %8 ]
%15 = phi i32 [ %20, %13 ], [ %6, %8 ]
%16 = phi i32 [ %18, %13 ], [ %6, %8 ]
%17 = icmp sgt i32 %14, %16
%18 = select i1 %17, i32 %14, i32 %16
%19 = icmp slt i32 %14, %15
%20 = select i1 %19, i32 %14, i32 %15
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
%22 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%23 = load i32, i32* %1
%24 = icmp eq i32 %23, 0
br i1 %24, label %25, label %13
25: ; preds = %13
br i1 %7, label %31, label %26
26: ; preds = %8, %25
%27 = phi i32 [ %20, %25 ], [ %6, %8 ]
%28 = phi i32 [ %18, %25 ], [ %6, %8 ]
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i32 %28)
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i32 %27)
br label %31
31: ; preds = %0, %26, %25
ret i32 0
}