#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 dcac_get_attr_fd_list(int *, int);
int /*<<< orphan*/ dcac_get_attr_name(int, char *, int);
int getpid();
int /*<<< orphan*/ printf(char *, int, ...);
int main() {
  char str[1024];
  int i;
  int fds[256];
  printf("Attribute set of process %d\n", getpid());
  int size = dcac_get_attr_fd_list(fds, 256);
  for (i = 0; i < size; i++) {
    dcac_get_attr_name(fds[i], str, 1024);
    printf("%d: %s\n", fds[i], str);
  }
  printf("Total count: %d\n", i);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x830,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1030 <getpid@plt>
mov    %eax,%esi
lea    0xe9e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x820(%rbp),%rdi
mov    $0x100,%esi
call   1060 <dcac_get_attr_fd_list@plt>
mov    %eax,-0x824(%rbp)
movl   $0x0,-0x414(%rbp)
mov    -0x414(%rbp),%eax
cmp    -0x824(%rbp),%eax
jge    11f2 <main+0xb2>
movslq -0x414(%rbp),%rax
mov    -0x820(%rbp,%rax,4),%edi
lea    -0x410(%rbp),%rsi
mov    $0x400,%edx
call   1050 <dcac_get_attr_name@plt>
movslq -0x414(%rbp),%rax
mov    -0x820(%rbp,%rax,4),%esi
lea    -0x410(%rbp),%rdx
lea    0xe46(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x414(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x414(%rbp)
jmp    118a <main+0x4a>
mov    -0x414(%rbp),%esi
lea    0xe26(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x830,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x800,%rsp
xor    %ebp,%ebp
xor    %eax,%eax
call   1030 <getpid@plt>
lea    0xea1(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rsp,%rdi
mov    $0x100,%esi
call   1060 <dcac_get_attr_fd_list@plt>
test   %eax,%eax
jle    11bc <main+0x7c>
mov    %eax,%r14d
mov    %eax,%r12d
lea    0x400(%rsp),%rbp
lea    0xe8f(%rip),%r15
xor    %ebx,%ebx
mov    (%rsp,%rbx,4),%edi
mov    %rbp,%rsi
mov    $0x400,%edx
call   1050 <dcac_get_attr_name@plt>
mov    (%rsp,%rbx,4),%esi
mov    %r15,%rdi
mov    %rbp,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1190 <main+0x50>
mov    %r14d,%ebp
lea    0xe62(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x800,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [29 x i8] c"Attribute set of process %d\0A\00"
@.str.1 = [8 x i8] c"%d: %s\0A\00"
@.str.2 = [17 x i8] c"Total count: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [1024 x i8]
%3 = alloca i32
%4 = alloca [256 x i32]
%5 = alloca i32
store i32 0, i32* %1
%6 = call i32 (...) @getpid()
%7 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i32 %6)
%8 = getelementptr inbounds [256 x i32], [256 x i32]* %4, i64 0, i64 0
%9 = call i32 @dcac_get_attr_fd_list(i32* %8, i32 256)
store i32 %9, i32* %5
store i32 0, i32* %3
br label %10
10: ; preds = %27, %0
%11 = load i32, i32* %3
%12 = load i32, i32* %5
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %30
14: ; preds = %10
%15 = load i32, i32* %3
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [256 x i32], [256 x i32]* %4, i64 0, i64 %16
%18 = load i32, i32* %17
%19 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%20 = call i32 @dcac_get_attr_name(i32 %18, i8* %19, i32 1024)
%21 = load i32, i32* %3
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [256 x i32], [256 x i32]* %4, i64 0, i64 %22
%24 = load i32, i32* %23
%25 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%26 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 %24, i8* %25)
br label %27
27: ; preds = %14
%28 = load i32, i32* %3
%29 = add nsw i32 %28, 1
store i32 %29, i32* %3
br label %10
30: ; preds = %10
%31 = load i32, i32* %3
%32 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i32 %31)
%33 = load i32, i32* %1
ret i32 %33
}

LLVM IR (-O2):
@.str = [29 x i8] c"Attribute set of process %d\0A\00"
@.str.1 = [8 x i8] c"%d: %s\0A\00"
@.str.2 = [17 x i8] c"Total count: %d\0A\00"
define i32 @main() {
%1 = alloca [1024 x i8]
%2 = alloca [256 x i32]
%3 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%4 = bitcast [256 x i32]* %2 to i8*
%5 = tail call i32 (...) @getpid()
%6 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i32 %5)
%7 = getelementptr inbounds [256 x i32], [256 x i32]* %2, i64 0, i64 0
%8 = call i32 @dcac_get_attr_fd_list(i32* %7, i32 256)
%9 = icmp sgt i32 %8, 0
br i1 %9, label %10, label %21
10: ; preds = %0
%11 = zext i32 %8 to i64
br label %12
12: ; preds = %10, %12
%13 = phi i64 [ 0, %10 ], [ %19, %12 ]
%14 = getelementptr inbounds [256 x i32], [256 x i32]* %2, i64 0, i64 %13
%15 = load i32, i32* %14
%16 = call i32 @dcac_get_attr_name(i32 %15, i8* %3, i32 1024)
%17 = load i32, i32* %14
%18 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 %17, i8* %3)
%19 = add nuw nsw i64 %13, 1
%20 = icmp eq i64 %19, %11
br i1 %20, label %21, label %12
21: ; preds = %12, %0
%22 = phi i32 [ 0, %0 ], [ %8, %12 ]
%23 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i32 %22)
ret i32 0
}