#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 */
struct ssds_item {
  int dummy;
};
struct ssds_field {
  int dummy;
};
struct ssds_class {
  int dummy;
};

/* Variables and functions */
struct ssds_class *get_action_class(char *);
struct ssds_field *get_action_field(struct ssds_class *, char *, int);
struct ssds_item *get_action_item(struct ssds_class *, char *, int);
int /*<<< orphan*/ printf(char *, char *, struct ssds_field *);
int set_action_val(struct ssds_item *, struct ssds_field *, char *, int);
int set_action_val_bin(struct ssds_item *, struct ssds_field *, char *, int);
int set_action_val_name_any(char *saction, char *f_val, int len, int bin) {
  int ret;
  int ferr;
  struct ssds_class *dclass = NULL;
  struct ssds_field *dfield = NULL;
  struct ssds_item *ditem = NULL;
  ret = 0;
  ferr = 0;
  dclass = get_action_class(saction);
  if (dclass) {
    ditem = get_action_item(dclass, saction, 2);
    dfield = get_action_field(dclass, saction, 3);
  } else {
    ferr |= 4;
  }
  if (!ditem) {
    if (0)
      printf(" NOTE: no item in (%s) !!! dfield %p\n", saction, dfield);
    ferr |= 1;
  }
  if (!dfield)
    ferr |= 2;
  if (ditem && dclass && dfield) {
    if (bin) {
      ret = set_action_val_bin(ditem, dfield, f_val, len);
    } else {
      ret = set_action_val(ditem, dfield, f_val, 32);
    }
  }
  return ret;
}


