void test_htpass_authenticate_user_fred_valid() {
  printf("=== RUN: %s\n", __func__);
  int rc = htpass_authenticate_user("./src/htpass_test.htpasswd", "fred",
                                    "passw0rd");
  printf("%s: fred - %d\n", __func__, rc);
  if (rc != 0)
    test_fail(__func__);
  printf("--- PASS: %s\n", __func__);
}


x86 assembly (clang, -O0):
<test_htpass_authenticate_user_fred_valid>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xec1(%rip),%rdi
lea    0xec7(%rip),%rsi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xee2(%rip),%rdi
lea    0xef6(%rip),%rsi
lea    0xef4(%rip),%rdx
mov    $0x0,%al
call   1030 <htpass_authenticate_user@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%edx
lea    0xee9(%rip),%rdi
lea    0xe90(%rip),%rsi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x0,-0x4(%rbp)
je     119c <test_htpass_authenticate_user_fred_valid+0x6c>
lea    0xe78(%rip),%rdi
mov    $0x0,%al
call   1050 <test_fail@plt>
lea    0xecb(%rip),%rdi
lea    0xe63(%rip),%rsi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_htpass_authenticate_user_fred_valid>:
push   %rbp
push   %rbx
push   %rax
lea    0xec6(%rip),%rdi
lea    0xecc(%rip),%rbx
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xee4(%rip),%rdi
lea    0xef8(%rip),%rsi
lea    0xef6(%rip),%rdx
xor    %eax,%eax
call   1030 <htpass_authenticate_user@plt>
mov    %eax,%ebp
lea    0xeef(%rip),%rdi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <printf@plt>
test   %ebp,%ebp
je     118e <test_htpass_authenticate_user_fred_valid+0x5e>
lea    0xe86(%rip),%rdi
xor    %eax,%eax
call   1050 <test_fail@plt>
lea    0xed9(%rip),%rdi
lea    0xe71(%rip),%rsi
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1040 <printf@plt>

LLVM IR (-O0):
@.str = [13 x i8] c"=== RUN: %s\0A\00"
@__func__.test_htpass_authenticate_user_fred_valid = [41 x i8] c"test_htpass_authenticate_user_fred_valid\00"
@.str.1 = [27 x i8] c"./src/htpass_test.htpasswd\00"
@.str.2 = [5 x i8] c"fred\00"
@.str.3 = [9 x i8] c"passw0rd\00"
@.str.4 = [15 x i8] c"%s: fred - %d\0A\00"
@.str.5 = [14 x i8] c"--- PASS: %s\0A\00"
define void @test_htpass_authenticate_user_fred_valid() {
%1 = alloca i32
%2 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([41 x i8], [41 x i8]* @__func__.test_htpass_authenticate_user_fred_valid, i64 0, i64 0))
%3 = call i32 (i8*, i8*, i8*, ...) bitcast (i32 (...)* @htpass_authenticate_user to i32 (i8*, i8*, i8*, ...)*)(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
store i32 %3, i32* %1
%4 = load i32, i32* %1
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([41 x i8], [41 x i8]* @__func__.test_htpass_authenticate_user_fred_valid, i64 0, i64 0), i32 %4)
%6 = load i32, i32* %1
%7 = icmp ne i32 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %0
%9 = call i32 (i8*, ...) bitcast (i32 (...)* @test_fail to i32 (i8*, ...)*)(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @__func__.test_htpass_authenticate_user_fred_valid, i64 0, i64 0))
br label %10
10: ; preds = %8, %0
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([41 x i8], [41 x i8]* @__func__.test_htpass_authenticate_user_fred_valid, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [13 x i8] c"=== RUN: %s\0A\00"
@__func__.test_htpass_authenticate_user_fred_valid = [41 x i8] c"test_htpass_authenticate_user_fred_valid\00"
@.str.1 = [27 x i8] c"./src/htpass_test.htpasswd\00"
@.str.2 = [5 x i8] c"fred\00"
@.str.3 = [9 x i8] c"passw0rd\00"
@.str.4 = [15 x i8] c"%s: fred - %d\0A\00"
@.str.5 = [14 x i8] c"--- PASS: %s\0A\00"
define void @test_htpass_authenticate_user_fred_valid() {
%1 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([41 x i8], [41 x i8]* @__func__.test_htpass_authenticate_user_fred_valid, i64 0, i64 0))
%2 = tail call i32 (i8*, i8*, i8*, ...) bitcast (i32 (...)* @htpass_authenticate_user to i32 (i8*, i8*, i8*, ...)*)(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([41 x i8], [41 x i8]* @__func__.test_htpass_authenticate_user_fred_valid, i64 0, i64 0), i32 %2)
%4 = icmp eq i32 %2, 0
br i1 %4, label %7, label %5
5: ; preds = %0
%6 = tail call i32 (i8*, ...) bitcast (i32 (...)* @test_fail to i32 (i8*, ...)*)(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @__func__.test_htpass_authenticate_user_fred_valid, i64 0, i64 0))
br label %7
7: ; preds = %5, %0
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([41 x i8], [41 x i8]* @__func__.test_htpass_authenticate_user_fred_valid, i64 0, i64 0))
ret void
}