int test1() {
  const char *s = "Rahul12!";
  int i = 0;
  char **fixes = fix_passwords(s);
  if (strcmp(fixes[0], "Rahul12!") != 0)
    printf("ERROR (swcall): Got: %s\n", fixes[0]);
  if (strcmp(fixes[1], "rAHUL12!") != 0)
    printf("ERROR (swcall): Got: %s\n", fixes[0]);
  if (strcmp(fixes[2], "rahul12!") != 0)
    printf("ERROR (swcfirst): Got: %s\n", fixes[1]);
  if (strcmp(fixes[3], "Rahul12") != 0)
    printf("ERROR (rmlast): Got: %s\n", fixes[2]);
  if (strcmp(fixes[4], "Rahul121") != 0)
    printf("ERROR (swslast): Got: %s\n", fixes[3]);
  if (strcmp(fixes[5], "ahul12!") != 0)
    printf("ERROR (rmfirst): Got: %s\n", fixes[4]);
  if (fixes[6] != 0)
    printf("ERROR (swcfirstl): Got: %x\n", fixes[5]);
  return 0;
}


x86 assembly (clang, -O0):
<test1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xec1(%rip),%rax
mov    %rax,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x0,%al
call   1050 <fix_passwords@plt>
cltq
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
lea    0xe97(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
je     118c <test1+0x5c>
mov    -0x18(%rbp),%rax
mov    (%rax),%rsi
lea    0xe84(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe87(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
je     11be <test1+0x8e>
mov    -0x18(%rbp),%rax
mov    (%rax),%rsi
lea    0xe52(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe5e(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
je     11f1 <test1+0xc1>
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe4a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rax
mov    0x18(%rax),%rdi
lea    0xe4f(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
je     1224 <test1+0xf4>
mov    -0x18(%rbp),%rax
mov    0x10(%rax),%rsi
lea    0xe3a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rax
mov    0x20(%rax),%rdi
lea    0xe3d(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
je     1257 <test1+0x127>
mov    -0x18(%rbp),%rax
mov    0x18(%rax),%rsi
lea    0xe29(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rax
mov    0x28(%rax),%rdi
lea    0xd9b(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
je     128a <test1+0x15a>
mov    -0x18(%rbp),%rax
mov    0x20(%rax),%rsi
lea    0xe10(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rax
cmpq   $0x0,0x30(%rax)
je     12af <test1+0x17f>
mov    -0x18(%rbp),%rax
mov    0x28(%rax),%rsi
lea    0xe05(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test1>:
push   %r15
push   %r14
push   %rbx
lea    0xec4(%rip),%r14
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <fix_passwords@plt>
movslq %eax,%rbx
mov    (%rbx),%r15
mov    %r15,%rdi
mov    %r14,%rsi
call   1040 <strcmp@plt>
test   %eax,%eax
je     116c <test1+0x3c>
lea    0xea7(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x8(%rbx),%rdi
lea    0xeab(%rip),%rsi
call   1040 <strcmp@plt>
test   %eax,%eax
je     1191 <test1+0x61>
mov    (%rbx),%rsi
lea    0xe7f(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x10(%rbx),%rdi
lea    0xe8f(%rip),%rsi
call   1040 <strcmp@plt>
test   %eax,%eax
je     11b7 <test1+0x87>
mov    0x8(%rbx),%rsi
lea    0xe84(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x18(%rbx),%rdi
lea    0xe8d(%rip),%rsi
call   1040 <strcmp@plt>
test   %eax,%eax
je     11dd <test1+0xad>
mov    0x10(%rbx),%rsi
lea    0xe81(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x20(%rbx),%rdi
lea    0xe88(%rip),%rsi
call   1040 <strcmp@plt>
test   %eax,%eax
je     1203 <test1+0xd3>
mov    0x18(%rbx),%rsi
lea    0xe7d(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x28(%rbx),%rdi
lea    0xdf3(%rip),%rsi
call   1040 <strcmp@plt>
test   %eax,%eax
je     1229 <test1+0xf9>
mov    0x20(%rbx),%rsi
lea    0xe71(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
cmpq   $0x0,0x30(%rbx)
je     1242 <test1+0x112>
mov    0x28(%rbx),%rsi
lea    0xe72(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [9 x i8] c"Rahul12!\00"
@.str.1 = [25 x i8] c"ERROR (swcall): Got: %s\0A\00"
@.str.2 = [9 x i8] c"rAHUL12!\00"
@.str.3 = [9 x i8] c"rahul12!\00"
@.str.4 = [27 x i8] c"ERROR (swcfirst): Got: %s\0A\00"
@.str.5 = [8 x i8] c"Rahul12\00"
@.str.6 = [25 x i8] c"ERROR (rmlast): Got: %s\0A\00"
@.str.7 = [9 x i8] c"Rahul121\00"
@.str.8 = [26 x i8] c"ERROR (swslast): Got: %s\0A\00"
@.str.9 = [8 x i8] c"ahul12!\00"
@.str.10 = [26 x i8] c"ERROR (rmfirst): Got: %s\0A\00"
@.str.11 = [28 x i8] c"ERROR (swcfirstl): Got: %x\0A\00"
define i32 @test1() {
%1 = alloca i8*
%2 = alloca i32
%3 = alloca i8**
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8** %1
store i32 0, i32* %2
%4 = load i8*, i8** %1
%5 = call i32 (i8*, ...) bitcast (i32 (...)* @fix_passwords to i32 (i8*, ...)*)(i8* %4)
%6 = sext i32 %5 to i64
%7 = inttoptr i64 %6 to i8**
store i8** %7, i8*** %3
%8 = load i8**, i8*** %3
%9 = getelementptr inbounds i8*, i8** %8, i64 0
%10 = load i8*, i8** %9
%11 = call i32 @strcmp(i8* %10, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %18
13: ; preds = %0
%14 = load i8**, i8*** %3
%15 = getelementptr inbounds i8*, i8** %14, i64 0
%16 = load i8*, i8** %15
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* %16)
br label %18
18: ; preds = %13, %0
%19 = load i8**, i8*** %3
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
%22 = call i32 @strcmp(i8* %21, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%23 = icmp ne i32 %22, 0
br i1 %23, label %24, label %29
24: ; preds = %18
%25 = load i8**, i8*** %3
%26 = getelementptr inbounds i8*, i8** %25, i64 0
%27 = load i8*, i8** %26
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* %27)
br label %29
29: ; preds = %24, %18
%30 = load i8**, i8*** %3
%31 = getelementptr inbounds i8*, i8** %30, i64 2
%32 = load i8*, i8** %31
%33 = call i32 @strcmp(i8* %32, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%34 = icmp ne i32 %33, 0
br i1 %34, label %35, label %40
35: ; preds = %29
%36 = load i8**, i8*** %3
%37 = getelementptr inbounds i8*, i8** %36, i64 1
%38 = load i8*, i8** %37
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0), i8* %38)
br label %40
40: ; preds = %35, %29
%41 = load i8**, i8*** %3
%42 = getelementptr inbounds i8*, i8** %41, i64 3
%43 = load i8*, i8** %42
%44 = call i32 @strcmp(i8* %43, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0))
%45 = icmp ne i32 %44, 0
br i1 %45, label %46, label %51
46: ; preds = %40
%47 = load i8**, i8*** %3
%48 = getelementptr inbounds i8*, i8** %47, i64 2
%49 = load i8*, i8** %48
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0), i8* %49)
br label %51
51: ; preds = %46, %40
%52 = load i8**, i8*** %3
%53 = getelementptr inbounds i8*, i8** %52, i64 4
%54 = load i8*, i8** %53
%55 = call i32 @strcmp(i8* %54, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0))
%56 = icmp ne i32 %55, 0
br i1 %56, label %57, label %62
57: ; preds = %51
%58 = load i8**, i8*** %3
%59 = getelementptr inbounds i8*, i8** %58, i64 3
%60 = load i8*, i8** %59
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.8, i64 0, i64 0), i8* %60)
br label %62
62: ; preds = %57, %51
%63 = load i8**, i8*** %3
%64 = getelementptr inbounds i8*, i8** %63, i64 5
%65 = load i8*, i8** %64
%66 = call i32 @strcmp(i8* %65, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.9, i64 0, i64 0))
%67 = icmp ne i32 %66, 0
br i1 %67, label %68, label %73
68: ; preds = %62
%69 = load i8**, i8*** %3
%70 = getelementptr inbounds i8*, i8** %69, i64 4
%71 = load i8*, i8** %70
%72 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.10, i64 0, i64 0), i8* %71)
br label %73
73: ; preds = %68, %62
%74 = load i8**, i8*** %3
%75 = getelementptr inbounds i8*, i8** %74, i64 6
%76 = load i8*, i8** %75
%77 = icmp ne i8* %76, null
br i1 %77, label %78, label %83
78: ; preds = %73
%79 = load i8**, i8*** %3
%80 = getelementptr inbounds i8*, i8** %79, i64 5
%81 = load i8*, i8** %80
%82 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.11, i64 0, i64 0), i8* %81)
br label %83
83: ; preds = %78, %73
ret i32 0
}

LLVM IR (-O2):
@.str = [9 x i8] c"Rahul12!\00"
@.str.1 = [25 x i8] c"ERROR (swcall): Got: %s\0A\00"
@.str.2 = [9 x i8] c"rAHUL12!\00"
@.str.3 = [9 x i8] c"rahul12!\00"
@.str.4 = [27 x i8] c"ERROR (swcfirst): Got: %s\0A\00"
@.str.5 = [8 x i8] c"Rahul12\00"
@.str.6 = [25 x i8] c"ERROR (rmlast): Got: %s\0A\00"
@.str.7 = [9 x i8] c"Rahul121\00"
@.str.8 = [26 x i8] c"ERROR (swslast): Got: %s\0A\00"
@.str.9 = [8 x i8] c"ahul12!\00"
@.str.10 = [26 x i8] c"ERROR (rmfirst): Got: %s\0A\00"
@.str.11 = [28 x i8] c"ERROR (swcfirstl): Got: %x\0A\00"
define i32 @test1() {
%1 = tail call i32 (i8*, ...) bitcast (i32 (...)* @fix_passwords to i32 (i8*, ...)*)(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%2 = sext i32 %1 to i64
%3 = inttoptr i64 %2 to i8**
%4 = load i8*, i8** %3
%5 = tail call i32 @strcmp(i8* dereferenceable(1) %4, i8* dereferenceable(9) getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i32 %5, 0
br i1 %6, label %9, label %7
7: ; preds = %0
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* %4)
br label %9
9: ; preds = %7, %0
%10 = getelementptr inbounds i8*, i8** %3, i64 1
%11 = load i8*, i8** %10
%12 = tail call i32 @strcmp(i8* dereferenceable(1) %11, i8* dereferenceable(9) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%13 = icmp eq i32 %12, 0
br i1 %13, label %17, label %14
14: ; preds = %9
%15 = load i8*, i8** %3
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* %15)
br label %17
17: ; preds = %14, %9
%18 = getelementptr inbounds i8*, i8** %3, i64 2
%19 = load i8*, i8** %18
%20 = tail call i32 @strcmp(i8* dereferenceable(1) %19, i8* dereferenceable(9) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%21 = icmp eq i32 %20, 0
br i1 %21, label %25, label %22
22: ; preds = %17
%23 = load i8*, i8** %10
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0), i8* %23)
br label %25
25: ; preds = %22, %17
%26 = getelementptr inbounds i8*, i8** %3, i64 3
%27 = load i8*, i8** %26
%28 = tail call i32 @strcmp(i8* dereferenceable(1) %27, i8* dereferenceable(8) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0))
%29 = icmp eq i32 %28, 0
br i1 %29, label %33, label %30
30: ; preds = %25
%31 = load i8*, i8** %18
%32 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0), i8* %31)
br label %33
33: ; preds = %30, %25
%34 = getelementptr inbounds i8*, i8** %3, i64 4
%35 = load i8*, i8** %34
%36 = tail call i32 @strcmp(i8* dereferenceable(1) %35, i8* dereferenceable(9) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0))
%37 = icmp eq i32 %36, 0
br i1 %37, label %41, label %38
38: ; preds = %33
%39 = load i8*, i8** %26
%40 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.8, i64 0, i64 0), i8* %39)
br label %41
41: ; preds = %38, %33
%42 = getelementptr inbounds i8*, i8** %3, i64 5
%43 = load i8*, i8** %42
%44 = tail call i32 @strcmp(i8* dereferenceable(1) %43, i8* dereferenceable(8) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.9, i64 0, i64 0))
%45 = icmp eq i32 %44, 0
br i1 %45, label %49, label %46
46: ; preds = %41
%47 = load i8*, i8** %34
%48 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.10, i64 0, i64 0), i8* %47)
br label %49
49: ; preds = %46, %41
%50 = getelementptr inbounds i8*, i8** %3, i64 6
%51 = load i8*, i8** %50
%52 = icmp eq i8* %51, null
br i1 %52, label %56, label %53
53: ; preds = %49
%54 = load i8*, i8** %42
%55 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.11, i64 0, i64 0), i8* %54)
br label %56
56: ; preds = %53, %49
ret i32 0
}