#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int atoi(char *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
char *strchr(char *, char);
int /*<<< orphan*/ strcpy(char *, char *);
void GetLockInfo(FILE *Fl, int *pid, char *name) {
  char Buf[256];
  fgets(Buf, 256, Fl);
  char *Locker = Buf;
  while (*Locker == ' ' || *Locker == '\t')
    Locker++;
  *pid = atoi(Locker);
  if (strchr(Locker, ' ')) {
    Locker = strchr(Locker, ' ') + 1;
  } else {
    Locker = "UNKNOWN";
  }
  strcpy(name, Locker);
}


x86 assembly (clang, -O0):
<GetLockInfo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
lea    -0x120(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    $0x100,%esi
call   1050 <fgets@plt>
lea    -0x120(%rbp),%rax
mov    %rax,-0x128(%rbp)
mov    -0x128(%rbp),%rax
movsbl (%rax),%ecx
mov    $0x1,%al
cmp    $0x20,%ecx
mov    %al,-0x129(%rbp)
je     11ab <GetLockInfo+0x6b>
mov    -0x128(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x9,%eax
sete   %al
mov    %al,-0x129(%rbp)
mov    -0x129(%rbp),%al
test   $0x1,%al
jne    11be <GetLockInfo+0x7e>
jmp    11d5 <GetLockInfo+0x95>
mov    -0x128(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x128(%rbp)
jmp    117a <GetLockInfo+0x3a>
mov    -0x128(%rbp),%rdi
call   1060 <atoi@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x128(%rbp),%rdi
mov    $0x20,%esi
call   1040 <strchr@plt>
cmp    $0x0,%rax
je     1225 <GetLockInfo+0xe5>
mov    -0x128(%rbp),%rdi
mov    $0x20,%esi
call   1040 <strchr@plt>
add    $0x1,%rax
mov    %rax,-0x128(%rbp)
jmp    1233 <GetLockInfo+0xf3>
lea    0xdd4(%rip),%rax
mov    %rax,-0x128(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x128(%rbp),%rsi
call   1030 <strcpy@plt>
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GetLockInfo>:
push   %r15
push   %r14
push   %rbx
sub    $0x100,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rdx
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x100,%esi
call   1050 <fgets@plt>
jmp    1174 <GetLockInfo+0x34>
nopw   0x0(%rax,%rax,1)
add    $0x1,%rbx
movzbl (%rbx),%eax
cmp    $0x20,%al
je     1170 <GetLockInfo+0x30>
cmp    $0x9,%al
je     1170 <GetLockInfo+0x30>
mov    %rbx,%rdi
call   1060 <atoi@plt>
mov    %eax,(%r15)
mov    %rbx,%rdi
mov    $0x20,%esi
call   1040 <strchr@plt>
lea    0x1(%rax),%rcx
test   %rax,%rax
lea    0xe5b(%rip),%rsi
cmovne %rcx,%rsi
mov    %r14,%rdi
call   1030 <strcpy@plt>
add    $0x100,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [8 x i8] c"UNKNOWN\00"
define void @GetLockInfo(i32* nocapture %0, i32* nocapture writeonly %1, i8* %2) {
%4 = alloca [256 x i8]
%5 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%6 = call i32 @fgets(i8* %5, i32 256, i32* %0)
br label %7
7: ; preds = %10, %3
%8 = phi i8* [ %5, %3 ], [ %11, %10 ]
%9 = load i8, i8* %8
switch i8 %9, label %12 [
i8 32, label %10
i8 9, label %10
]
10: ; preds = %7, %7
%11 = getelementptr inbounds i8, i8* %8, i64 1
br label %7
12: ; preds = %7
%13 = call i32 @atoi(i8* %8)
store i32 %13, i32* %1
%14 = call i8* @strchr(i8* %8, i8 signext 32)
%15 = icmp eq i8* %14, null
%16 = getelementptr inbounds i8, i8* %14, i64 1
%17 = select i1 %15, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* %16
%18 = call i32 @strcpy(i8* %2, i8* %17)
ret void
}