#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 */
double atof(char const *);
scalar_t__ atoi(char const *);
int /*<<< orphan*/ best_scaled_value(double, int *, int *);
int code_table_4_0(unsigned char **);
unsigned char *code_table_4_9_location(unsigned char **);
int /*<<< orphan*/ f_set_pdt(int, unsigned char **, float *, unsigned int,
                             char *, int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ uint_char(int, unsigned char *);
int f_set_prob(int mode, unsigned char **sec, float *data, unsigned int ndata,
               char *inv_out, void **local, const char *arg1, const char *arg2,
               const char *arg3, const char *arg4, const char *arg5) {
  int pdt, val, scale;
  double value;
  unsigned char *p;
  if (mode < 0)
    return 0;
  pdt = code_table_4_0(sec);
  switch (pdt) {
  case 0:
  case 1:
  case 2:
  case 4:
  case 6:
    f_set_pdt(mode, sec, data, ndata, inv_out, NULL, "+5");
    break;
  case 8:
  case 10:
  case 11:
  case 12:
  case 13:
  case 14:
  case 15:
    f_set_pdt(mode, sec, data, ndata, inv_out, NULL, "+9");
    break;
  }
  p = code_table_4_9_location(sec);
  if (p == NULL) {
    fprintf(stderr, "\nWARNING: set_prob does not work with PDT %d\n", pdt);
    return 0;
  }
  p[-2] = (unsigned char)atoi(arg1);
  p[-1] = (unsigned char)atoi(arg2);
  p[0] = (unsigned char)atoi(arg3);
  value = atof(arg4);
  best_scaled_value(value, &scale, &val);
  p[1] = scale & 255;
  uint_char(val, p + 2);
  value = atof(arg5);
  best_scaled_value(value, &scale, &val);
  p[6] = scale & 255;
  uint_char(val, p + 7);
  return 0;
}


x86 assembly (clang, -O0):
<f_set_prob>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    0x30(%rbp),%rax
mov    0x28(%rbp),%rax
mov    0x20(%rbp),%rax
mov    0x18(%rbp),%rax
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    11c8 <f_set_prob+0x48>
movl   $0x0,-0x4(%rbp)
jmp    137c <f_set_prob+0x1fc>
mov    -0x10(%rbp),%rdi
call   1080 <code_table_4_0@plt>
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%eax
mov    %eax,-0x54(%rbp)
sub    $0x3,%eax
jb     122f <f_set_prob+0xaf>
jmp    11e8 <f_set_prob+0x68>
mov    -0x54(%rbp),%eax
sub    $0x4,%eax
je     122f <f_set_prob+0xaf>
jmp    11f9 <f_set_prob+0x79>
mov    -0x54(%rbp),%eax
sub    $0x6,%eax
je     122f <f_set_prob+0xaf>
jmp    120a <f_set_prob+0x8a>
mov    -0x54(%rbp),%eax
sub    $0x8,%eax
je     125b <f_set_prob+0xdb>
jmp    121b <f_set_prob+0x9b>
mov    -0x54(%rbp),%eax
add    $0xfffffff6,%eax
sub    $0x6,%eax
jb     125b <f_set_prob+0xdb>
jmp    1282 <f_set_prob+0x102>
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    0xdb3(%rip),%rax
mov    %rax,(%rsp)
call   1070 <f_set_pdt@plt>
jmp    1282 <f_set_prob+0x102>
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    0xd8a(%rip),%rax
mov    %rax,(%rsp)
call   1070 <f_set_pdt@plt>
mov    -0x10(%rbp),%rdi
call   1060 <code_table_4_9_location@plt>
mov    %rax,-0x50(%rbp)
cmpq   $0x0,-0x50(%rbp)
jne    12be <f_set_prob+0x13e>
mov    0x2d3f(%rip),%rax
mov    (%rax),%edi
mov    -0x34(%rbp),%edx
lea    0xd59(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    137c <f_set_prob+0x1fc>
mov    0x10(%rbp),%rdi
call   1090 <atoi@plt>
mov    %al,%cl
mov    -0x50(%rbp),%rax
mov    %cl,-0x2(%rax)
mov    0x18(%rbp),%rdi
call   1090 <atoi@plt>
mov    %al,%cl
mov    -0x50(%rbp),%rax
mov    %cl,-0x1(%rax)
mov    0x20(%rbp),%rdi
call   1090 <atoi@plt>
mov    %al,%cl
mov    -0x50(%rbp),%rax
mov    %cl,(%rax)
mov    0x28(%rbp),%rdi
call   1040 <atof@plt>
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
lea    -0x3c(%rbp),%rdi
lea    -0x38(%rbp),%rsi
call   10a0 <best_scaled_value@plt>
mov    -0x3c(%rbp),%eax
and    $0xff,%eax
mov    %al,%cl
mov    -0x50(%rbp),%rax
mov    %cl,0x1(%rax)
mov    -0x38(%rbp),%edi
mov    -0x50(%rbp),%rsi
add    $0x2,%rsi
call   1030 <uint_char@plt>
mov    0x30(%rbp),%rdi
call   1040 <atof@plt>
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
lea    -0x3c(%rbp),%rdi
lea    -0x38(%rbp),%rsi
call   10a0 <best_scaled_value@plt>
mov    -0x3c(%rbp),%eax
and    $0xff,%eax
mov    %al,%cl
mov    -0x50(%rbp),%rax
mov    %cl,0x6(%rax)
mov    -0x38(%rbp),%edi
mov    -0x50(%rbp),%rsi
add    $0x7,%rsi
call   1030 <uint_char@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<f_set_prob>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
test   %edi,%edi
js     12a9 <f_set_prob+0x129>
mov    %r8,%r14
mov    %ecx,%r15d
mov    %rdx,%r12
mov    %rsi,%rbx
mov    %edi,%ebp
mov    %rsi,%rdi
call   1080 <code_table_4_0@plt>
mov    %eax,%r13d
cmp    $0xf,%eax
ja     11ea <f_set_prob+0x6a>
mov    $0xfd57,%eax
bt     %r13d,%eax
jae    11ea <f_set_prob+0x6a>
movslq %r13d,%rax
lea    0xe6b(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
mov    %rax,(%rsp)
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r12,%rdx
mov    %r15d,%ecx
mov    %r14,%r8
xor    %r9d,%r9d
call   1070 <f_set_pdt@plt>
mov    %rbx,%rdi
call   1060 <code_table_4_9_location@plt>
test   %rax,%rax
je     1291 <f_set_prob+0x111>
mov    %rax,%rbx
mov    0x70(%rsp),%r14
mov    0x68(%rsp),%r15
mov    0x60(%rsp),%r12
mov    0x58(%rsp),%rbp
mov    0x50(%rsp),%rdi
call   1090 <atoi@plt>
mov    %al,-0x2(%rbx)
mov    %rbp,%rdi
call   1090 <atoi@plt>
mov    %al,-0x1(%rbx)
mov    %r12,%rdi
call   1090 <atoi@plt>
mov    %al,(%rbx)
mov    %r15,%rdi
call   1040 <atof@plt>
lea    0x10(%rsp),%rbp
lea    0x14(%rsp),%r15
mov    %rbp,%rdi
mov    %r15,%rsi
call   10a0 <best_scaled_value@plt>
mov    0x10(%rsp),%al
mov    %al,0x1(%rbx)
mov    0x14(%rsp),%edi
lea    0x2(%rbx),%rsi
call   1030 <uint_char@plt>
mov    %r14,%rdi
call   1040 <atof@plt>
mov    %rbp,%rdi
mov    %r15,%rsi
call   10a0 <best_scaled_value@plt>
mov    0x10(%rsp),%al
mov    %al,0x6(%rbx)
mov    0x14(%rsp),%edi
add    $0x7,%rbx
mov    %rbx,%rsi
call   1030 <uint_char@plt>
jmp    12a9 <f_set_prob+0x129>
mov    0x2d48(%rip),%rax
mov    (%rax),%edi
lea    0xd65(%rip),%rsi
mov    %r13d,%edx
call   1050 <fprintf@plt>
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"+5\00"
@.str.1 = [3 x i8] c"+9\00"
@stderr = global i32 0
@.str.2 = [46 x i8] c"\0AWARNING: set_prob does not work with PDT %d\0A\00"
define i32 @f_set_prob(i32 %0, i8** %1, float* %2, i32 %3, i8* %4, i8** %5, i8* %6, i8* %7, i8* %8, i8* %9, i8* %10) {
%12 = alloca i32
%13 = alloca i32
%14 = alloca i8**
%15 = alloca float*
%16 = alloca i32
%17 = alloca i8*
%18 = alloca i8**
%19 = alloca i8*
%20 = alloca i8*
%21 = alloca i8*
%22 = alloca i8*
%23 = alloca i8*
%24 = alloca i32
%25 = alloca i32
%26 = alloca i32
%27 = alloca double
%28 = alloca i8*
store i32 %0, i32* %13
store i8** %1, i8*** %14
store float* %2, float** %15
store i32 %3, i32* %16
store i8* %4, i8** %17
store i8** %5, i8*** %18
store i8* %6, i8** %19
store i8* %7, i8** %20
store i8* %8, i8** %21
store i8* %9, i8** %22
store i8* %10, i8** %23
%29 = load i32, i32* %13
%30 = icmp slt i32 %29, 0
br i1 %30, label %31, label %32
31: ; preds = %11
store i32 0, i32* %12
br label %101
32: ; preds = %11
%33 = load i8**, i8*** %14
%34 = call i32 @code_table_4_0(i8** %33)
store i32 %34, i32* %24
%35 = load i32, i32* %24
switch i32 %35, label %50 [
i32 0, label %36
i32 1, label %36
i32 2, label %36
i32 4, label %36
i32 6, label %36
i32 8, label %43
i32 10, label %43
i32 11, label %43
i32 12, label %43
i32 13, label %43
i32 14, label %43
i32 15, label %43
]
36: ; preds = %32, %32, %32, %32, %32
%37 = load i32, i32* %13
%38 = load i8**, i8*** %14
%39 = load float*, float** %15
%40 = load i32, i32* %16
%41 = load i8*, i8** %17
%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 = %32, %32, %32, %32, %32, %32, %32
%44 = load i32, i32* %13
%45 = load i8**, i8*** %14
%46 = load float*, float** %15
%47 = load i32, i32* %16
%48 = load i8*, i8** %17
%49 = call i32 @f_set_pdt(i32 %44, i8** %45, float* %46, i32 %47, i8* %48, i32* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %50
50: ; preds = %32, %43, %36
%51 = load i8**, i8*** %14
%52 = call i8* @code_table_4_9_location(i8** %51)
store i8* %52, i8** %28
%53 = load i8*, i8** %28
%54 = icmp eq i8* %53, null
br i1 %54, label %55, label %59
55: ; preds = %50
%56 = load i32, i32* @stderr
%57 = load i32, i32* %24
%58 = call i32 @fprintf(i32 %56, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.2, i64 0, i64 0), i32 %57)
store i32 0, i32* %12
br label %101
59: ; preds = %50
%60 = load i8*, i8** %19
%61 = call i64 @atoi(i8* %60)
%62 = trunc i64 %61 to i8
%63 = load i8*, i8** %28
%64 = getelementptr inbounds i8, i8* %63, i64 -2
store i8 %62, i8* %64
%65 = load i8*, i8** %20
%66 = call i64 @atoi(i8* %65)
%67 = trunc i64 %66 to i8
%68 = load i8*, i8** %28
%69 = getelementptr inbounds i8, i8* %68, i64 -1
store i8 %67, i8* %69
%70 = load i8*, i8** %21
%71 = call i64 @atoi(i8* %70)
%72 = trunc i64 %71 to i8
%73 = load i8*, i8** %28
%74 = getelementptr inbounds i8, i8* %73, i64 0
store i8 %72, i8* %74
%75 = load i8*, i8** %22
%76 = call double @atof(i8* %75)
store double %76, double* %27
%77 = load double, double* %27
%78 = call i32 @best_scaled_value(double %77, i32* %26, i32* %25)
%79 = load i32, i32* %26
%80 = and i32 %79, 255
%81 = trunc i32 %80 to i8
%82 = load i8*, i8** %28
%83 = getelementptr inbounds i8, i8* %82, i64 1
store i8 %81, i8* %83
%84 = load i32, i32* %25
%85 = load i8*, i8** %28
%86 = getelementptr inbounds i8, i8* %85, i64 2
%87 = call i32 @uint_char(i32 %84, i8* %86)
%88 = load i8*, i8** %23
%89 = call double @atof(i8* %88)
store double %89, double* %27
%90 = load double, double* %27
%91 = call i32 @best_scaled_value(double %90, i32* %26, i32* %25)
%92 = load i32, i32* %26
%93 = and i32 %92, 255
%94 = trunc i32 %93 to i8
%95 = load i8*, i8** %28
%96 = getelementptr inbounds i8, i8* %95, i64 6
store i8 %94, i8* %96
%97 = load i32, i32* %25
%98 = load i8*, i8** %28
%99 = getelementptr inbounds i8, i8* %98, i64 7
%100 = call i32 @uint_char(i32 %97, i8* %99)
store i32 0, i32* %12
br label %101
101: ; preds = %59, %55, %31
%102 = load i32, i32* %12
ret i32 %102
}

LLVM IR (-O2):
@.str = [3 x i8] c"+5\00"
@.str.1 = [3 x i8] c"+9\00"
@stderr = global i32 0
@.str.2 = [46 x i8] c"\0AWARNING: set_prob does not work with PDT %d\0A\00"
@reltable.f_set_prob = [16 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str to i64), i64 ptrtoint ([16 x i32]* @reltable.f_set_prob to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str to i64), i64 ptrtoint ([16 x i32]* @reltable.f_set_prob to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str to i64), i64 ptrtoint ([16 x i32]* @reltable.f_set_prob to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str to i64), i64 ptrtoint ([16 x i32]* @reltable.f_set_prob to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str to i64), i64 ptrtoint ([16 x i32]* @reltable.f_set_prob to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str to i64), i64 ptrtoint ([16 x i32]* @reltable.f_set_prob to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str to i64), i64 ptrtoint ([16 x i32]* @reltable.f_set_prob to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str to i64), i64 ptrtoint ([16 x i32]* @reltable.f_set_prob to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.1 to i64), i64 ptrtoint ([16 x i32]* @reltable.f_set_prob to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str to i64), i64 ptrtoint ([16 x i32]* @reltable.f_set_prob to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.1 to i64), i64 ptrtoint ([16 x i32]* @reltable.f_set_prob to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.1 to i64), i64 ptrtoint ([16 x i32]* @reltable.f_set_prob to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.1 to i64), i64 ptrtoint ([16 x i32]* @reltable.f_set_prob to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.1 to i64), i64 ptrtoint ([16 x i32]* @reltable.f_set_prob to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.1 to i64), i64 ptrtoint ([16 x i32]* @reltable.f_set_prob to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.1 to i64), i64 ptrtoint ([16 x i32]* @reltable.f_set_prob to i64)) to i32)]
define i32 @f_set_prob(i32 %0, i8** %1, float* %2, i32 %3, i8* %4, i8** nocapture readnone %5, i8* nocapture %6, i8* nocapture %7, i8* nocapture %8, i8* nocapture %9, i8* nocapture %10) {
%12 = alloca i32
%13 = alloca i32
%14 = bitcast i32* %12 to i8*
%15 = bitcast i32* %13 to i8*
%16 = icmp slt i32 %0, 0
br i1 %16, label %61, label %17
17: ; preds = %11
%18 = tail call i32 @code_table_4_0(i8** %1)
%19 = icmp ult i32 %18, 16
br i1 %19, label %20, label %30
20: ; preds = %17
%21 = trunc i32 %18 to i16
%22 = lshr i16 -681, %21
%23 = and i16 %22, 1
%24 = icmp eq i16 %23, 0
br i1 %24, label %30, label %25
25: ; preds = %20
%26 = sext i32 %18 to i64
%27 = shl i64 %26, 2
%28 = call i8* @llvm.load.relative.i64(i8* bitcast ([16 x i32]* @reltable.f_set_prob to i8*), i64 %27)
%29 = tail call i32 @f_set_pdt(i32 %0, i8** %1, float* %2, i32 %3, i8* %4, i32* null, i8* %28)
br label %30
30: ; preds = %20, %17, %25
%31 = tail call i8* @code_table_4_9_location(i8** %1)
%32 = icmp eq i8* %31, null
br i1 %32, label %33, label %36
33: ; preds = %30
%34 = load i32, i32* @stderr
%35 = tail call i32 @fprintf(i32 %34, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.2, i64 0, i64 0), i32 %18)
br label %61
36: ; preds = %30
%37 = tail call i64 @atoi(i8* %6)
%38 = trunc i64 %37 to i8
%39 = getelementptr inbounds i8, i8* %31, i64 -2
store i8 %38, i8* %39
%40 = tail call i64 @atoi(i8* %7)
%41 = trunc i64 %40 to i8
%42 = getelementptr inbounds i8, i8* %31, i64 -1
store i8 %41, i8* %42
%43 = tail call i64 @atoi(i8* %8)
%44 = trunc i64 %43 to i8
store i8 %44, i8* %31
%45 = tail call double @atof(i8* %9)
%46 = call i32 @best_scaled_value(double %45, i32* %13, i32* %12)
%47 = load i32, i32* %13
%48 = trunc i32 %47 to i8
%49 = getelementptr inbounds i8, i8* %31, i64 1
store i8 %48, i8* %49
%50 = load i32, i32* %12
%51 = getelementptr inbounds i8, i8* %31, i64 2
%52 = call i32 @uint_char(i32 %50, i8* %51)
%53 = call double @atof(i8* %10)
%54 = call i32 @best_scaled_value(double %53, i32* %13, i32* %12)
%55 = load i32, i32* %13
%56 = trunc i32 %55 to i8
%57 = getelementptr inbounds i8, i8* %31, i64 6
store i8 %56, i8* %57
%58 = load i32, i32* %12
%59 = getelementptr inbounds i8, i8* %31, i64 7
%60 = call i32 @uint_char(i32 %58, i8* %59)
br label %61
61: ; preds = %11, %36, %33
ret i32 0
}