#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 */
char *find_query(char *, int);
int /*<<< orphan*/ printf(char *, ...);
int ssds_cgi_new_class(int, char *, char *);
int do_add_class(int dbfd, int ctxidx, int qnum) {
  int ret;
  char *classsp;
  char *idsp;
  ret = 0;
  classsp = find_query("new_class_name", qnum);
  idsp = find_query("new_class_id", qnum);
  if (classsp) {
    ret = ssds_cgi_new_class(dbfd, classsp, idsp);
    printf("<br>Created new class (%s)  \n", classsp);
  } else {
    printf("<br>New Class Name not defined\n");
  }
  return ret;
}


x86 assembly (clang, -O0):
<do_add_class>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0xc(%rbp),%esi
lea    0xeae(%rip),%rdi
call   1050 <find_query@plt>
mov    %rax,-0x18(%rbp)
mov    -0xc(%rbp),%esi
lea    0xeaa(%rip),%rdi
call   1050 <find_query@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11a3 <do_add_class+0x73>
mov    -0x4(%rbp),%edi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1040 <ssds_cgi_new_class@plt>
mov    %eax,-0x10(%rbp)
mov    -0x18(%rbp),%rsi
lea    0xe85(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11b1 <do_add_class+0x81>
lea    0xe90(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<do_add_class>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%ebp
mov    %edi,%r14d
lea    0xeb0(%rip),%rdi
mov    %edx,%esi
call   1060 <find_query@plt>
mov    %rax,%rbx
lea    0xeae(%rip),%rdi
mov    %ebp,%esi
call   1060 <find_query@plt>
test   %rbx,%rbx
je     1192 <do_add_class+0x52>
mov    %r14d,%edi
mov    %rbx,%rsi
mov    %rax,%rdx
call   1050 <ssds_cgi_new_class@plt>
mov    %eax,%ebp
lea    0xe98(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebp,%eax
jmp    11a0 <do_add_class+0x60>
lea    0xea1(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [15 x i8] c"new_class_name\00"
@.str.1 = [13 x i8] c"new_class_id\00"
@.str.2 = [30 x i8] c"<br>Created new class (%s) \0A\00"
@.str.3 = [32 x i8] c"<br>New Class Name not defined\0A\00"
define i32 @do_add_class(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i8*
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
store i32 0, i32* %7
%10 = load i32, i32* %6
%11 = call i8* @find_query(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %10)
store i8* %11, i8** %8
%12 = load i32, i32* %6
%13 = call i8* @find_query(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %12)
store i8* %13, i8** %9
%14 = load i8*, i8** %8
%15 = icmp ne i8* %14, null
br i1 %15, label %16, label %23
16: ; preds = %3
%17 = load i32, i32* %4
%18 = load i8*, i8** %8
%19 = load i8*, i8** %9
%20 = call i32 @ssds_cgi_new_class(i32 %17, i8* %18, i8* %19)
store i32 %20, i32* %7
%21 = load i8*, i8** %8
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), i8* %21)
br label %25
23: ; preds = %3
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0))
br label %25
25: ; preds = %23, %16
%26 = load i32, i32* %7
ret i32 %26
}

LLVM IR (-O2):
@.str = [15 x i8] c"new_class_name\00"
@.str.1 = [13 x i8] c"new_class_id\00"
@.str.2 = [30 x i8] c"<br>Created new class (%s) \0A\00"
@str = [31 x i8] c"<br>New Class Name not defined\00"
define i32 @do_add_class(i32 %0, i32 %1, i32 %2) {
%4 = tail call i8* @find_query(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %2)
%5 = tail call i8* @find_query(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %2)
%6 = icmp eq i8* %4, null
br i1 %6, label %10, label %7
7: ; preds = %3
%8 = tail call i32 @ssds_cgi_new_class(i32 %0, i8* %4, i8* %5)
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), i8* %4)
br label %12
10: ; preds = %3
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str, i64 0, i64 0))
br label %12
12: ; preds = %10, %7
%13 = phi i32 [ %8, %7 ], [ 0, %10 ]
ret i32 %13
}