#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_argc(char *, char **, int);
int /*<<< orphan*/ printf(char *, int);
int sprintf(char *, char *, char *, ...);
int ssds_send(int, char *, char *);
scalar_t__ strlen(char *);
int ssds_cgi_new_item(int fd, char *classsp, char *namesp, char *idsp) {
  int ret;
  char **argv;
  char *myargv[16];
  int argc;
  char rbuf[256];
  char sbuf[256];
  argv = myargv;
  ret = sprintf(sbuf, "msg 5678:class:%s:action:create_item:item:%s:reply:yes:",
                classsp, namesp);
  if (strlen(idsp) > 0) {
    ret += sprintf(&sbuf[ret], "id:%s:", idsp);
  }
  ret = ssds_send(fd, sbuf, rbuf);
  argc = get_argc(rbuf, argv, 16);
  if (0 && argc < 0)
    printf(" Argc error %d\n", argc);
  return ret;
}


x86 assembly (clang, -O0):
<ssds_cgi_new_item>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2c0,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
lea    -0xb0(%rbp),%rax
mov    %rax,-0x30(%rbp)
lea    -0x2c0(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rcx
lea    0xe85(%rip),%rsi
mov    $0x0,%al
call   1060 <sprintf@plt>
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x0,%rax
jle    11be <ssds_cgi_new_item+0x7e>
movslq -0x24(%rbp),%rax
lea    -0x2c0(%rbp),%rdi
add    %rax,%rdi
mov    -0x20(%rbp),%rdx
lea    0xe87(%rip),%rsi
mov    $0x0,%al
call   1060 <sprintf@plt>
add    -0x24(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x2c0(%rbp),%rsi
lea    -0x1c0(%rbp),%rdx
call   1040 <ssds_send@plt>
mov    %eax,-0x24(%rbp)
lea    -0x1c0(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    $0x10,%edx
call   1050 <get_argc@plt>
mov    %eax,-0xb4(%rbp)
mov    -0x24(%rbp),%eax
add    $0x2c0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ssds_cgi_new_item>:
push   %rbp
push   %r14
push   %rbx
sub    $0x280,%rsp
mov    %rcx,%rbx
mov    %rdx,%rcx
mov    %rsi,%rdx
mov    %edi,%r14d
lea    0xea2(%rip),%rsi
mov    %rsp,%rdi
xor    %eax,%eax
call   1060 <sprintf@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1030 <strlen@plt>
test   %rax,%rax
jle    118f <ssds_cgi_new_item+0x4f>
movslq %ebp,%rax
lea    (%rsp,%rax,1),%rdi
lea    0xeb3(%rip),%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1060 <sprintf@plt>
mov    %rsp,%rsi
lea    0x180(%rsp),%rbx
mov    %r14d,%edi
mov    %rbx,%rdx
call   1040 <ssds_send@plt>
mov    %eax,%ebp
lea    0x100(%rsp),%rsi
mov    %rbx,%rdi
mov    $0x10,%edx
call   1050 <get_argc@plt>
mov    %ebp,%eax
add    $0x280,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [56 x i8] c"msg 5678:class:%s:action:create_item:item:%s:reply:yes:\00"
@.str.1 = [7 x i8] c"id:%s:\00"
define i32 @ssds_cgi_new_item(i32 %0, i8* %1, i8* %2, i8* %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i8**
%11 = alloca [16 x i8*]
%12 = alloca i32
%13 = alloca [256 x i8]
%14 = alloca [256 x i8]
store i32 %0, i32* %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i8* %3, i8** %8
%15 = getelementptr inbounds [16 x i8*], [16 x i8*]* %11, i64 0, i64 0
store i8** %15, i8*** %10
%16 = getelementptr inbounds [256 x i8], [256 x i8]* %14, i64 0, i64 0
%17 = load i8*, i8** %6
%18 = load i8*, i8** %7
%19 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %16, i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str, i64 0, i64 0), i8* %17, i8* %18)
store i32 %19, i32* %9
%20 = load i8*, i8** %8
%21 = call i64 @strlen(i8* %20)
%22 = icmp sgt i64 %21, 0
br i1 %22, label %23, label %31
23: ; preds = %4
%24 = load i32, i32* %9
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [256 x i8], [256 x i8]* %14, i64 0, i64 %25
%27 = load i8*, i8** %8
%28 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %26, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %27)
%29 = load i32, i32* %9
%30 = add nsw i32 %29, %28
store i32 %30, i32* %9
br label %31
31: ; preds = %23, %4
%32 = load i32, i32* %5
%33 = getelementptr inbounds [256 x i8], [256 x i8]* %14, i64 0, i64 0
%34 = getelementptr inbounds [256 x i8], [256 x i8]* %13, i64 0, i64 0
%35 = call i32 @ssds_send(i32 %32, i8* %33, i8* %34)
store i32 %35, i32* %9
%36 = getelementptr inbounds [256 x i8], [256 x i8]* %13, i64 0, i64 0
%37 = load i8**, i8*** %10
%38 = call i32 @get_argc(i8* %36, i8** %37, i32 16)
store i32 %38, i32* %12
%39 = load i32, i32* %9
ret i32 %39
}

LLVM IR (-O2):
@.str = [56 x i8] c"msg 5678:class:%s:action:create_item:item:%s:reply:yes:\00"
@.str.1 = [7 x i8] c"id:%s:\00"
define i32 @ssds_cgi_new_item(i32 %0, i8* %1, i8* %2, i8* %3) {
%5 = alloca [16 x i8*]
%6 = alloca [256 x i8]
%7 = alloca [256 x i8]
%8 = bitcast [16 x i8*]* %5 to i8*
%9 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%10 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%11 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %10, i8* dereferenceable(1) getelementptr inbounds ([56 x i8], [56 x i8]* @.str, i64 0, i64 0), i8* %1, i8* %2)
%12 = tail call i64 @strlen(i8* dereferenceable(1) %3)
%13 = icmp sgt i64 %12, 0
br i1 %13, label %14, label %18
14: ; preds = %4
%15 = sext i32 %11 to i64
%16 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 %15
%17 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %16, i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %3)
br label %18
18: ; preds = %14, %4
%19 = getelementptr inbounds [16 x i8*], [16 x i8*]* %5, i64 0, i64 0
%20 = call i32 @ssds_send(i32 %0, i8* %10, i8* %9)
%21 = call i32 @get_argc(i8* %9, i8** %19, i32 16)
ret i32 %20
}