#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 get_arg_char(int, char **, char *, char *, int);
int get_argc(char *, char **, int);
int /*<<< orphan*/ sprintf(char *, char *, int, int, int);
int ssds_send(int, char *, char *);
int ssds_set_item_value(int fd, int class_num, int field_num, int item_num,
                        char *valsp, int len, char *rsp) {
  int ret;
  char **argv;
  char *myargv[16];
  int argc;
  char rbuf[132];
  char sbuf[132];
  char *sp;
  argv = myargv;
  sp = sbuf;
  sp += sprintf(sp,
                "msg 5678:class_num:%d:action:set_item_value:field_num:%d"
                ":item_num:%d:value:",
                class_num, field_num, item_num);
  while (len--) {
    *sp++ = *valsp++;
  }
  *sp++ = ':';
  *sp = 0;
  ret = ssds_send(fd, sbuf, rbuf);
  argc = get_argc(rbuf, argv, 16);
  ret = get_arg_char(argc, argv, "result", rsp, 32);
  return ret;
}


x86 assembly (clang, -O0):
<ssds_set_item_value>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1e0,%rsp
mov    0x10(%rbp),%rax
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    %r8,-0x18(%rbp)
mov    %r9d,-0x1c(%rbp)
lea    -0xb0(%rbp),%rax
mov    %rax,-0x28(%rbp)
lea    -0x1d0(%rbp),%rax
mov    %rax,-0x1d8(%rbp)
mov    -0x1d8(%rbp),%rdi
mov    -0x8(%rbp),%edx
mov    -0xc(%rbp),%ecx
mov    -0x10(%rbp),%r8d
lea    0xe6c(%rip),%rsi
call   1060 <sprintf@plt>
mov    %eax,%ecx
mov    -0x1d8(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x1d8(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x1c(%rbp)
cmp    $0x0,%eax
je     11f0 <ssds_set_item_value+0xb0>
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
mov    (%rax),%cl
mov    -0x1d8(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x1d8(%rbp)
mov    %cl,(%rax)
jmp    11af <ssds_set_item_value+0x6f>
mov    -0x1d8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x1d8(%rbp)
movb   $0x3a,(%rax)
mov    -0x1d8(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x4(%rbp),%edi
lea    -0x1d0(%rbp),%rsi
lea    -0x140(%rbp),%rdx
call   1030 <ssds_send@plt>
mov    %eax,-0x20(%rbp)
lea    -0x140(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    $0x10,%edx
call   1040 <get_argc@plt>
mov    %eax,-0xb4(%rbp)
mov    -0xb4(%rbp),%edi
mov    -0x28(%rbp),%rsi
mov    0x10(%rbp),%rcx
lea    0xdf1(%rip),%rdx
mov    $0x20,%r8d
call   1050 <get_arg_char@plt>
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
add    $0x1e0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ssds_set_item_value>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x1a0,%rsp
mov    %r9d,%ebx
mov    %r8,%r12
mov    %ecx,%r8d
mov    %edx,%ecx
mov    %esi,%edx
mov    %edi,%r15d
mov    0x1d0(%rsp),%r14
lea    0xe82(%rip),%rsi
mov    %rsp,%rdi
call   1070 <sprintf@plt>
movslq %eax,%rbp
lea    (%rsp,%rbp,1),%rdi
test   %ebx,%ebx
je     11a9 <ssds_set_item_value+0x59>
mov    %ebx,%edx
mov    %r12,%rsi
call   1050 <memcpy@plt>
add    $0xffffffff,%ebx
add    %rbx,%rbp
lea    (%rsp,%rbp,1),%rdi
add    $0x1,%rdi
movw   $0x3a,(%rdi)
mov    %rsp,%rsi
lea    0x110(%rsp),%rbx
mov    %r15d,%edi
mov    %rbx,%rdx
call   1030 <ssds_send@plt>
lea    0x90(%rsp),%rbp
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    $0x10,%edx
call   1040 <get_argc@plt>
lea    0xe69(%rip),%rdx
mov    %eax,%edi
mov    %rbp,%rsi
mov    %r14,%rcx
mov    $0x20,%r8d
call   1060 <get_arg_char@plt>
add    $0x1a0,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [76 x i8] c"msg 5678:class_num:%d:action:set_item_value:field_num:%d:item_num:%d:value:\00"
@.str.1 = [7 x i8] c"result\00"
define i32 @ssds_set_item_value(i32 %0, i32 %1, i32 %2, i32 %3, i8* %4, i32 %5, i8* %6) {
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i8*
%13 = alloca i32
%14 = alloca i8*
%15 = alloca i32
%16 = alloca i8**
%17 = alloca [16 x i8*]
%18 = alloca i32
%19 = alloca [132 x i8]
%20 = alloca [132 x i8]
%21 = alloca i8*
store i32 %0, i32* %8
store i32 %1, i32* %9
store i32 %2, i32* %10
store i32 %3, i32* %11
store i8* %4, i8** %12
store i32 %5, i32* %13
store i8* %6, i8** %14
%22 = getelementptr inbounds [16 x i8*], [16 x i8*]* %17, i64 0, i64 0
store i8** %22, i8*** %16
%23 = getelementptr inbounds [132 x i8], [132 x i8]* %20, i64 0, i64 0
store i8* %23, i8** %21
%24 = load i8*, i8** %21
%25 = load i32, i32* %9
%26 = load i32, i32* %10
%27 = load i32, i32* %11
%28 = call i32 @sprintf(i8* %24, i8* getelementptr inbounds ([76 x i8], [76 x i8]* @.str, i64 0, i64 0), i32 %25, i32 %26, i32 %27)
%29 = load i8*, i8** %21
%30 = sext i32 %28 to i64
%31 = getelementptr inbounds i8, i8* %29, i64 %30
store i8* %31, i8** %21
br label %32
32: ; preds = %36, %7
%33 = load i32, i32* %13
%34 = add nsw i32 %33, -1
store i32 %34, i32* %13
%35 = icmp ne i32 %33, 0
br i1 %35, label %36, label %42
36: ; preds = %32
%37 = load i8*, i8** %12
%38 = getelementptr inbounds i8, i8* %37, i32 1
store i8* %38, i8** %12
%39 = load i8, i8* %37
%40 = load i8*, i8** %21
%41 = getelementptr inbounds i8, i8* %40, i32 1
store i8* %41, i8** %21
store i8 %39, i8* %40
br label %32
42: ; preds = %32
%43 = load i8*, i8** %21
%44 = getelementptr inbounds i8, i8* %43, i32 1
store i8* %44, i8** %21
store i8 58, i8* %43
%45 = load i8*, i8** %21
store i8 0, i8* %45
%46 = load i32, i32* %8
%47 = getelementptr inbounds [132 x i8], [132 x i8]* %20, i64 0, i64 0
%48 = getelementptr inbounds [132 x i8], [132 x i8]* %19, i64 0, i64 0
%49 = call i32 @ssds_send(i32 %46, i8* %47, i8* %48)
store i32 %49, i32* %15
%50 = getelementptr inbounds [132 x i8], [132 x i8]* %19, i64 0, i64 0
%51 = load i8**, i8*** %16
%52 = call i32 @get_argc(i8* %50, i8** %51, i32 16)
store i32 %52, i32* %18
%53 = load i32, i32* %18
%54 = load i8**, i8*** %16
%55 = load i8*, i8** %14
%56 = call i32 @get_arg_char(i32 %53, i8** %54, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %55, i32 32)
store i32 %56, i32* %15
%57 = load i32, i32* %15
ret i32 %57
}

LLVM IR (-O2):
@.str = [76 x i8] c"msg 5678:class_num:%d:action:set_item_value:field_num:%d:item_num:%d:value:\00"
@.str.1 = [7 x i8] c"result\00"
define i32 @ssds_set_item_value(i32 %0, i32 %1, i32 %2, i32 %3, i8* nocapture %4, i32 %5, i8* %6) {
%8 = alloca [16 x i8*]
%9 = alloca [132 x i8]
%10 = alloca [132 x i8]
%11 = bitcast [16 x i8*]* %8 to i8*
%12 = getelementptr inbounds [132 x i8], [132 x i8]* %9, i64 0, i64 0
%13 = getelementptr inbounds [132 x i8], [132 x i8]* %10, i64 0, i64 0
%14 = getelementptr inbounds [16 x i8*], [16 x i8*]* %8, i64 0, i64 0
%15 = call i32 @sprintf(i8* %13, i8* dereferenceable(1) getelementptr inbounds ([76 x i8], [76 x i8]* @.str, i64 0, i64 0), i32 %1, i32 %2, i32 %3)
%16 = sext i32 %15 to i64
%17 = getelementptr [132 x i8], [132 x i8]* %10, i64 0, i64 %16
%18 = icmp eq i32 %5, 0
br i1 %18, label %26, label %19
19: ; preds = %7
%20 = zext i32 %5 to i64
%21 = add i32 %5, -1
%22 = zext i32 %21 to i64
%23 = add nsw i64 %16, %22
%24 = add nsw i64 %23, 1
%25 = getelementptr [132 x i8], [132 x i8]* %10, i64 0, i64 %24
br label %26
26: ; preds = %19, %7
%27 = phi i8* [ %17, %7 ], [ %25, %19 ]
%28 = getelementptr inbounds i8, i8* %27, i64 1
store i8 58, i8* %27
store i8 0, i8* %28
%29 = call i32 @ssds_send(i32 %0, i8* %13, i8* %12)
%30 = call i32 @get_argc(i8* %12, i8** %14, i32 16)
%31 = call i32 @get_arg_char(i32 %30, i8** %14, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %6, i32 32)
ret i32 %31
}