#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 */
typedef int /*<<< orphan*/ buf;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int INT_MAX;
int INT_MIN;
int atoi(char *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int range_processor(FILE *fp) {
  int min = INT_MAX;
  int max = INT_MIN;
  char buf[256];
  while ((fgets(buf, sizeof(buf), fp)) != NULL) {
    if (buf[0] == '\n')
      return -1;
    int value = atoi(buf);
    min = min > value ? value : min;
    max = max < value ? value : max;
  }
  return max - min;
}


x86 assembly (clang, -O0):
<range_processor>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
mov    %rdi,-0x10(%rbp)
mov    0x2eb2(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    0x2e9e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
lea    -0x120(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x100,%esi
call   1030 <fgets@plt>
cmp    $0x0,%rax
je     11fd <range_processor+0xdd>
movsbl -0x120(%rbp),%eax
cmp    $0xa,%eax
jne    1182 <range_processor+0x62>
movl   $0xffffffff,-0x4(%rbp)
jmp    1206 <range_processor+0xe6>
lea    -0x120(%rbp),%rdi
call   1040 <atoi@plt>
mov    %eax,-0x124(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x124(%rbp),%eax
jle    11b4 <range_processor+0x94>
mov    -0x124(%rbp),%eax
mov    %eax,-0x128(%rbp)
jmp    11bd <range_processor+0x9d>
mov    -0x14(%rbp),%eax
mov    %eax,-0x128(%rbp)
mov    -0x128(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x124(%rbp),%eax
jge    11e6 <range_processor+0xc6>
mov    -0x124(%rbp),%eax
mov    %eax,-0x12c(%rbp)
jmp    11ef <range_processor+0xcf>
mov    -0x18(%rbp),%eax
mov    %eax,-0x12c(%rbp)
mov    -0x12c(%rbp),%eax
mov    %eax,-0x18(%rbp)
jmp    1147 <range_processor+0x27>
mov    -0x18(%rbp),%eax
sub    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<range_processor>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x108,%rsp
mov    %rdi,%r14
mov    0x2eb1(%rip),%rax
mov    (%rax),%ebp
mov    0x2ea0(%rip),%rax
mov    (%rax),%ebx
mov    %rsp,%rdi
mov    $0x100,%esi
mov    %r14,%rdx
call   1030 <fgets@plt>
test   %rax,%rax
je     118d <range_processor+0x6d>
mov    %rsp,%r15
nopw   0x0(%rax,%rax,1)
cmpb   $0xa,(%rsp)
je     1191 <range_processor+0x71>
mov    %r15,%rdi
call   1040 <atoi@plt>
cmp    %eax,%ebp
cmovg  %eax,%ebp
cmp    %eax,%ebx
cmovl  %eax,%ebx
mov    %r15,%rdi
mov    $0x100,%esi
mov    %r14,%rdx
call   1030 <fgets@plt>
test   %rax,%rax
jne    1160 <range_processor+0x40>
sub    %ebp,%ebx
jmp    1196 <range_processor+0x76>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
add    $0x108,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@INT_MAX = global i32 0
@INT_MIN = global i32 0
define i32 @range_processor(i32* %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca [256 x i8]
%7 = alloca i32
store i32* %0, i32** %3
%8 = load i32, i32* @INT_MAX
store i32 %8, i32* %4
%9 = load i32, i32* @INT_MIN
store i32 %9, i32* %5
br label %10
10: ; preds = %40, %1
%11 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%12 = load i32*, i32** %3
%13 = call i32* @fgets(i8* %11, i32 256, i32* %12)
%14 = icmp ne i32* %13, null
br i1 %14, label %15, label %42
15: ; preds = %10
%16 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = icmp eq i32 %18, 10
br i1 %19, label %20, label %21
20: ; preds = %15
store i32 -1, i32* %2
br label %46
21: ; preds = %15
%22 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%23 = call i32 @atoi(i8* %22)
store i32 %23, i32* %7
%24 = load i32, i32* %4
%25 = load i32, i32* %7
%26 = icmp sgt i32 %24, %25
br i1 %26, label %27, label %29
27: ; preds = %21
%28 = load i32, i32* %7
br label %31
29: ; preds = %21
%30 = load i32, i32* %4
br label %31
31: ; preds = %29, %27
%32 = phi i32 [ %28, %27 ], [ %30, %29 ]
store i32 %32, i32* %4
%33 = load i32, i32* %5
%34 = load i32, i32* %7
%35 = icmp slt i32 %33, %34
br i1 %35, label %36, label %38
36: ; preds = %31
%37 = load i32, i32* %7
br label %40
38: ; preds = %31
%39 = load i32, i32* %5
br label %40
40: ; preds = %38, %36
%41 = phi i32 [ %37, %36 ], [ %39, %38 ]
store i32 %41, i32* %5
br label %10
42: ; preds = %10
%43 = load i32, i32* %5
%44 = load i32, i32* %4
%45 = sub nsw i32 %43, %44
store i32 %45, i32* %2
br label %46
46: ; preds = %42, %20
%47 = load i32, i32* %2
ret i32 %47
}

LLVM IR (-O2):
@INT_MAX = global i32 0
@INT_MIN = global i32 0
define i32 @range_processor(i32* nocapture %0) {
%2 = alloca [256 x i8]
%3 = load i32, i32* @INT_MAX
%4 = load i32, i32* @INT_MIN
%5 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%6 = call i32* @fgets(i8* %5, i32 256, i32* %0)
%7 = icmp eq i32* %6, null
br i1 %7, label %21, label %8
8: ; preds = %1, %13
%9 = phi i32 [ %18, %13 ], [ %4, %1 ]
%10 = phi i32 [ %16, %13 ], [ %3, %1 ]
%11 = load i8, i8* %5
%12 = icmp eq i8 %11, 10
br i1 %12, label %25, label %13
13: ; preds = %8
%14 = call i32 @atoi(i8* %5)
%15 = icmp sgt i32 %10, %14
%16 = select i1 %15, i32 %14, i32 %10
%17 = icmp slt i32 %9, %14
%18 = select i1 %17, i32 %14, i32 %9
%19 = call i32* @fgets(i8* %5, i32 256, i32* %0)
%20 = icmp eq i32* %19, null
br i1 %20, label %21, label %8
21: ; preds = %13, %1
%22 = phi i32 [ %3, %1 ], [ %16, %13 ]
%23 = phi i32 [ %4, %1 ], [ %18, %13 ]
%24 = sub nsw i32 %23, %22
br label %25
25: ; preds = %8, %21
%26 = phi i32 [ %24, %21 ], [ -1, %8 ]
ret i32 %26
}