#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*/ sprintf(char *, char *, char *);
char *strchr(char *, char);
int strlen(char *);
int remove_sub_name(char *log_name, char *file_name) {
  char *p;
  sprintf(log_name, "log/%s",
          (strlen("RuleEngine") > 1) ? "RuleEngine" : file_name);
  p = strchr(log_name, '.');
  if (p != NULL)
    *p = '\0';
}


x86 assembly (clang, -O0):
<remove_sub_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
lea    0xeb8(%rip),%rdi
call   1030 <strlen@plt>
cmp    $0x1,%eax
jle    116d <remove_sub_name+0x3d>
lea    0xea3(%rip),%rax
mov    %rax,-0x30(%rbp)
jmp    1175 <remove_sub_name+0x45>
mov    -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%rdx
lea    0xe7c(%rip),%rsi
call   1050 <sprintf@plt>
mov    -0x10(%rbp),%rdi
mov    $0x2e,%esi
call   1040 <strchr@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     11ad <remove_sub_name+0x7d>
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<remove_sub_name>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    %rdi,%r14
lea    0xec5(%rip),%r15
mov    %r15,%rdi
call   1030 <strlen@plt>
cmp    $0x2,%eax
cmovge %r15,%rbx
lea    0xea8(%rip),%rsi
mov    %r14,%rdi
mov    %rbx,%rdx
call   1050 <sprintf@plt>
mov    %r14,%rdi
mov    $0x2e,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     1178 <remove_sub_name+0x48>
movb   $0x0,(%rax)
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [7 x i8] c"log/%s\00"
@.str.1 = [11 x i8] c"RuleEngine\00"
define i32 @remove_sub_name(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
%7 = load i8*, i8** %4
%8 = call i32 @strlen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%9 = icmp sgt i32 %8, 1
br i1 %9, label %10, label %11
10: ; preds = %2
br label %13
11: ; preds = %2
%12 = load i8*, i8** %5
br label %13
13: ; preds = %11, %10
%14 = phi i8* [ getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), %10 ], [ %12, %11 ]
%15 = call i32 @sprintf(i8* %7, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %14)
%16 = load i8*, i8** %4
%17 = call i8* @strchr(i8* %16, i8 signext 46)
store i8* %17, i8** %6
%18 = load i8*, i8** %6
%19 = icmp ne i8* %18, null
br i1 %19, label %20, label %22
20: ; preds = %13
%21 = load i8*, i8** %6
store i8 0, i8* %21
br label %22
22: ; preds = %20, %13
%23 = load i32, i32* %3
ret i32 %23
}

LLVM IR (-O2):
@.str = [7 x i8] c"log/%s\00"
@.str.1 = [11 x i8] c"RuleEngine\00"
define i32 @remove_sub_name(i8* %0, i8* %1) {
%3 = tail call i32 @strlen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%4 = icmp sgt i32 %3, 1
%5 = select i1 %4, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* %1
%6 = tail call i32 @sprintf(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %5)
%7 = tail call i8* @strchr(i8* dereferenceable(1) %0, i8 signext 46)
%8 = icmp eq i8* %7, null
br i1 %8, label %10, label %9
9: ; preds = %2
store i8 0, i8* %7
br label %10
10: ; preds = %9, %2
ret i32 undef
}