x86 assembly (clang, -O0):
<set_action_val_name_any>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <get_action_class@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     11d5 <set_action_val_name_any+0x85>
mov    -0x28(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    $0x2,%edx
call   1040 <get_action_item@plt>
mov    %rax,-0x38(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    $0x3,%edx
call   1060 <get_action_field@plt>
mov    %rax,-0x30(%rbp)
jmp    11de <set_action_val_name_any+0x8e>
mov    -0x20(%rbp),%eax
or     $0x4,%eax
mov    %eax,-0x20(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    11f2 <set_action_val_name_any+0xa2>
mov    -0x20(%rbp),%eax
or     $0x1,%eax
mov    %eax,-0x20(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    1206 <set_action_val_name_any+0xb6>
mov    -0x20(%rbp),%eax
or     $0x2,%eax
mov    %eax,-0x20(%rbp)
cmpq   $0x0,-0x38(%rbp)
je     126b <set_action_val_name_any+0x11b>
cmpq   $0x0,-0x28(%rbp)
je     126b <set_action_val_name_any+0x11b>
cmpq   $0x0,-0x30(%rbp)
je     126b <set_action_val_name_any+0x11b>
cmpl   $0x0,-0x18(%rbp)
je     124d <set_action_val_name_any+0xfd>
mov    -0x38(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x10(%rbp),%rdx
mov    -0x14(%rbp),%ecx
call   1070 <set_action_val_bin@plt>
mov    %eax,-0x1c(%rbp)
jmp    1266 <set_action_val_name_any+0x116>
mov    -0x38(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x10(%rbp),%rdx
mov    $0x20,%ecx
call   1030 <set_action_val@plt>
mov    %eax,-0x1c(%rbp)
jmp    126b <set_action_val_name_any+0x11b>
mov    -0x1c(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_action_val_name_any>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %ecx,%r12d
mov    %edx,%r14d
mov    %rsi,%r15
mov    %rdi,%rbp
call   1050 <get_action_class@plt>
test   %rax,%rax
je     11c5 <set_action_val_name_any+0x75>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %rbp,%rsi
mov    $0x2,%edx
call   1040 <get_action_item@plt>
mov    %rax,%r13
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    $0x3,%edx
call   1060 <get_action_field@plt>
test   %r13,%r13
je     11c5 <set_action_val_name_any+0x75>
test   %rax,%rax
je     11c5 <set_action_val_name_any+0x75>
mov    %r13,%rdi
mov    %rax,%rsi
mov    %r15,%rdx
test   %r12d,%r12d
je     11d6 <set_action_val_name_any+0x86>
mov    %r14d,%ecx
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1070 <set_action_val_bin@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0x20,%ecx
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <set_action_val@plt>

LLVM IR (-O0):
%struct.ssds_class = type { i32 }
%struct.ssds_field = type { i32 }
%struct.ssds_item = type { i32 }
define i32 @set_action_val_name_any(i8* %0, i8* %1, i32 %2, i32 %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca %struct.ssds_class*
%12 = alloca %struct.ssds_field*
%13 = alloca %struct.ssds_item*
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
store i32 %3, i32* %8
store %struct.ssds_class* null, %struct.ssds_class** %11
store %struct.ssds_field* null, %struct.ssds_field** %12
store %struct.ssds_item* null, %struct.ssds_item** %13
store i32 0, i32* %9
store i32 0, i32* %10
%14 = load i8*, i8** %5
%15 = call %struct.ssds_class* @get_action_class(i8* %14)
store %struct.ssds_class* %15, %struct.ssds_class** %11
%16 = load %struct.ssds_class*, %struct.ssds_class** %11
%17 = icmp ne %struct.ssds_class* %16, null
br i1 %17, label %18, label %25
18: ; preds = %4
%19 = load %struct.ssds_class*, %struct.ssds_class** %11
%20 = load i8*, i8** %5
%21 = call %struct.ssds_item* @get_action_item(%struct.ssds_class* %19, i8* %20, i32 2)
store %struct.ssds_item* %21, %struct.ssds_item** %13
%22 = load %struct.ssds_class*, %struct.ssds_class** %11
%23 = load i8*, i8** %5
%24 = call %struct.ssds_field* @get_action_field(%struct.ssds_class* %22, i8* %23, i32 3)
store %struct.ssds_field* %24, %struct.ssds_field** %12
br label %28
25: ; preds = %4
%26 = load i32, i32* %10
%27 = or i32 %26, 4
store i32 %27, i32* %10
br label %28
28: ; preds = %25, %18
%29 = load %struct.ssds_item*, %struct.ssds_item** %13
%30 = icmp ne %struct.ssds_item* %29, null
br i1 %30, label %34, label %31
31: ; preds = %28
%32 = load i32, i32* %10
%33 = or i32 %32, 1
store i32 %33, i32* %10
br label %34
34: ; preds = %31, %28
%35 = load %struct.ssds_field*, %struct.ssds_field** %12
%36 = icmp ne %struct.ssds_field* %35, null
br i1 %36, label %40, label %37
37: ; preds = %34
%38 = load i32, i32* %10
%39 = or i32 %38, 2
store i32 %39, i32* %10
br label %40
40: ; preds = %37, %34
%41 = load %struct.ssds_item*, %struct.ssds_item** %13
%42 = icmp ne %struct.ssds_item* %41, null
br i1 %42, label %43, label %64
43: ; preds = %40
%44 = load %struct.ssds_class*, %struct.ssds_class** %11
%45 = icmp ne %struct.ssds_class* %44, null
br i1 %45, label %46, label %64
46: ; preds = %43
%47 = load %struct.ssds_field*, %struct.ssds_field** %12
%48 = icmp ne %struct.ssds_field* %47, null
br i1 %48, label %49, label %64
49: ; preds = %46
%50 = load i32, i32* %8
%51 = icmp ne i32 %50, 0
br i1 %51, label %52, label %58
52: ; preds = %49
%53 = load %struct.ssds_item*, %struct.ssds_item** %13
%54 = load %struct.ssds_field*, %struct.ssds_field** %12
%55 = load i8*, i8** %6
%56 = load i32, i32* %7
%57 = call i32 @set_action_val_bin(%struct.ssds_item* %53, %struct.ssds_field* %54, i8* %55, i32 %56)
store i32 %57, i32* %9
br label %63
58: ; preds = %49
%59 = load %struct.ssds_item*, %struct.ssds_item** %13
%60 = load %struct.ssds_field*, %struct.ssds_field** %12
%61 = load i8*, i8** %6
%62 = call i32 @set_action_val(%struct.ssds_item* %59, %struct.ssds_field* %60, i8* %61, i32 32)
store i32 %62, i32* %9
br label %63
63: ; preds = %58, %52
br label %64
64: ; preds = %63, %46, %43, %40
%65 = load i32, i32* %9
ret i32 %65
}

LLVM IR (-O2):
%struct.ssds_class = type { i32 }
%struct.ssds_field = type { i32 }
%struct.ssds_item = type { i32 }
define i32 @set_action_val_name_any(i8* %0, i8* %1, i32 %2, i32 %3) {
%5 = tail call %struct.ssds_class* @get_action_class(i8* %0)
%6 = icmp eq %struct.ssds_class* %5, null
br i1 %6, label %19, label %7
7: ; preds = %4
%8 = tail call %struct.ssds_item* @get_action_item(%struct.ssds_class* %5, i8* %0, i32 2)
%9 = tail call %struct.ssds_field* @get_action_field(%struct.ssds_class* %5, i8* %0, i32 3)
%10 = icmp ne %struct.ssds_item* %8, null
%11 = icmp ne %struct.ssds_field* %9, null
%12 = select i1 %10, i1 %11, i1 false
br i1 %12, label %13, label %19
13: ; preds = %7
%14 = icmp eq i32 %3, 0
br i1 %14, label %17, label %15
15: ; preds = %13
%16 = tail call i32 @set_action_val_bin(%struct.ssds_item* %8, %struct.ssds_field* %9, i8* %1, i32 %2)
br label %19
17: ; preds = %13
%18 = tail call i32 @set_action_val(%struct.ssds_item* %8, %struct.ssds_field* %9, i8* %1, i32 32)
br label %19
19: ; preds = %4, %15, %17, %7
%20 = phi i32 [ %16, %15 ], [ %18, %17 ], [ 0, %7 ], [ 0, %4 ]
ret i32 %20
}