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

/* Variables and functions */
int /*<<< orphan*/ setprivileges(int /*<<< orphan*/, int, char *);
char *get_privileges(mode_t mode, char *privileges) {
  int i;
  for (i = 0; i < 9; i++) {
    setprivileges(mode, i, privileges);
  }
  privileges[9] = '\0';
  return privileges;
}


x86 assembly (clang, -O0):
<get_privileges>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x9,-0x14(%rbp)
jge    114d <get_privileges+0x3d>
mov    -0x4(%rbp),%edi
mov    -0x14(%rbp),%esi
mov    -0x10(%rbp),%rdx
call   1030 <setprivileges@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1126 <get_privileges+0x16>
mov    -0x10(%rbp),%rax
movb   $0x0,0x9(%rax)
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_privileges>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
xor    %esi,%esi
mov    %rbx,%rdx
call   1030 <setprivileges@plt>
mov    %ebp,%edi
mov    $0x1,%esi
mov    %rbx,%rdx
call   1030 <setprivileges@plt>
mov    %ebp,%edi
mov    $0x2,%esi
mov    %rbx,%rdx
call   1030 <setprivileges@plt>
mov    %ebp,%edi
mov    $0x3,%esi
mov    %rbx,%rdx
call   1030 <setprivileges@plt>
mov    %ebp,%edi
mov    $0x4,%esi
mov    %rbx,%rdx
call   1030 <setprivileges@plt>
mov    %ebp,%edi
mov    $0x5,%esi
mov    %rbx,%rdx
call   1030 <setprivileges@plt>
mov    %ebp,%edi
mov    $0x6,%esi
mov    %rbx,%rdx
call   1030 <setprivileges@plt>
mov    %ebp,%edi
mov    $0x7,%esi
mov    %rbx,%rdx
call   1030 <setprivileges@plt>
mov    %ebp,%edi
mov    $0x8,%esi
mov    %rbx,%rdx
call   1030 <setprivileges@plt>
movb   $0x0,0x9(%rbx)
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i8* @get_privileges(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
store i32 %0, i32* %3
store i8* %1, i8** %4
store i32 0, i32* %5
br label %6
6: ; preds = %14, %2
%7 = load i32, i32* %5
%8 = icmp slt i32 %7, 9
br i1 %8, label %9, label %17
9: ; preds = %6
%10 = load i32, i32* %3
%11 = load i32, i32* %5
%12 = load i8*, i8** %4
%13 = call i32 @setprivileges(i32 %10, i32 %11, i8* %12)
br label %14
14: ; preds = %9
%15 = load i32, i32* %5
%16 = add nsw i32 %15, 1
store i32 %16, i32* %5
br label %6
17: ; preds = %6
%18 = load i8*, i8** %4
%19 = getelementptr inbounds i8, i8* %18, i64 9
store i8 0, i8* %19
%20 = load i8*, i8** %4
ret i8* %20
}

LLVM IR (-O2):
define i8* @get_privileges(i32 %0, i8* returned %1) {
%3 = tail call i32 @setprivileges(i32 %0, i32 0, i8* %1)
%4 = tail call i32 @setprivileges(i32 %0, i32 1, i8* %1)
%5 = tail call i32 @setprivileges(i32 %0, i32 2, i8* %1)
%6 = tail call i32 @setprivileges(i32 %0, i32 3, i8* %1)
%7 = tail call i32 @setprivileges(i32 %0, i32 4, i8* %1)
%8 = tail call i32 @setprivileges(i32 %0, i32 5, i8* %1)
%9 = tail call i32 @setprivileges(i32 %0, i32 6, i8* %1)
%10 = tail call i32 @setprivileges(i32 %0, i32 7, i8* %1)
%11 = tail call i32 @setprivileges(i32 %0, i32 8, i8* %1)
%12 = getelementptr inbounds i8, i8* %1, i64 9
store i8 0, i8* %12
ret i8* %1
}