#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 strlen(char const *);
int /*<<< orphan*/ strncpy(char *, char const *, int);
void extract_file_id(const char *file_path, char *id) {
  int start = strlen(file_path) - 1;
  int length = 0;
  while (file_path[start--] != '.')
    ;
  while (file_path[start--] != '_') {
    length++;
  }
  start += 2;
  strncpy(id, file_path + start, length);
  id[length] = '\0';
}


x86 assembly (clang, -O0):
<extract_file_id>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
sub    $0x1,%eax
mov    %eax,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x14(%rbp),%ecx
mov    %ecx,%edx
add    $0xffffffff,%edx
mov    %edx,-0x14(%rbp)
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2e,%eax
je     116a <extract_file_id+0x4a>
jmp    1146 <extract_file_id+0x26>
jmp    116f <extract_file_id+0x4f>
mov    -0x8(%rbp),%rax
mov    -0x14(%rbp),%ecx
mov    %ecx,%edx
add    $0xffffffff,%edx
mov    %edx,-0x14(%rbp)
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x5f,%eax
je     119c <extract_file_id+0x7c>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    116f <extract_file_id+0x4f>
mov    -0x14(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
movslq -0x14(%rbp),%rax
add    %rax,%rsi
mov    -0x18(%rbp),%edx
call   1030 <strncpy@plt>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<extract_file_id>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
call   1040 <strlen@plt>
add    $0xffffffff,%eax
movslq %eax,%rcx
mov    %rcx,%rax
shl    $0x20,%rax
movabs $0xffffffff00000000,%rdx
ff ff ff
cs nopw 0x0(%rax,%rax,1)
add    %rdx,%rax
cmpb   $0x2e,(%rbx,%rcx,1)
lea    -0x1(%rcx),%rcx
jne    1150 <extract_file_id+0x30>
sar    $0x20,%rax
xor    %ebp,%ebp
cmpb   $0x5f,(%rbx,%rax,1)
je     1181 <extract_file_id+0x61>
xor    %ebp,%ebp
nopl   0x0(%rax,%rax,1)
lea    -0x1(%rax),%rcx
add    $0x1,%ebp
cmpb   $0x5f,-0x1(%rbx,%rax,1)
mov    %rcx,%rax
jne    1170 <extract_file_id+0x50>
add    $0x1,%ecx
movslq %ecx,%rax
add    %rax,%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %ebp,%edx
call   1030 <strncpy@plt>
mov    %ebp,%eax
movb   $0x0,(%r14,%rax,1)
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
define void @extract_file_id(i8* %0, i8* %1) {
%3 = tail call i32 @strlen(i8* %0)
%4 = add i32 %3, -1
%5 = sext i32 %4 to i64
br label %6
6: ; preds = %6, %2
%7 = phi i64 [ %8, %6 ], [ %5, %2 ]
%8 = add i64 %7, -1
%9 = getelementptr inbounds i8, i8* %0, i64 %7
%10 = load i8, i8* %9
%11 = icmp eq i8 %10, 46
br i1 %11, label %12, label %6
12: ; preds = %6
%13 = shl i64 %8, 32
%14 = ashr exact i64 %13, 32
%15 = getelementptr inbounds i8, i8* %0, i64 %14
%16 = load i8, i8* %15
%17 = icmp eq i8 %16, 95
br i1 %17, label %26, label %18
18: ; preds = %12, %18
%19 = phi i64 [ %21, %18 ], [ %14, %12 ]
%20 = phi i32 [ %22, %18 ], [ 0, %12 ]
%21 = add i64 %19, -1
%22 = add nuw nsw i32 %20, 1
%23 = getelementptr inbounds i8, i8* %0, i64 %21
%24 = load i8, i8* %23
%25 = icmp eq i8 %24, 95
br i1 %25, label %26, label %18
26: ; preds = %18, %12
%27 = phi i64 [ %8, %12 ], [ %21, %18 ]
%28 = phi i32 [ 0, %12 ], [ %22, %18 ]
%29 = shl i64 %27, 32
%30 = add i64 %29, 4294967296
%31 = ashr exact i64 %30, 32
%32 = getelementptr inbounds i8, i8* %0, i64 %31
%33 = tail call i32 @strncpy(i8* %1, i8* %32, i32 %28)
%34 = zext i32 %28 to i64
%35 = getelementptr inbounds i8, i8* %1, i64 %34
store i8 0, i8* %35
ret void
}