#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 temp_return;
  int start;
  int end;
  int length;
  FILE *piData;
  temp_return = 0;
  if ((argc <= 2) || (argc > 3)) {
    temp_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 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);
    temp_return = 0;
  }
  return temp_return;
}


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)
movl   $0x0,-0x14(%rbp)
cmpl   $0x2,-0x8(%rbp)
jle    11a1 <main+0x31>
cmpl   $0x3,-0x8(%rbp)
jle    11b0 <main+0x40>
mov    $0x0,%al
call   1070 <usage@plt>
mov    %eax,-0x14(%rbp)
jmp    1330 <main+0x1c0>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1090 <atoi@plt>
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1090 <atoi@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    11f4 <main+0x84>
lea    0xe1f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1336 <main+0x1c6>
cmpl   $0x0,-0x1c(%rbp)
jge    1218 <main+0xa8>
lea    0xe48(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1336 <main+0x1c6>
mov    -0x18(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jle    123e <main+0xce>
lea    0xe6b(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1336 <main+0x1c6>
jmp    1243 <main+0xd3>
jmp    1248 <main+0xd8>
mov    -0x1c(%rbp),%eax
mov    -0x18(%rbp),%ecx
sub    %ecx,%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%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    0xe5e(%rip),%rdi
lea    0xe5f(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    12b4 <main+0x144>
movl   $0x1,-0x4(%rbp)
movl   $0x1,-0x3c(%rbp)
jmp    130f <main+0x19f>
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%esi
mov    0x2d1e(%rip),%rax
mov    (%rax),%edx
call   1060 <fseek@plt>
mov    -0x48(%rbp),%rdi
mov    -0x20(%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 -0x20(%rbp),%rax
movb   $0x0,(%rsi,%rax,1)
lea    0xdf4(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x3c(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,%rsp
mov    -0x3c(%rbp),%eax
test   %eax,%eax
je     132b <main+0x1bb>
jmp    1326 <main+0x1b6>
jmp    1336 <main+0x1c6>
jmp    1330 <main+0x1c0>
mov    -0x14(%rbp),%eax
mov    %eax,-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    0xedd(%rip),%rdi
jmp    11cb <main+0x5b>
lea    0xe8c(%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     1262 <main+0xf2>
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
mov    %r13,%rsp
jmp    11d5 <main+0x65>
mov    %r13,%rsp
jmp    11d0 <main+0x60>

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 = [78 x i8] c"You entered an incorrect start or end value. End must be GREATER than 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 i32*
%11 = alloca i8*
%12 = alloca i64
%13 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
%14 = load i32, i32* %4
%15 = icmp sle i32 %14, 2
br i1 %15, label %19, label %16
16: ; preds = %2
%17 = load i32, i32* %4
%18 = icmp sgt i32 %17, 3
br i1 %18, label %19, label %21
19: ; preds = %16, %2
%20 = call i32 (...) @usage()
store i32 %20, i32* %6
br label %79
21: ; preds = %16
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 1
%24 = load i8*, i8** %23
%25 = call i32 @atoi(i8* %24)
store i32 %25, i32* %7
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 2
%28 = load i8*, i8** %27
%29 = call i32 @atoi(i8* %28)
store i32 %29, i32* %8
%30 = load i32, i32* %7
%31 = icmp slt i32 %30, 0
br i1 %31, label %32, label %34
32: ; preds = %21
%33 = 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 %81
34: ; preds = %21
%35 = load i32, i32* %8
%36 = icmp slt i32 %35, 0
br i1 %36, label %37, label %39
37: ; preds = %34
%38 = 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 %81
39: ; preds = %34
%40 = load i32, i32* %7
%41 = load i32, i32* %8
%42 = icmp sgt i32 %40, %41
br i1 %42, label %43, label %45
43: ; preds = %39
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([78 x i8], [78 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %3
br label %81
45: ; preds = %39
br label %46
46: ; preds = %45
br label %47
47: ; preds = %46
%48 = load i32, i32* %8
%49 = load i32, i32* %7
%50 = sub nsw i32 %48, %49
%51 = add nsw i32 %50, 1
store i32 %51, i32* %9
%52 = load i32, i32* %9
%53 = add nsw i32 %52, 1
%54 = zext i32 %53 to i64
%55 = call i8* @llvm.stacksave()
store i8* %55, i8** %11
%56 = alloca i8, i64 %54
store i64 %54, i64* %12
%57 = 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* %57, i32** %10
%58 = load i32*, i32** %10
%59 = icmp eq i32* %58, null
br i1 %59, label %60, label %61
60: ; preds = %47
store i32 1, i32* %3
store i32 1, i32* %13
br label %75
61: ; preds = %47
%62 = load i32*, i32** %10
%63 = load i32, i32* %7
%64 = load i32, i32* @SEEK_SET
%65 = call i32 @fseek(i32* %62, i32 %63, i32 %64)
%66 = load i32, i32* %9
%67 = load i32*, i32** %10
%68 = call i32 @fread(i8* %56, i32 1, i32 %66, i32* %67)
%69 = load i32*, i32** %10
%70 = call i32 @fclose(i32* %69)
%71 = load i32, i32* %9
%72 = sext i32 %71 to i64
%73 = getelementptr inbounds i8, i8* %56, i64 %72
store i8 0, i8* %73
%74 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* %56)
store i32 0, i32* %6
store i32 0, i32* %13
br label %75
75: ; preds = %61, %60
%76 = load i8*, i8** %11
%77 = load i32, i32* %13
switch i32 %77, label %83 [
i32 0, label %78
i32 1, label %81
]
78: ; preds = %75
br label %79
79: ; preds = %78, %19
%80 = load i32, i32* %6
store i32 %80, i32* %3
br label %81
81: ; preds = %79, %75, %43, %37, %32
%82 = load i32, i32* %3
ret i32 %82
83: ; preds = %75
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 = [77 x i8] c"You entered an incorrect start or end value. End must be GREATER than 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 %42
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 %42
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 %42
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 ([77 x i8], [77 x i8]* @str, i64 0, i64 0))
br label %42
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 %33, label %34
33: ; preds = %24
tail call void @llvm.stackrestore(i8* %29)
br label %42
34: ; preds = %24
%35 = load i32, i32* @SEEK_SET
%36 = tail call i32 @fseek(i32* %31, i32 %9, i32 %35)
%37 = call i32 @fread(i8* %30, i32 1, i32 %26, i32* %31)
%38 = tail call i32 @fclose(i32* %31)
%39 = sext i32 %26 to i64
%40 = getelementptr inbounds i8, i8* %30, i64 %39
store i8 0, i8* %40
%41 = call i32 @puts(i8* %30)
tail call void @llvm.stackrestore(i8* %29)
br label %42
42: ; preds = %4, %34, %33, %22, %18, %14
%43 = phi i32 [ 1, %14 ], [ 1, %18 ], [ 1, %22 ], [ 1, %33 ], [ %5, %4 ], [ 0, %34 ]
ret i32 %43
}