#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 afs_get_filenames_pos(char *);
int /*<<< orphan*/ printf(char *, char *);
void afs_list_files(char *pstrBuffer) {
  int i, iFilenamesPos, iNbChunks;
  iFilenamesPos = afs_get_filenames_pos(pstrBuffer);
  iNbChunks = (*((int *)(pstrBuffer + 0x04)));
  for (i = 0; i < iNbChunks; i++)
    printf("%s\n", pstrBuffer + iFilenamesPos + i * 0x30);
}


x86 assembly (clang, -O0):
<afs_list_files>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <afs_get_filenames_pos@plt>
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    0x4(%rax),%eax
mov    %eax,-0x14(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1183 <afs_list_files+0x63>
mov    -0x8(%rbp),%rsi
movslq -0x10(%rbp),%rax
add    %rax,%rsi
imul   $0x30,-0xc(%rbp),%eax
cltq
add    %rax,%rsi
lea    0xe90(%rip),%rdi
call   1040 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1149 <afs_list_files+0x29>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<afs_list_files>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%rbx
call   1030 <afs_get_filenames_pos@plt>
mov    0x4(%rbx),%r15d
test   %r15d,%r15d
jle    1165 <afs_list_files+0x45>
cltq
add    %rax,%rbx
lea    0xebe(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
add    $0x30,%rbx
add    $0xffffffffffffffff,%r15
jne    1150 <afs_list_files+0x30>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%s\0A\00"
define void @afs_list_files(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %2
%6 = load i8*, i8** %2
%7 = call i32 @afs_get_filenames_pos(i8* %6)
store i32 %7, i32* %4
%8 = load i8*, i8** %2
%9 = getelementptr inbounds i8, i8* %8, i64 4
%10 = bitcast i8* %9 to i32*
%11 = load i32, i32* %10
store i32 %11, i32* %5
store i32 0, i32* %3
br label %12
12: ; preds = %26, %1
%13 = load i32, i32* %3
%14 = load i32, i32* %5
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %29
16: ; preds = %12
%17 = load i8*, i8** %2
%18 = load i32, i32* %4
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8, i8* %17, i64 %19
%21 = load i32, i32* %3
%22 = mul nsw i32 %21, 48
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8, i8* %20, i64 %23
%25 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %24)
br label %26
26: ; preds = %16
%27 = load i32, i32* %3
%28 = add nsw i32 %27, 1
store i32 %28, i32* %3
br label %12
29: ; preds = %12
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"%s\0A\00"
define void @afs_list_files(i8* %0) {
%2 = tail call i32 @afs_get_filenames_pos(i8* %0)
%3 = getelementptr inbounds i8, i8* %0, i64 4
%4 = bitcast i8* %3 to i32*
%5 = load i32, i32* %4
%6 = icmp sgt i32 %5, 0
br i1 %6, label %7, label %18
7: ; preds = %1
%8 = sext i32 %2 to i64
%9 = getelementptr inbounds i8, i8* %0, i64 %8
%10 = zext i32 %5 to i64
br label %11
11: ; preds = %7, %11
%12 = phi i64 [ 0, %7 ], [ %16, %11 ]
%13 = mul nuw nsw i64 %12, 48
%14 = getelementptr inbounds i8, i8* %9, i64 %13
%15 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %14)
%16 = add nuw nsw i64 %12, 1
%17 = icmp eq i64 %16, %10
br i1 %17, label %18, label %11
18: ; preds = %11, %1
ret void
}