#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*/ printf(char *, ...);
int /*<<< orphan*/ sprintf(char *, char *, ...);
int ssds_send(int, char *, char *);
int ssds_get_vers(int fd, char *sp, char *name) {
  int res;
  char **argv;
  char *myargv[16];
  int argc;
  char rbuf[132];
  char sbuf[132];
  argv = myargv;
  if (name) {
    sprintf(sbuf, "msg 5678:action:set_vers:name:%s:", name);
    res = ssds_send(fd, sbuf, rbuf);
    if (res < 0)
      printf(" Client res error %d \n", res);
    argc = get_argc(rbuf, argv, 16);
    res = get_arg_char(argc, argv, "reply", sp, 32);
    if (0 && res < 0)
      printf(" Client res error %d \n", res);
    if (0)
      printf("ssds_client.c:ssds_get_vers Set to (%s)\n", name);
  } else {
    sprintf(sbuf, "msg 5678:action:get_vers:");
    res = ssds_send(fd, sbuf, rbuf);
    if (res < 0)
      printf(" Client res error %d \n", res);
    argc = get_argc(rbuf, argv, 16);
    res = get_arg_char(argc, argv, "name", sp, 32);
    if (0 && res < 0)
      printf(" Client res error %d \n", res);
    if (0)
      printf("ssds_client.c:ssds_get_vers Found (%s)\n", sp);
  }
  return res;
}


x86 assembly (clang, -O0):
<ssds_get_vers>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1d0,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
lea    -0xb0(%rbp),%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     120c <ssds_get_vers+0xbc>
lea    -0x1d0(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xe72(%rip),%rsi
mov    $0x0,%al
call   1070 <sprintf@plt>
mov    -0x4(%rbp),%edi
lea    -0x1d0(%rbp),%rsi
lea    -0x140(%rbp),%rdx
call   1040 <ssds_send@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jge    11c9 <ssds_get_vers+0x79>
mov    -0x1c(%rbp),%esi
lea    0xe60(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x140(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    $0x10,%edx
call   1050 <get_argc@plt>
mov    %eax,-0xb4(%rbp)
mov    -0xb4(%rbp),%edi
mov    -0x28(%rbp),%rsi
mov    -0x10(%rbp),%rcx
lea    0xe40(%rip),%rdx
mov    $0x20,%r8d
call   1060 <get_arg_char@plt>
mov    %eax,-0x1c(%rbp)
jmp    1293 <ssds_get_vers+0x143>
lea    -0x1d0(%rbp),%rdi
lea    0xe25(%rip),%rsi
mov    $0x0,%al
call   1070 <sprintf@plt>
mov    -0x4(%rbp),%edi
lea    -0x1d0(%rbp),%rsi
lea    -0x140(%rbp),%rdx
call   1040 <ssds_send@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jge    1255 <ssds_get_vers+0x105>
mov    -0x1c(%rbp),%esi
lea    0xdd4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x140(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    $0x10,%edx
call   1050 <get_argc@plt>
mov    %eax,-0xb4(%rbp)
mov    -0xb4(%rbp),%edi
mov    -0x28(%rbp),%rsi
mov    -0x10(%rbp),%rcx
lea    0xdd4(%rip),%rdx
mov    $0x20,%r8d
call   1060 <get_arg_char@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1d0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ssds_get_vers>:
push   %r15
push   %r14
push   %rbx
sub    $0x1a0,%rsp
mov    %rsi,%r14
mov    %edi,%ebx
test   %rdx,%rdx
je     11eb <ssds_get_vers+0x9b>
lea    0xe8f(%rip),%rsi
mov    %rsp,%r15
mov    %r15,%rdi
xor    %eax,%eax
call   1070 <sprintf@plt>
lea    0x90(%rsp),%rdx
mov    %ebx,%edi
mov    %r15,%rsi
call   1040 <ssds_send@plt>
lea    0xea2(%rip),%r15
test   %eax,%eax
jns    11ab <ssds_get_vers+0x5b>
lea    0xe80(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0x90(%rsp),%rdi
lea    0x120(%rsp),%rbx
mov    %rbx,%rsi
mov    $0x10,%edx
call   1050 <get_argc@plt>
mov    %eax,%edi
mov    %rbx,%rsi
mov    %r15,%rdx
mov    %r14,%rcx
mov    $0x20,%r8d
call   1060 <get_arg_char@plt>
add    $0x1a0,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
movups 0xe57(%rip),%xmm0
movups %xmm0,0xa(%rsp)
movups 0xe41(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%rsi
lea    0x90(%rsp),%rdx
mov    %ebx,%edi
call   1040 <ssds_send@plt>
lea    0xe3e(%rip),%r15
test   %eax,%eax
jns    11ab <ssds_get_vers+0x5b>
jmp    119b <ssds_get_vers+0x4b>

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

LLVM IR (-O2):
@.str = [34 x i8] c"msg 5678:action:set_vers:name:%s:\00"
@.str.1 = [23 x i8] c" Client res error %d \0A\00"
@.str.2 = [6 x i8] c"reply\00"
@.str.3 = [26 x i8] c"msg 5678:action:get_vers:\00"
@.str.4 = [5 x i8] c"name\00"
define i32 @ssds_get_vers(i32 %0, i8* %1, i8* %2) {
%4 = alloca [16 x i8*]
%5 = alloca [132 x i8]
%6 = alloca [132 x i8]
%7 = bitcast [16 x i8*]* %4 to i8*
%8 = getelementptr inbounds [132 x i8], [132 x i8]* %5, i64 0, i64 0
%9 = getelementptr inbounds [132 x i8], [132 x i8]* %6, i64 0, i64 0
%10 = getelementptr inbounds [16 x i8*], [16 x i8*]* %4, i64 0, i64 0
%11 = icmp eq i8* %2, null
br i1 %11, label %16, label %12
12: ; preds = %3
%13 = call i32 (i8*, i8*, ...) @sprintf(i8* %9, i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i8* %2)
%14 = call i32 @ssds_send(i32 %0, i8* %9, i8* %8)
%15 = icmp slt i32 %14, 0
br i1 %15, label %19, label %23
16: ; preds = %3
%17 = call i32 @ssds_send(i32 %0, i8* %9, i8* %8)
%18 = icmp slt i32 %17, 0
br i1 %18, label %19, label %23
19: ; preds = %16, %12
%20 = phi i32 [ %14, %12 ], [ %17, %16 ]
%21 = phi i8* [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), %12 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), %16 ]
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 %20)
br label %23
23: ; preds = %19, %16, %12
%24 = phi i8* [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), %12 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), %16 ], [ %21, %19 ]
%25 = call i32 @get_argc(i8* %8, i8** %10, i32 16)
%26 = call i32 @get_arg_char(i32 %25, i8** %10, i8* %24, i8* %1, i32 32)
ret i32 %26
}