#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*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ sscanf(char *, char *, int *, int *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
int nextrange(FILE *coveragefp, int *cstart, int *cend, char *coverstring) {
  int i;
  static char inbuf[256];
  int retval;
  if (fgets(inbuf, 256 - 1, coveragefp) != NULL) {
    retval = strlen(inbuf);
    if ((inbuf[0] >= '0' && inbuf[0] <= '9') ||
        (inbuf[0] >= 'A' && inbuf[0] <= 'F') ||
        (inbuf[0] >= 'a' && inbuf[0] <= 'f')) {
      sscanf(inbuf, "%x-%x", cstart, cend);
      i = 0;
      while (inbuf[i] != ' ')
        i++;
      while (inbuf[i] == ' ')
        i++;
      strcpy(coverstring, &inbuf[i]);
    }
  } else {
    retval = 0;
  }
  return (retval);
}


x86 assembly (clang, -O0):
<nextrange>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x8(%rbp),%rdx
lea    0x2eed(%rip),%rdi
mov    $0xff,%esi
call   1050 <fgets@plt>
cmp    $0x0,%rax
je     1275 <nextrange+0x135>
lea    0x2ed2(%rip),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x28(%rbp)
movsbl 0x2ec3(%rip),%eax
cmp    $0x30,%eax
jl     11a6 <nextrange+0x66>
movsbl 0x2eb3(%rip),%eax
cmp    $0x39,%eax
jle    11e6 <nextrange+0xa6>
movsbl 0x2ea3(%rip),%eax
cmp    $0x41,%eax
jl     11c6 <nextrange+0x86>
movsbl 0x2e93(%rip),%eax
cmp    $0x46,%eax
jle    11e6 <nextrange+0xa6>
movsbl 0x2e83(%rip),%eax
cmp    $0x61,%eax
jl     1270 <nextrange+0x130>
movsbl 0x2e73(%rip),%eax
cmp    $0x66,%eax
jg     1270 <nextrange+0x130>
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rcx
lea    0x2e5b(%rip),%rdi
lea    0xe04(%rip),%rsi
call   1060 <sscanf@plt>
movl   $0x0,-0x24(%rbp)
movslq -0x24(%rbp),%rcx
lea    0x2e3d(%rip),%rax
movsbl (%rax,%rcx,1),%eax
cmp    $0x20,%eax
je     122e <nextrange+0xee>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1208 <nextrange+0xc8>
jmp    1233 <nextrange+0xf3>
movslq -0x24(%rbp),%rcx
lea    0x2e12(%rip),%rax
movsbl (%rax,%rcx,1),%eax
cmp    $0x20,%eax
jne    1259 <nextrange+0x119>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1233 <nextrange+0xf3>
mov    -0x20(%rbp),%rdi
movslq -0x24(%rbp),%rax
lea    0x2de8(%rip),%rsi
add    %rax,%rsi
call   1030 <strcpy@plt>
jmp    127c <nextrange+0x13c>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nextrange>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rcx,%r14
mov    %rdx,%r12
mov    %rsi,%rbp
mov    %rdi,%rdx
lea    0x2ef5(%rip),%rdi
mov    $0xff,%esi
call   1050 <fgets@plt>
test   %rax,%rax
je     11fd <nextrange+0xbd>
lea    0x2edb(%rip),%rbx
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %eax,%r15d
mov    0x2eca(%rip),%al
lea    -0x30(%rax),%ecx
cmp    $0xa,%cl
jb     11a7 <nextrange+0x67>
add    $0xbf,%al
cmp    $0x25,%al
ja     1200 <nextrange+0xc0>
movzbl %al,%eax
movabs $0x3f0000003f,%rcx
bt     %rax,%rcx
jae    1200 <nextrange+0xc0>
lea    0xe52(%rip),%rsi
mov    %rbx,%rdi
mov    %rbp,%rdx
mov    %r12,%rcx
call   1060 <sscanf@plt>
mov    $0xffffffffffffffff,%rax
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
cmpb   $0x20,0x1(%rax,%rbx,1)
lea    0x1(%rax),%rax
jne    11d0 <nextrange+0x90>
mov    %eax,%eax
nopl   (%rax)
cmpb   $0x20,(%rax,%rbx,1)
lea    0x1(%rax),%rax
je     11e0 <nextrange+0xa0>
add    $0xffffffff,%eax
add    %rax,%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
jmp    1200 <nextrange+0xc0>
xor    %r15d,%r15d
mov    %r15d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@nextrange.inbuf = internal global [256 x i8] zeroinitializer
@.str = [6 x i8] c"%x-%x\00"
define i32 @nextrange(i32* %0, i32* %1, i32* %2, i8* %3) {
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
store i32* %0, i32** %5
store i32* %1, i32** %6
store i32* %2, i32** %7
store i8* %3, i8** %8
%11 = load i32*, i32** %5
%12 = call i32* @fgets(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @nextrange.inbuf, i64 0, i64 0), i32 255, i32* %11)
%13 = icmp ne i32* %12, null
br i1 %13, label %14, label %71
14: ; preds = %4
%15 = call i32 @strlen(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @nextrange.inbuf, i64 0, i64 0))
store i32 %15, i32* %10
%16 = load i8, i8* getelementptr inbounds ([256 x i8], [256 x i8]* @nextrange.inbuf, i64 0, i64 0)
%17 = sext i8 %16 to i32
%18 = icmp sge i32 %17, 48
br i1 %18, label %19, label %23
19: ; preds = %14
%20 = load i8, i8* getelementptr inbounds ([256 x i8], [256 x i8]* @nextrange.inbuf, i64 0, i64 0)
%21 = sext i8 %20 to i32
%22 = icmp sle i32 %21, 57
br i1 %22, label %39, label %23
23: ; preds = %19, %14
%24 = load i8, i8* getelementptr inbounds ([256 x i8], [256 x i8]* @nextrange.inbuf, i64 0, i64 0)
%25 = sext i8 %24 to i32
%26 = icmp sge i32 %25, 65
br i1 %26, label %27, label %31
27: ; preds = %23
%28 = load i8, i8* getelementptr inbounds ([256 x i8], [256 x i8]* @nextrange.inbuf, i64 0, i64 0)
%29 = sext i8 %28 to i32
%30 = icmp sle i32 %29, 70
br i1 %30, label %39, label %31
31: ; preds = %27, %23
%32 = load i8, i8* getelementptr inbounds ([256 x i8], [256 x i8]* @nextrange.inbuf, i64 0, i64 0)
%33 = sext i8 %32 to i32
%34 = icmp sge i32 %33, 97
br i1 %34, label %35, label %70
35: ; preds = %31
%36 = load i8, i8* getelementptr inbounds ([256 x i8], [256 x i8]* @nextrange.inbuf, i64 0, i64 0)
%37 = sext i8 %36 to i32
%38 = icmp sle i32 %37, 102
br i1 %38, label %39, label %70
39: ; preds = %35, %27, %19
%40 = load i32*, i32** %6
%41 = load i32*, i32** %7
%42 = call i32 @sscanf(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @nextrange.inbuf, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %40, i32* %41)
store i32 0, i32* %9
br label %43
43: ; preds = %50, %39
%44 = load i32, i32* %9
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds [256 x i8], [256 x i8]* @nextrange.inbuf, i64 0, i64 %45
%47 = load i8, i8* %46
%48 = sext i8 %47 to i32
%49 = icmp ne i32 %48, 32
br i1 %49, label %50, label %53
50: ; preds = %43
%51 = load i32, i32* %9
%52 = add nsw i32 %51, 1
store i32 %52, i32* %9
br label %43
53: ; preds = %43
br label %54
54: ; preds = %61, %53
%55 = load i32, i32* %9
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds [256 x i8], [256 x i8]* @nextrange.inbuf, i64 0, i64 %56
%58 = load i8, i8* %57
%59 = sext i8 %58 to i32
%60 = icmp eq i32 %59, 32
br i1 %60, label %61, label %64
61: ; preds = %54
%62 = load i32, i32* %9
%63 = add nsw i32 %62, 1
store i32 %63, i32* %9
br label %54
64: ; preds = %54
%65 = load i8*, i8** %8
%66 = load i32, i32* %9
%67 = sext i32 %66 to i64
%68 = getelementptr inbounds [256 x i8], [256 x i8]* @nextrange.inbuf, i64 0, i64 %67
%69 = call i32 @strcpy(i8* %65, i8* %68)
br label %70
70: ; preds = %64, %35, %31
br label %72
71: ; preds = %4
store i32 0, i32* %10
br label %72
72: ; preds = %71, %70
%73 = load i32, i32* %10
ret i32 %73
}

