#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*/ changePassword(int /*<<< orphan*/ *, char *, char *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ printf(char *);
scalar_t__ searchForUser(int /*<<< orphan*/ *, char *, char *);
int /*<<< orphan*/ sleep(int);
scalar_t__ strcmp(char *, char *);
char *stringInput(int);
scalar_t__ strlen(char *);
void changeYourPassword(sqlite3 *db, char *username) {
  char *password;
  char *newPassword, *newPassword2;
  for (int i = 0; i < 3; i++) {
    printf("Current password: ");
    password = stringInput(1);
    if (searchForUser(db, username, password)) {
      printf("New password: ");
      newPassword = stringInput(1);
      if (strlen(newPassword) <= 0) {
        printf("\nInvalid password entered. Please try again.\n");
      } else {
        printf("Re-enter new password: ");
        newPassword2 = stringInput(1);
        if (strlen(newPassword2) <= 0) {
          printf("\nInvalid password entered. Please try again.\n");
        } else {
          if (strcmp(newPassword, newPassword2) == 0) {
            changePassword(db, username, newPassword);
            printf("\nPassword change successful. Exiting program.\n");
            i = 3;
          } else if (i == 2) {
            printf("\nToo many tries used. Exiting program.\n");
          } else {
            printf("\nNon-equal inputs detected. Please try again.\n");
          }
        }
        free(newPassword2);
      }
      free(newPassword);
    } else if (i == 2) {
      printf("\nToo many tries used. Exiting program.\n");
    } else {
      printf("\nIncorrect password. Try again.\n");
    }
    free(password);
    sleep(2);
  }
}


