#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*/ SEEK_END;
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ errno;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
size_t fread(unsigned char *, int, size_t, int /*<<< orphan*/ *);
int /*<<< orphan*/ free(unsigned char *);
size_t fseek(int /*<<< orphan*/ *, int /*<<< orphan*/, int /*<<< orphan*/);
scalar_t__ ftell(int /*<<< orphan*/ *);
int /*<<< orphan*/ jlog(int, char *, char *, ...);
scalar_t__ malloc(size_t);
char *strchr(char *, char);
char *strdup(char *);
char *strerror(int /*<<< orphan*/);
int /*<<< orphan*/ strlen(char *);
char *strstr(char const *, char *);
char *x509_get_cn(char *path) {
  FILE *f;
  size_t n;
  unsigned char *buf;
  char *needle;
  char *end;
  char *cn;
  size_t ret;
  f = fopen(path, "rb");
  if (f == NULL) {
    jlog(0x01, "utils]> fopen() no such file : %s :: %s %i \n", path,
         "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
         "2022-01-22/02-19-57/repos/aboudreault/dnds-debian/refs/heads/master/"
         "libdnds/src/utils.c",
         130);
    return NULL;
  }
  ret = fseek(f, 0, SEEK_END);
  if (ret == -1) {
    jlog(0x01, "utils]> fseek() %s :: %s:%i\n", strerror(errno),
         "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
         "2022-01-22/02-19-57/repos/aboudreault/dnds-debian/refs/heads/master/"
         "libdnds/src/utils.c",
         136);
    return NULL;
  }
  n = (size_t)ftell(f);
  ret = fseek(f, 0, SEEK_SET);
  if (ret == -1) {
    jlog(0x01, "utils]> fseek() %s :: %s:%i\n", strerror(errno),
         "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
         "2022-01-22/02-19-57/repos/aboudreault/dnds-debian/refs/heads/master/"
         "libdnds/src/utils.c",
         144);
    return NULL;
  }
  buf = (unsigned char *)malloc(n + 1);
  if (buf == NULL) {
    jlog(0x01, "utils]> malloc() %s :: %s:%i\n", strerror(errno),
         "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
         "2022-01-22/02-19-57/repos/aboudreault/dnds-debian/refs/heads/master/"
         "libdnds/src/utils.c",
         150);
    return NULL;
  }
  ret = fread(buf, 1, n, f);
  if (ret != n) {
    fclose(f);
    free(buf);
    jlog(0x01, "utils]> fread() %s :: %s:%i\n", strerror(errno),
         "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
         "2022-01-22/02-19-57/repos/aboudreault/dnds-debian/refs/heads/master/"
         "libdnds/src/utils.c",
         158);
    return NULL;
  }
  buf[n] = '\0';
  needle = strstr((const char *)buf, "Subject:");
  if (needle == NULL) {
    jlog(0x01, "utils]> strstr() \"Subject\" substring not found :: %s:%i\n",
         "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
         "2022-01-22/02-19-57/repos/aboudreault/dnds-debian/refs/heads/master/"
         "libdnds/src/utils.c",
         166);
    return NULL;
  }
  needle = strstr(needle, "CN=");
  if (needle == NULL) {
    jlog(0x01, "utils]> strstr() \"CN=\" substring not found :: %s:%i\n",
         "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
         "2022-01-22/02-19-57/repos/aboudreault/dnds-debian/refs/heads/master/"
         "libdnds/src/utils.c",
         172);
    return NULL;
  }
  needle += strlen("CN=");
  if (needle == NULL) {
    jlog(0x01, "utils]> strstr() \"CN=\" substring not found :: %s:%i\n",
         "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
         "2022-01-22/02-19-57/repos/aboudreault/dnds-debian/refs/heads/master/"
         "libdnds/src/utils.c",
         178);
    return NULL;
  }
  end = strchr(needle, '/');
  if (end == NULL) {
    jlog(0x01, "utils]> strchr() \"/\" character not found :: %s:%i\n",
         "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
         "2022-01-22/02-19-57/repos/aboudreault/dnds-debian/refs/heads/master/"
         "libdnds/src/utils.c",
         185);
    return NULL;
  }
  *end = '\0';
  cn = strdup(needle);
  if (cn == NULL) {
    jlog(0x01, "utils]> strdup() %s :: %s:%i\n", strerror(errno),
         "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
         "2022-01-22/02-19-57/repos/aboudreault/dnds-debian/refs/heads/master/"
         "libdnds/src/utils.c",
         193);
    return NULL;
  }
  if (buf)
    free(buf);
  if (cn == NULL)
    return NULL;
  return cn;
}


