#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*/ pid_t;

/* Variables and functions */
int /*<<< orphan*/ strtol(char *, int /*<<< orphan*/ *, int);
void getPidFromCmd(char *cmd, pid_t *pid) {
  int i = 0;
  char temp[20];
  while (*cmd != ' ') {
    cmd++;
  }
  cmd++;
  while (*cmd != '\0') {
    temp[i] = *cmd;
    cmd++;
    i++;
  }
  temp[i] = '\0';
  *pid = strtol(temp, NULL, 10);
}


x86 assembly (clang, -O0):
<getPidFromCmd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
je     1148 <getPidFromCmd+0x38>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1127 <getPidFromCmd+0x17>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     118c <getPidFromCmd+0x7c>
mov    -0x8(%rbp),%rax
mov    (%rax),%cl
movslq -0x14(%rbp),%rax
mov    %cl,-0x30(%rbp,%rax,1)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1154 <getPidFromCmd+0x44>
movslq -0x14(%rbp),%rax
movb   $0x0,-0x30(%rbp,%rax,1)
lea    -0x30(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1030 <strtol@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getPidFromCmd>:
push   %rbx
sub    $0x20,%rsp
mov    %rsi,%rbx
nopl   0x0(%rax,%rax,1)
cmpb   $0x20,(%rdi)
lea    0x1(%rdi),%rdi
jne    1120 <getPidFromCmd+0x10>
mov    (%rdi),%al
test   %al,%al
je     1154 <getPidFromCmd+0x44>
xor    %ecx,%ecx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %al,(%rsp,%rcx,1)
movzbl 0x1(%rdi,%rcx,1),%eax
add    $0x1,%rcx
test   %al,%al
jne    1140 <getPidFromCmd+0x30>
mov    %ecx,%eax
jmp    1156 <getPidFromCmd+0x46>
xor    %eax,%eax
movb   $0x0,(%rsp,%rax,1)
mov    %rsp,%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1030 <strtol@plt>
mov    %eax,(%rbx)
add    $0x20,%rsp
pop    %rbx
ret

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

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