#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*/ die(char const *);
scalar_t__ end_line(char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
scalar_t__ start_line(char *);
unsigned int strtoul(char *, int /*<<< orphan*/ *, int);
int get_start_end(const char *filename, unsigned int *start,
                  unsigned int *end) {
  FILE *map;
  char buffer[1024];
  *start = 0;
  *end = 0;
  map = fopen(filename, "r");
  if (!map) {
    die(filename);
  }
  while (fgets(buffer, 1024, map)) {
    if (start_line(buffer)) {
      *start = strtoul(buffer, NULL, 16);
    } else if (end_line(buffer)) {
      *end = strtoul(buffer, NULL, 16);
    }
  }
  fclose(map);
  if (*start == 0 || *end == 0) {
    return 0;
  }
  return 1;
}


x86 assembly (clang, -O0):
<get_start_end>:
push   %rbp
mov    %rsp,%rbp
sub    $0x430,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x18(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x20(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x10(%rbp),%rdi
lea    0xe5a(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    11c3 <get_start_end+0x53>
mov    -0x10(%rbp),%rdi
call   1070 <die@plt>
jmp    11c8 <get_start_end+0x58>
lea    -0x430(%rbp),%rdi
mov    -0x28(%rbp),%rdx
mov    $0x400,%esi
call   1050 <fgets@plt>
cmp    $0x0,%rax
je     125c <get_start_end+0xec>
lea    -0x430(%rbp),%rdi
call   1090 <start_line@plt>
cmp    $0x0,%rax
je     121f <get_start_end+0xaf>
lea    -0x430(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0x10,%edx
call   1080 <strtoul@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
jmp    1257 <get_start_end+0xe7>
lea    -0x430(%rbp),%rdi
call   1040 <end_line@plt>
cmp    $0x0,%rax
je     1252 <get_start_end+0xe2>
lea    -0x430(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0x10,%edx
call   1080 <strtoul@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
jmp    1257 <get_start_end+0xe7>
jmp    11c8 <get_start_end+0x58>
mov    -0x28(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x18(%rbp),%rax
cmpl   $0x0,(%rax)
je     127f <get_start_end+0x10f>
mov    -0x20(%rbp),%rax
cmpl   $0x0,(%rax)
jne    128b <get_start_end+0x11b>
movl   $0x0,-0x4(%rbp)
jmp    1292 <get_start_end+0x122>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x430,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_start_end>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x400,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
movl   $0x0,(%rsi)
movl   $0x0,(%rdx)
lea    0xe64(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%r12
test   %rax,%rax
jne    11b1 <get_start_end+0x41>
mov    %rbx,%rdi
call   1070 <die@plt>
mov    %rsp,%rdi
mov    $0x400,%esi
mov    %r12,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
je     1218 <get_start_end+0xa8>
mov    %rsp,%r13
jmp    11f6 <get_start_end+0x86>
nopl   0x0(%rax,%rax,1)
mov    %r13,%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1080 <strtoul@plt>
mov    %eax,(%rbx)
mov    %r13,%rdi
mov    $0x400,%esi
mov    %r12,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
je     1218 <get_start_end+0xa8>
mov    %r13,%rdi
call   1090 <start_line@plt>
mov    %r15,%rbx
test   %rax,%rax
jne    11d0 <get_start_end+0x60>
mov    %r13,%rdi
call   1040 <end_line@plt>
mov    %r14,%rbx
test   %rax,%rax
jne    11d0 <get_start_end+0x60>
jmp    11e1 <get_start_end+0x71>
mov    %r12,%rdi
call   1030 <fclose@plt>
cmpl   $0x0,(%r15)
je     1231 <get_start_end+0xc1>
xor    %eax,%eax
cmpl   $0x0,(%r14)
setne  %al
jmp    1233 <get_start_end+0xc3>
xor    %eax,%eax
add    $0x400,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
define i32 @get_start_end(i8* %0, i32* %1, i32* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca [1024 x i8]
store i8* %0, i8** %5
store i32* %1, i32** %6
store i32* %2, i32** %7
%10 = load i32*, i32** %6
store i32 0, i32* %10
%11 = load i32*, i32** %7
store i32 0, i32* %11
%12 = load i8*, i8** %5
%13 = call i32* @fopen(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %13, i32** %8
%14 = load i32*, i32** %8
%15 = icmp ne i32* %14, null
br i1 %15, label %19, label %16
16: ; preds = %3
%17 = load i8*, i8** %5
%18 = call i32 @die(i8* %17)
br label %19
19: ; preds = %16, %3
br label %20
20: ; preds = %42, %19
%21 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%22 = load i32*, i32** %8
%23 = call i64 @fgets(i8* %21, i32 1024, i32* %22)
%24 = icmp ne i64 %23, 0
br i1 %24, label %25, label %43
25: ; preds = %20
%26 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%27 = call i64 @start_line(i8* %26)
%28 = icmp ne i64 %27, 0
br i1 %28, label %29, label %33
29: ; preds = %25
%30 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%31 = call i32 @strtoul(i8* %30, i32* null, i32 16)
%32 = load i32*, i32** %6
store i32 %31, i32* %32
br label %42
33: ; preds = %25
%34 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%35 = call i64 @end_line(i8* %34)
%36 = icmp ne i64 %35, 0
br i1 %36, label %37, label %41
37: ; preds = %33
%38 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%39 = call i32 @strtoul(i8* %38, i32* null, i32 16)
%40 = load i32*, i32** %7
store i32 %39, i32* %40
br label %41
41: ; preds = %37, %33
br label %42
42: ; preds = %41, %29
br label %20
43: ; preds = %20
%44 = load i32*, i32** %8
%45 = call i32 @fclose(i32* %44)
%46 = load i32*, i32** %6
%47 = load i32, i32* %46
%48 = icmp eq i32 %47, 0
br i1 %48, label %53, label %49
49: ; preds = %43
%50 = load i32*, i32** %7
%51 = load i32, i32* %50
%52 = icmp eq i32 %51, 0
br i1 %52, label %53, label %54
53: ; preds = %49, %43
store i32 0, i32* %4
br label %55
54: ; preds = %49
store i32 1, i32* %4
br label %55
55: ; preds = %54, %53
%56 = load i32, i32* %4
ret i32 %56
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
define i32 @get_start_end(i8* %0, i32* nocapture %1, i32* nocapture %2) {
%4 = alloca [1024 x i8]
%5 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
store i32 0, i32* %1
store i32 0, i32* %2
%6 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i32* %6, null
br i1 %7, label %8, label %10
8: ; preds = %3
%9 = tail call i32 @die(i8* %0)
br label %10
10: ; preds = %8, %3
%11 = call i64 @fgets(i8* %5, i32 1024, i32* %6)
%12 = icmp eq i64 %11, 0
br i1 %12, label %25, label %13
13: ; preds = %10, %22
%14 = call i64 @start_line(i8* %5)
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %13
%17 = call i64 @end_line(i8* %5)
%18 = icmp eq i64 %17, 0
br i1 %18, label %22, label %19
19: ; preds = %16, %13
%20 = phi i32* [ %1, %13 ], [ %2, %16 ]
%21 = call i32 @strtoul(i8* nocapture %5, i32* null, i32 16)
store i32 %21, i32* %20
br label %22
22: ; preds = %19, %16
%23 = call i64 @fgets(i8* %5, i32 1024, i32* %6)
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %13
25: ; preds = %22, %10
%26 = call i32 @fclose(i32* %6)
%27 = load i32, i32* %1
%28 = icmp eq i32 %27, 0
br i1 %28, label %33, label %29
29: ; preds = %25
%30 = load i32, i32* %2
%31 = icmp ne i32 %30, 0
%32 = zext i1 %31 to i32
br label %33
33: ; preds = %29, %25
%34 = phi i32 [ 0, %25 ], [ %32, %29 ]
ret i32 %34
}