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

/* Variables and functions */
int /*<<< orphan*/ AwGetPanPref(char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
char *getenv(char *);
int /*<<< orphan*/ memcpy(char *, char *, scalar_t__);
int /*<<< orphan*/ rtl_tracedbg(int /*<<< orphan*/, char *, int, char *, char *,
                                ...);
int /*<<< orphan*/ sprintf(char *, char *, char *);
char *strchr(char *, char);
int /*<<< orphan*/ strcpy(char *, char *);
scalar_t__ strlen(char *);
char *AwGetPanAddr(char *pan) {
  static int traced = 0;
  static int errtraced = 0;
  char sfile[512];
  char buf[512];
  char addr[512];
  char v2[512];
  FILE *f;
  char *pt;
  int found = 0;
  pt = getenv("AW_DATA_DIR");
  if (!pt || !*pt) {
    return NULL;
  }
  pan[0] = '\0';
  v2[0] = '\0';
  sprintf(sfile, "%s/routeraddr.txt", pt);
  f = fopen(sfile, "r");
  if (!f) {
    if (traced)
      return NULL;
    {
      extern int TraceDebug;
      extern int TraceLevel;
      if (TraceLevel >= (0)) {
        rtl_tracedbg(
            (0),
            TraceDebug <= 0
                ? NULL
                : "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                  "outputs/2022-01-22/02-19-57/repos/actility/ong/refs/heads/"
                  "master/drivers/watteco/lib/panaddr.c",
            82, "ERROR cannot open file '%s'\n", sfile);
      }
    };
    traced = 1;
    return NULL;
  }
  while (fgets(buf, sizeof(buf) - 1, f)) {
    if (!strlen(buf))
      continue;
    if (buf[0] == '@' && buf[1] == '1' && buf[2] == '=') {
      pt = strchr(buf, '\n');
      if (pt)
        *pt = '\0';
      pt = strchr(buf, '\r');
      if (pt)
        *pt = '\0';
      strcpy(pan, buf + 3);
      found = 1;
      break;
    }
    if (buf[0] == '@' && buf[1] == '2' && buf[2] == '=') {
      pt = strchr(buf, '\n');
      if (pt)
        *pt = '\0';
      pt = strchr(buf, '\r');
      if (pt)
        *pt = '\0';
      strcpy(v2, buf + 3);
    }
  }
  if (!found) {
    if (!errtraced) {
      extern int TraceDebug;
      extern int TraceLevel;
      if (TraceLevel >= (0)) {
        rtl_tracedbg(
            (0),
            TraceDebug <= 0
                ? NULL
                : "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                  "outputs/2022-01-22/02-19-57/repos/actility/ong/refs/heads/"
                  "master/drivers/watteco/lib/panaddr.c",
            117, "ERROR router address (@1) not found in '%s'\n",
            "routeraddr.txt");
      }
    };
    addr[0] = '\0';
    AwGetPanPref(addr);
    if (strlen(addr) && strlen(v2)) {
      if (!errtraced) {
        extern int TraceDebug;
        extern int TraceLevel;
        if (TraceLevel >= (0)) {
          rtl_tracedbg(
              (0),
              TraceDebug <= 0
                  ? NULL
                  : "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                    "outputs/2022-01-22/02-19-57/repos/actility/ong/refs/heads/"
                    "master/drivers/watteco/lib/panaddr.c",
              124, "ERROR router address built with '%s' & '%s'\n", addr, v2);
        }
      };
      addr[4] = '\0';
      memcpy(v2, addr, strlen(addr));
      strcpy(pan, v2);
    }
    errtraced = 1;
  }
  fclose(f);
  return pan;
}


x86 assembly (clang, -O0):
<AwGetPanAddr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x840,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x824(%rbp)
lea    0xe30(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x820(%rbp)
cmpq   $0x0,-0x820(%rbp)
je     11fa <AwGetPanAddr+0x4a>
mov    -0x820(%rbp),%rax
cmpb   $0x0,(%rax)
jne    1207 <AwGetPanAddr+0x57>
movq   $0x0,-0x8(%rbp)
jmp    15e2 <AwGetPanAddr+0x432>
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
movb   $0x0,-0x810(%rbp)
lea    -0x210(%rbp),%rdi
mov    -0x820(%rbp),%rdx
lea    0xde2(%rip),%rsi
call   10d0 <sprintf@plt>
lea    -0x210(%rbp),%rdi
lea    0xde1(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x818(%rbp)
cmpq   $0x0,-0x818(%rbp)
jne    12cd <AwGetPanAddr+0x11d>
cmpl   $0x0,0x2e1e(%rip)
je     1271 <AwGetPanAddr+0xc1>
movq   $0x0,-0x8(%rbp)
jmp    15e2 <AwGetPanAddr+0x432>
mov    0x2d60(%rip),%rax
cmpl   $0x0,(%rax)
jl     12b6 <AwGetPanAddr+0x106>
mov    0x2d60(%rip),%rax
mov    (%rax),%ecx
lea    0xd8f(%rip),%rsi
xor    %eax,%eax
cmp    $0x0,%ecx
cmovle %rax,%rsi
lea    -0x210(%rbp),%r8
xor    %edi,%edi
mov    $0x52,%edx
lea    0xe08(%rip),%rcx
mov    $0x0,%al
call   10b0 <rtl_tracedbg@plt>
movl   $0x1,0x2dbc(%rip)
movq   $0x0,-0x8(%rbp)
jmp    15e2 <AwGetPanAddr+0x432>
jmp    12d2 <AwGetPanAddr+0x122>
lea    -0x410(%rbp),%rdi
mov    -0x818(%rbp),%rdx
mov    $0x1ff,%esi
call   1090 <fgets@plt>
cmp    $0x0,%rax
je     146e <AwGetPanAddr+0x2be>
lea    -0x410(%rbp),%rdi
call   1070 <strlen@plt>
cmp    $0x0,%rax
jne    130f <AwGetPanAddr+0x15f>
jmp    12d2 <AwGetPanAddr+0x122>
movsbl -0x410(%rbp),%eax
cmp    $0x40,%eax
jne    13c2 <AwGetPanAddr+0x212>
movsbl -0x40f(%rbp),%eax
cmp    $0x31,%eax
jne    13c2 <AwGetPanAddr+0x212>
movsbl -0x40e(%rbp),%eax
cmp    $0x3d,%eax
jne    13c2 <AwGetPanAddr+0x212>
lea    -0x410(%rbp),%rdi
mov    $0xa,%esi
call   1080 <strchr@plt>
mov    %rax,-0x820(%rbp)
cmpq   $0x0,-0x820(%rbp)
je     136f <AwGetPanAddr+0x1bf>
mov    -0x820(%rbp),%rax
movb   $0x0,(%rax)
lea    -0x410(%rbp),%rdi
mov    $0xd,%esi
call   1080 <strchr@plt>
mov    %rax,-0x820(%rbp)
cmpq   $0x0,-0x820(%rbp)
je     139f <AwGetPanAddr+0x1ef>
mov    -0x820(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x10(%rbp),%rdi
lea    -0x410(%rbp),%rsi
add    $0x3,%rsi
call   1040 <strcpy@plt>
movl   $0x1,-0x824(%rbp)
jmp    146e <AwGetPanAddr+0x2be>
movsbl -0x410(%rbp),%eax
cmp    $0x40,%eax
jne    1469 <AwGetPanAddr+0x2b9>
movsbl -0x40f(%rbp),%eax
cmp    $0x32,%eax
jne    1469 <AwGetPanAddr+0x2b9>
movsbl -0x40e(%rbp),%eax
cmp    $0x3d,%eax
jne    1469 <AwGetPanAddr+0x2b9>
lea    -0x410(%rbp),%rdi
mov    $0xa,%esi
call   1080 <strchr@plt>
mov    %rax,-0x820(%rbp)
cmpq   $0x0,-0x820(%rbp)
je     1422 <AwGetPanAddr+0x272>
mov    -0x820(%rbp),%rax
movb   $0x0,(%rax)
lea    -0x410(%rbp),%rdi
mov    $0xd,%esi
call   1080 <strchr@plt>
mov    %rax,-0x820(%rbp)
cmpq   $0x0,-0x820(%rbp)
je     1452 <AwGetPanAddr+0x2a2>
mov    -0x820(%rbp),%rax
movb   $0x0,(%rax)
lea    -0x810(%rbp),%rdi
lea    -0x410(%rbp),%rsi
add    $0x3,%rsi
call   1040 <strcpy@plt>
jmp    12d2 <AwGetPanAddr+0x122>
cmpl   $0x0,-0x824(%rbp)
jne    15ce <AwGetPanAddr+0x41e>
cmpl   $0x0,0x2bfe(%rip)
jne    14d2 <AwGetPanAddr+0x322>
mov    0x2b49(%rip),%rax
cmpl   $0x0,(%rax)
jl     14cd <AwGetPanAddr+0x31d>
mov    0x2b49(%rip),%rax
mov    (%rax),%ecx
lea    0xb78(%rip),%rsi
xor    %eax,%eax
cmp    $0x0,%ecx
cmovle %rax,%rsi
xor    %edi,%edi
mov    $0x75,%edx
lea    0xc15(%rip),%rcx
lea    0xb49(%rip),%r8
mov    $0x0,%al
call   10b0 <rtl_tracedbg@plt>
jmp    14d2 <AwGetPanAddr+0x322>
movb   $0x0,-0x610(%rbp)
lea    -0x610(%rbp),%rdi
call   1050 <AwGetPanPref@plt>
lea    -0x610(%rbp),%rdi
call   1070 <strlen@plt>
cmp    $0x0,%rax
je     15c4 <AwGetPanAddr+0x414>
lea    -0x810(%rbp),%rdi
call   1070 <strlen@plt>
cmp    $0x0,%rax
je     15c4 <AwGetPanAddr+0x414>
cmpl   $0x0,0x2b68(%rip)
jne    156f <AwGetPanAddr+0x3bf>
mov    0x2ab3(%rip),%rax
cmpl   $0x0,(%rax)
jl     156a <AwGetPanAddr+0x3ba>
mov    0x2ab3(%rip),%rax
mov    (%rax),%ecx
lea    0xae2(%rip),%rsi
xor    %eax,%eax
cmp    $0x0,%ecx
cmovle %rax,%rsi
lea    -0x610(%rbp),%r8
lea    -0x810(%rbp),%r9
xor    %edi,%edi
mov    $0x7c,%edx
lea    0xb9e(%rip),%rcx
mov    $0x0,%al
call   10b0 <rtl_tracedbg@plt>
jmp    156f <AwGetPanAddr+0x3bf>
movb   $0x0,-0x60c(%rbp)
lea    -0x810(%rbp),%rax
mov    %rax,-0x838(%rbp)
lea    -0x610(%rbp),%rax
mov    %rax,-0x830(%rbp)
lea    -0x610(%rbp),%rdi
call   1070 <strlen@plt>
mov    -0x838(%rbp),%rdi
mov    -0x830(%rbp),%rsi
mov    %rax,%rdx
call   10a0 <memcpy@plt>
mov    -0x10(%rbp),%rdi
lea    -0x810(%rbp),%rsi
call   1040 <strcpy@plt>
movl   $0x1,0x2ab2(%rip)
mov    -0x818(%rbp),%rdi
call   1060 <fclose@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x840,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<AwGetPanAddr>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x800,%rsp
mov    %rdi,%r14
lea    0xe36(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     13e5 <AwGetPanAddr+0x235>
cmpb   $0x0,(%rax)
je     13e5 <AwGetPanAddr+0x235>
movb   $0x0,(%r14)
movb   $0x0,0x400(%rsp)
lea    0xe18(%rip),%rsi
lea    0x600(%rsp),%rbx
mov    %rbx,%rdi
mov    %rax,%rdx
call   10d0 <sprintf@plt>
lea    0xe10(%rip),%rsi
mov    %rbx,%rdi
call   10c0 <fopen@plt>
test   %rax,%rax
je     13dc <AwGetPanAddr+0x22c>
mov    %rax,%r12
mov    %rsp,%rdi
mov    $0x1ff,%esi
mov    %rax,%rdx
call   1090 <fgets@plt>
test   %rax,%rax
je     12ce <AwGetPanAddr+0x11e>
lea    0x3(%rsp),%r15
mov    %rsp,%rbx
lea    0x400(%rsp),%r13
jmp    1270 <AwGetPanAddr+0xc0>
nopl   (%rax)
mov    %r13,%rdi
mov    %r15,%rsi
call   1040 <strcpy@plt>
mov    %rbx,%rdi
mov    $0x1ff,%esi
mov    %r12,%rdx
call   1090 <fgets@plt>
test   %rax,%rax
je     12ce <AwGetPanAddr+0x11e>
movzbl (%rsp),%ecx
test   %cl,%cl
je     125b <AwGetPanAddr+0xab>
movzbl 0x1(%rsp),%edx
movzbl 0x2(%rsp),%eax
cmp    $0x40,%cl
jne    1294 <AwGetPanAddr+0xe4>
cmp    $0x31,%dl
jne    1294 <AwGetPanAddr+0xe4>
cmp    $0x3d,%al
je     143c <AwGetPanAddr+0x28c>
cmp    $0x40,%cl
jne    125b <AwGetPanAddr+0xab>
cmp    $0x32,%dl
jne    125b <AwGetPanAddr+0xab>
cmp    $0x3d,%al
jne    125b <AwGetPanAddr+0xab>
mov    %rbx,%rdi
mov    $0xa,%esi
call   1080 <strchr@plt>
test   %rax,%rax
je     12b7 <AwGetPanAddr+0x107>
movb   $0x0,(%rax)
mov    %rbx,%rdi
mov    $0xd,%esi
call   1080 <strchr@plt>
test   %rax,%rax
je     1250 <AwGetPanAddr+0xa0>
movb   $0x0,(%rax)
jmp    1250 <AwGetPanAddr+0xa0>
mov    0x2d03(%rip),%rbx
cmpb   $0x1,0x2da4(%rip)
je     1319 <AwGetPanAddr+0x169>
cmpl   $0x0,(%rbx)
js     1319 <AwGetPanAddr+0x169>
mov    0x2cfe(%rip),%rax
cmpl   $0x0,(%rax)
lea    0xd2c(%rip),%rax
mov    $0x0,%esi
cmovg  %rax,%rsi
lea    0xdd0(%rip),%rcx
lea    0xd04(%rip),%r8
xor    %edi,%edi
mov    $0x75,%edx
xor    %eax,%eax
call   10b0 <rtl_tracedbg@plt>
movb   $0x0,0x200(%rsp)
lea    0x200(%rsp),%rdi
call   1050 <AwGetPanPref@plt>
cmpb   $0x0,0x200(%rsp)
je     13d0 <AwGetPanAddr+0x220>
cmpb   $0x0,0x400(%rsp)
je     13d0 <AwGetPanAddr+0x220>
cmpb   $0x1,0x2d2f(%rip)
je     1397 <AwGetPanAddr+0x1e7>
cmpl   $0x0,(%rbx)
js     1397 <AwGetPanAddr+0x1e7>
mov    0x2c89(%rip),%rax
cmpl   $0x0,(%rax)
lea    0xcb7(%rip),%rax
mov    $0x0,%esi
cmovg  %rax,%rsi
lea    0xd88(%rip),%rcx
lea    0x200(%rsp),%r8
lea    0x400(%rsp),%r9
xor    %edi,%edi
mov    $0x7c,%edx
xor    %eax,%eax
call   10b0 <rtl_tracedbg@plt>
movb   $0x0,0x204(%rsp)
lea    0x200(%rsp),%rbx
mov    %rbx,%rdi
call   1070 <strlen@plt>
lea    0x400(%rsp),%r15
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %rax,%rdx
call   10a0 <memcpy@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <strcpy@plt>
movb   $0x1,0x2ca9(%rip)
jmp    1471 <AwGetPanAddr+0x2c1>
cmpb   $0x0,0x2c99(%rip)
je     13ed <AwGetPanAddr+0x23d>
xor    %r14d,%r14d
jmp    1479 <AwGetPanAddr+0x2c9>
mov    0x2be4(%rip),%rax
cmpl   $0x0,(%rax)
js     1430 <AwGetPanAddr+0x280>
mov    0x2be8(%rip),%rax
cmpl   $0x0,(%rax)
lea    0xc16(%rip),%rax
mov    $0x0,%esi
cmovg  %rax,%rsi
lea    0xc9d(%rip),%rcx
lea    0x600(%rsp),%r8
xor    %edi,%edi
mov    $0x52,%edx
xor    %eax,%eax
call   10b0 <rtl_tracedbg@plt>
movb   $0x1,0x2c45(%rip)
xor    %r14d,%r14d
jmp    1479 <AwGetPanAddr+0x2c9>
mov    %rsp,%rdi
mov    $0xa,%esi
call   1080 <strchr@plt>
test   %rax,%rax
je     1451 <AwGetPanAddr+0x2a1>
movb   $0x0,(%rax)
mov    %rsp,%rdi
mov    $0xd,%esi
call   1080 <strchr@plt>
test   %rax,%rax
je     1466 <AwGetPanAddr+0x2b6>
movb   $0x0,(%rax)
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <strcpy@plt>
mov    %r12,%rdi
call   1060 <fclose@plt>
mov    %r14,%rax
add    $0x800,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@AwGetPanAddr.traced = internal global i32 0
@AwGetPanAddr.errtraced = internal global i32 0
@.str = [12 x i8] c"AW_DATA_DIR\00"
@.str.1 = [18 x i8] c"%s/routeraddr.txt\00"
@.str.2 = [2 x i8] c"r\00"
@TraceLevel = external global i32
@TraceDebug = external global i32
@.str.3 = [151 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/actility/ong/refs/heads/master/drivers/watteco/lib/panaddr.c\00"
@.str.4 = [29 x i8] c"ERROR cannot open file '%s'\0A\00"
@.str.5 = [45 x i8] c"ERROR router address (@1) not found in '%s'\0A\00"
@.str.6 = [15 x i8] c"routeraddr.txt\00"
@.str.7 = [45 x i8] c"ERROR router address built with '%s' & '%s'\0A\00"
define i8* @AwGetPanAddr(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca [512 x i8]
%5 = alloca [512 x i8]
%6 = alloca [512 x i8]
%7 = alloca [512 x i8]
%8 = alloca i32*
%9 = alloca i8*
%10 = alloca i32
store i8* %0, i8** %3
store i32 0, i32* %10
%11 = call i8* @getenv(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
store i8* %11, i8** %9
%12 = load i8*, i8** %9
%13 = icmp ne i8* %12, null
br i1 %13, label %14, label %18
14: ; preds = %1
%15 = load i8*, i8** %9
%16 = load i8, i8* %15
%17 = icmp ne i8 %16, 0
br i1 %17, label %19, label %18
18: ; preds = %14, %1
store i8* null, i8** %2
br label %182
19: ; preds = %14
%20 = load i8*, i8** %3
%21 = getelementptr inbounds i8, i8* %20, i64 0
store i8 0, i8* %21
%22 = getelementptr inbounds [512 x i8], [512 x i8]* %7, i64 0, i64 0
store i8 0, i8* %22
%23 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 0
%24 = load i8*, i8** %9
%25 = call i32 @sprintf(i8* %23, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %24)
%26 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 0
%27 = call i32* @fopen(i8* %26, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %27, i32** %8
%28 = load i32*, i32** %8
%29 = icmp ne i32* %28, null
br i1 %29, label %45, label %30
30: ; preds = %19
%31 = load i32, i32* @AwGetPanAddr.traced
%32 = icmp ne i32 %31, 0
br i1 %32, label %33, label %34
33: ; preds = %30
store i8* null, i8** %2
br label %182
34: ; preds = %30
%35 = load i32, i32* @TraceLevel
%36 = icmp sge i32 %35, 0
br i1 %36, label %37, label %44
37: ; preds = %34
%38 = load i32, i32* @TraceDebug
%39 = icmp sle i32 %38, 0
%40 = zext i1 %39 to i64
%41 = select i1 %39, i8* null, i8* getelementptr inbounds ([151 x i8], [151 x i8]* @.str.3, i64 0, i64 0)
%42 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 0
%43 = call i32 (i32, i8*, i32, i8*, i8*, ...) @rtl_tracedbg(i32 0, i8* %41, i32 82, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0), i8* %42)
br label %44
44: ; preds = %37, %34
store i32 1, i32* @AwGetPanAddr.traced
store i8* null, i8** %2
br label %182
45: ; preds = %19
br label %46
46: ; preds = %124, %55, %45
%47 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%48 = load i32*, i32** %8
%49 = call i64 @fgets(i8* %47, i32 511, i32* %48)
%50 = icmp ne i64 %49, 0
br i1 %50, label %51, label %125
51: ; preds = %46
%52 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%53 = call i64 @strlen(i8* %52)
%54 = icmp ne i64 %53, 0
br i1 %54, label %56, label %55
55: ; preds = %51
br label %46
56: ; preds = %51
%57 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%58 = load i8, i8* %57
%59 = sext i8 %58 to i32
%60 = icmp eq i32 %59, 64
br i1 %60, label %61, label %90
61: ; preds = %56
%62 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 1
%63 = load i8, i8* %62
%64 = sext i8 %63 to i32
%65 = icmp eq i32 %64, 49
br i1 %65, label %66, label %90
66: ; preds = %61
%67 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 2
%68 = load i8, i8* %67
%69 = sext i8 %68 to i32
%70 = icmp eq i32 %69, 61
br i1 %70, label %71, label %90
71: ; preds = %66
%72 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%73 = call i8* @strchr(i8* %72, i8 signext 10)
store i8* %73, i8** %9
%74 = load i8*, i8** %9
%75 = icmp ne i8* %74, null
br i1 %75, label %76, label %78
76: ; preds = %71
%77 = load i8*, i8** %9
store i8 0, i8* %77
br label %78
78: ; preds = %76, %71
%79 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%80 = call i8* @strchr(i8* %79, i8 signext 13)
store i8* %80, i8** %9
%81 = load i8*, i8** %9
%82 = icmp ne i8* %81, null
br i1 %82, label %83, label %85
83: ; preds = %78
%84 = load i8*, i8** %9
store i8 0, i8* %84
br label %85
85: ; preds = %83, %78
%86 = load i8*, i8** %3
%87 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%88 = getelementptr inbounds i8, i8* %87, i64 3
%89 = call i32 @strcpy(i8* %86, i8* %88)
store i32 1, i32* %10
br label %125
90: ; preds = %66, %61, %56
%91 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%92 = load i8, i8* %91
%93 = sext i8 %92 to i32
%94 = icmp eq i32 %93, 64
br i1 %94, label %95, label %124
95: ; preds = %90
%96 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 1
%97 = load i8, i8* %96
%98 = sext i8 %97 to i32
%99 = icmp eq i32 %98, 50
br i1 %99, label %100, label %124
100: ; preds = %95
%101 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 2
%102 = load i8, i8* %101
%103 = sext i8 %102 to i32
%104 = icmp eq i32 %103, 61
br i1 %104, label %105, label %124
105: ; preds = %100
%106 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%107 = call i8* @strchr(i8* %106, i8 signext 10)
store i8* %107, i8** %9
%108 = load i8*, i8** %9
%109 = icmp ne i8* %108, null
br i1 %109, label %110, label %112
110: ; preds = %105
%111 = load i8*, i8** %9
store i8 0, i8* %111
br label %112
112: ; preds = %110, %105
%113 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%114 = call i8* @strchr(i8* %113, i8 signext 13)
store i8* %114, i8** %9
%115 = load i8*, i8** %9
%116 = icmp ne i8* %115, null
br i1 %116, label %117, label %119
117: ; preds = %112
%118 = load i8*, i8** %9
store i8 0, i8* %118
br label %119
119: ; preds = %117, %112
%120 = getelementptr inbounds [512 x i8], [512 x i8]* %7, i64 0, i64 0
%121 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%122 = getelementptr inbounds i8, i8* %121, i64 3
%123 = call i32 @strcpy(i8* %120, i8* %122)
br label %124
124: ; preds = %119, %100, %95, %90
br label %46
125: ; preds = %85, %46
%126 = load i32, i32* %10
%127 = icmp ne i32 %126, 0
br i1 %127, label %178, label %128
128: ; preds = %125
%129 = load i32, i32* @AwGetPanAddr.errtraced
%130 = icmp ne i32 %129, 0
br i1 %130, label %141, label %131
131: ; preds = %128
%132 = load i32, i32* @TraceLevel
%133 = icmp sge i32 %132, 0
br i1 %133, label %134, label %140
134: ; preds = %131
%135 = load i32, i32* @TraceDebug
%136 = icmp sle i32 %135, 0
%137 = zext i1 %136 to i64
%138 = select i1 %136, i8* null, i8* getelementptr inbounds ([151 x i8], [151 x i8]* @.str.3, i64 0, i64 0)
%139 = call i32 (i32, i8*, i32, i8*, i8*, ...) @rtl_tracedbg(i32 0, i8* %138, i32 117, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0))
br label %140
140: ; preds = %134, %131
br label %141
141: ; preds = %140, %128
%142 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
store i8 0, i8* %142
%143 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%144 = call i32 @AwGetPanPref(i8* %143)
%145 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%146 = call i64 @strlen(i8* %145)
%147 = icmp ne i64 %146, 0
br i1 %147, label %148, label %177
148: ; preds = %141
%149 = getelementptr inbounds [512 x i8], [512 x i8]* %7, i64 0, i64 0
%150 = call i64 @strlen(i8* %149)
%151 = icmp ne i64 %150, 0
br i1 %151, label %152, label %177
152: ; preds = %148
%153 = load i32, i32* @AwGetPanAddr.errtraced
%154 = icmp ne i32 %153, 0
br i1 %154, label %167, label %155
155: ; preds = %152
%156 = load i32, i32* @TraceLevel
%157 = icmp sge i32 %156, 0
br i1 %157, label %158, label %166
158: ; preds = %155
%159 = load i32, i32* @TraceDebug
%160 = icmp sle i32 %159, 0
%161 = zext i1 %160 to i64
%162 = select i1 %160, i8* null, i8* getelementptr inbounds ([151 x i8], [151 x i8]* @.str.3, i64 0, i64 0)
%163 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%164 = getelementptr inbounds [512 x i8], [512 x i8]* %7, i64 0, i64 0
%165 = call i32 (i32, i8*, i32, i8*, i8*, ...) @rtl_tracedbg(i32 0, i8* %162, i32 124, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.7, i64 0, i64 0), i8* %163, i8* %164)
br label %166
166: ; preds = %158, %155
br label %167
167: ; preds = %166, %152
%168 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 4
store i8 0, i8* %168
%169 = getelementptr inbounds [512 x i8], [512 x i8]* %7, i64 0, i64 0
%170 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%171 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%172 = call i64 @strlen(i8* %171)
%173 = call i32 @memcpy(i8* %169, i8* %170, i64 %172)
%174 = load i8*, i8** %3
%175 = getelementptr inbounds [512 x i8], [512 x i8]* %7, i64 0, i64 0
%176 = call i32 @strcpy(i8* %174, i8* %175)
br label %177
177: ; preds = %167, %148, %141
store i32 1, i32* @AwGetPanAddr.errtraced
br label %178
178: ; preds = %177, %125
%179 = load i32*, i32** %8
%180 = call i32 @fclose(i32* %179)
%181 = load i8*, i8** %3
store i8* %181, i8** %2
br label %182
182: ; preds = %178, %44, %33, %18
%183 = load i8*, i8** %2
ret i8* %183
}

LLVM IR (-O2):
@AwGetPanAddr.traced = internal unnamed_addr global i1 false
@AwGetPanAddr.errtraced = internal unnamed_addr global i1 false
@.str = [12 x i8] c"AW_DATA_DIR\00"
@.str.1 = [18 x i8] c"%s/routeraddr.txt\00"
@.str.2 = [2 x i8] c"r\00"
@TraceLevel = external global i32
@TraceDebug = external global i32
@.str.3 = [151 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/actility/ong/refs/heads/master/drivers/watteco/lib/panaddr.c\00"
@.str.4 = [29 x i8] c"ERROR cannot open file '%s'\0A\00"
@.str.5 = [45 x i8] c"ERROR router address (@1) not found in '%s'\0A\00"
@.str.6 = [15 x i8] c"routeraddr.txt\00"
@.str.7 = [45 x i8] c"ERROR router address built with '%s' & '%s'\0A\00"
define i8* @AwGetPanAddr(i8* %0) {
%2 = alloca [512 x i8]
%3 = alloca [512 x i8]
%4 = alloca [512 x i8]
%5 = alloca [512 x i8]
%6 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 0
%7 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%8 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 0
%9 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%10 = tail call i8* @getenv(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%11 = icmp eq i8* %10, null
br i1 %11, label %112, label %12
12: ; preds = %1
%13 = load i8, i8* %10
%14 = icmp eq i8 %13, 0
br i1 %14, label %112, label %15
15: ; preds = %12
store i8 0, i8* %0
store i8 0, i8* %9
%16 = call i32 @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %10)
%17 = call i32* @fopen(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%18 = icmp eq i32* %17, null
br i1 %18, label %26, label %19
19: ; preds = %15
%20 = call i64 @fgets(i8* %7, i32 511, i32* %17)
%21 = icmp eq i64 %20, 0
br i1 %21, label %75, label %22
22: ; preds = %19
%23 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 1
%24 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 2
%25 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 3
br label %37
26: ; preds = %15
%27 = load i1, i1* @AwGetPanAddr.traced
br i1 %27, label %112, label %28
28: ; preds = %26
%29 = load i32, i32* @TraceLevel
%30 = icmp sgt i32 %29, -1
br i1 %30, label %31, label %36
31: ; preds = %28
%32 = load i32, i32* @TraceDebug
%33 = icmp slt i32 %32, 1
%34 = select i1 %33, i8* null, i8* getelementptr inbounds ([151 x i8], [151 x i8]* @.str.3, i64 0, i64 0)
%35 = call i32 (i32, i8*, i32, i8*, i8*, ...) @rtl_tracedbg(i32 0, i8* %34, i32 82, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0), i8* %6)
br label %36
36: ; preds = %31, %28
store i1 true, i1* @AwGetPanAddr.traced
br label %112
37: ; preds = %22, %72
%38 = load i8, i8* %7
%39 = icmp eq i8 %38, 0
br i1 %39, label %72, label %40
40: ; preds = %37
%41 = icmp eq i8 %38, 64
%42 = load i8, i8* %23
%43 = icmp eq i8 %42, 49
%44 = select i1 %41, i1 %43, i1 false
%45 = load i8, i8* %24
%46 = icmp eq i8 %45, 61
%47 = select i1 %44, i1 %46, i1 false
br i1 %47, label %48, label %58
48: ; preds = %40
%49 = call i8* @strchr(i8* %7, i8 signext 10)
%50 = icmp eq i8* %49, null
br i1 %50, label %52, label %51
51: ; preds = %48
store i8 0, i8* %49
br label %52
52: ; preds = %51, %48
%53 = call i8* @strchr(i8* %7, i8 signext 13)
%54 = icmp eq i8* %53, null
br i1 %54, label %56, label %55
55: ; preds = %52
store i8 0, i8* %53
br label %56
56: ; preds = %55, %52
%57 = call i32 @strcpy(i8* %0, i8* %25)
br label %110
58: ; preds = %40
%59 = icmp eq i8 %42, 50
%60 = select i1 %41, i1 %59, i1 false
%61 = select i1 %60, i1 %46, i1 false
br i1 %61, label %62, label %72
62: ; preds = %58
%63 = call i8* @strchr(i8* %7, i8 signext 10)
%64 = icmp eq i8* %63, null
br i1 %64, label %66, label %65
65: ; preds = %62
store i8 0, i8* %63
br label %66
66: ; preds = %65, %62
%67 = call i8* @strchr(i8* %7, i8 signext 13)
%68 = icmp eq i8* %67, null
br i1 %68, label %70, label %69
69: ; preds = %66
store i8 0, i8* %67
br label %70
70: ; preds = %69, %66
%71 = call i32 @strcpy(i8* %9, i8* %25)
br label %72
72: ; preds = %58, %70, %37
%73 = call i64 @fgets(i8* %7, i32 511, i32* %17)
%74 = icmp eq i64 %73, 0
br i1 %74, label %75, label %37
75: ; preds = %72, %19
%76 = load i1, i1* @AwGetPanAddr.errtraced
%77 = xor i1 %76, true
%78 = load i32, i32* @TraceLevel
%79 = icmp sgt i32 %78, -1
%80 = select i1 %77, i1 %79, i1 false
br i1 %80, label %81, label %86
81: ; preds = %75
%82 = load i32, i32* @TraceDebug
%83 = icmp slt i32 %82, 1
%84 = select i1 %83, i8* null, i8* getelementptr inbounds ([151 x i8], [151 x i8]* @.str.3, i64 0, i64 0)
%85 = call i32 (i32, i8*, i32, i8*, i8*, ...) @rtl_tracedbg(i32 0, i8* %84, i32 117, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0))
br label %86
86: ; preds = %81, %75
store i8 0, i8* %8
%87 = call i32 @AwGetPanPref(i8* %8)
%88 = load i8, i8* %8
%89 = icmp eq i8 %88, 0
%90 = load i8, i8* %9
%91 = icmp eq i8 %90, 0
%92 = select i1 %89, i1 true, i1 %91
br i1 %92, label %109, label %93
93: ; preds = %86
%94 = load i1, i1* @AwGetPanAddr.errtraced
%95 = xor i1 %94, true
%96 = load i32, i32* @TraceLevel
%97 = icmp sgt i32 %96, -1
%98 = select i1 %95, i1 %97, i1 false
br i1 %98, label %99, label %104
99: ; preds = %93
%100 = load i32, i32* @TraceDebug
%101 = icmp slt i32 %100, 1
%102 = select i1 %101, i8* null, i8* getelementptr inbounds ([151 x i8], [151 x i8]* @.str.3, i64 0, i64 0)
%103 = call i32 (i32, i8*, i32, i8*, i8*, ...) @rtl_tracedbg(i32 0, i8* %102, i32 124, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.7, i64 0, i64 0), i8* %8, i8* %9)
br label %104
104: ; preds = %99, %93
%105 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 4
store i8 0, i8* %105
%106 = call i64 @strlen(i8* %8)
%107 = call i32 @memcpy(i8* %9, i8* %8, i64 %106)
%108 = call i32 @strcpy(i8* %0, i8* %9)
br label %109
109: ; preds = %104, %86
store i1 true, i1* @AwGetPanAddr.errtraced
br label %110
110: ; preds = %56, %109
%111 = call i32 @fclose(i32* %17)
br label %112
112: ; preds = %26, %1, %12, %110, %36
%113 = phi i8* [ %0, %110 ], [ null, %36 ], [ null, %12 ], [ null, %1 ], [ null, %26 ]
ret i8* %113
}