#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 */
int /*<<< orphan*/ asprintf(char **, char *, ...);
scalar_t__ compar_str(char **, char **, int /*<<< orphan*/ *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ ht_assert(int, char *, char *, int);
void ht_test_test_compar_str(void *param) {
  char *buf1 = NULL;
  char *buf2 = NULL;
  int i;
  for (i = 0; i < 40; i++) {
    asprintf(&buf1, "key #%d", i);
    asprintf(&buf2, "key #%d", i);
    ht_assert(compar_str(&buf1, &buf2, NULL) == 0,
              "compar_str(&buf1, &buf2, NULL) == 0",
              "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
              "2022-01-22/02-19-57/repos/hwp/hwp_utils/refs/heads/master/tests/"
              "common_test.c",
              34);
  }
  asprintf(&buf1, "a");
  asprintf(&buf2, "b");
  ht_assert(compar_str(&buf1, &buf2, NULL) < 0,
            "compar_str(&buf1, &buf2, NULL) < 0",
            "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
            "2022-01-22/02-19-57/repos/hwp/hwp_utils/refs/heads/master/tests/"
            "common_test.c",
            39);
  free(buf1);
  free(buf2);
}


x86 assembly (clang, -O0):
<ht_test_test_compar_str>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x28,-0x1c(%rbp)
jge    11da <ht_test_test_compar_str+0x9a>
mov    -0x1c(%rbp),%edx
lea    -0x10(%rbp),%rdi
lea    0xe85(%rip),%rsi
mov    $0x0,%al
call   1050 <asprintf@plt>
mov    -0x1c(%rbp),%edx
lea    -0x18(%rbp),%rdi
lea    0xe70(%rip),%rsi
mov    $0x0,%al
call   1050 <asprintf@plt>
lea    -0x10(%rbp),%rdi
lea    -0x18(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1040 <compar_str@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
lea    0xe4d(%rip),%rsi
lea    0xe6a(%rip),%rdx
mov    $0x22,%ecx
call   1060 <ht_assert@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1163 <ht_test_test_compar_str+0x23>
lea    -0x10(%rbp),%rdi
lea    0xed5(%rip),%rsi
mov    $0x0,%al
call   1050 <asprintf@plt>
lea    -0x18(%rbp),%rdi
lea    0xec5(%rip),%rsi
mov    $0x0,%al
call   1050 <asprintf@plt>
lea    -0x10(%rbp),%rdi
lea    -0x18(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1040 <compar_str@plt>
cmp    $0x0,%rax
setl   %al
and    $0x1,%al
movzbl %al,%edi
lea    0xe9c(%rip),%rsi
lea    0xe03(%rip),%rdx
mov    $0x27,%ecx
call   1060 <ht_assert@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ht_test_test_compar_str>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
movq   $0x0,0x10(%rsp)
movq   $0x0,0x8(%rsp)
lea    0xe99(%rip),%r14
lea    0x10(%rsp),%r15
lea    0x8(%rsp),%rbx
lea    0xe90(%rip),%r12
lea    0xead(%rip),%r13
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %r14,%rsi
mov    %ebp,%edx
xor    %eax,%eax
call   1050 <asprintf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %ebp,%edx
xor    %eax,%eax
call   1050 <asprintf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
xor    %edx,%edx
call   1040 <compar_str@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
mov    %r12,%rsi
mov    %r13,%rdx
mov    $0x22,%ecx
call   1060 <ht_assert@plt>
add    $0x1,%ebp
cmp    $0x28,%ebp
jne    1190 <ht_test_test_compar_str+0x50>
lea    0xed7(%rip),%rsi
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <asprintf@plt>
lea    0xec3(%rip),%rsi
lea    0x8(%rsp),%rbp
mov    %rbp,%rdi
xor    %eax,%eax
call   1050 <asprintf@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
xor    %edx,%edx
call   1040 <compar_str@plt>
shr    $0x3f,%rax
lea    0xe9e(%rip),%rsi
lea    0xe05(%rip),%rdx
mov    %eax,%edi
mov    $0x27,%ecx
call   1060 <ht_assert@plt>
mov    0x10(%rsp),%rdi
call   1030 <free@plt>
mov    0x8(%rsp),%rdi
call   1030 <free@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [8 x i8] c"key #%d\00"
@.str.1 = [36 x i8] c"compar_str(&buf1, &buf2, NULL) == 0\00"
@.str.2 = [142 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/hwp/hwp_utils/refs/heads/master/tests/common_test.c\00"
@.str.3 = [2 x i8] c"a\00"
@.str.4 = [2 x i8] c"b\00"
@.str.5 = [35 x i8] c"compar_str(&buf1, &buf2, NULL) < 0\00"
define void @ht_test_test_compar_str(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
store i8* %0, i8** %2
store i8* null, i8** %3
store i8* null, i8** %4
store i32 0, i32* %5
br label %6
6: ; preds = %18, %1
%7 = load i32, i32* %5
%8 = icmp slt i32 %7, 40
br i1 %8, label %9, label %21
9: ; preds = %6
%10 = load i32, i32* %5
%11 = call i32 (i8**, i8*, ...) @asprintf(i8** %3, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %10)
%12 = load i32, i32* %5
%13 = call i32 (i8**, i8*, ...) @asprintf(i8** %4, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %12)
%14 = call i64 @compar_str(i8** %3, i8** %4, i32* null)
%15 = icmp eq i64 %14, 0
%16 = zext i1 %15 to i32
%17 = call i32 @ht_assert(i32 %16, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([142 x i8], [142 x i8]* @.str.2, i64 0, i64 0), i32 34)
br label %18
18: ; preds = %9
%19 = load i32, i32* %5
%20 = add nsw i32 %19, 1
store i32 %20, i32* %5
br label %6
21: ; preds = %6
%22 = call i32 (i8**, i8*, ...) @asprintf(i8** %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%23 = call i32 (i8**, i8*, ...) @asprintf(i8** %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%24 = call i64 @compar_str(i8** %3, i8** %4, i32* null)
%25 = icmp slt i64 %24, 0
%26 = zext i1 %25 to i32
%27 = call i32 @ht_assert(i32 %26, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([142 x i8], [142 x i8]* @.str.2, i64 0, i64 0), i32 39)
%28 = load i8*, i8** %3
%29 = call i32 @free(i8* %28)
%30 = load i8*, i8** %4
%31 = call i32 @free(i8* %30)
ret void
}

LLVM IR (-O2):
@.str = [8 x i8] c"key #%d\00"
@.str.1 = [36 x i8] c"compar_str(&buf1, &buf2, NULL) == 0\00"
@.str.2 = [142 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/hwp/hwp_utils/refs/heads/master/tests/common_test.c\00"
@.str.3 = [2 x i8] c"a\00"
@.str.4 = [2 x i8] c"b\00"
@.str.5 = [35 x i8] c"compar_str(&buf1, &buf2, NULL) < 0\00"
define void @ht_test_test_compar_str(i8* nocapture readnone %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = bitcast i8** %2 to i8*
store i8* null, i8** %2
%5 = bitcast i8** %3 to i8*
store i8* null, i8** %3
br label %6
6: ; preds = %1, %6
%7 = phi i32 [ 0, %1 ], [ %14, %6 ]
%8 = call i32 (i8**, i8*, ...) @asprintf(i8** %2, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = call i32 (i8**, i8*, ...) @asprintf(i8** %3, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %7)
%10 = call i64 @compar_str(i8** %2, i8** %3, i32* null)
%11 = icmp eq i64 %10, 0
%12 = zext i1 %11 to i32
%13 = call i32 @ht_assert(i32 %12, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([142 x i8], [142 x i8]* @.str.2, i64 0, i64 0), i32 34)
%14 = add nuw nsw i32 %7, 1
%15 = icmp eq i32 %14, 40
br i1 %15, label %16, label %6
16: ; preds = %6
%17 = call i32 (i8**, i8*, ...) @asprintf(i8** %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%18 = call i32 (i8**, i8*, ...) @asprintf(i8** %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%19 = call i64 @compar_str(i8** %2, i8** %3, i32* null)
%20 = lshr i64 %19, 63
%21 = trunc i64 %20 to i32
%22 = call i32 @ht_assert(i32 %21, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([142 x i8], [142 x i8]* @.str.2, i64 0, i64 0), i32 39)
%23 = load i8*, i8** %2
%24 = call i32 @free(i8* %23)
%25 = load i8*, i8** %3
%26 = call i32 @free(i8* %25)
ret void
}