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

/* Variables and functions */
int /*<<< orphan*/ O_RDONLY;
int _dl_search_path(char *, int, char *, int, char const *);
int /*<<< orphan*/ close(int);
int open(char const *, int /*<<< orphan*/);
int read(int, char *, int);
int _dl_search_conf(char *buf, int len, const char *conf,
                    const char *filename) {
  char ld_so_conf[1024];
  int i, l, fd;
  if ((fd = open(conf, O_RDONLY)) != -1) {
    l = read(fd, ld_so_conf, sizeof(ld_so_conf) - 1);
    ld_so_conf[sizeof(ld_so_conf) - 1] = 0;
    close(fd);
    if (l > 0) {
      if (ld_so_conf[l - 1] == '\n')
        ld_so_conf[--l] = 0;
      for (i = 0; i < l; i++)
        if (ld_so_conf[i] == '\n')
          ld_so_conf[i] = ':';
      if ((fd = _dl_search_path(buf, len, ld_so_conf, l, filename)) != -1)
        return fd;
    }
  }
  return -1;
}


x86 assembly (clang, -O0):
<_dl_search_conf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x440,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
mov    0x2e83(%rip),%rax
mov    (%rax),%esi
call   1060 <open@plt>
mov    %eax,-0x43c(%rbp)
cmp    $0xffffffff,%eax
je     1289 <_dl_search_conf+0x149>
mov    -0x43c(%rbp),%edi
lea    -0x430(%rbp),%rsi
mov    $0x3ff,%edx
call   1040 <read@plt>
mov    %eax,-0x438(%rbp)
movb   $0x0,-0x31(%rbp)
mov    -0x43c(%rbp),%edi
call   1030 <close@plt>
cmpl   $0x0,-0x438(%rbp)
jle    1284 <_dl_search_conf+0x144>
mov    -0x438(%rbp),%eax
sub    $0x1,%eax
cltq
movsbl -0x430(%rbp,%rax,1),%eax
ff
cmp    $0xa,%eax
jne    11e9 <_dl_search_conf+0xa9>
mov    -0x438(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x438(%rbp)
cltq
movb   $0x0,-0x430(%rbp,%rax,1)
movl   $0x0,-0x434(%rbp)
mov    -0x434(%rbp),%eax
cmp    -0x438(%rbp),%eax
jge    1245 <_dl_search_conf+0x105>
movslq -0x434(%rbp),%rax
movsbl -0x430(%rbp,%rax,1),%eax
ff
cmp    $0xa,%eax
jne    122c <_dl_search_conf+0xec>
movslq -0x434(%rbp),%rax
movb   $0x3a,-0x430(%rbp,%rax,1)
3a
jmp    1231 <_dl_search_conf+0xf1>
mov    -0x434(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x434(%rbp)
jmp    11f3 <_dl_search_conf+0xb3>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
lea    -0x430(%rbp),%rdx
mov    -0x438(%rbp),%ecx
mov    -0x28(%rbp),%r8
call   1050 <_dl_search_path@plt>
mov    %eax,-0x43c(%rbp)
cmp    $0xffffffff,%eax
je     127f <_dl_search_conf+0x13f>
mov    -0x43c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1290 <_dl_search_conf+0x150>
jmp    1284 <_dl_search_conf+0x144>
jmp    1289 <_dl_search_conf+0x149>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x440,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_dl_search_conf>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x400,%rsp
mov    %rcx,%r14
mov    %esi,%r15d
mov    %rdi,%r12
mov    0x2e89(%rip),%rax
mov    (%rax),%esi
mov    %rdx,%rdi
call   1060 <open@plt>
cmp    $0xffffffff,%eax
je     13ad <_dl_search_conf+0x26d>
mov    %eax,%ebx
mov    %rsp,%rsi
mov    %eax,%edi
mov    $0x3ff,%edx
call   1040 <read@plt>
mov    %eax,%ebp
movb   $0x0,0x3ff(%rsp)
mov    %ebx,%edi
call   1030 <close@plt>
test   %ebp,%ebp
jle    13ad <_dl_search_conf+0x26d>
mov    %ebp,%ecx
add    $0xffffffff,%ebp
cmpb   $0xa,(%rsp,%rbp,1)
jne    11b5 <_dl_search_conf+0x75>
movb   $0x0,(%rsp,%rbp,1)
mov    %ebp,%ecx
test   %ebp,%ebp
je     1395 <_dl_search_conf+0x255>
mov    %ecx,%eax
cmp    $0x10,%ecx
jae    11c3 <_dl_search_conf+0x83>
xor    %edx,%edx
jmp    1389 <_dl_search_conf+0x249>
mov    %eax,%edx
and    $0xfffffff0,%edx
xor    %esi,%esi
movdqa 0xe2e(%rip),%xmm0
movdqa 0xe36(%rip),%xmm1
jmp    11ed <_dl_search_conf+0xad>
nopl   0x0(%rax)
add    $0x10,%rsi
cmp    %rsi,%rdx
je     1376 <_dl_search_conf+0x236>
movq   (%rsp,%rsi,1),%xmm3
movdqa %xmm3,%xmm2
pcmpeqb %xmm0,%xmm2
movd   %xmm2,%edi
test   $0x1,%dil
je     1208 <_dl_search_conf+0xc8>
movb   $0x3a,(%rsp,%rsi,1)
movdqa %xmm2,%xmm4
pslld  $0x8,%xmm4
movd   %xmm4,%edi
shr    $0x10,%edi
test   $0x1,%dil
je     1223 <_dl_search_conf+0xe3>
movb   $0x3a,0x1(%rsp,%rsi,1)
pshuflw $0x55,%xmm3,%xmm4
pcmpeqb %xmm0,%xmm4
pextrw $0x2,%xmm4,%edi
test   $0x1,%dil
je     123c <_dl_search_conf+0xfc>
movb   $0x3a,0x2(%rsp,%rsi,1)
movdqa %xmm2,%xmm4
psllq  $0x18,%xmm4
pextrw $0x3,%xmm4,%edi
test   $0x1,%dil
je     1255 <_dl_search_conf+0x115>
movb   $0x3a,0x3(%rsp,%rsi,1)
pshufd $0x55,%xmm3,%xmm3
pcmpeqb %xmm1,%xmm3
pextrw $0x4,%xmm3,%edi
test   $0x1,%dil
je     126e <_dl_search_conf+0x12e>
movb   $0x3a,0x4(%rsp,%rsi,1)
movdqa %xmm2,%xmm3
pslldq $0x5,%xmm3
pextrw $0x5,%xmm3,%edi
test   $0x1,%dil
je     1287 <_dl_search_conf+0x147>
movb   $0x3a,0x5(%rsp,%rsi,1)
pextrw $0x3,%xmm2,%edi
test   $0x1,%dil
je     1297 <_dl_search_conf+0x157>
movb   $0x3a,0x6(%rsp,%rsi,1)
pslldq $0x7,%xmm2
pextrw $0x7,%xmm2,%edi
test   $0x1,%dil
je     12ac <_dl_search_conf+0x16c>
movb   $0x3a,0x7(%rsp,%rsi,1)
movq   0x8(%rsp,%rsi,1),%xmm3
movdqa %xmm3,%xmm2
pcmpeqb %xmm0,%xmm2
movd   %xmm2,%edi
test   $0x1,%dil
je     12c9 <_dl_search_conf+0x189>
movb   $0x3a,0x8(%rsp,%rsi,1)
movdqa %xmm2,%xmm4
pslld  $0x8,%xmm4
movd   %xmm4,%edi
shr    $0x10,%edi
test   $0x1,%dil
je     12e4 <_dl_search_conf+0x1a4>
movb   $0x3a,0x9(%rsp,%rsi,1)
pshuflw $0x55,%xmm3,%xmm4
pcmpeqb %xmm0,%xmm4
pextrw $0x2,%xmm4,%edi
test   $0x1,%dil
je     12fd <_dl_search_conf+0x1bd>
movb   $0x3a,0xa(%rsp,%rsi,1)
movdqa %xmm2,%xmm4
psllq  $0x18,%xmm4
pextrw $0x3,%xmm4,%edi
test   $0x1,%dil
je     1316 <_dl_search_conf+0x1d6>
movb   $0x3a,0xb(%rsp,%rsi,1)
pshufd $0x55,%xmm3,%xmm3
pcmpeqb %xmm1,%xmm3
pextrw $0x4,%xmm3,%edi
test   $0x1,%dil
je     132f <_dl_search_conf+0x1ef>
movb   $0x3a,0xc(%rsp,%rsi,1)
movdqa %xmm2,%xmm3
pslldq $0x5,%xmm3
pextrw $0x5,%xmm3,%edi
test   $0x1,%dil
je     1348 <_dl_search_conf+0x208>
movb   $0x3a,0xd(%rsp,%rsi,1)
pextrw $0x3,%xmm2,%edi
test   $0x1,%dil
je     1358 <_dl_search_conf+0x218>
movb   $0x3a,0xe(%rsp,%rsi,1)
pslldq $0x7,%xmm2
pextrw $0x7,%xmm2,%edi
test   $0x1,%dil
je     11e0 <_dl_search_conf+0xa0>
movb   $0x3a,0xf(%rsp,%rsi,1)
jmp    11e0 <_dl_search_conf+0xa0>
cmp    %rax,%rdx
jne    1389 <_dl_search_conf+0x249>
jmp    1397 <_dl_search_conf+0x257>
nopl   (%rax)
add    $0x1,%rdx
cmp    %rdx,%rax
je     1397 <_dl_search_conf+0x257>
cmpb   $0xa,(%rsp,%rdx,1)
jne    1380 <_dl_search_conf+0x240>
movb   $0x3a,(%rsp,%rdx,1)
jmp    1380 <_dl_search_conf+0x240>
xor    %ecx,%ecx
mov    %rsp,%rdx
mov    %r12,%rdi
mov    %r15d,%esi
mov    %r14,%r8
call   1050 <_dl_search_path@plt>
cmp    $0xffffffff,%eax
jne    13b2 <_dl_search_conf+0x272>
mov    $0xffffffff,%eax
add    $0x400,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@O_RDONLY = global i32 0
define i32 @_dl_search_conf(i8* %0, i32 %1, i8* %2, i8* %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca [1024 x i8]
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
store i8* %0, i8** %6
store i32 %1, i32* %7
store i8* %2, i8** %8
store i8* %3, i8** %9
%14 = load i8*, i8** %8
%15 = load i32, i32* @O_RDONLY
%16 = call i32 @open(i8* %14, i32 %15)
store i32 %16, i32* %13
%17 = icmp ne i32 %16, -1
br i1 %17, label %18, label %72
18: ; preds = %4
%19 = load i32, i32* %13
%20 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%21 = call i32 @read(i32 %19, i8* %20, i32 1023)
store i32 %21, i32* %12
%22 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 1023
store i8 0, i8* %22
%23 = load i32, i32* %13
%24 = call i32 @close(i32 %23)
%25 = load i32, i32* %12
%26 = icmp sgt i32 %25, 0
br i1 %26, label %27, label %71
27: ; preds = %18
%28 = load i32, i32* %12
%29 = sub nsw i32 %28, 1
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 %30
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
%34 = icmp eq i32 %33, 10
br i1 %34, label %35, label %40
35: ; preds = %27
%36 = load i32, i32* %12
%37 = add nsw i32 %36, -1
store i32 %37, i32* %12
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 %38
store i8 0, i8* %39
br label %40
40: ; preds = %35, %27
store i32 0, i32* %11
br label %41
41: ; preds = %57, %40
%42 = load i32, i32* %11
%43 = load i32, i32* %12
%44 = icmp slt i32 %42, %43
br i1 %44, label %45, label %60
45: ; preds = %41
%46 = load i32, i32* %11
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 %47
%49 = load i8, i8* %48
%50 = sext i8 %49 to i32
%51 = icmp eq i32 %50, 10
br i1 %51, label %52, label %56
52: ; preds = %45
%53 = load i32, i32* %11
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 %54
store i8 58, i8* %55
br label %56
56: ; preds = %52, %45
br label %57
57: ; preds = %56
%58 = load i32, i32* %11
%59 = add nsw i32 %58, 1
store i32 %59, i32* %11
br label %41
60: ; preds = %41
%61 = load i8*, i8** %6
%62 = load i32, i32* %7
%63 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%64 = load i32, i32* %12
%65 = load i8*, i8** %9
%66 = call i32 @_dl_search_path(i8* %61, i32 %62, i8* %63, i32 %64, i8* %65)
store i32 %66, i32* %13
%67 = icmp ne i32 %66, -1
br i1 %67, label %68, label %70
68: ; preds = %60
%69 = load i32, i32* %13
store i32 %69, i32* %5
br label %73
70: ; preds = %60
br label %71
71: ; preds = %70, %18
br label %72
72: ; preds = %71, %4
store i32 -1, i32* %5
br label %73
73: ; preds = %72, %68
%74 = load i32, i32* %5
ret i32 %74
}

LLVM IR (-O2):
@O_RDONLY = global i32 0
define i32 @_dl_search_conf(i8* %0, i32 %1, i8* nocapture %2, i8* %3) {
%5 = alloca [1024 x i8]
%6 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%7 = load i32, i32* @O_RDONLY
%8 = tail call i32 @open(i8* %2, i32 %7)
%9 = icmp eq i32 %8, -1
br i1 %9, label %137, label %10
10: ; preds = %4
%11 = call i32 @read(i32 %8, i8* %6, i32 1023)
%12 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 1023
store i8 0, i8* %12
%13 = tail call i32 @close(i32 %8)
%14 = icmp sgt i32 %11, 0
br i1 %14, label %15, label %137
15: ; preds = %10
%16 = add nsw i32 %11, -1
%17 = zext i32 %16 to i64
%18 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 %17
%19 = load i8, i8* %18
%20 = icmp eq i8 %19, 10
br i1 %20, label %21, label %23
21: ; preds = %15
store i8 0, i8* %18
%22 = icmp eq i32 %16, 0
br i1 %22, label %133, label %23
23: ; preds = %15, %21
%24 = phi i32 [ %16, %21 ], [ %11, %15 ]
%25 = zext i32 %24 to i64
%26 = icmp ult i32 %24, 16
br i1 %26, label %122, label %27
27: ; preds = %23
%28 = and i64 %25, 4294967280
br label %29
29: ; preds = %117, %27
%30 = phi i64 [ 0, %27 ], [ %118, %117 ]
%31 = or i64 %30, 8
%32 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 %30
%33 = bitcast i8* %32 to <8 x i8>*
%34 = load <8 x i8>, <8 x i8>* %33
%35 = getelementptr inbounds i8, i8* %32, i64 8
%36 = bitcast i8* %35 to <8 x i8>*
%37 = load <8 x i8>, <8 x i8>* %36
%38 = icmp eq <8 x i8> %34, <i8 10, i8 10, i8 10, i8 10, i8 10, i8 10, i8 10, i8 10>
%39 = icmp eq <8 x i8> %37, <i8 10, i8 10, i8 10, i8 10, i8 10, i8 10, i8 10, i8 10>
%40 = extractelement <8 x i1> %38, i64 0
br i1 %40, label %41, label %43
41: ; preds = %29
%42 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 %30
store i8 58, i8* %42
br label %43
43: ; preds = %41, %29
%44 = extractelement <8 x i1> %38, i64 1
br i1 %44, label %45, label %48
45: ; preds = %43
%46 = or i64 %30, 1
%47 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 %46
store i8 58, i8* %47
br label %48
48: ; preds = %45, %43
%49 = extractelement <8 x i1> %38, i64 2
br i1 %49, label %50, label %53
50: ; preds = %48
%51 = or i64 %30, 2
%52 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 %51
store i8 58, i8* %52
br label %53
53: ; preds = %50, %48
%54 = extractelement <8 x i1> %38, i64 3
br i1 %54, label %55, label %58
55: ; preds = %53
%56 = or i64 %30, 3
%57 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 %56
store i8 58, i8* %57
br label %58
58: ; preds = %55, %53
%59 = extractelement <8 x i1> %38, i64 4
br i1 %59, label %60, label %63
60: ; preds = %58
%61 = or i64 %30, 4
%62 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 %61
store i8 58, i8* %62
br label %63
63: ; preds = %60, %58
%64 = extractelement <8 x i1> %38, i64 5
br i1 %64, label %65, label %68
65: ; preds = %63
%66 = or i64 %30, 5
%67 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 %66
store i8 58, i8* %67
br label %68
68: ; preds = %65, %63
%69 = extractelement <8 x i1> %38, i64 6
br i1 %69, label %70, label %73
70: ; preds = %68
%71 = or i64 %30, 6
%72 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 %71
store i8 58, i8* %72
br label %73
73: ; preds = %70, %68
%74 = extractelement <8 x i1> %38, i64 7
br i1 %74, label %75, label %78
75: ; preds = %73
%76 = or i64 %30, 7
%77 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 %76
store i8 58, i8* %77
br label %78
78: ; preds = %75, %73
%79 = extractelement <8 x i1> %39, i64 0
br i1 %79, label %80, label %82
80: ; preds = %78
%81 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 %31
store i8 58, i8* %81
br label %82
82: ; preds = %80, %78
%83 = extractelement <8 x i1> %39, i64 1
br i1 %83, label %84, label %87
84: ; preds = %82
%85 = or i64 %30, 9
%86 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 %85
store i8 58, i8* %86
br label %87
87: ; preds = %84, %82
%88 = extractelement <8 x i1> %39, i64 2
br i1 %88, label %89, label %92
89: ; preds = %87
%90 = or i64 %30, 10
%91 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 %90
store i8 58, i8* %91
br label %92
92: ; preds = %89, %87
%93 = extractelement <8 x i1> %39, i64 3
br i1 %93, label %94, label %97
94: ; preds = %92
%95 = or i64 %30, 11
%96 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 %95
store i8 58, i8* %96
br label %97
97: ; preds = %94, %92
%98 = extractelement <8 x i1> %39, i64 4
br i1 %98, label %99, label %102
99: ; preds = %97
%100 = or i64 %30, 12
%101 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 %100
store i8 58, i8* %101
br label %102
102: ; preds = %99, %97
%103 = extractelement <8 x i1> %39, i64 5
br i1 %103, label %104, label %107
104: ; preds = %102
%105 = or i64 %30, 13
%106 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 %105
store i8 58, i8* %106
br label %107
107: ; preds = %104, %102
%108 = extractelement <8 x i1> %39, i64 6
br i1 %108, label %109, label %112
109: ; preds = %107
%110 = or i64 %30, 14
%111 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 %110
store i8 58, i8* %111
br label %112
112: ; preds = %109, %107
%113 = extractelement <8 x i1> %39, i64 7
br i1 %113, label %114, label %117
114: ; preds = %112
%115 = or i64 %30, 15
%116 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 %115
store i8 58, i8* %116
br label %117
117: ; preds = %114, %112
%118 = add nuw i64 %30, 16
%119 = icmp eq i64 %118, %28
br i1 %119, label %120, label %29
120: ; preds = %117
%121 = icmp eq i64 %28, %25
br i1 %121, label %133, label %122
122: ; preds = %23, %120
%123 = phi i64 [ 0, %23 ], [ %28, %120 ]
br label %124
124: ; preds = %122, %130
%125 = phi i64 [ %131, %130 ], [ %123, %122 ]
%126 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 %125
%127 = load i8, i8* %126
%128 = icmp eq i8 %127, 10
br i1 %128, label %129, label %130
129: ; preds = %124
store i8 58, i8* %126
br label %130
130: ; preds = %124, %129
%131 = add nuw nsw i64 %125, 1
%132 = icmp eq i64 %131, %25
br i1 %132, label %133, label %124
133: ; preds = %130, %120, %21
%134 = phi i32 [ 0, %21 ], [ %24, %120 ], [ %24, %130 ]
%135 = call i32 @_dl_search_path(i8* %0, i32 %1, i8* %6, i32 %134, i8* %3)
%136 = icmp eq i32 %135, -1
br i1 %136, label %137, label %138
137: ; preds = %10, %133, %4
br label %138
138: ; preds = %133, %137
%139 = phi i32 [ -1, %137 ], [ %135, %133 ]
ret i32 %139
}