LLVM IR (-O2):
@nextrange.inbuf = internal global [256 x i8] zeroinitializer
@.str = [6 x i8] c"%x-%x\00"
define i32 @nextrange(i32* nocapture %0, i32* %1, i32* %2, i8* %3) {
%5 = tail call i32* @fgets(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @nextrange.inbuf, i64 0, i64 0), i32 255, i32* %0)
%6 = icmp eq i32* %5, null
br i1 %6, label %34, label %7
7: ; preds = %4
%8 = tail call i32 @strlen(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @nextrange.inbuf, i64 0, i64 0))
%9 = load i8, i8* getelementptr inbounds ([256 x i8], [256 x i8]* @nextrange.inbuf, i64 0, i64 0)
%10 = freeze i8 %9
%11 = add i8 %10, -48
%12 = icmp ult i8 %11, 10
br i1 %12, label %14, label %13
13: ; preds = %7
switch i8 %10, label %34 [
i8 102, label %14
i8 101, label %14
i8 100, label %14
i8 99, label %14
i8 98, label %14
i8 97, label %14
i8 70, label %14
i8 69, label %14
i8 68, label %14
i8 67, label %14
i8 66, label %14
i8 65, label %14
]
14: ; preds = %13, %13, %13, %13, %13, %13, %13, %13, %13, %13, %13, %13, %7
%15 = tail call i32 @sscanf(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @nextrange.inbuf, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %1, i32* %2)
br label %16
16: ; preds = %16, %14
%17 = phi i64 [ %21, %16 ], [ 0, %14 ]
%18 = getelementptr inbounds [256 x i8], [256 x i8]* @nextrange.inbuf, i64 0, i64 %17
%19 = load i8, i8* %18
%20 = icmp eq i8 %19, 32
%21 = add nuw i64 %17, 1
br i1 %20, label %22, label %16
22: ; preds = %16
%23 = and i64 %17, 4294967295
br label %24
24: ; preds = %22, %24
%25 = phi i64 [ %23, %22 ], [ %29, %24 ]
%26 = getelementptr inbounds [256 x i8], [256 x i8]* @nextrange.inbuf, i64 0, i64 %25
%27 = load i8, i8* %26
%28 = icmp eq i8 %27, 32
%29 = add nuw i64 %25, 1
br i1 %28, label %24, label %30
30: ; preds = %24
%31 = and i64 %25, 4294967295
%32 = getelementptr inbounds [256 x i8], [256 x i8]* @nextrange.inbuf, i64 0, i64 %31
%33 = tail call i32 @strcpy(i8* %3, i8* %32)
br label %34
34: ; preds = %13, %4, %30
%35 = phi i32 [ %8, %30 ], [ %8, %13 ], [ 0, %4 ]
ret i32 %35
}