#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 */
scalar_t__ calloc(int, int);
char *extract_fileID(char *buf) {
  char *fnameID;
  int i = 0, k;
  fnameID = (char *)calloc(25, sizeof(char));
  while (buf[i++] != ' ')
    ;
  k = 0;
  while (buf[i] != '\n')
    fnameID[k++] = buf[i++];
  fnameID[k] = '\0';
  return fnameID;
}


x86 assembly (clang, -O0):
<extract_fileID>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x14(%rbp)
mov    $0x19,%edi
mov    $0x1,%esi
call   1030 <calloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x14(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x14(%rbp)
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x20,%eax
je     115a <extract_fileID+0x4a>
jmp    1136 <extract_fileID+0x26>
movl   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0xa,%eax
je     11a5 <extract_fileID+0x95>
mov    -0x8(%rbp),%rax
mov    -0x14(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x14(%rbp)
movslq %ecx,%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x18(%rbp)
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
jmp    1161 <extract_fileID+0x51>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<extract_fileID>:
push   %rbx
mov    %rdi,%rbx
mov    $0x19,%edi
mov    $0x1,%esi
call   1030 <calloc@plt>
xor    %edx,%edx
cs nopw 0x0(%rax,%rax,1)
nop
cmpb   $0x20,(%rbx,%rdx,1)
lea    0x1(%rdx),%rdx
jne    1130 <extract_fileID+0x20>
mov    %edx,%ecx
mov    (%rbx,%rcx,1),%cl
cmp    $0xa,%cl
jne    1148 <extract_fileID+0x38>
xor    %ecx,%ecx
jmp    1172 <extract_fileID+0x62>
mov    %edx,%edx
add    %rbx,%rdx
add    $0x1,%rdx
xor    %esi,%esi
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %cl,(%rax,%rsi,1)
movzbl (%rdx,%rsi,1),%ecx
add    $0x1,%rsi
cmp    $0xa,%cl
jne    1160 <extract_fileID+0x50>
mov    %esi,%ecx
movb   $0x0,(%rax,%rcx,1)
pop    %rbx
ret

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

LLVM IR (-O2):
define i8* @extract_fileID(i8* nocapture %0) {
%2 = tail call i64 @calloc(i32 25, i32 1)
br label %3
3: ; preds = %3, %1
%4 = phi i64 [ %5, %3 ], [ 0, %1 ]
%5 = add nuw i64 %4, 1
%6 = getelementptr inbounds i8, i8* %0, i64 %4
%7 = load i8, i8* %6
%8 = icmp eq i8 %7, 32
br i1 %8, label %9, label %3
9: ; preds = %3
%10 = inttoptr i64 %2 to i8*
%11 = and i64 %5, 4294967295
%12 = getelementptr inbounds i8, i8* %0, i64 %11
%13 = load i8, i8* %12
%14 = icmp eq i8 %13, 10
br i1 %14, label %27, label %15
15: ; preds = %9, %15
%16 = phi i64 [ %19, %15 ], [ %11, %9 ]
%17 = phi i64 [ %20, %15 ], [ 0, %9 ]
%18 = phi i8 [ %23, %15 ], [ %13, %9 ]
%19 = add nuw i64 %16, 1
%20 = add nuw i64 %17, 1
%21 = getelementptr inbounds i8, i8* %10, i64 %17
store i8 %18, i8* %21
%22 = getelementptr inbounds i8, i8* %0, i64 %19
%23 = load i8, i8* %22
%24 = icmp eq i8 %23, 10
br i1 %24, label %25, label %15
25: ; preds = %15
%26 = and i64 %20, 4294967295
br label %27
27: ; preds = %25, %9
%28 = phi i64 [ 0, %9 ], [ %26, %25 ]
%29 = getelementptr inbounds i8, i8* %10, i64 %28
store i8 0, i8* %29
ret i8* %10
}