#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_int(int, char **, char *, int *);
int get_argc(char *, char **, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sprintf(char *, char *, int);
int ssds_send(int, char *, char *);
int ssds_num_fields(int fd, int class_num) {
  int res;
  int num;
  char **argv;
  char *myargv[16];
  int argc;
  char rbuf[132];
  char sbuf[132];
  argv = myargv;
  sprintf(sbuf, "msg 5678:action:get_fields:class_num:%d:", class_num);
  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_int(argc, argv, "reply", &num);
  if (0 && res < 0)
    printf(" Client res error %d \n", res);
  if (0)
    printf("ssds_client.c:ssds_num_fields rbuf (%s) argc %d num %d\n", rbuf,
           argc, num);
  return num;
}


x86 assembly (clang, -O0):
<ssds_num_fields>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1c0,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
lea    -0xa0(%rbp),%rax
mov    %rax,-0x18(%rbp)
lea    -0x1c0(%rbp),%rdi
mov    -0x8(%rbp),%edx
lea    0xe83(%rip),%rsi
call   1070 <sprintf@plt>
mov    -0x4(%rbp),%edi
lea    -0x1c0(%rbp),%rsi
lea    -0x130(%rbp),%rdx
call   1040 <ssds_send@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jge    11b6 <ssds_num_fields+0x66>
mov    -0xc(%rbp),%esi
lea    0xe7a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x130(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    $0x10,%edx
call   1050 <get_argc@plt>
mov    %eax,-0xa4(%rbp)
mov    -0xa4(%rbp),%edi
mov    -0x18(%rbp),%rsi
lea    0xe5e(%rip),%rdx
lea    -0x10(%rbp),%rcx
call   1060 <get_arg_int@plt>
mov    %eax,-0xc(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1c0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ssds_num_fields>:
push   %r14
push   %rbx
sub    $0x1a8,%rsp
mov    %esi,%edx
mov    %edi,%ebx
lea    0xe9b(%rip),%rsi
lea    0x120(%rsp),%r14
mov    %r14,%rdi
call   1070 <sprintf@plt>
lea    0x10(%rsp),%rdx
mov    %ebx,%edi
mov    %r14,%rsi
call   1040 <ssds_send@plt>
test   %eax,%eax
jns    1198 <ssds_num_fields+0x48>
lea    0xe9a(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0x10(%rsp),%rdi
lea    0xa0(%rsp),%rbx
mov    %rbx,%rsi
mov    $0x10,%edx
call   1050 <get_argc@plt>
lea    0xe87(%rip),%rdx
lea    0xc(%rsp),%rcx
mov    %eax,%edi
mov    %rbx,%rsi
call   1060 <get_arg_int@plt>
mov    0xc(%rsp),%eax
add    $0x1a8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [41 x i8] c"msg 5678:action:get_fields:class_num:%d:\00"
@.str.1 = [23 x i8] c" Client res error %d \0A\00"
@.str.2 = [6 x i8] c"reply\00"
define i32 @ssds_num_fields(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8**
%8 = alloca [16 x i8*]
%9 = alloca i32
%10 = alloca [132 x i8]
%11 = alloca [132 x i8]
store i32 %0, i32* %3
store i32 %1, i32* %4
%12 = getelementptr inbounds [16 x i8*], [16 x i8*]* %8, i64 0, i64 0
store i8** %12, i8*** %7
%13 = getelementptr inbounds [132 x i8], [132 x i8]* %11, i64 0, i64 0
%14 = load i32, i32* %4
%15 = call i32 @sprintf(i8* %13, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i32 %14)
%16 = load i32, i32* %3
%17 = getelementptr inbounds [132 x i8], [132 x i8]* %11, i64 0, i64 0
%18 = getelementptr inbounds [132 x i8], [132 x i8]* %10, i64 0, i64 0
%19 = call i32 @ssds_send(i32 %16, i8* %17, i8* %18)
store i32 %19, i32* %5
%20 = load i32, i32* %5
%21 = icmp slt i32 %20, 0
br i1 %21, label %22, label %25
22: ; preds = %2
%23 = load i32, i32* %5
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 %23)
br label %25
25: ; preds = %22, %2
%26 = getelementptr inbounds [132 x i8], [132 x i8]* %10, i64 0, i64 0
%27 = load i8**, i8*** %7
%28 = call i32 @get_argc(i8* %26, i8** %27, i32 16)
store i32 %28, i32* %9
%29 = load i32, i32* %9
%30 = load i8**, i8*** %7
%31 = call i32 @get_arg_int(i32 %29, i8** %30, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32* %6)
store i32 %31, i32* %5
%32 = load i32, i32* %6
ret i32 %32
}

LLVM IR (-O2):
@.str = [41 x i8] c"msg 5678:action:get_fields:class_num:%d:\00"
@.str.1 = [23 x i8] c" Client res error %d \0A\00"
@.str.2 = [6 x i8] c"reply\00"
define i32 @ssds_num_fields(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca [16 x i8*]
%5 = alloca [132 x i8]
%6 = alloca [132 x i8]
%7 = bitcast i32* %3 to i8*
%8 = bitcast [16 x i8*]* %4 to i8*
%9 = getelementptr inbounds [132 x i8], [132 x i8]* %5, i64 0, i64 0
%10 = getelementptr inbounds [132 x i8], [132 x i8]* %6, i64 0, i64 0
%11 = getelementptr inbounds [16 x i8*], [16 x i8*]* %4, i64 0, i64 0
%12 = call i32 @sprintf(i8* %10, i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i32 %1)
%13 = call i32 @ssds_send(i32 %0, i8* %10, i8* %9)
%14 = icmp slt i32 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %2
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 %13)
br label %17
17: ; preds = %15, %2
%18 = call i32 @get_argc(i8* %9, i8** %11, i32 16)
%19 = call i32 @get_arg_int(i32 %18, i8** %11, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32* %3)
%20 = load i32, i32* %3
ret i32 %20
}