#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 concatenate(char **, char const *, int);
int strlen(char const *);
int concatenate_var(char **filename, const char *s) {
  if (s[0] == '.' && (!*filename || !(*filename)[0] ||
                      (*filename)[strlen(*filename) - 1] == '/')) {
    if (concatenate(filename, "_", 1))
      return 1;
  }
  return concatenate(filename, s, strlen(s));
}


x86 assembly (clang, -O0):
<concatenate_var>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2e,%eax
jne    11bd <concatenate_var+0x9d>
mov    -0x10(%rbp),%rax
cmpq   $0x0,(%rax)
je     118e <concatenate_var+0x6e>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
cmpb   $0x0,(%rax)
je     118e <concatenate_var+0x6e>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2f,%eax
jne    11bd <concatenate_var+0x9d>
mov    -0x10(%rbp),%rdi
lea    0xe67(%rip),%rsi
mov    $0x1,%edx
call   1040 <concatenate@plt>
cmp    $0x0,%eax
je     11b8 <concatenate_var+0x98>
movl   $0x1,-0x4(%rbp)
jmp    11e8 <concatenate_var+0xc8>
jmp    11bd <concatenate_var+0x9d>
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    %eax,%edx
call   1040 <concatenate@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<concatenate_var>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    %rdi,%r14
cmpb   $0x2e,(%rsi)
jne    1173 <concatenate_var+0x53>
mov    (%r14),%r15
test   %r15,%r15
je     1150 <concatenate_var+0x30>
cmpb   $0x0,(%r15)
je     1150 <concatenate_var+0x30>
mov    %r15,%rdi
call   1030 <strlen@plt>
cltq
cmpb   $0x2f,-0x1(%rax,%r15,1)
jne    1173 <concatenate_var+0x53>
lea    0xea9(%rip),%rsi
mov    %r14,%rdi
mov    $0x1,%edx
call   1040 <concatenate@plt>
test   %eax,%eax
je     1173 <concatenate_var+0x53>
mov    $0x1,%eax
pop    %rbx
pop    %r14
pop    %r15
ret
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
pop    %rbx
pop    %r14
pop    %r15
jmp    1040 <concatenate@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"_\00"
define i32 @concatenate_var(i8** %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i8*
store i8** %0, i8*** %4
store i8* %1, i8** %5
%6 = load i8*, i8** %5
%7 = getelementptr inbounds i8, i8* %6, i64 0
%8 = load i8, i8* %7
%9 = sext i8 %8 to i32
%10 = icmp eq i32 %9, 46
br i1 %10, label %11, label %39
11: ; preds = %2
%12 = load i8**, i8*** %4
%13 = load i8*, i8** %12
%14 = icmp ne i8* %13, null
br i1 %14, label %15, label %33
15: ; preds = %11
%16 = load i8**, i8*** %4
%17 = load i8*, i8** %16
%18 = getelementptr inbounds i8, i8* %17, i64 0
%19 = load i8, i8* %18
%20 = icmp ne i8 %19, 0
br i1 %20, label %21, label %33
21: ; preds = %15
%22 = load i8**, i8*** %4
%23 = load i8*, i8** %22
%24 = load i8**, i8*** %4
%25 = load i8*, i8** %24
%26 = call i32 @strlen(i8* %25)
%27 = sub nsw i32 %26, 1
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8, i8* %23, i64 %28
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = icmp eq i32 %31, 47
br i1 %32, label %33, label %39
33: ; preds = %21, %15, %11
%34 = load i8**, i8*** %4
%35 = call i32 @concatenate(i8** %34, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 1)
%36 = icmp ne i32 %35, 0
br i1 %36, label %37, label %38
37: ; preds = %33
store i32 1, i32* %3
br label %45
38: ; preds = %33
br label %39
39: ; preds = %38, %21, %2
%40 = load i8**, i8*** %4
%41 = load i8*, i8** %5
%42 = load i8*, i8** %5
%43 = call i32 @strlen(i8* %42)
%44 = call i32 @concatenate(i8** %40, i8* %41, i32 %43)
store i32 %44, i32* %3
br label %45
45: ; preds = %39, %37
%46 = load i32, i32* %3
ret i32 %46
}

LLVM IR (-O2):
@.str = [2 x i8] c"_\00"
define i32 @concatenate_var(i8** %0, i8* %1) {
%3 = load i8, i8* %1
%4 = icmp eq i8 %3, 46
br i1 %4, label %5, label %21
5: ; preds = %2
%6 = load i8*, i8** %0
%7 = icmp eq i8* %6, null
br i1 %7, label %18, label %8
8: ; preds = %5
%9 = load i8, i8* %6
%10 = icmp eq i8 %9, 0
br i1 %10, label %18, label %11
11: ; preds = %8
%12 = tail call i32 @strlen(i8* %6)
%13 = add nsw i32 %12, -1
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i8, i8* %6, i64 %14
%16 = load i8, i8* %15
%17 = icmp eq i8 %16, 47
br i1 %17, label %18, label %21
18: ; preds = %11, %8, %5
%19 = tail call i32 @concatenate(i8** %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 1)
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %24
21: ; preds = %18, %11, %2
%22 = tail call i32 @strlen(i8* %1)
%23 = tail call i32 @concatenate(i8** %0, i8* %1, i32 %22)
br label %24
24: ; preds = %18, %21
%25 = phi i32 [ %23, %21 ], [ 1, %18 ]
ret i32 %25
}