#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_class(int fd, char *classsp, 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_class:reply:yes:", classsp);
  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_class>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2c0,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
lea    -0xb0(%rbp),%rax
mov    %rax,-0x28(%rbp)
lea    -0x2c0(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xe8d(%rip),%rsi
call   1060 <sprintf@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x0,%rax
jle    11b2 <ssds_cgi_new_class+0x72>
movslq -0x1c(%rbp),%rax
lea    -0x2c0(%rbp),%rdi
add    %rax,%rdi
mov    -0x18(%rbp),%rdx
lea    0xe8a(%rip),%rsi
call   1060 <sprintf@plt>
add    -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x2c0(%rbp),%rsi
lea    -0x1c0(%rbp),%rdx
call   1040 <ssds_send@plt>
mov    %eax,-0x1c(%rbp)
lea    -0x1c0(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    $0x10,%edx
call   1050 <get_argc@plt>
mov    %eax,-0xb4(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x2c0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ssds_cgi_new_class>:
push   %rbp
push   %r14
push   %rbx
sub    $0x280,%rsp
mov    %rdx,%rbx
mov    %rsi,%rdx
mov    %edi,%r14d
lea    0xea5(%rip),%rsi
mov    %rsp,%rdi
call   1060 <sprintf@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1030 <strlen@plt>
test   %rax,%rax
jle    1188 <ssds_cgi_new_class+0x48>
movslq %ebp,%rax
lea    (%rsp,%rax,1),%rdi
lea    0xeb1(%rip),%rsi
mov    %rbx,%rdx
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 = [49 x i8] c"msg 5678:class:%s:action:create_class:reply:yes:\00"
@.str.1 = [7 x i8] c"id:%s:\00"
define i32 @ssds_cgi_new_class(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 [256 x i8]
%12 = alloca [256 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 = getelementptr inbounds [256 x i8], [256 x i8]* %12, i64 0, i64 0
%15 = load i8*, i8** %5
%16 = call i32 @sprintf(i8* %14, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0), i8* %15)
store i32 %16, i32* %7
%17 = load i8*, i8** %6
%18 = call i64 @strlen(i8* %17)
%19 = icmp sgt i64 %18, 0
br i1 %19, label %20, label %28
20: ; preds = %3
%21 = load i32, i32* %7
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [256 x i8], [256 x i8]* %12, i64 0, i64 %22
%24 = load i8*, i8** %6
%25 = call i32 @sprintf(i8* %23, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %24)
%26 = load i32, i32* %7
%27 = add nsw i32 %26, %25
store i32 %27, i32* %7
br label %28
28: ; preds = %20, %3
%29 = load i32, i32* %4
%30 = getelementptr inbounds [256 x i8], [256 x i8]* %12, i64 0, i64 0
%31 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
%32 = call i32 @ssds_send(i32 %29, i8* %30, i8* %31)
store i32 %32, i32* %7
%33 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
%34 = load i8**, i8*** %8
%35 = call i32 @get_argc(i8* %33, i8** %34, i32 16)
store i32 %35, i32* %10
%36 = load i32, i32* %7
ret i32 %36
}

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