#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 */

/* Variables and functions */
int /*<<< orphan*/ _dbprintf(char *, char *, int, char *);
scalar_t__ strncmp(char *, char *, int);
char *strtok(int /*<<< orphan*/ *, char *);
unsigned long strtoul(char *, int /*<<< orphan*/ *, int);
int getrfaddr(unsigned long *rfaddr) {
  char *parm;
  parm = strtok(NULL, " ");
  if (!parm)
    return -1;
  _dbprintf(
      "rfaddr %s\n",
      "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
      "2022-01-22/02-19-57/repos/SensorFlare/mochad/refs/heads/master/encode.c",
      325, parm);
  if ((strncmp(parm, "0x", 2) == 0) || (strncmp(parm, "0X", 2) == 0)) {
    *rfaddr = strtoul(parm + 2, NULL, 16);
    return 1;
  }
  *rfaddr = strtoul(parm, NULL, 16);
  return 0;
}


x86 assembly (clang, -O0):
<getrfaddr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xea9(%rip),%rsi
call   1050 <strtok@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1177 <getrfaddr+0x37>
movl   $0xffffffff,-0x4(%rbp)
jmp    1220 <getrfaddr+0xe0>
mov    -0x18(%rbp),%rcx
lea    0xe80(%rip),%rdi
lea    0xe84(%rip),%rsi
mov    $0x145,%edx
call   1040 <_dbprintf@plt>
mov    -0x18(%rbp),%rdi
lea    0xef7(%rip),%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     11d1 <getrfaddr+0x91>
mov    -0x18(%rbp),%rdi
lea    0xedb(%rip),%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    11fd <getrfaddr+0xbd>
mov    -0x18(%rbp),%rdi
add    $0x2,%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0x10,%edx
call   1060 <strtoul@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    1220 <getrfaddr+0xe0>
mov    -0x18(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0x10,%edx
call   1060 <strtoul@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getrfaddr>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%r14
lea    0xeb2(%rip),%rsi
xor    %edi,%edi
call   1050 <strtok@plt>
test   %rax,%rax
je     11c9 <getrfaddr+0x89>
mov    %rax,%rbx
lea    0xe9e(%rip),%rdi
lea    0xea2(%rip),%rsi
mov    $0x145,%edx
mov    %rax,%rcx
call   1040 <_dbprintf@plt>
lea    0xf16(%rip),%rsi
mov    %rbx,%rdi
mov    $0x2,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     11ac <getrfaddr+0x6c>
lea    0xf00(%rip),%rsi
mov    %rbx,%rdi
mov    $0x2,%edx
call   1030 <strncmp@plt>
xor    %ebp,%ebp
test   %rax,%rax
jne    11b5 <getrfaddr+0x75>
add    $0x2,%rbx
mov    $0x1,%ebp
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1060 <strtoul@plt>
mov    %rax,(%r14)
jmp    11ce <getrfaddr+0x8e>
mov    $0xffffffff,%ebp
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c" \00"
@.str.1 = [11 x i8] c"rfaddr %s\0A\00"
@.str.2 = [136 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/SensorFlare/mochad/refs/heads/master/encode.c\00"
@.str.3 = [3 x i8] c"0x\00"
@.str.4 = [3 x i8] c"0X\00"
define i32 @getrfaddr(i64* %0) {
%2 = alloca i32
%3 = alloca i64*
%4 = alloca i8*
store i64* %0, i64** %3
%5 = call i8* @strtok(i32* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %5, i8** %4
%6 = load i8*, i8** %4
%7 = icmp ne i8* %6, null
br i1 %7, label %9, label %8
8: ; preds = %1
store i32 -1, i32* %2
br label %28
9: ; preds = %1
%10 = load i8*, i8** %4
%11 = call i32 @_dbprintf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([136 x i8], [136 x i8]* @.str.2, i64 0, i64 0), i32 325, i8* %10)
%12 = load i8*, i8** %4
%13 = call i64 @strncmp(i8* %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 2)
%14 = icmp eq i64 %13, 0
br i1 %14, label %19, label %15
15: ; preds = %9
%16 = load i8*, i8** %4
%17 = call i64 @strncmp(i8* %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 2)
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %24
19: ; preds = %15, %9
%20 = load i8*, i8** %4
%21 = getelementptr inbounds i8, i8* %20, i64 2
%22 = call i64 @strtoul(i8* %21, i32* null, i32 16)
%23 = load i64*, i64** %3
store i64 %22, i64* %23
store i32 1, i32* %2
br label %28
24: ; preds = %15
%25 = load i8*, i8** %4
%26 = call i64 @strtoul(i8* %25, i32* null, i32 16)
%27 = load i64*, i64** %3
store i64 %26, i64* %27
store i32 0, i32* %2
br label %28
28: ; preds = %24, %19, %8
%29 = load i32, i32* %2
ret i32 %29
}

LLVM IR (-O2):
@.str = [2 x i8] c" \00"
@.str.1 = [11 x i8] c"rfaddr %s\0A\00"
@.str.2 = [136 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/SensorFlare/mochad/refs/heads/master/encode.c\00"
@.str.3 = [3 x i8] c"0x\00"
@.str.4 = [3 x i8] c"0X\00"
define i32 @getrfaddr(i64* nocapture writeonly %0) {
%2 = tail call i8* @strtok(i32* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i8* %2, null
br i1 %3, label %17, label %4
4: ; preds = %1
%5 = tail call i32 @_dbprintf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([136 x i8], [136 x i8]* @.str.2, i64 0, i64 0), i32 325, i8* %2)
%6 = tail call i64 @strncmp(i8* %2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 2)
%7 = icmp eq i64 %6, 0
br i1 %7, label %11, label %8
8: ; preds = %4
%9 = tail call i64 @strncmp(i8* %2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 2)
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %8, %4
%12 = getelementptr inbounds i8, i8* %2, i64 2
br label %13
13: ; preds = %8, %11
%14 = phi i8* [ %12, %11 ], [ %2, %8 ]
%15 = phi i32 [ 1, %11 ], [ 0, %8 ]
%16 = tail call i64 @strtoul(i8* nocapture %14, i32* null, i32 16)
store i64 %16, i64* %0
br label %17
17: ; preds = %13, %1
%18 = phi i32 [ -1, %1 ], [ %15, %13 ]
ret i32 %18
}