#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 /*<<< orphan*/ get_task_xattr(int);
int getpid();
int /*<<< orphan*/ printf(char *, int);
int strtol(char *, int /*<<< orphan*/ *, int /*<<< orphan*/);
int main(int argc, char **argv) {
  if (argc > 1 && argv[1]) {
    int pid = strtol(argv[1], NULL, 0);
    printf("to get attr of pid %d\n", pid);
    get_task_xattr(pid);
  } else {
    get_task_xattr(getpid());
  }
  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)
cmpl   $0x1,-0x8(%rbp)
jle    11a1 <main+0x61>
mov    -0x10(%rbp),%rax
cmpq   $0x0,0x8(%rax)
je     11a1 <main+0x61>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   1050 <strtol@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%esi
lea    0xe71(%rip),%rdi
call   1040 <printf@plt>
mov    -0x14(%rbp),%edi
call   1060 <get_task_xattr@plt>
jmp    11af <main+0x6f>
mov    $0x0,%al
call   1030 <getpid@plt>
mov    %eax,%edi
call   1060 <get_task_xattr@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
cmp    $0x2,%edi
jl     116a <main+0x2a>
mov    0x8(%rsi),%rdi
test   %rdi,%rdi
je     116a <main+0x2a>
xor    %esi,%esi
xor    %edx,%edx
call   1050 <strtol@plt>
mov    %eax,%ebx
lea    0xe9f(%rip),%rdi
mov    %eax,%esi
call   1040 <printf@plt>
jmp    1173 <main+0x33>
xor    %eax,%eax
call   1030 <getpid@plt>
mov    %eax,%ebx
mov    %ebx,%edi
call   1060 <get_task_xattr@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [23 x i8] c"to get attr of pid %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = icmp sgt i32 %7, 1
br i1 %8, label %9, label %23
9: ; preds = %2
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i64 1
%12 = load i8*, i8** %11
%13 = icmp ne i8* %12, null
br i1 %13, label %14, label %23
14: ; preds = %9
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = call i32 @strtol(i8* %17, i32* null, i32 0)
store i32 %18, i32* %6
%19 = load i32, i32* %6
%20 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %19)
%21 = load i32, i32* %6
%22 = call i32 @get_task_xattr(i32 %21)
br label %26
23: ; preds = %9, %2
%24 = call i32 (...) @getpid()
%25 = call i32 @get_task_xattr(i32 %24)
br label %26
26: ; preds = %23, %14
ret i32 0
}

LLVM IR (-O2):
@.str = [23 x i8] c"to get attr of pid %d\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 1
br i1 %3, label %4, label %11
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = icmp eq i8* %6, null
br i1 %7, label %11, label %8
8: ; preds = %4
%9 = tail call i32 @strtol(i8* nocapture %6, i32* null, i32 0)
%10 = tail call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %9)
br label %13
11: ; preds = %4, %2
%12 = tail call i32 (...) @getpid()
br label %13
13: ; preds = %11, %8
%14 = phi i32 [ %12, %11 ], [ %9, %8 ]
%15 = tail call i32 @get_task_xattr(i32 %14)
ret i32 0
}