#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*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ SEEK_SET;
int atoi(char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fread(char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int usage();
int main(int argc, char *argv[]) {
  int start;
  int end;
  int length;
  FILE *piData;
  if ((argc <= 2) || (argc > 3)) {
    return usage();
  } else {
    start = atoi(argv[1]);
    end = atoi(argv[2]);
    if (start < 0) {
      printf("You entered an incorrect start value! The start value must NOT "
             "be negative!\n");
      return 1;
    } else if (end < 0) {
      printf("You entered an incorrect end value! The end value must NOT be "
             "negative!\n");
      return 1;
    } else if (start > end) {
      printf("You entered an incorrect start or end value. End must be GREATER "
             "THAN or EQUAL TO start!\n");
      return 1;
    }
    length = (end - start) + 1;
    char pi_value[length + 1];
    piData = fopen("/dev/pi", "r");
    if (piData == NULL) {
      return 1;
    }
    fseek(piData, start, SEEK_SET);
    fread(pi_value, 1, length, piData);
    fclose(piData);
    pi_value[length] = '\0';
    printf("%s\n", pi_value);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jle    119a <main+0x2a>
cmpl   $0x3,-0x8(%rbp)
jle    11a9 <main+0x39>
mov    $0x0,%al
call   1070 <usage@plt>
mov    %eax,-0x4(%rbp)
jmp    1329 <main+0x1b9>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1090 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1090 <atoi@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    11ed <main+0x7d>
lea    0xe26(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1329 <main+0x1b9>
cmpl   $0x0,-0x18(%rbp)
jge    1211 <main+0xa1>
lea    0xe4f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1329 <main+0x1b9>
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jle    1237 <main+0xc7>
lea    0xe72(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1329 <main+0x1b9>
jmp    123c <main+0xcc>
jmp    1241 <main+0xd1>
mov    -0x18(%rbp),%eax
mov    -0x14(%rbp),%ecx
sub    %ecx,%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %rsp,%rcx
mov    %rcx,-0x30(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x48(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x38(%rbp)
lea    0xe71(%rip),%rdi
lea    0xe72(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    12ad <main+0x13d>
movl   $0x1,-0x4(%rbp)
movl   $0x1,-0x3c(%rbp)
jmp    1301 <main+0x191>
mov    -0x28(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    0x2d25(%rip),%rax
mov    (%rax),%edx
call   1060 <fseek@plt>
mov    -0x48(%rbp),%rdi
mov    -0x1c(%rbp),%edx
mov    -0x28(%rbp),%rcx
mov    $0x1,%esi
call   1030 <fread@plt>
mov    -0x28(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x48(%rbp),%rsi
movslq -0x1c(%rbp),%rax
movb   $0x0,(%rsi,%rax,1)
lea    0xe07(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x3c(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,%rsp
mov    -0x3c(%rbp),%eax
test   %eax,%eax
je     131d <main+0x1ad>
jmp    1318 <main+0x1a8>
jmp    1329 <main+0x1b9>
jmp    1322 <main+0x1b2>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
cmp    $0x3,%edi
jne    11b4 <main+0x44>
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
call   1090 <atoi@plt>
mov    %eax,%r15d
mov    0x10(%rbx),%rdi
call   1090 <atoi@plt>
test   %r15d,%r15d
js     11bb <main+0x4b>
mov    %eax,%ebx
test   %eax,%eax
js     11c4 <main+0x54>
sub    %r15d,%ebx
jae    11e4 <main+0x74>
lea    0xe58(%rip),%rdi
jmp    11cb <main+0x5b>
xor    %eax,%eax
jmp    1070 <usage@plt>
lea    0xee9(%rip),%rdi
jmp    11cb <main+0x5b>
lea    0xe98(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %rsp,%r13
lea    0x2(%rbx),%eax
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
mov    %rsp,%r14
sub    %rax,%r14
mov    %r14,%rsp
lea    0xdfe(%rip),%rdi
lea    0xdff(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     125c <main+0xec>
mov    %rax,%r12
movslq %ebx,%rbx
add    $0x1,%rbx
mov    0x2dbc(%rip),%rax
mov    (%rax),%edx
mov    %r12,%rdi
mov    %r15d,%esi
call   1060 <fseek@plt>
mov    %r14,%rdi
mov    $0x1,%esi
mov    %ebx,%edx
mov    %r12,%rcx
call   1040 <fread@plt>
mov    %r12,%rdi
call   1050 <fclose@plt>
movb   $0x0,(%r14,%rbx,1)
mov    %r14,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
jmp    1261 <main+0xf1>
mov    $0x1,%eax
mov    %r13,%rsp
jmp    11d5 <main+0x65>

LLVM IR (-O0):
@.str = [77 x i8] c"You entered an incorrect start value! The start value must NOT be negative!\0A\00"
@.str.1 = [73 x i8] c"You entered an incorrect end value! The end value must NOT be negative!\0A\00"
@.str.2 = [90 x i8] c"You entered an incorrect start or end value. End must be GREATER THAN or EQUAL TO start!\0A\00"
@.str.3 = [8 x i8] c"/dev/pi\00"
@.str.4 = [2 x i8] c"r\00"
@SEEK_SET = global i32 0
@.str.5 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32*
%10 = alloca i8*
%11 = alloca i64
%12 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = load i32, i32* %4
%14 = icmp sle i32 %13, 2
br i1 %14, label %18, label %15
15: ; preds = %2
%16 = load i32, i32* %4
%17 = icmp sgt i32 %16, 3
br i1 %17, label %18, label %20
18: ; preds = %15, %2
%19 = call i32 (...) @usage()
store i32 %19, i32* %3
br label %79
20: ; preds = %15
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 1
%23 = load i8*, i8** %22
%24 = call i32 @atoi(i8* %23)
store i32 %24, i32* %6
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 2
%27 = load i8*, i8** %26
%28 = call i32 @atoi(i8* %27)
store i32 %28, i32* %7
%29 = load i32, i32* %6
%30 = icmp slt i32 %29, 0
br i1 %30, label %31, label %33
31: ; preds = %20
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([77 x i8], [77 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %79
33: ; preds = %20
%34 = load i32, i32* %7
%35 = icmp slt i32 %34, 0
br i1 %35, label %36, label %38
36: ; preds = %33
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([73 x i8], [73 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %3
br label %79
38: ; preds = %33
%39 = load i32, i32* %6
%40 = load i32, i32* %7
%41 = icmp sgt i32 %39, %40
br i1 %41, label %42, label %44
42: ; preds = %38
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([90 x i8], [90 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %3
br label %79
44: ; preds = %38
br label %45
45: ; preds = %44
br label %46
46: ; preds = %45
%47 = load i32, i32* %7
%48 = load i32, i32* %6
%49 = sub nsw i32 %47, %48
%50 = add nsw i32 %49, 1
store i32 %50, i32* %8
%51 = load i32, i32* %8
%52 = add nsw i32 %51, 1
%53 = zext i32 %52 to i64
%54 = call i8* @llvm.stacksave()
store i8* %54, i8** %10
%55 = alloca i8, i64 %53
store i64 %53, i64* %11
%56 = call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i32* %56, i32** %9
%57 = load i32*, i32** %9
%58 = icmp eq i32* %57, null
br i1 %58, label %59, label %60
59: ; preds = %46
store i32 1, i32* %3
store i32 1, i32* %12
br label %74
60: ; preds = %46
%61 = load i32*, i32** %9
%62 = load i32, i32* %6
%63 = load i32, i32* @SEEK_SET
%64 = call i32 @fseek(i32* %61, i32 %62, i32 %63)
%65 = load i32, i32* %8
%66 = load i32*, i32** %9
%67 = call i32 @fread(i8* %55, i32 1, i32 %65, i32* %66)
%68 = load i32*, i32** %9
%69 = call i32 @fclose(i32* %68)
%70 = load i32, i32* %8
%71 = sext i32 %70 to i64
%72 = getelementptr inbounds i8, i8* %55, i64 %71
store i8 0, i8* %72
%73 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* %55)
store i32 0, i32* %12
br label %74
74: ; preds = %60, %59
%75 = load i8*, i8** %10
%76 = load i32, i32* %12
switch i32 %76, label %81 [
i32 0, label %77
i32 1, label %79
]
77: ; preds = %74
br label %78
78: ; preds = %77
store i32 0, i32* %3
br label %79
79: ; preds = %78, %74, %42, %36, %31, %18
%80 = load i32, i32* %3
ret i32 %80
81: ; preds = %74
unreachable
}

LLVM IR (-O2):
@.str.3 = [8 x i8] c"/dev/pi\00"
@.str.4 = [2 x i8] c"r\00"
@SEEK_SET = global i32 0
@str = [89 x i8] c"You entered an incorrect start or end value. End must be GREATER THAN or EQUAL TO start!\00"
@str.6 = [72 x i8] c"You entered an incorrect end value! The end value must NOT be negative!\00"
@str.7 = [76 x i8] c"You entered an incorrect start value! The start value must NOT be negative!\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 3
br i1 %3, label %6, label %4
4: ; preds = %2
%5 = tail call i32 (...) @usage()
br label %43
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i32 @atoi(i8* %8)
%10 = getelementptr inbounds i8*, i8** %1, i64 2
%11 = load i8*, i8** %10
%12 = tail call i32 @atoi(i8* %11)
%13 = icmp slt i32 %9, 0
br i1 %13, label %14, label %16
14: ; preds = %6
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([76 x i8], [76 x i8]* @str.7, i64 0, i64 0))
br label %43
16: ; preds = %6
%17 = icmp slt i32 %12, 0
br i1 %17, label %18, label %20
18: ; preds = %16
%19 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([72 x i8], [72 x i8]* @str.6, i64 0, i64 0))
br label %43
20: ; preds = %16
%21 = icmp ult i32 %12, %9
br i1 %21, label %22, label %24
22: ; preds = %20
%23 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([89 x i8], [89 x i8]* @str, i64 0, i64 0))
br label %43
24: ; preds = %20
%25 = sub nsw i32 %12, %9
%26 = add nsw i32 %25, 1
%27 = add nsw i32 %25, 2
%28 = zext i32 %27 to i64
%29 = tail call i8* @llvm.stacksave()
%30 = alloca i8, i64 %28
%31 = tail call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%32 = icmp eq i32* %31, null
br i1 %32, label %41, label %33
33: ; preds = %24
%34 = load i32, i32* @SEEK_SET
%35 = tail call i32 @fseek(i32* %31, i32 %9, i32 %34)
%36 = call i32 @fread(i8* %30, i32 1, i32 %26, i32* %31)
%37 = tail call i32 @fclose(i32* %31)
%38 = sext i32 %26 to i64
%39 = getelementptr inbounds i8, i8* %30, i64 %38
store i8 0, i8* %39
%40 = call i32 @puts(i8* %30)
br label %41
41: ; preds = %24, %33
%42 = phi i32 [ 1, %24 ], [ 0, %33 ]
tail call void @llvm.stackrestore(i8* %29)
br label %43
43: ; preds = %41, %22, %18, %14, %4
%44 = phi i32 [ %5, %4 ], [ 1, %14 ], [ 1, %18 ], [ 1, %22 ], [ %42, %41 ]
ret i32 %44
}