#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 */
typedef int /*<<< orphan*/ sqlite3;

/* Variables and functions */
int /*<<< orphan*/ addUser(int /*<<< orphan*/ *, int, char *, char *);
int /*<<< orphan*/ free(char *);
int inputYesOrNo(char *);
int /*<<< orphan*/ printf(char *, ...);
char *stringInput(int);
scalar_t__ strlen(char *);
void addUserFunction(sqlite3 *db) {
  int adminPriv = inputYesOrNo("Make the new user admin(Y/N)?");
  printf("New username: ");
  char *newUsername = stringInput(0);
  if (strlen(newUsername) <= 0) {
    printf("\nInvalid username entered. Please try again.\n");
  } else {
    printf("New user's password: ");
    char *newPassword = stringInput(1);
    if (strlen(newPassword) <= 0) {
      printf("\nInvalid password entered. Please try again.\n");
    } else {
      addUser(db, adminPriv, newUsername, newPassword);
      printf("\n%s has been entered into the database\n", newUsername);
    }
    free(newPassword);
  }
  free(newUsername);
}


x86 assembly (clang, -O0):
<addUserFunction>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xe8d(%rip),%rdi
call   1080 <inputYesOrNo@plt>
mov    %eax,-0xc(%rbp)
lea    0xe9c(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
xor    %edi,%edi
call   1050 <stringInput@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <strlen@plt>
cmp    $0x0,%rax
jg     11ba <addUserFunction+0x5a>
lea    0xe7f(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    122b <addUserFunction+0xcb>
lea    0xe9a(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    $0x1,%edi
call   1050 <stringInput@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1060 <strlen@plt>
cmp    $0x0,%rax
jg     11fc <addUserFunction+0x9c>
lea    0xe81(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    1222 <addUserFunction+0xc2>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
call   1040 <addUser@plt>
mov    -0x18(%rbp),%rsi
lea    0xe84(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<addUserFunction>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
lea    0xe7f(%rip),%rdi
call   1090 <inputYesOrNo@plt>
mov    %eax,%r15d
lea    0xe8e(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
xor    %edi,%edi
call   1060 <stringInput@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1070 <strlen@plt>
test   %rax,%rax
jle    11fa <addUserFunction+0x8a>
lea    0xe78(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
mov    $0x1,%edi
call   1060 <stringInput@plt>
mov    %rax,%rbp
mov    %rax,%rdi
call   1070 <strlen@plt>
test   %rax,%rax
jle    1208 <addUserFunction+0x98>
mov    %r14,%rdi
mov    %r15d,%esi
mov    %rbx,%rdx
mov    %rbp,%rcx
call   1040 <addUser@plt>
lea    0xe55(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
jmp    1214 <addUserFunction+0xa4>
lea    0xe97(%rip),%rdi
call   1050 <puts@plt>
jmp    121c <addUserFunction+0xac>
lea    0xe5c(%rip),%rdi
call   1050 <puts@plt>
mov    %rbp,%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>

LLVM IR (-O0):
@.str = [30 x i8] c"Make the new user admin(Y/N)?\00"
@.str.1 = [15 x i8] c"New username: \00"
@.str.2 = [46 x i8] c"\0AInvalid username entered. Please try again.\0A\00"
@.str.3 = [22 x i8] c"New user's password: \00"
@.str.4 = [46 x i8] c"\0AInvalid password entered. Please try again.\0A\00"
@.str.5 = [40 x i8] c"\0A%s has been entered into the database\0A\00"
define void @addUserFunction(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
store i32* %0, i32** %2
%6 = call i32 @inputYesOrNo(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
store i32 %6, i32* %3
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
%8 = call i8* @stringInput(i32 0)
store i8* %8, i8** %4
%9 = load i8*, i8** %4
%10 = call i64 @strlen(i8* %9)
%11 = icmp sle i64 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %1
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.2, i64 0, i64 0))
br label %33
14: ; preds = %1
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
%16 = call i8* @stringInput(i32 1)
store i8* %16, i8** %5
%17 = load i8*, i8** %5
%18 = call i64 @strlen(i8* %17)
%19 = icmp sle i64 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %14
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.4, i64 0, i64 0))
br label %30
22: ; preds = %14
%23 = load i32*, i32** %2
%24 = load i32, i32* %3
%25 = load i8*, i8** %4
%26 = load i8*, i8** %5
%27 = call i32 @addUser(i32* %23, i32 %24, i8* %25, i8* %26)
%28 = load i8*, i8** %4
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.5, i64 0, i64 0), i8* %28)
br label %30
30: ; preds = %22, %20
%31 = load i8*, i8** %5
%32 = call i32 @free(i8* %31)
br label %33
33: ; preds = %30, %12
%34 = load i8*, i8** %4
%35 = call i32 @free(i8* %34)
ret void
}

LLVM IR (-O2):
@.str = [30 x i8] c"Make the new user admin(Y/N)?\00"
@.str.1 = [15 x i8] c"New username: \00"
@.str.3 = [22 x i8] c"New user's password: \00"
@.str.5 = [40 x i8] c"\0A%s has been entered into the database\0A\00"
@str = [45 x i8] c"\0AInvalid password entered. Please try again.\00"
@str.6 = [45 x i8] c"\0AInvalid username entered. Please try again.\00"
define void @addUserFunction(i32* %0) {
%2 = tail call i32 @inputYesOrNo(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
%4 = tail call i8* @stringInput(i32 0)
%5 = tail call i64 @strlen(i8* dereferenceable(1) %4)
%6 = icmp slt i64 %5, 1
br i1 %6, label %7, label %9
7: ; preds = %1
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @str.6, i64 0, i64 0))
br label %21
9: ; preds = %1
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
%11 = tail call i8* @stringInput(i32 1)
%12 = tail call i64 @strlen(i8* dereferenceable(1) %11)
%13 = icmp slt i64 %12, 1
br i1 %13, label %14, label %16
14: ; preds = %9
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @str, i64 0, i64 0))
br label %19
16: ; preds = %9
%17 = tail call i32 @addUser(i32* %0, i32 %2, i8* %4, i8* %11)
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.5, i64 0, i64 0), i8* %4)
br label %19
19: ; preds = %16, %14
%20 = tail call i32 @free(i8* %11)
br label %21
21: ; preds = %19, %7
%22 = tail call i32 @free(i8* %4)
ret void
}