#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 */
long *find_pid_by_name(char *);
int /*<<< orphan*/ printf(char *, char *, ...);
int main(int argc, char *argv[]) {
  long *pid = NULL;
  if (argc != 2) {
    printf("Usage %s <filename>\n", argv[0]);
    return -1;
  }
  pid = find_pid_by_name(argv[1]);
  while (pid != 0 && *pid != 0) {
    printf("%s is [%d]\n", argv[1], *pid);
    ++pid;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     1169 <main+0x49>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11dd <main+0xbd>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1040 <find_pid_by_name@plt>
mov    %rax,-0x18(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x18(%rbp)
mov    %al,-0x19(%rbp)
je     1198 <main+0x78>
mov    -0x18(%rbp),%rax
cmpq   $0x0,(%rax)
setne  %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    11a8 <main+0x88>
jmp    11d6 <main+0xb6>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
mov    -0x18(%rbp),%rax
mov    (%rax),%rdx
lea    0xe57(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x18(%rbp)
jmp    117a <main+0x5a>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
cmp    $0x2,%edi
jne    117c <main+0x5c>
mov    0x8(%r14),%rdi
call   1040 <find_pid_by_name@plt>
xor    %ebp,%ebp
test   %rax,%rax
je     1192 <main+0x72>
mov    %rax,%rbx
mov    (%rax),%rdx
test   %rdx,%rdx
je     1192 <main+0x72>
add    $0x8,%rbx
lea    0xec0(%rip),%r15
xor    %ebp,%ebp
nopw   0x0(%rax,%rax,1)
mov    0x8(%r14),%rsi
mov    %r15,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    (%rbx),%rdx
add    $0x8,%rbx
test   %rdx,%rdx
jne    1160 <main+0x40>
jmp    1192 <main+0x72>
mov    (%r14),%rsi
lea    0xe7a(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0xffffffff,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [21 x i8] c"Usage %s <filename>\0A\00"
@.str.1 = [12 x i8] c"%s is [%d]\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i64* null, i64** %6
%7 = load i32, i32* %4
%8 = icmp ne i32 %7, 2
br i1 %8, label %9, label %14
9: ; preds = %2
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i64 0
%12 = load i8*, i8** %11
%13 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %12)
store i32 -1, i32* %3
br label %38
14: ; preds = %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = call i64* @find_pid_by_name(i8* %17)
store i64* %18, i64** %6
br label %19
19: ; preds = %28, %14
%20 = load i64*, i64** %6
%21 = icmp ne i64* %20, null
br i1 %21, label %22, label %26
22: ; preds = %19
%23 = load i64*, i64** %6
%24 = load i64, i64* %23
%25 = icmp ne i64 %24, 0
br label %26
26: ; preds = %22, %19
%27 = phi i1 [ false, %19 ], [ %25, %22 ]
br i1 %27, label %28, label %37
28: ; preds = %26
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 1
%31 = load i8*, i8** %30
%32 = load i64*, i64** %6
%33 = load i64, i64* %32
%34 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %31, i64 %33)
%35 = load i64*, i64** %6
%36 = getelementptr inbounds i64, i64* %35, i32 1
store i64* %36, i64** %6
br label %19
37: ; preds = %26
store i32 0, i32* %3
br label %38
38: ; preds = %37, %9
%39 = load i32, i32* %3
ret i32 %39
}

LLVM IR (-O2):
@.str = [21 x i8] c"Usage %s <filename>\0A\00"
@.str.1 = [12 x i8] c"%s is [%d]\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %7, label %4
4: ; preds = %2
%5 = load i8*, i8** %1
%6 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %5)
br label %23
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = tail call i64* @find_pid_by_name(i8* %9)
%11 = icmp eq i64* %10, null
br i1 %11, label %23, label %12
12: ; preds = %7
%13 = load i64, i64* %10
%14 = icmp eq i64 %13, 0
br i1 %14, label %23, label %15
15: ; preds = %12, %15
%16 = phi i64 [ %21, %15 ], [ %13, %12 ]
%17 = phi i64* [ %20, %15 ], [ %10, %12 ]
%18 = load i8*, i8** %8
%19 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %18, i64 %16)
%20 = getelementptr inbounds i64, i64* %17, i64 1
%21 = load i64, i64* %20
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %15
23: ; preds = %15, %12, %7, %4
%24 = phi i32 [ -1, %4 ], [ 0, %7 ], [ 0, %12 ], [ 0, %15 ]
ret i32 %24
}