#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*/ STDOUT_FILENO;
size_t strlen(char *);
char *strrchr(char *, char);
int /*<<< orphan*/ write(int /*<<< orphan*/, char *, int);
void init_0(int argc __attribute__((unused)), char **argv) {
  char *p = strrchr(argv[0], '/');
  if (p == NULL)
    return;
  p++;
  size_t len = strlen(p);
  write(STDOUT_FILENO, "init array in DSO: ", 19);
  write(STDOUT_FILENO, p, len);
  write(STDOUT_FILENO, "\n", 1);
}


x86 assembly (clang, -O0):
<init_0>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    $0x2f,%esi
call   1050 <strrchr@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1164 <init_0+0x34>
jmp    11c9 <init_0+0x99>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x20(%rbp)
mov    0x2e6c(%rip),%rax
mov    (%rax),%edi
lea    0xe73(%rip),%rsi
mov    $0x13,%edx
call   1030 <write@plt>
mov    0x2e52(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rax
mov    %eax,%edx
call   1030 <write@plt>
mov    0x2e3a(%rip),%rax
mov    (%rax),%edi
lea    0xe55(%rip),%rsi
mov    $0x1,%edx
call   1030 <write@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<init_0>:
push   %r15
push   %r14
push   %rbx
mov    (%rsi),%rdi
mov    $0x2f,%esi
call   1050 <strrchr@plt>
test   %rax,%rax
je     119b <init_0+0x6b>
mov    %rax,%rbx
add    $0x1,%rbx
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %rax,%r14
mov    0x2e90(%rip),%r15
mov    (%r15),%edi
lea    0xe96(%rip),%rsi
mov    $0x13,%edx
call   1030 <write@plt>
mov    (%r15),%edi
mov    %rbx,%rsi
mov    %r14d,%edx
call   1030 <write@plt>
mov    (%r15),%edi
lea    0xe88(%rip),%rsi
mov    $0x1,%edx
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <write@plt>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@STDOUT_FILENO = global i32 0
@.str = [20 x i8] c"init array in DSO: \00"
@.str.1 = [2 x i8] c"\0A\00"
define void @init_0(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i8*
%6 = alloca i64
store i32 %0, i32* %3
store i8** %1, i8*** %4
%7 = load i8**, i8*** %4
%8 = getelementptr inbounds i8*, i8** %7, i64 0
%9 = load i8*, i8** %8
%10 = call i8* @strrchr(i8* %9, i8 signext 47)
store i8* %10, i8** %5
%11 = load i8*, i8** %5
%12 = icmp eq i8* %11, null
br i1 %12, label %13, label %14
13: ; preds = %2
br label %28
14: ; preds = %2
%15 = load i8*, i8** %5
%16 = getelementptr inbounds i8, i8* %15, i32 1
store i8* %16, i8** %5
%17 = load i8*, i8** %5
%18 = call i64 @strlen(i8* %17)
store i64 %18, i64* %6
%19 = load i32, i32* @STDOUT_FILENO
%20 = call i32 @write(i32 %19, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 19)
%21 = load i32, i32* @STDOUT_FILENO
%22 = load i8*, i8** %5
%23 = load i64, i64* %6
%24 = trunc i64 %23 to i32
%25 = call i32 @write(i32 %21, i8* %22, i32 %24)
%26 = load i32, i32* @STDOUT_FILENO
%27 = call i32 @write(i32 %26, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 1)
br label %28
28: ; preds = %14, %13
ret void
}

LLVM IR (-O2):
@STDOUT_FILENO = global i32 0
@.str = [20 x i8] c"init array in DSO: \00"
@.str.1 = [2 x i8] c"\0A\00"
define void @init_0(i32 %0, i8** nocapture %1) {
%3 = load i8*, i8** %1
%4 = tail call i8* @strrchr(i8* dereferenceable(1) %3, i8 signext 47)
%5 = icmp eq i8* %4, null
br i1 %5, label %16, label %6
6: ; preds = %2
%7 = getelementptr inbounds i8, i8* %4, i64 1
%8 = tail call i64 @strlen(i8* %7)
%9 = load i32, i32* @STDOUT_FILENO
%10 = tail call i32 @write(i32 %9, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 19)
%11 = load i32, i32* @STDOUT_FILENO
%12 = trunc i64 %8 to i32
%13 = tail call i32 @write(i32 %11, i8* %7, i32 %12)
%14 = load i32, i32* @STDOUT_FILENO
%15 = tail call i32 @write(i32 %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 1)
br label %16
16: ; preds = %2, %6
ret void
}