x86 assembly (clang, -O0):
<x509_get_cn>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe19(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    122c <x509_get_cn+0x5c>
mov    -0x10(%rbp),%rdx
mov    $0x1,%edi
lea    0xdf8(%rip),%rsi
lea    0xe1e(%rip),%rcx
mov    $0x82,%r8d
mov    $0x0,%al
call   1080 <jlog@plt>
movq   $0x0,-0x8(%rbp)
jmp    159c <x509_get_cn+0x3cc>
mov    -0x18(%rbp),%rdi
mov    0x2db1(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   10b0 <fseek@plt>
mov    %rax,-0x48(%rbp)
cmpq   $0xffffffffffffffff,-0x48(%rbp)
jne    128d <x509_get_cn+0xbd>
mov    0x2d82(%rip),%rax
mov    (%rax),%edi
call   10e0 <strerror@plt>
mov    %rax,%rdx
mov    $0x1,%edi
lea    0xe5c(%rip),%rsi
lea    0xdbd(%rip),%rcx
mov    $0x88,%r8d
mov    $0x0,%al
call   1080 <jlog@plt>
movq   $0x0,-0x8(%rbp)
jmp    159c <x509_get_cn+0x3cc>
mov    -0x18(%rbp),%rdi
call   1090 <ftell@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
mov    0x2d2b(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   10b0 <fseek@plt>
mov    %rax,-0x48(%rbp)
cmpq   $0xffffffffffffffff,-0x48(%rbp)
jne    12fb <x509_get_cn+0x12b>
mov    0x2d14(%rip),%rax
mov    (%rax),%edi
call   10e0 <strerror@plt>
mov    %rax,%rdx
mov    $0x1,%edi
lea    0xdee(%rip),%rsi
lea    0xd4f(%rip),%rcx
mov    $0x90,%r8d
mov    $0x0,%al
call   1080 <jlog@plt>
movq   $0x0,-0x8(%rbp)
jmp    159c <x509_get_cn+0x3cc>
mov    -0x20(%rbp),%rdi
add    $0x1,%rdi
call   10a0 <malloc@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1355 <x509_get_cn+0x185>
mov    0x2cba(%rip),%rax
mov    (%rax),%edi
call   10e0 <strerror@plt>
mov    %rax,%rdx
mov    $0x1,%edi
lea    0xdb1(%rip),%rsi
lea    0xcf5(%rip),%rcx
mov    $0x96,%r8d
mov    $0x0,%al
call   1080 <jlog@plt>
movq   $0x0,-0x8(%rbp)
jmp    159c <x509_get_cn+0x3cc>
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    -0x18(%rbp),%rcx
mov    $0x1,%esi
call   1040 <fread@plt>
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rax
cmp    -0x20(%rbp),%rax
je     13cd <x509_get_cn+0x1fd>
mov    -0x18(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    0x2c42(%rip),%rax
mov    (%rax),%edi
call   10e0 <strerror@plt>
mov    %rax,%rdx
mov    $0x1,%edi
lea    0xd57(%rip),%rsi
lea    0xc7d(%rip),%rcx
mov    $0x9e,%r8d
mov    $0x0,%al
call   1080 <jlog@plt>
movq   $0x0,-0x8(%rbp)
jmp    159c <x509_get_cn+0x3cc>
mov    -0x28(%rbp),%rax
mov    -0x20(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x28(%rbp),%rdi
lea    0xd3c(%rip),%rsi
call   10f0 <strstr@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    1424 <x509_get_cn+0x254>
mov    $0x1,%edi
lea    0xd25(%rip),%rsi
lea    0xc25(%rip),%rdx
mov    $0xa6,%ecx
mov    $0x0,%al
call   1080 <jlog@plt>
movq   $0x0,-0x8(%rbp)
jmp    159c <x509_get_cn+0x3cc>
mov    -0x30(%rbp),%rdi
lea    0xd33(%rip),%rsi
call   10f0 <strstr@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    146f <x509_get_cn+0x29f>
mov    $0x1,%edi
lea    0xd17(%rip),%rsi
lea    0xbda(%rip),%rdx
mov    $0xac,%ecx
mov    $0x0,%al
call   1080 <jlog@plt>
movq   $0x0,-0x8(%rbp)
jmp    159c <x509_get_cn+0x3cc>
lea    0xcec(%rip),%rdi
call   1060 <strlen@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    14c2 <x509_get_cn+0x2f2>
mov    $0x1,%edi
lea    0xcc4(%rip),%rsi
lea    0xb87(%rip),%rdx
mov    $0xb2,%ecx
mov    $0x0,%al
call   1080 <jlog@plt>
movq   $0x0,-0x8(%rbp)
jmp    159c <x509_get_cn+0x3cc>
mov    -0x30(%rbp),%rdi
mov    $0x2f,%esi
call   1070 <strchr@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    150b <x509_get_cn+0x33b>
mov    $0x1,%edi
lea    0xcb0(%rip),%rsi
lea    0xb3e(%rip),%rdx
mov    $0xb9,%ecx
mov    $0x0,%al
call   1080 <jlog@plt>
movq   $0x0,-0x8(%rbp)
jmp    159c <x509_get_cn+0x3cc>
mov    -0x38(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x30(%rbp),%rdi
call   10d0 <strdup@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
jne    1568 <x509_get_cn+0x398>
mov    0x2aa7(%rip),%rax
mov    (%rax),%edi
call   10e0 <strerror@plt>
mov    %rax,%rdx
mov    $0x1,%edi
lea    0xc87(%rip),%rsi
lea    0xae2(%rip),%rcx
mov    $0xc1,%r8d
mov    $0x0,%al
call   1080 <jlog@plt>
movq   $0x0,-0x8(%rbp)
jmp    159c <x509_get_cn+0x3cc>
cmpq   $0x0,-0x28(%rbp)
je     157c <x509_get_cn+0x3ac>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
cmpq   $0x0,-0x40(%rbp)
jne    1594 <x509_get_cn+0x3c4>
movq   $0x0,-0x8(%rbp)
jmp    159c <x509_get_cn+0x3cc>
mov    -0x40(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<x509_get_cn>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0xe1e(%rip),%rsi
call   10c0 <fopen@plt>
test   %rax,%rax
je     12ec <x509_get_cn+0x11c>
mov    %rax,%r12
mov    0x2dee(%rip),%rax
mov    (%rax),%edx
mov    %r12,%rdi
xor    %esi,%esi
call   10b0 <fseek@plt>
cmp    $0xffffffffffffffff,%rax
je     1310 <x509_get_cn+0x140>
mov    %r12,%rdi
call   1090 <ftell@plt>
mov    %rax,%r15
mov    0x2dae(%rip),%rax
mov    (%rax),%edx
mov    %r12,%rdi
xor    %esi,%esi
call   10b0 <fseek@plt>
cmp    $0xffffffffffffffff,%rax
je     1342 <x509_get_cn+0x172>
lea    0x1(%r15),%rdi
call   10a0 <malloc@plt>
test   %rax,%rax
je     1371 <x509_get_cn+0x1a1>
mov    %rax,%r14
mov    %rax,%rdi
mov    $0x1,%esi
mov    %r15,%rdx
mov    %r12,%rcx
call   1040 <fread@plt>
cmp    %r15,%rax
jne    13a0 <x509_get_cn+0x1d0>
movb   $0x0,(%r14,%r15,1)
lea    0xeab(%rip),%rsi
mov    %r14,%rdi
call   10f0 <strstr@plt>
test   %rax,%rax
je     13f3 <x509_get_cn+0x223>
lea    0xed5(%rip),%rsi
mov    %rax,%rdi
call   10f0 <strstr@plt>
test   %rax,%rax
je     1410 <x509_get_cn+0x240>
mov    %rax,%rbx
lea    0xeba(%rip),%rdi
call   1060 <strlen@plt>
cltq
add    %rax,%rbx
mov    %rbx,%rdi
mov    $0x2f,%esi
call   1070 <strchr@plt>
test   %rax,%rax
je     142d <x509_get_cn+0x25d>
movb   $0x0,(%rax)
mov    %rbx,%rdi
call   10d0 <strdup@plt>
test   %rax,%rax
je     1451 <x509_get_cn+0x281>
mov    %rax,%r15
mov    %r14,%rdi
call   1030 <free@plt>
jmp    13e4 <x509_get_cn+0x214>
lea    0xd10(%rip),%rsi
lea    0xd36(%rip),%rcx
xor    %r15d,%r15d
mov    $0x1,%edi
mov    %rbx,%rdx
mov    $0x82,%r8d
jmp    13dd <x509_get_cn+0x20d>
mov    0x2cc1(%rip),%rax
mov    (%rax),%edi
call   10e0 <strerror@plt>
lea    0xda3(%rip),%rsi
lea    0xd04(%rip),%rcx
xor    %r15d,%r15d
mov    $0x1,%edi
mov    %rax,%rdx
mov    $0x88,%r8d
jmp    13dd <x509_get_cn+0x20d>
mov    0x2c8f(%rip),%rax
mov    (%rax),%edi
call   10e0 <strerror@plt>
lea    0xd71(%rip),%rsi
lea    0xcd2(%rip),%rcx
xor    %r15d,%r15d
mov    $0x1,%edi
mov    %rax,%rdx
mov    $0x90,%r8d
jmp    13dd <x509_get_cn+0x20d>
mov    0x2c60(%rip),%rax
mov    (%rax),%edi
call   10e0 <strerror@plt>
lea    0xd5f(%rip),%rsi
lea    0xca3(%rip),%rcx
xor    %r15d,%r15d
mov    $0x1,%edi
mov    %rax,%rdx
mov    $0x96,%r8d
jmp    13dd <x509_get_cn+0x20d>
mov    %r12,%rdi
call   1050 <fclose@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    0x2c21(%rip),%rax
mov    (%rax),%edi
call   10e0 <strerror@plt>
lea    0xd3e(%rip),%rsi
lea    0xc64(%rip),%rcx
xor    %r15d,%r15d
mov    $0x1,%edi
mov    %rax,%rdx
mov    $0x9e,%r8d
xor    %eax,%eax
call   1080 <jlog@plt>
mov    %r15,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
lea    0xd2f(%rip),%rsi
lea    0xc2f(%rip),%rdx
xor    %r15d,%r15d
mov    $0x1,%edi
mov    $0xa6,%ecx
jmp    1448 <x509_get_cn+0x278>
lea    0xd4f(%rip),%rsi
lea    0xc12(%rip),%rdx
xor    %r15d,%r15d
mov    $0x1,%edi
mov    $0xac,%ecx
jmp    1448 <x509_get_cn+0x278>
lea    0xd67(%rip),%rsi
lea    0xbf5(%rip),%rdx
xor    %r15d,%r15d
mov    $0x1,%edi
mov    $0xb9,%ecx
xor    %eax,%eax
call   1080 <jlog@plt>
jmp    13e4 <x509_get_cn+0x214>
mov    0x2b80(%rip),%rax
mov    (%rax),%edi
call   10e0 <strerror@plt>
lea    0xd68(%rip),%rsi
lea    0xbc3(%rip),%rcx
xor    %r15d,%r15d
mov    $0x1,%edi
mov    %rax,%rdx
mov    $0xc1,%r8d
jmp    13dd <x509_get_cn+0x20d>

LLVM IR (-O0):
@.str = [3 x i8] c"rb\00"
@.str.1 = [45 x i8] c"utils]> fopen() no such file : %s :: %s %i \0A\00"
@.str.2 = [152 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/aboudreault/dnds-debian/refs/heads/master/libdnds/src/utils.c\00"
@SEEK_END = global i32 0
@.str.3 = [29 x i8] c"utils]> fseek() %s :: %s:%i\0A\00"
@errno = global i32 0
@SEEK_SET = global i32 0
@.str.4 = [30 x i8] c"utils]> malloc() %s :: %s:%i\0A\00"
@.str.5 = [29 x i8] c"utils]> fread() %s :: %s:%i\0A\00"
@.str.6 = [9 x i8] c"Subject:\00"
@.str.7 = [57 x i8] c"utils]> strstr() \22Subject\22 substring not found :: %s:%i\0A\00"
@.str.8 = [4 x i8] c"CN=\00"
@.str.9 = [53 x i8] c"utils]> strstr() \22CN=\22 substring not found :: %s:%i\0A\00"
@.str.10 = [51 x i8] c"utils]> strchr() \22/\22 character not found :: %s:%i\0A\00"
@.str.11 = [30 x i8] c"utils]> strdup() %s :: %s:%i\0A\00"
define i8* @x509_get_cn(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca i64
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i64
store i8* %0, i8** %3
%11 = load i8*, i8** %3
%12 = call i32* @fopen(i8* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %12, i32** %4
%13 = load i32*, i32** %4
%14 = icmp eq i32* %13, null
br i1 %14, label %15, label %18
15: ; preds = %1
%16 = load i8*, i8** %3
%17 = call i32 (i32, i8*, i8*, ...) @jlog(i32 1, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0), i8* %16, i8* getelementptr inbounds ([152 x i8], [152 x i8]* @.str.2, i64 0, i64 0), i32 130)
store i8* null, i8** %2
br label %122
18: ; preds = %1
%19 = load i32*, i32** %4
%20 = load i32, i32* @SEEK_END
%21 = call i64 @fseek(i32* %19, i32 0, i32 %20)
store i64 %21, i64* %10
%22 = load i64, i64* %10
%23 = icmp eq i64 %22, -1
br i1 %23, label %24, label %28
24: ; preds = %18
%25 = load i32, i32* @errno
%26 = call i8* @strerror(i32 %25)
%27 = call i32 (i32, i8*, i8*, ...) @jlog(i32 1, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0), i8* %26, i8* getelementptr inbounds ([152 x i8], [152 x i8]* @.str.2, i64 0, i64 0), i32 136)
store i8* null, i8** %2
br label %122
28: ; preds = %18
%29 = load i32*, i32** %4
%30 = call i64 @ftell(i32* %29)
store i64 %30, i64* %5
%31 = load i32*, i32** %4
%32 = load i32, i32* @SEEK_SET
%33 = call i64 @fseek(i32* %31, i32 0, i32 %32)
store i64 %33, i64* %10
%34 = load i64, i64* %10
%35 = icmp eq i64 %34, -1
br i1 %35, label %36, label %40
36: ; preds = %28
%37 = load i32, i32* @errno
%38 = call i8* @strerror(i32 %37)
%39 = call i32 (i32, i8*, i8*, ...) @jlog(i32 1, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0), i8* %38, i8* getelementptr inbounds ([152 x i8], [152 x i8]* @.str.2, i64 0, i64 0), i32 144)
store i8* null, i8** %2
br label %122
40: ; preds = %28
%41 = load i64, i64* %5
%42 = add i64 %41, 1
%43 = call i64 @malloc(i64 %42)
%44 = inttoptr i64 %43 to i8*
store i8* %44, i8** %6
%45 = load i8*, i8** %6
%46 = icmp eq i8* %45, null
br i1 %46, label %47, label %51
47: ; preds = %40
%48 = load i32, i32* @errno
%49 = call i8* @strerror(i32 %48)
%50 = call i32 (i32, i8*, i8*, ...) @jlog(i32 1, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i8* %49, i8* getelementptr inbounds ([152 x i8], [152 x i8]* @.str.2, i64 0, i64 0), i32 150)
store i8* null, i8** %2
br label %122
51: ; preds = %40
%52 = load i8*, i8** %6
%53 = load i64, i64* %5
%54 = load i32*, i32** %4
%55 = call i64 @fread(i8* %52, i32 1, i64 %53, i32* %54)
store i64 %55, i64* %10
%56 = load i64, i64* %10
%57 = load i64, i64* %5
%58 = icmp ne i64 %56, %57
br i1 %58, label %59, label %67
59: ; preds = %51
%60 = load i32*, i32** %4
%61 = call i32 @fclose(i32* %60)
%62 = load i8*, i8** %6
%63 = call i32 @free(i8* %62)
%64 = load i32, i32* @errno
%65 = call i8* @strerror(i32 %64)
%66 = call i32 (i32, i8*, i8*, ...) @jlog(i32 1, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0), i8* %65, i8* getelementptr inbounds ([152 x i8], [152 x i8]* @.str.2, i64 0, i64 0), i32 158)
store i8* null, i8** %2
br label %122
67: ; preds = %51
%68 = load i8*, i8** %6
%69 = load i64, i64* %5
%70 = getelementptr inbounds i8, i8* %68, i64 %69
store i8 0, i8* %70
%71 = load i8*, i8** %6
%72 = call i8* @strstr(i8* %71, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0))
store i8* %72, i8** %7
%73 = load i8*, i8** %7
%74 = icmp eq i8* %73, null
br i1 %74, label %75, label %77
75: ; preds = %67
%76 = call i32 (i32, i8*, i8*, ...) @jlog(i32 1, i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([152 x i8], [152 x i8]* @.str.2, i64 0, i64 0), i32 166)
store i8* null, i8** %2
br label %122
77: ; preds = %67
%78 = load i8*, i8** %7
%79 = call i8* @strstr(i8* %78, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0))
store i8* %79, i8** %7
%80 = load i8*, i8** %7
%81 = icmp eq i8* %80, null
br i1 %81, label %82, label %84
82: ; preds = %77
%83 = call i32 (i32, i8*, i8*, ...) @jlog(i32 1, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([152 x i8], [152 x i8]* @.str.2, i64 0, i64 0), i32 172)
store i8* null, i8** %2
br label %122
84: ; preds = %77
%85 = call i32 @strlen(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0))
%86 = load i8*, i8** %7
%87 = sext i32 %85 to i64
%88 = getelementptr inbounds i8, i8* %86, i64 %87
store i8* %88, i8** %7
%89 = load i8*, i8** %7
%90 = icmp eq i8* %89, null
br i1 %90, label %91, label %93
91: ; preds = %84
%92 = call i32 (i32, i8*, i8*, ...) @jlog(i32 1, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([152 x i8], [152 x i8]* @.str.2, i64 0, i64 0), i32 178)
store i8* null, i8** %2
br label %122
93: ; preds = %84
%94 = load i8*, i8** %7
%95 = call i8* @strchr(i8* %94, i8 signext 47)
store i8* %95, i8** %8
%96 = load i8*, i8** %8
%97 = icmp eq i8* %96, null
br i1 %97, label %98, label %100
98: ; preds = %93
%99 = call i32 (i32, i8*, i8*, ...) @jlog(i32 1, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([152 x i8], [152 x i8]* @.str.2, i64 0, i64 0), i32 185)
store i8* null, i8** %2
br label %122
100: ; preds = %93
%101 = load i8*, i8** %8
store i8 0, i8* %101
%102 = load i8*, i8** %7
%103 = call i8* @strdup(i8* %102)
store i8* %103, i8** %9
%104 = load i8*, i8** %9
%105 = icmp eq i8* %104, null
br i1 %105, label %106, label %110
106: ; preds = %100
%107 = load i32, i32* @errno
%108 = call i8* @strerror(i32 %107)
%109 = call i32 (i32, i8*, i8*, ...) @jlog(i32 1, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.11, i64 0, i64 0), i8* %108, i8* getelementptr inbounds ([152 x i8], [152 x i8]* @.str.2, i64 0, i64 0), i32 193)
store i8* null, i8** %2
br label %122
110: ; preds = %100
%111 = load i8*, i8** %6
%112 = icmp ne i8* %111, null
br i1 %112, label %113, label %116
113: ; preds = %110
%114 = load i8*, i8** %6
%115 = call i32 @free(i8* %114)
br label %116
116: ; preds = %113, %110
%117 = load i8*, i8** %9
%118 = icmp eq i8* %117, null
br i1 %118, label %119, label %120
119: ; preds = %116
store i8* null, i8** %2
br label %122
120: ; preds = %116
%121 = load i8*, i8** %9
store i8* %121, i8** %2
br label %122
122: ; preds = %120, %119, %106, %98, %91, %82, %75, %59, %47, %36, %24, %15
%123 = load i8*, i8** %2
ret i8* %123
}

LLVM IR (-O2):
@.str = [3 x i8] c"rb\00"
@.str.1 = [45 x i8] c"utils]> fopen() no such file : %s :: %s %i \0A\00"
@.str.2 = [152 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/aboudreault/dnds-debian/refs/heads/master/libdnds/src/utils.c\00"
@SEEK_END = global i32 0
@.str.3 = [29 x i8] c"utils]> fseek() %s :: %s:%i\0A\00"
@errno = global i32 0
@SEEK_SET = global i32 0
@.str.4 = [30 x i8] c"utils]> malloc() %s :: %s:%i\0A\00"
@.str.5 = [29 x i8] c"utils]> fread() %s :: %s:%i\0A\00"
@.str.6 = [9 x i8] c"Subject:\00"
@.str.7 = [57 x i8] c"utils]> strstr() \22Subject\22 substring not found :: %s:%i\0A\00"
@.str.8 = [4 x i8] c"CN=\00"
@.str.9 = [53 x i8] c"utils]> strstr() \22CN=\22 substring not found :: %s:%i\0A\00"
@.str.10 = [51 x i8] c"utils]> strchr() \22/\22 character not found :: %s:%i\0A\00"
@.str.11 = [30 x i8] c"utils]> strdup() %s :: %s:%i\0A\00"
define noalias i8* @x509_get_cn(i8* %0) {
%2 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i32* %2, null
br i1 %3, label %4, label %6
4: ; preds = %1
%5 = tail call i32 (i32, i8*, i8*, ...) @jlog(i32 1, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0), i8* %0, i8* getelementptr inbounds ([152 x i8], [152 x i8]* @.str.2, i64 0, i64 0), i32 130)
br label %69
6: ; preds = %1
%7 = load i32, i32* @SEEK_END
%8 = tail call i64 @fseek(i32* %2, i32 0, i32 %7)
%9 = icmp eq i64 %8, -1
br i1 %9, label %10, label %14
10: ; preds = %6
%11 = load i32, i32* @errno
%12 = tail call i8* @strerror(i32 %11)
%13 = tail call i32 (i32, i8*, i8*, ...) @jlog(i32 1, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0), i8* %12, i8* getelementptr inbounds ([152 x i8], [152 x i8]* @.str.2, i64 0, i64 0), i32 136)
br label %69
14: ; preds = %6
%15 = tail call i64 @ftell(i32* %2)
%16 = load i32, i32* @SEEK_SET
%17 = tail call i64 @fseek(i32* %2, i32 0, i32 %16)
%18 = icmp eq i64 %17, -1
br i1 %18, label %19, label %23
19: ; preds = %14
%20 = load i32, i32* @errno
%21 = tail call i8* @strerror(i32 %20)
%22 = tail call i32 (i32, i8*, i8*, ...) @jlog(i32 1, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0), i8* %21, i8* getelementptr inbounds ([152 x i8], [152 x i8]* @.str.2, i64 0, i64 0), i32 144)
br label %69
23: ; preds = %14
%24 = add i64 %15, 1
%25 = tail call i64 @malloc(i64 %24)
%26 = inttoptr i64 %25 to i8*
%27 = icmp eq i64 %25, 0
br i1 %27, label %28, label %32
28: ; preds = %23
%29 = load i32, i32* @errno
%30 = tail call i8* @strerror(i32 %29)
%31 = tail call i32 (i32, i8*, i8*, ...) @jlog(i32 1, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i8* %30, i8* getelementptr inbounds ([152 x i8], [152 x i8]* @.str.2, i64 0, i64 0), i32 150)
br label %69
32: ; preds = %23
%33 = tail call i64 @fread(i8* %26, i32 1, i64 %15, i32* %2)
%34 = icmp eq i64 %33, %15
br i1 %34, label %41, label %35
35: ; preds = %32
%36 = tail call i32 @fclose(i32* %2)
%37 = tail call i32 @free(i8* %26)
%38 = load i32, i32* @errno
%39 = tail call i8* @strerror(i32 %38)
%40 = tail call i32 (i32, i8*, i8*, ...) @jlog(i32 1, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0), i8* %39, i8* getelementptr inbounds ([152 x i8], [152 x i8]* @.str.2, i64 0, i64 0), i32 158)
br label %69
41: ; preds = %32
%42 = getelementptr inbounds i8, i8* %26, i64 %15
store i8 0, i8* %42
%43 = tail call i8* @strstr(i8* %26, i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0))
%44 = icmp eq i8* %43, null
br i1 %44, label %45, label %47
45: ; preds = %41
%46 = tail call i32 (i32, i8*, i8*, ...) @jlog(i32 1, i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([152 x i8], [152 x i8]* @.str.2, i64 0, i64 0), i32 166)
br label %69
47: ; preds = %41
%48 = tail call i8* @strstr(i8* %43, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0))
%49 = icmp eq i8* %48, null
br i1 %49, label %50, label %52
50: ; preds = %47
%51 = tail call i32 (i32, i8*, i8*, ...) @jlog(i32 1, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([152 x i8], [152 x i8]* @.str.2, i64 0, i64 0), i32 172)
br label %69
52: ; preds = %47
%53 = tail call i32 @strlen(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0))
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds i8, i8* %48, i64 %54
%56 = tail call i8* @strchr(i8* %55, i8 signext 47)
%57 = icmp eq i8* %56, null
br i1 %57, label %58, label %60
58: ; preds = %52
%59 = tail call i32 (i32, i8*, i8*, ...) @jlog(i32 1, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([152 x i8], [152 x i8]* @.str.2, i64 0, i64 0), i32 185)
br label %69
60: ; preds = %52
store i8 0, i8* %56
%61 = tail call i8* @strdup(i8* %55)
%62 = icmp eq i8* %61, null
br i1 %62, label %63, label %67
63: ; preds = %60
%64 = load i32, i32* @errno
%65 = tail call i8* @strerror(i32 %64)
%66 = tail call i32 (i32, i8*, i8*, ...) @jlog(i32 1, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.11, i64 0, i64 0), i8* %65, i8* getelementptr inbounds ([152 x i8], [152 x i8]* @.str.2, i64 0, i64 0), i32 193)
br label %69
67: ; preds = %60
%68 = tail call i32 @free(i8* %26)
br label %69
69: ; preds = %67, %63, %58, %50, %45, %35, %28, %19, %10, %4
%70 = phi i8* [ null, %4 ], [ null, %10 ], [ null, %19 ], [ null, %28 ], [ null, %35 ], [ null, %45 ], [ null, %50 ], [ null, %58 ], [ null, %63 ], [ %61, %67 ]
ret i8* %70
}