#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*/ Dump(char *, int);
int /*<<< orphan*/ Report(char *, int, char *, char *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ printf(char *, ...);
int trio_asprintf(char **, char *, char *, int *);
int /*<<< orphan*/ trio_equal_case(char *, char *);
int VerifyAllocate(void) {
  int nerrors = 0;
  int rc;
  char *string;
  int count;
  int test_size = sizeof("0123456789") - 1;
  rc = trio_asprintf(&string, "%s%n", "0123456789", &count);
  if (rc < 0) {
    nerrors++;
    Dump(string, rc);
  } else if (count != test_size) {
    nerrors++;
    printf("Validation failed in %s:%d\n",
           "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
           "2022-01-22/02-19-57/repos/hypermail-project/hypermail/refs/heads/"
           "master/src/trio/regression.c",
           258);
    printf("  Expected %%n = %d\n", test_size);
    printf("  Got      %%n = %d\n", count);
  } else if (!trio_equal_case(string, "0123456789")) {
    nerrors++;
    Report("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
           "2022-01-22/02-19-57/repos/hypermail-project/hypermail/refs/heads/"
           "master/src/trio/regression.c",
           265, "0123456789", string);
  }
  if (string)
    free(string);
  return nerrors;
}


x86 assembly (clang, -O0):
<VerifyAllocate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0xa,-0x18(%rbp)
lea    -0x10(%rbp),%rdi
lea    0xe7f(%rip),%rsi
lea    0xe7d(%rip),%rdx
lea    -0x14(%rbp),%rcx
call   1070 <trio_asprintf@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jge    11b8 <VerifyAllocate+0x58>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1050 <Dump@plt>
jmp    1256 <VerifyAllocate+0xf6>
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
je     120e <VerifyAllocate+0xae>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
lea    0xe3c(%rip),%rdi
lea    0xe51(%rip),%rsi
mov    $0x102,%edx
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x18(%rbp),%esi
lea    0xed9(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x14(%rbp),%esi
lea    0xedd(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1251 <VerifyAllocate+0xf1>
mov    -0x10(%rbp),%rdi
lea    0xdec(%rip),%rsi
call   1040 <trio_equal_case@plt>
cmp    $0x0,%eax
jne    124c <VerifyAllocate+0xec>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
mov    -0x10(%rbp),%rcx
lea    0xdf1(%rip),%rdi
mov    $0x109,%esi
lea    0xdbe(%rip),%rdx
call   1080 <Report@plt>
jmp    1251 <VerifyAllocate+0xf1>
jmp    1256 <VerifyAllocate+0xf6>
cmpq   $0x0,-0x10(%rbp)
je     126a <VerifyAllocate+0x10a>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<VerifyAllocate>:
push   %rbx
sub    $0x10,%rsp
lea    0xe94(%rip),%rsi
lea    0xe92(%rip),%rdx
lea    0x8(%rsp),%rdi
lea    0x4(%rsp),%rcx
call   1070 <trio_asprintf@plt>
test   %eax,%eax
js     11c3 <VerifyAllocate+0x63>
cmpl   $0xa,0x4(%rsp)
jne    11d1 <VerifyAllocate+0x71>
mov    0x8(%rsp),%rdi
lea    0xe6c(%rip),%rsi
call   1040 <trio_equal_case@plt>
xor    %ebx,%ebx
test   %eax,%eax
jne    1215 <VerifyAllocate+0xb5>
mov    0x8(%rsp),%rcx
lea    0xe7c(%rip),%rdi
lea    0xe4e(%rip),%rdx
mov    $0x109,%esi
call   1080 <Report@plt>
jmp    1210 <VerifyAllocate+0xb0>
mov    0x8(%rsp),%rdi
mov    %eax,%esi
call   1050 <Dump@plt>
jmp    1210 <VerifyAllocate+0xb0>
lea    0xe38(%rip),%rdi
lea    0xe4d(%rip),%rsi
mov    $0x102,%edx
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xed8(%rip),%rdi
mov    $0xa,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x4(%rsp),%esi
lea    0xed6(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0x1,%ebx
mov    0x8(%rsp),%rdi
test   %rdi,%rdi
je     1224 <VerifyAllocate+0xc4>
call   1030 <free@plt>
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [5 x i8] c"%s%n\00"
@.str.1 = [11 x i8] c"0123456789\00"
@.str.2 = [28 x i8] c"Validation failed in %s:%d\0A\00"
@.str.3 = [158 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/hypermail-project/hypermail/refs/heads/master/src/trio/regression.c\00"
@.str.4 = [21 x i8] c" Expected %%n = %d\0A\00"
@.str.5 = [21 x i8] c" Got %%n = %d\0A\00"
define i32 @VerifyAllocate() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store i32 10, i32* %5
%6 = call i32 @trio_asprintf(i8** %3, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32* %4)
store i32 %6, i32* %2
%7 = load i32, i32* %2
%8 = icmp slt i32 %7, 0
br i1 %8, label %9, label %15
9: ; preds = %0
%10 = load i32, i32* %1
%11 = add nsw i32 %10, 1
store i32 %11, i32* %1
%12 = load i8*, i8** %3
%13 = load i32, i32* %2
%14 = call i32 @Dump(i8* %12, i32 %13)
br label %38
15: ; preds = %0
%16 = load i32, i32* %4
%17 = load i32, i32* %5
%18 = icmp ne i32 %16, %17
br i1 %18, label %19, label %27
19: ; preds = %15
%20 = load i32, i32* %1
%21 = add nsw i32 %20, 1
store i32 %21, i32* %1
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([158 x i8], [158 x i8]* @.str.3, i64 0, i64 0), i32 258)
%23 = load i32, i32* %5
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i32 %23)
%25 = load i32, i32* %4
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0), i32 %25)
br label %37
27: ; preds = %15
%28 = load i8*, i8** %3
%29 = call i32 @trio_equal_case(i8* %28, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%30 = icmp ne i32 %29, 0
br i1 %30, label %36, label %31
31: ; preds = %27
%32 = load i32, i32* %1
%33 = add nsw i32 %32, 1
store i32 %33, i32* %1
%34 = load i8*, i8** %3
%35 = call i32 @Report(i8* getelementptr inbounds ([158 x i8], [158 x i8]* @.str.3, i64 0, i64 0), i32 265, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* %34)
br label %36
36: ; preds = %31, %27
br label %37
37: ; preds = %36, %19
br label %38
38: ; preds = %37, %9
%39 = load i8*, i8** %3
%40 = icmp ne i8* %39, null
br i1 %40, label %41, label %44
41: ; preds = %38
%42 = load i8*, i8** %3
%43 = call i32 @free(i8* %42)
br label %44
44: ; preds = %41, %38
%45 = load i32, i32* %1
ret i32 %45
}

LLVM IR (-O2):
@.str = [5 x i8] c"%s%n\00"
@.str.1 = [11 x i8] c"0123456789\00"
@.str.2 = [28 x i8] c"Validation failed in %s:%d\0A\00"
@.str.3 = [158 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/hypermail-project/hypermail/refs/heads/master/src/trio/regression.c\00"
@.str.4 = [21 x i8] c" Expected %%n = %d\0A\00"
@.str.5 = [21 x i8] c" Got %%n = %d\0A\00"
define i32 @VerifyAllocate() {
%1 = alloca i8*
%2 = alloca i32
%3 = bitcast i8** %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = call i32 @trio_asprintf(i8** %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%6 = icmp slt i32 %5, 0
br i1 %6, label %7, label %10
7: ; preds = %0
%8 = load i8*, i8** %1
%9 = call i32 @Dump(i8* %8, i32 %5)
br label %25
10: ; preds = %0
%11 = load i32, i32* %2
%12 = icmp eq i32 %11, 10
br i1 %12, label %18, label %13
13: ; preds = %10
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([158 x i8], [158 x i8]* @.str.3, i64 0, i64 0), i32 258)
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i32 10)
%16 = load i32, i32* %2
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0), i32 %16)
br label %25
18: ; preds = %10
%19 = load i8*, i8** %1
%20 = call i32 @trio_equal_case(i8* %19, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %25
22: ; preds = %18
%23 = load i8*, i8** %1
%24 = call i32 @Report(i8* getelementptr inbounds ([158 x i8], [158 x i8]* @.str.3, i64 0, i64 0), i32 265, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* %23)
br label %25
25: ; preds = %13, %22, %18, %7
%26 = phi i32 [ 1, %7 ], [ 1, %13 ], [ 0, %18 ], [ 1, %22 ]
%27 = load i8*, i8** %1
%28 = icmp eq i8* %27, null
br i1 %28, label %31, label %29
29: ; preds = %25
%30 = call i32 @free(i8* %27)
br label %31
31: ; preds = %29, %25
ret i32 %26
}