#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 atoi(char const *);
int code_table_4_0(unsigned char **);
int /*<<< orphan*/ f_set_pdt(int, unsigned char **, float *, unsigned int,
                             char *, int /*<<< orphan*/ *, char *);
unsigned char *percentile_value_location(unsigned char **);
int f_set_percentile(int mode, unsigned char **sec, float *data,
                     unsigned int ndata, char *inv_out, void **local,
                     const char *arg1) {
  int pdt, percent;
  unsigned char *p;
  if (mode < 0)
    return 0;
  pdt = code_table_4_0(sec);
  percent = atoi(arg1);
  if (percent < 0)
    percent = 0;
  if (percent > 100)
    percent = 100;
  switch (pdt) {
  case 0:
  case 1:
  case 2:
  case 4:
  case 5:
    f_set_pdt(mode, sec, data, ndata, inv_out, NULL, "+6");
    break;
  case 8:
  case 9:
  case 11:
  case 12:
  case 13:
  case 14:
  case 15:
    f_set_pdt(mode, sec, data, ndata, inv_out, NULL, "+10");
    break;
  }
  p = percentile_value_location(sec);
  if (p != NULL)
    *p = (unsigned char)percent;
  return 0;
}


x86 assembly (clang, -O0):
<f_set_percentile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    0x10(%rbp),%rax
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
cmpl   $0x0,-0x8(%rbp)
jge    1178 <f_set_percentile+0x38>
movl   $0x0,-0x4(%rbp)
jmp    127f <f_set_percentile+0x13f>
mov    -0x10(%rbp),%rdi
call   1050 <code_table_4_0@plt>
mov    %eax,-0x34(%rbp)
mov    0x10(%rbp),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x38(%rbp)
cmpl   $0x0,-0x38(%rbp)
jge    11a1 <f_set_percentile+0x61>
movl   $0x0,-0x38(%rbp)
cmpl   $0x64,-0x38(%rbp)
jle    11b2 <f_set_percentile+0x72>
movl   $0x64,-0x38(%rbp)
mov    -0x34(%rbp),%eax
mov    %eax,-0x44(%rbp)
sub    $0x3,%eax
jb     1202 <f_set_percentile+0xc2>
jmp    11c6 <f_set_percentile+0x86>
mov    -0x44(%rbp),%eax
add    $0xfffffffc,%eax
sub    $0x2,%eax
jb     1202 <f_set_percentile+0xc2>
jmp    11da <f_set_percentile+0x9a>
mov    -0x44(%rbp),%eax
add    $0xfffffff8,%eax
sub    $0x2,%eax
jb     122e <f_set_percentile+0xee>
jmp    11ee <f_set_percentile+0xae>
mov    -0x44(%rbp),%eax
add    $0xfffffff5,%eax
sub    $0x5,%eax
jb     122e <f_set_percentile+0xee>
jmp    1255 <f_set_percentile+0x115>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x1c(%rbp),%ecx
mov    -0x28(%rbp),%r8
xor    %eax,%eax
mov    %eax,%r9d
lea    0xde0(%rip),%rax
mov    %rax,(%rsp)
call   1040 <f_set_pdt@plt>
jmp    1255 <f_set_percentile+0x115>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x1c(%rbp),%ecx
mov    -0x28(%rbp),%r8
xor    %eax,%eax
mov    %eax,%r9d
lea    0xdb7(%rip),%rax
mov    %rax,(%rsp)
call   1040 <f_set_pdt@plt>
mov    -0x10(%rbp),%rdi
call   1030 <percentile_value_location@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
je     1278 <f_set_percentile+0x138>
mov    -0x38(%rbp),%eax
mov    %al,%cl
mov    -0x40(%rbp),%rax
mov    %cl,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<f_set_percentile>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
test   %edi,%edi
js     11df <f_set_percentile+0x9f>
mov    %rdx,%r12
mov    %rsi,%r13
mov    %edi,%r15d
mov    %ecx,0xc(%rsp)
mov    %r8,0x10(%rsp)
mov    0x50(%rsp),%r14
mov    %rsi,%rdi
call   1050 <code_table_4_0@plt>
mov    %eax,%ebx
mov    %r14,%rdi
call   1060 <atoi@plt>
xor    %ecx,%ecx
test   %eax,%eax
cmovns %eax,%ecx
cmp    $0x64,%ecx
mov    $0x64,%ebp
cmovb  %ecx,%ebp
cmp    $0xf,%ebx
ja     11cf <f_set_percentile+0x8f>
mov    $0xfb37,%eax
bt     %ebx,%eax
jae    11cf <f_set_percentile+0x8f>
movslq %ebx,%rax
lea    0xe5e(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
mov    %rax,(%rsp)
mov    %r15d,%edi
mov    %r13,%rsi
mov    %r12,%rdx
mov    0xc(%rsp),%ecx
mov    0x10(%rsp),%r8
xor    %r9d,%r9d
call   1040 <f_set_pdt@plt>
mov    %r13,%rdi
call   1030 <percentile_value_location@plt>
test   %rax,%rax
je     11df <f_set_percentile+0x9f>
mov    %bpl,(%rax)
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"+6\00"
@.str.1 = [4 x i8] c"+10\00"
define i32 @f_set_percentile(i32 %0, i8** %1, float* %2, i32 %3, i8* %4, i8** %5, i8* %6) {
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8**
%11 = alloca float*
%12 = alloca i32
%13 = alloca i8*
%14 = alloca i8**
%15 = alloca i8*
%16 = alloca i32
%17 = alloca i32
%18 = alloca i8*
store i32 %0, i32* %9
store i8** %1, i8*** %10
store float* %2, float** %11
store i32 %3, i32* %12
store i8* %4, i8** %13
store i8** %5, i8*** %14
store i8* %6, i8** %15
%19 = load i32, i32* %9
%20 = icmp slt i32 %19, 0
br i1 %20, label %21, label %22
21: ; preds = %7
store i32 0, i32* %8
br label %60
22: ; preds = %7
%23 = load i8**, i8*** %10
%24 = call i32 @code_table_4_0(i8** %23)
store i32 %24, i32* %16
%25 = load i8*, i8** %15
%26 = call i32 @atoi(i8* %25)
store i32 %26, i32* %17
%27 = load i32, i32* %17
%28 = icmp slt i32 %27, 0
br i1 %28, label %29, label %30
29: ; preds = %22
store i32 0, i32* %17
br label %30
30: ; preds = %29, %22
%31 = load i32, i32* %17
%32 = icmp sgt i32 %31, 100
br i1 %32, label %33, label %34
33: ; preds = %30
store i32 100, i32* %17
br label %34
34: ; preds = %33, %30
%35 = load i32, i32* %16
switch i32 %35, label %50 [
i32 0, label %36
i32 1, label %36
i32 2, label %36
i32 4, label %36
i32 5, label %36
i32 8, label %43
i32 9, label %43
i32 11, label %43
i32 12, label %43
i32 13, label %43
i32 14, label %43
i32 15, label %43
]
36: ; preds = %34, %34, %34, %34, %34
%37 = load i32, i32* %9
%38 = load i8**, i8*** %10
%39 = load float*, float** %11
%40 = load i32, i32* %12
%41 = load i8*, i8** %13
%42 = call i32 @f_set_pdt(i32 %37, i8** %38, float* %39, i32 %40, i8* %41, i32* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %50
43: ; preds = %34, %34, %34, %34, %34, %34, %34
%44 = load i32, i32* %9
%45 = load i8**, i8*** %10
%46 = load float*, float** %11
%47 = load i32, i32* %12
%48 = load i8*, i8** %13
%49 = call i32 @f_set_pdt(i32 %44, i8** %45, float* %46, i32 %47, i8* %48, i32* null, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
br label %50
50: ; preds = %34, %43, %36
%51 = load i8**, i8*** %10
%52 = call i8* @percentile_value_location(i8** %51)
store i8* %52, i8** %18
%53 = load i8*, i8** %18
%54 = icmp ne i8* %53, null
br i1 %54, label %55, label %59
55: ; preds = %50
%56 = load i32, i32* %17
%57 = trunc i32 %56 to i8
%58 = load i8*, i8** %18
store i8 %57, i8* %58
br label %59
59: ; preds = %55, %50
store i32 0, i32* %8
br label %60
60: ; preds = %59, %21
%61 = load i32, i32* %8
ret i32 %61
}

LLVM IR (-O2):
@.str = [3 x i8] c"+6\00"
@.str.1 = [4 x i8] c"+10\00"
@reltable.f_set_percentile = [16 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str to i64), i64 ptrtoint ([16 x i32]* @reltable.f_set_percentile to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str to i64), i64 ptrtoint ([16 x i32]* @reltable.f_set_percentile to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str to i64), i64 ptrtoint ([16 x i32]* @reltable.f_set_percentile to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str to i64), i64 ptrtoint ([16 x i32]* @reltable.f_set_percentile to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str to i64), i64 ptrtoint ([16 x i32]* @reltable.f_set_percentile to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str to i64), i64 ptrtoint ([16 x i32]* @reltable.f_set_percentile to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str to i64), i64 ptrtoint ([16 x i32]* @reltable.f_set_percentile to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str to i64), i64 ptrtoint ([16 x i32]* @reltable.f_set_percentile to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.1 to i64), i64 ptrtoint ([16 x i32]* @reltable.f_set_percentile to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.1 to i64), i64 ptrtoint ([16 x i32]* @reltable.f_set_percentile to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str to i64), i64 ptrtoint ([16 x i32]* @reltable.f_set_percentile to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.1 to i64), i64 ptrtoint ([16 x i32]* @reltable.f_set_percentile to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.1 to i64), i64 ptrtoint ([16 x i32]* @reltable.f_set_percentile to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.1 to i64), i64 ptrtoint ([16 x i32]* @reltable.f_set_percentile to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.1 to i64), i64 ptrtoint ([16 x i32]* @reltable.f_set_percentile to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.1 to i64), i64 ptrtoint ([16 x i32]* @reltable.f_set_percentile to i64)) to i32)]
define i32 @f_set_percentile(i32 %0, i8** %1, float* %2, i32 %3, i8* %4, i8** nocapture readnone %5, i8* nocapture %6) {
%8 = icmp slt i32 %0, 0
br i1 %8, label %32, label %9
9: ; preds = %7
%10 = tail call i32 @code_table_4_0(i8** %1)
%11 = tail call i32 @atoi(i8* %6)
%12 = icmp sgt i32 %11, 0
%13 = select i1 %12, i32 %11, i32 0
%14 = icmp ult i32 %13, 100
%15 = select i1 %14, i32 %13, i32 100
%16 = icmp ult i32 %10, 16
br i1 %16, label %17, label %27
17: ; preds = %9
%18 = trunc i32 %10 to i16
%19 = lshr i16 -1225, %18
%20 = and i16 %19, 1
%21 = icmp eq i16 %20, 0
br i1 %21, label %27, label %22
22: ; preds = %17
%23 = sext i32 %10 to i64
%24 = shl i64 %23, 2
%25 = call i8* @llvm.load.relative.i64(i8* bitcast ([16 x i32]* @reltable.f_set_percentile to i8*), i64 %24)
%26 = tail call i32 @f_set_pdt(i32 %0, i8** %1, float* %2, i32 %3, i8* %4, i32* null, i8* %25)
br label %27
27: ; preds = %17, %9, %22
%28 = tail call i8* @percentile_value_location(i8** %1)
%29 = icmp eq i8* %28, null
br i1 %29, label %32, label %30
30: ; preds = %27
%31 = trunc i32 %15 to i8
store i8 %31, i8* %28
br label %32
32: ; preds = %27, %30, %7
ret i32 0
}