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

/* Variables and functions */
scalar_t__ EOF;
int /*<<< orphan*/ *fopen(char *, char *);
scalar_t__ fscanf(int /*<<< orphan*/ *, char *, char *);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strtok(char *, char const *);
void *strtoul(int /*<<< orphan*/, int /*<<< orphan*/ *, int /*<<< orphan*/);
int getNodeInfo(char *fileName, uint16_t nodeID, uint32_t *startBlockID,
                uint32_t *nbrBlocks) {
  char word[50];
  int atNodes = 0;
  int atNbrBlocks = 0;
  int returnVal = 0;
  FILE *filePtr;
  filePtr = fopen(fileName, "r");
  while (fscanf(filePtr, "%s", word) != EOF) {
    if (atNbrBlocks == 1) {
      *nbrBlocks = strtoul(strtok(word, ","), NULL, 0);
      atNbrBlocks = 0;
    } else if (atNodes == 1) {
      int node;
      int startBlock;
      int endBlock;
      const char delimeters[] = "<,>";
      node = strtoul(strtok(word, delimeters), NULL, 0);
      startBlock = strtoul(strtok(NULL, delimeters), NULL, 0);
      endBlock = strtoul(strtok(NULL, delimeters), NULL, 0);
      if (node == nodeID) {
        *startBlockID = startBlock;
        *nbrBlocks = endBlock - startBlock;
        returnVal = 1;
      }
    } else if (strcmp(word, "nbrBlocksToDownload=") == 0) {
      atNbrBlocks = 1;
    } else if (strcmp(word, "<nodeID,startBlockID,endBlockID>=") == 0) {
      atNodes = 1;
    }
  }
  return returnVal;
}