x86 assembly (clang, -O0):
<changeYourPassword>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x2c(%rbp)
cmpl   $0x3,-0x2c(%rbp)
jge    1327 <changeYourPassword+0x1a7>
lea    0xe58(%rip),%rdi
call   1070 <printf@plt>
mov    $0x1,%edi
call   1040 <stringInput@plt>
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1050 <searchForUser@plt>
cmp    $0x0,%rax
je     12da <changeYourPassword+0x15a>
lea    0xe36(%rip),%rdi
call   1070 <printf@plt>
mov    $0x1,%edi
call   1040 <stringInput@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1060 <strlen@plt>
cmp    $0x0,%rax
jg     1214 <changeYourPassword+0x94>
lea    0xe18(%rip),%rdi
call   1070 <printf@plt>
jmp    12cc <changeYourPassword+0x14c>
lea    0xe35(%rip),%rdi
call   1070 <printf@plt>
mov    $0x1,%edi
call   1040 <stringInput@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
call   1060 <strlen@plt>
cmp    $0x0,%rax
jg     1252 <changeYourPassword+0xd2>
lea    0xdda(%rip),%rdi
call   1070 <printf@plt>
jmp    12c3 <changeYourPassword+0x143>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    1292 <changeYourPassword+0x112>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1090 <changePassword@plt>
lea    0xde7(%rip),%rdi
call   1070 <printf@plt>
movl   $0x3,-0x2c(%rbp)
jmp    12be <changeYourPassword+0x13e>
cmpl   $0x2,-0x2c(%rbp)
jne    12ad <changeYourPassword+0x12d>
lea    0xdf4(%rip),%rdi
call   1070 <printf@plt>
jmp    12b9 <changeYourPassword+0x139>
lea    0xe0b(%rip),%rdi
call   1070 <printf@plt>
jmp    12be <changeYourPassword+0x13e>
jmp    12c3 <changeYourPassword+0x143>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
jmp    1306 <changeYourPassword+0x186>
cmpl   $0x2,-0x2c(%rbp)
jne    12f5 <changeYourPassword+0x175>
lea    0xdac(%rip),%rdi
call   1070 <printf@plt>
jmp    1301 <changeYourPassword+0x181>
lea    0xdf2(%rip),%rdi
call   1070 <printf@plt>
jmp    1306 <changeYourPassword+0x186>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    $0x2,%edi
call   10a0 <sleep@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1197 <changeYourPassword+0x17>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<changeYourPassword>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
xor    %r15d,%r15d
lea    0xe55(%rip),%rbp
mov    %rdi,(%rsp)
jmp    11fa <changeYourPassword+0x6a>
lea    0xf25(%rip),%rdi
call   1040 <puts@plt>
mov    %rbp,%rdi
call   1030 <free@plt>
mov    %r14,%rbp
mov    %rbx,%r14
mov    (%rsp),%rbx
mov    %r12,%rdi
call   1030 <free@plt>
mov    %r13,%rdi
call   1030 <free@plt>
mov    $0x2,%edi
call   10b0 <sleep@plt>
lea    0x1(%r15),%eax
cmp    $0x2,%r15d
mov    %eax,%r15d
jge    1313 <changeYourPassword+0x183>
mov    %rbp,%rdi
call   1080 <printf@plt>
mov    $0x1,%edi
call   1050 <stringInput@plt>
mov    %rax,%r13
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %rax,%rdx
call   1060 <searchForUser@plt>
test   %rax,%rax
je     12b0 <changeYourPassword+0x120>
lea    0xde6(%rip),%rdi
call   1080 <printf@plt>
mov    $0x1,%edi
call   1050 <stringInput@plt>
mov    %rax,%r12
mov    %rax,%rdi
call   1070 <strlen@plt>
test   %rax,%rax
jle    12d0 <changeYourPassword+0x140>
mov    %r14,%rbx
mov    %rbp,%r14
lea    0xdc5(%rip),%rdi
call   1080 <printf@plt>
mov    $0x1,%edi
call   1050 <stringInput@plt>
mov    %rax,%rbp
mov    %rax,%rdi
call   1070 <strlen@plt>
test   %rax,%rax
jle    11b1 <changeYourPassword+0x21>
mov    %r12,%rdi
mov    %rbp,%rsi
call   1090 <strcmp@plt>
test   %rax,%rax
je     12f2 <changeYourPassword+0x162>
cmp    $0x2,%r15d
lea    0xdbf(%rip),%rdi
lea    0xde6(%rip),%rax
cmove  %rax,%rdi
jmp    11b8 <changeYourPassword+0x28>
nopl   0x0(%rax,%rax,1)
cmp    $0x2,%r15d
jne    12e1 <changeYourPassword+0x151>
lea    0xdcb(%rip),%rdi
call   1040 <puts@plt>
mov    $0x2,%r15d
jmp    11d7 <changeYourPassword+0x47>
nopl   (%rax)
lea    0xe06(%rip),%rdi
call   1040 <puts@plt>
jmp    11cf <changeYourPassword+0x3f>
lea    0xd52(%rip),%rdi
call   1040 <puts@plt>
jmp    11d7 <changeYourPassword+0x47>
mov    (%rsp),%rdi
mov    %rbx,%rsi
mov    %r12,%rdx
call   10a0 <changePassword@plt>
mov    $0x3,%r15d
lea    0xda1(%rip),%rdi
jmp    11b8 <changeYourPassword+0x28>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [19 x i8] c"Current password: \00"
@.str.1 = [15 x i8] c"New password: \00"
@.str.2 = [46 x i8] c"\0AInvalid password entered. Please try again.\0A\00"
@.str.3 = [24 x i8] c"Re-enter new password: \00"
@.str.4 = [47 x i8] c"\0APassword change successful. Exiting program.\0A\00"
@.str.5 = [40 x i8] c"\0AToo many tries used. Exiting program.\0A\00"
@.str.6 = [47 x i8] c"\0ANon-equal inputs detected. Please try again.\0A\00"
@.str.7 = [33 x i8] c"\0AIncorrect password. Try again.\0A\00"
define void @changeYourPassword(i32* %0, i8* %1) {
%3 = alloca i32*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
store i32* %0, i32** %3
store i8* %1, i8** %4
store i32 0, i32* %8
br label %9
9: ; preds = %74, %2
%10 = load i32, i32* %8
%11 = icmp slt i32 %10, 3
br i1 %11, label %12, label %77
12: ; preds = %9
%13 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%14 = call i8* @stringInput(i32 1)
store i8* %14, i8** %5
%15 = load i32*, i32** %3
%16 = load i8*, i8** %4
%17 = load i8*, i8** %5
%18 = call i64 @searchForUser(i32* %15, i8* %16, i8* %17)
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %62
20: ; preds = %12
%21 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
%22 = call i8* @stringInput(i32 1)
store i8* %22, i8** %6
%23 = load i8*, i8** %6
%24 = call i64 @strlen(i8* %23)
%25 = icmp sle i64 %24, 0
br i1 %25, label %26, label %28
26: ; preds = %20
%27 = call i32 @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.2, i64 0, i64 0))
br label %59
28: ; preds = %20
%29 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0))
%30 = call i8* @stringInput(i32 1)
store i8* %30, i8** %7
%31 = load i8*, i8** %7
%32 = call i64 @strlen(i8* %31)
%33 = icmp sle i64 %32, 0
br i1 %33, label %34, label %36
34: ; preds = %28
%35 = call i32 @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.2, i64 0, i64 0))
br label %56
36: ; preds = %28
%37 = load i8*, i8** %6
%38 = load i8*, i8** %7
%39 = call i64 @strcmp(i8* %37, i8* %38)
%40 = icmp eq i64 %39, 0
br i1 %40, label %41, label %47
41: ; preds = %36
%42 = load i32*, i32** %3
%43 = load i8*, i8** %4
%44 = load i8*, i8** %6
%45 = call i32 @changePassword(i32* %42, i8* %43, i8* %44)
%46 = call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.4, i64 0, i64 0))
store i32 3, i32* %8
br label %55
47: ; preds = %36
%48 = load i32, i32* %8
%49 = icmp eq i32 %48, 2
br i1 %49, label %50, label %52
50: ; preds = %47
%51 = call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.5, i64 0, i64 0))
br label %54
52: ; preds = %47
%53 = call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.6, i64 0, i64 0))
br label %54
54: ; preds = %52, %50
br label %55
55: ; preds = %54, %41
br label %56
56: ; preds = %55, %34
%57 = load i8*, i8** %7
%58 = call i32 @free(i8* %57)
br label %59
59: ; preds = %56, %26
%60 = load i8*, i8** %6
%61 = call i32 @free(i8* %60)
br label %70
62: ; preds = %12
%63 = load i32, i32* %8
%64 = icmp eq i32 %63, 2
br i1 %64, label %65, label %67
65: ; preds = %62
%66 = call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.5, i64 0, i64 0))
br label %69
67: ; preds = %62
%68 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.7, i64 0, i64 0))
br label %69
69: ; preds = %67, %65
br label %70
70: ; preds = %69, %59
%71 = load i8*, i8** %5
%72 = call i32 @free(i8* %71)
%73 = call i32 @sleep(i32 2)
br label %74
74: ; preds = %70
%75 = load i32, i32* %8
%76 = add nsw i32 %75, 1
store i32 %76, i32* %8
br label %9
77: ; preds = %9
ret void
}

LLVM IR (-O2):
@.str = [19 x i8] c"Current password: \00"
@.str.1 = [15 x i8] c"New password: \00"
@.str.3 = [24 x i8] c"Re-enter new password: \00"
@str = [32 x i8] c"\0AIncorrect password. Try again.\00"
@str.9 = [46 x i8] c"\0ANon-equal inputs detected. Please try again.\00"
@str.10 = [39 x i8] c"\0AToo many tries used. Exiting program.\00"
@str.11 = [46 x i8] c"\0APassword change successful. Exiting program.\00"
@str.13 = [45 x i8] c"\0AInvalid password entered. Please try again.\00"
define void @changeYourPassword(i32* %0, i8* %1) {
br label %4
3: ; preds = %44
ret void
4: ; preds = %2, %44
%5 = phi i32 [ 0, %2 ], [ %48, %44 ]
%6 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%7 = tail call i8* @stringInput(i32 1)
%8 = tail call i64 @searchForUser(i32* %0, i8* %1, i8* %7)
%9 = icmp eq i64 %8, 0
br i1 %9, label %38, label %10
10: ; preds = %4
%11 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
%12 = tail call i8* @stringInput(i32 1)
%13 = tail call i64 @strlen(i8* dereferenceable(1) %12)
%14 = icmp slt i64 %13, 1
br i1 %14, label %15, label %17
15: ; preds = %10
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @str.13, i64 0, i64 0))
br label %35
17: ; preds = %10
%18 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0))
%19 = tail call i8* @stringInput(i32 1)
%20 = tail call i64 @strlen(i8* dereferenceable(1) %19)
%21 = icmp slt i64 %20, 1
br i1 %21, label %30, label %22
22: ; preds = %17
%23 = tail call i64 @strcmp(i8* %12, i8* %19)
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %27
25: ; preds = %22
%26 = tail call i32 @changePassword(i32* %0, i8* %1, i8* %12)
br label %30
27: ; preds = %22
%28 = icmp eq i32 %5, 2
%29 = select i1 %28, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @str.10, i64 0, i64 0), i8* getelementptr inbounds ([46 x i8], [46 x i8]* @str.9, i64 0, i64 0)
br label %30
30: ; preds = %27, %17, %25
%31 = phi i8* [ getelementptr inbounds ([46 x i8], [46 x i8]* @str.11, i64 0, i64 0), %25 ], [ getelementptr inbounds ([45 x i8], [45 x i8]* @str.13, i64 0, i64 0), %17 ], [ %29, %27 ]
%32 = phi i32 [ 3, %25 ], [ %5, %17 ], [ %5, %27 ]
%33 = tail call i32 @puts(i8* dereferenceable(1) %31)
%34 = tail call i32 @free(i8* %19)
br label %35
35: ; preds = %30, %15
%36 = phi i32 [ %5, %15 ], [ %32, %30 ]
%37 = tail call i32 @free(i8* %12)
br label %44
38: ; preds = %4
%39 = icmp eq i32 %5, 2
br i1 %39, label %40, label %42
40: ; preds = %38
%41 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str.10, i64 0, i64 0))
br label %44
42: ; preds = %38
%43 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str, i64 0, i64 0))
br label %44
44: ; preds = %40, %42, %35
%45 = phi i32 [ %36, %35 ], [ 2, %40 ], [ %5, %42 ]
%46 = tail call i32 @free(i8* %7)
%47 = tail call i32 @sleep(i32 2)
%48 = add nsw i32 %45, 1
%49 = icmp slt i32 %45, 2
br i1 %49, label %4, label %3
}