x86 assembly (clang, -O0):
<getNodeInfo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movl   $0x0,-0x64(%rbp)
movl   $0x0,-0x68(%rbp)
movl   $0x0,-0x6c(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe76(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x78(%rbp)
mov    -0x78(%rbp),%rdi
lea    -0x60(%rbp),%rdx
lea    0xe60(%rip),%rsi
call   1030 <fscanf@plt>
mov    0x2e3a(%rip),%rcx
cmp    (%rcx),%rax
je     12f6 <getNodeInfo+0x1a6>
cmpl   $0x1,-0x68(%rbp)
jne    11f2 <getNodeInfo+0xa2>
lea    -0x60(%rbp),%rdi
lea    0xe39(%rip),%rsi
call   1060 <strtok@plt>
mov    %eax,%edi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   1070 <strtoul@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x0,-0x68(%rbp)
jmp    12f1 <getNodeInfo+0x1a1>
cmpl   $0x1,-0x64(%rbp)
jne    129b <getNodeInfo+0x14b>
mov    0xe05(%rip),%eax
mov    %eax,-0x88(%rbp)
lea    -0x60(%rbp),%rdi
lea    -0x88(%rbp),%rsi
call   1060 <strtok@plt>
mov    %eax,%edi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   1070 <strtoul@plt>
mov    %eax,-0x7c(%rbp)
lea    -0x88(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edi
call   1060 <strtok@plt>
mov    %eax,%edi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   1070 <strtoul@plt>
mov    %eax,-0x80(%rbp)
lea    -0x88(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edi
call   1060 <strtok@plt>
mov    %eax,%edi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   1070 <strtoul@plt>
mov    %eax,-0x84(%rbp)
mov    -0x7c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jne    1296 <getNodeInfo+0x146>
mov    -0x80(%rbp),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x84(%rbp),%ecx
sub    -0x80(%rbp),%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x1,-0x6c(%rbp)
jmp    12ec <getNodeInfo+0x19c>
lea    -0x60(%rbp),%rdi
lea    0xd65(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    12c1 <getNodeInfo+0x171>
movl   $0x1,-0x68(%rbp)
jmp    12e7 <getNodeInfo+0x197>
lea    -0x60(%rbp),%rdi
lea    0xd54(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    12e2 <getNodeInfo+0x192>
movl   $0x1,-0x64(%rbp)
jmp    12e7 <getNodeInfo+0x197>
jmp    12ec <getNodeInfo+0x19c>
jmp    12f1 <getNodeInfo+0x1a1>
jmp    1193 <getNodeInfo+0x43>
mov    -0x6c(%rbp),%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getNodeInfo>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
mov    %rcx,0x18(%rsp)
mov    %rdx,0x20(%rsp)
mov    %esi,0x10(%rsp)
lea    0xe8d(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,%r14
lea    0xe80(%rip),%rsi
lea    0x30(%rsp),%rdx
mov    %rax,%rdi
call   1030 <fscanf@plt>
mov    0x2e52(%rip),%r15
movl   $0x0,0xc(%rsp)
cmp    (%r15),%rax
jne    11b6 <getNodeInfo+0x66>
mov    0xc(%rsp),%eax
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %r13d,%r13d
lea    0x30(%rsp),%rbp
lea    0xe3d(%rip),%r12
xor    %ebx,%ebx
movl   $0x0,0xc(%rsp)
mov    %r14,0x28(%rsp)
jmp    120d <getNodeInfo+0xbd>
cs nopw 0x0(%rax,%rax,1)
mov    $0x1,%r13d
xor    %ebx,%ebx
mov    %r14,%r15
mov    0x28(%rsp),%r14
mov    %r12,%rbp
lea    0xe08(%rip),%r12
mov    %r14,%rdi
mov    %r12,%rsi
mov    %rbp,%rdx
call   1030 <fscanf@plt>
cmp    (%r15),%rax
je     11a3 <getNodeInfo+0x53>
cmp    $0x1,%ebx
je     12b0 <getNodeInfo+0x160>
cmp    $0x1,%r13d
jne    12e0 <getNodeInfo+0x190>
mov    %r15,%r14
movl   $0x3e2c3c,0x14(%rsp)
mov    %rbp,%r12
mov    %rbp,%rdi
lea    0x14(%rsp),%rbx
mov    %rbx,%rsi
call   1060 <strtok@plt>
mov    %eax,%edi
xor    %esi,%esi
xor    %edx,%edx
call   1070 <strtoul@plt>
mov    %rax,%r13
xor    %edi,%edi
mov    %rbx,%rsi
call   1060 <strtok@plt>
mov    %eax,%edi
xor    %esi,%esi
xor    %edx,%edx
call   1070 <strtoul@plt>
mov    %rax,%r15
xor    %edi,%edi
mov    %rbx,%rsi
call   1060 <strtok@plt>
mov    %eax,%edi
xor    %esi,%esi
xor    %edx,%edx
call   1070 <strtoul@plt>
cmp    0x10(%rsp),%r13d
jne    11e0 <getNodeInfo+0x90>
mov    0x20(%rsp),%rcx
mov    %r15d,(%rcx)
sub    %r15d,%eax
mov    0x18(%rsp),%rcx
mov    %eax,(%rcx)
movl   $0x1,0xc(%rsp)
jmp    11e0 <getNodeInfo+0x90>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rbp,%rdi
lea    0xd4b(%rip),%rsi
call   1060 <strtok@plt>
xor    %ebx,%ebx
mov    %eax,%edi
xor    %esi,%esi
xor    %edx,%edx
call   1070 <strtoul@plt>
mov    0x18(%rsp),%rcx
mov    %eax,(%rcx)
jmp    11fa <getNodeInfo+0xaa>
nopl   0x0(%rax,%rax,1)
mov    %rbp,%rdi
lea    0xd1d(%rip),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     1314 <getNodeInfo+0x1c4>
mov    %rbp,%rdi
lea    0xd1e(%rip),%rsi
call   1040 <strcmp@plt>
xor    %r13d,%r13d
test   %rax,%rax
sete   %r13b
xor    %ebx,%ebx
jmp    11fa <getNodeInfo+0xaa>
xor    %r13d,%r13d
mov    $0x1,%ebx
jmp    11fa <getNodeInfo+0xaa>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [3 x i8] c"%s\00"
@EOF = global i64 0
@.str.2 = [2 x i8] c",\00"
@__const.getNodeInfo.delimeters = [4 x i8] c"<,>\00"
@.str.3 = [21 x i8] c"nbrBlocksToDownload=\00"
@.str.4 = [34 x i8] c"<nodeID,startBlockID,endBlockID>=\00"
define i32 @getNodeInfo(i8* %0, i32 %1, i32* %2, i32* %3) {
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca [50 x i8]
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32*
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca [4 x i8]
store i8* %0, i8** %5
store i32 %1, i32* %6
store i32* %2, i32** %7
store i32* %3, i32** %8
store i32 0, i32* %10
store i32 0, i32* %11
store i32 0, i32* %12
%18 = load i8*, i8** %5
%19 = call i32* @fopen(i8* %18, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %19, i32** %13
br label %20
20: ; preds = %77, %4
%21 = load i32*, i32** %13
%22 = getelementptr inbounds [50 x i8], [50 x i8]* %9, i64 0, i64 0
%23 = call i64 @fscanf(i32* %21, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %22)
%24 = load i64, i64* @EOF
%25 = icmp ne i64 %23, %24
br i1 %25, label %26, label %78
26: ; preds = %20
%27 = load i32, i32* %11
%28 = icmp eq i32 %27, 1
br i1 %28, label %29, label %35
29: ; preds = %26
%30 = getelementptr inbounds [50 x i8], [50 x i8]* %9, i64 0, i64 0
%31 = call i32 @strtok(i8* %30, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%32 = call i8* @strtoul(i32 %31, i32* null, i32 0)
%33 = ptrtoint i8* %32 to i32
%34 = load i32*, i32** %8
store i32 %33, i32* %34
store i32 0, i32* %11
br label %77
35: ; preds = %26
%36 = load i32, i32* %10
%37 = icmp eq i32 %36, 1
br i1 %37, label %38, label %64
38: ; preds = %35
%39 = bitcast [4 x i8]* %17 to i8*
%40 = getelementptr inbounds [50 x i8], [50 x i8]* %9, i64 0, i64 0
%41 = getelementptr inbounds [4 x i8], [4 x i8]* %17, i64 0, i64 0
%42 = call i32 @strtok(i8* %40, i8* %41)
%43 = call i8* @strtoul(i32 %42, i32* null, i32 0)
%44 = ptrtoint i8* %43 to i32
store i32 %44, i32* %14
%45 = getelementptr inbounds [4 x i8], [4 x i8]* %17, i64 0, i64 0
%46 = call i32 @strtok(i8* null, i8* %45)
%47 = call i8* @strtoul(i32 %46, i32* null, i32 0)
%48 = ptrtoint i8* %47 to i32
store i32 %48, i32* %15
%49 = getelementptr inbounds [4 x i8], [4 x i8]* %17, i64 0, i64 0
%50 = call i32 @strtok(i8* null, i8* %49)
%51 = call i8* @strtoul(i32 %50, i32* null, i32 0)
%52 = ptrtoint i8* %51 to i32
store i32 %52, i32* %16
%53 = load i32, i32* %14
%54 = load i32, i32* %6
%55 = icmp eq i32 %53, %54
br i1 %55, label %56, label %63
56: ; preds = %38
%57 = load i32, i32* %15
%58 = load i32*, i32** %7
store i32 %57, i32* %58
%59 = load i32, i32* %16
%60 = load i32, i32* %15
%61 = sub nsw i32 %59, %60
%62 = load i32*, i32** %8
store i32 %61, i32* %62
store i32 1, i32* %12
br label %63
63: ; preds = %56, %38
br label %76
64: ; preds = %35
%65 = getelementptr inbounds [50 x i8], [50 x i8]* %9, i64 0, i64 0
%66 = call i64 @strcmp(i8* %65, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
%67 = icmp eq i64 %66, 0
br i1 %67, label %68, label %69
68: ; preds = %64
store i32 1, i32* %11
br label %75
69: ; preds = %64
%70 = getelementptr inbounds [50 x i8], [50 x i8]* %9, i64 0, i64 0
%71 = call i64 @strcmp(i8* %70, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0))
%72 = icmp eq i64 %71, 0
br i1 %72, label %73, label %74
73: ; preds = %69
store i32 1, i32* %10
br label %74
74: ; preds = %73, %69
br label %75
75: ; preds = %74, %68
br label %76
76: ; preds = %75, %63
br label %77
77: ; preds = %76, %29
br label %20
78: ; preds = %20
%79 = load i32, i32* %12
ret i32 %79
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [3 x i8] c"%s\00"
@EOF = global i64 0
@.str.2 = [2 x i8] c",\00"
@.str.3 = [21 x i8] c"nbrBlocksToDownload=\00"
@.str.4 = [34 x i8] c"<nodeID,startBlockID,endBlockID>=\00"
define i32 @getNodeInfo(i8* nocapture %0, i32 %1, i32* nocapture writeonly %2, i32* nocapture writeonly %3) {
%5 = alloca [50 x i8]
%6 = alloca i32
%7 = getelementptr inbounds [50 x i8], [50 x i8]* %5, i64 0, i64 0
%8 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%9 = call i64 @fscanf(i32* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %7)
%10 = load i64, i64* @EOF
%11 = icmp eq i64 %9, %10
br i1 %11, label %58, label %12
12: ; preds = %4
%13 = bitcast i32* %6 to i8*
br label %14
14: ; preds = %12, %51
%15 = phi i32 [ 0, %12 ], [ %54, %51 ]
%16 = phi i32 [ 0, %12 ], [ %53, %51 ]
%17 = phi i32 [ 0, %12 ], [ %52, %51 ]
%18 = icmp eq i32 %16, 1
br i1 %18, label %19, label %24
19: ; preds = %14
%20 = call i32 @strtok(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%21 = call i8* @strtoul(i32 %20, i32* null, i32 0)
%22 = ptrtoint i8* %21 to i64
%23 = trunc i64 %22 to i32
store i32 %23, i32* %3
br label %51
24: ; preds = %14
%25 = icmp eq i32 %15, 1
br i1 %25, label %26, label %44
26: ; preds = %24
store i32 4074556, i32* %6
%27 = call i32 @strtok(i8* %7, i8* %13)
%28 = call i8* @strtoul(i32 %27, i32* null, i32 0)
%29 = ptrtoint i8* %28 to i64
%30 = trunc i64 %29 to i32
%31 = call i32 @strtok(i8* null, i8* %13)
%32 = call i8* @strtoul(i32 %31, i32* null, i32 0)
%33 = ptrtoint i8* %32 to i64
%34 = trunc i64 %33 to i32
%35 = call i32 @strtok(i8* null, i8* %13)
%36 = call i8* @strtoul(i32 %35, i32* null, i32 0)
%37 = icmp eq i32 %30, %1
br i1 %37, label %38, label %42
38: ; preds = %26
%39 = ptrtoint i8* %36 to i64
%40 = trunc i64 %39 to i32
store i32 %34, i32* %2
%41 = sub nsw i32 %40, %34
store i32 %41, i32* %3
br label %42
42: ; preds = %38, %26
%43 = phi i32 [ 1, %38 ], [ %17, %26 ]
br label %51
44: ; preds = %24
%45 = call i64 @strcmp(i8* %7, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
%46 = icmp eq i64 %45, 0
br i1 %46, label %51, label %47
47: ; preds = %44
%48 = call i64 @strcmp(i8* %7, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0))
%49 = icmp eq i64 %48, 0
%50 = zext i1 %49 to i32
br label %51
51: ; preds = %47, %44, %42, %19
%52 = phi i32 [ %17, %19 ], [ %43, %42 ], [ %17, %44 ], [ %17, %47 ]
%53 = phi i32 [ 0, %19 ], [ 0, %42 ], [ 1, %44 ], [ 0, %47 ]
%54 = phi i32 [ %15, %19 ], [ 1, %42 ], [ 0, %44 ], [ %50, %47 ]
%55 = call i64 @fscanf(i32* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %7)
%56 = load i64, i64* @EOF
%57 = icmp eq i64 %55, %56
br i1 %57, label %58, label %14
58: ; preds = %51, %4
%59 = phi i32 [ 0, %4 ], [ %52, %51 ]
ret i32 %59
}