#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*/ call;
typedef int /*<<< orphan*/ buf;

/* Variables and functions */
int BUFSIZ;
int /*<<< orphan*/ count_chr(char *, char, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ snprintf(char *, int, char *, char *, char *, char, int);
size_t test_check_format(char *, char *, char, int);
int TEST_count_chr(void) {
  char call[BUFSIZ];
  char buf[] = " a a a";
  size_t ret;
  ret = (test_check_format(("\"%s\", '%c', %zu"), buf, 'a', sizeof(buf) - 1),
         snprintf((call), (sizeof(call)),
                  ("%s("
                   "\"%s\", '%c', %zu"
                   ")"),
                  "count_chr", buf, 'a', sizeof(buf) - 1),
         count_chr(buf, 'a', sizeof(buf) - 1));
  do {
    if (!((ret) == ((size_t)3))) {
      printf("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
             "2022-01-22/02-19-57/repos/hadrianw/werf/refs/heads/master/block.c"
             ":%d ",
             1469);
      printf(call);
      printf("\n\t"
             "ret"
             " "
             "=="
             " "
             "(size_t)3"
             "\n"
             "\treceived: "
             "%zu"
             "\n"
             "\texpected: "
             "%zu"
             "\n",
             (ret), ((size_t)3));
      return -1;
    }
  } while (0);
  ret =
      (test_check_format(("\"%s\", '%c', %zu"), buf + 1, 'a', sizeof(buf) - 2),
       snprintf((call), (sizeof(call)),
                ("%s("
                 "\"%s\", '%c', %zu"
                 ")"),
                "count_chr", buf + 1, 'a', sizeof(buf) - 2),
       count_chr(buf + 1, 'a', sizeof(buf) - 2));
  do {
    if (!((ret) == ((size_t)3))) {
      printf("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
             "2022-01-22/02-19-57/repos/hadrianw/werf/refs/heads/master/block.c"
             ":%d ",
             1473);
      printf(call);
      printf("\n\t"
             "ret"
             " "
             "=="
             " "
             "(size_t)3"
             "\n"
             "\treceived: "
             "%zu"
             "\n"
             "\texpected: "
             "%zu"
             "\n",
             (ret), ((size_t)3));
      return -1;
    }
  } while (0);
  return 0;
}


x86 assembly (clang, -O0):
<TEST_count_chr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    0x2e91(%rip),%rax
mov    (%rax),%eax
mov    %rax,-0x38(%rbp)
mov    %rsp,%rcx
mov    %rcx,-0x10(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x40(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x18(%rbp)
mov    0xe82(%rip),%eax
mov    %eax,-0x1f(%rbp)
mov    0xe7c(%rip),%ax
mov    %ax,-0x1b(%rbp)
mov    0xe74(%rip),%al
mov    %al,-0x19(%rbp)
lea    -0x1f(%rbp),%rsi
lea    0xe67(%rip),%rdi
mov    $0x61,%edx
mov    $0x6,%ecx
call   1060 <test_check_format@plt>
mov    -0x40(%rbp),%rdi
mov    -0x38(%rbp),%rax
mov    %eax,%esi
lea    -0x1f(%rbp),%r8
lea    0xe53(%rip),%rdx
lea    0xe60(%rip),%rcx
mov    $0x61,%r9d
sub    $0x10,%rsp
movl   $0x6,(%rsp)
call   1040 <snprintf@plt>
add    $0x10,%rsp
lea    -0x1f(%rbp),%rdi
mov    $0x61,%esi
mov    $0x6,%edx
call   1050 <count_chr@plt>
cltq
mov    %rax,-0x28(%rbp)
cmpq   $0x3,-0x28(%rbp)
je     1251 <TEST_count_chr+0x111>
lea    0xe25(%rip),%rdi
mov    $0x5bd,%esi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x40(%rbp),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x28(%rbp),%rsi
lea    0xe89(%rip),%rdi
mov    $0x3,%edx
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x2c(%rbp)
jmp    133b <TEST_count_chr+0x1fb>
jmp    1256 <TEST_count_chr+0x116>
jmp    125b <TEST_count_chr+0x11b>
lea    -0x1f(%rbp),%rsi
add    $0x1,%rsi
lea    0xd9d(%rip),%rdi
mov    $0x61,%edx
mov    $0x5,%ecx
call   1060 <test_check_format@plt>
mov    -0x40(%rbp),%rdi
mov    -0x38(%rbp),%rax
mov    %eax,%esi
lea    -0x1f(%rbp),%r8
add    $0x1,%r8
lea    0xd85(%rip),%rdx
lea    0xd92(%rip),%rcx
mov    $0x61,%r9d
sub    $0x10,%rsp
movl   $0x5,(%rsp)
call   1040 <snprintf@plt>
add    $0x10,%rsp
lea    -0x1f(%rbp),%rdi
add    $0x1,%rdi
mov    $0x61,%esi
mov    $0x5,%edx
call   1050 <count_chr@plt>
cltq
mov    %rax,-0x28(%rbp)
cmpq   $0x3,-0x28(%rbp)
je     1323 <TEST_count_chr+0x1e3>
lea    0xd53(%rip),%rdi
mov    $0x5c1,%esi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x40(%rbp),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x28(%rbp),%rsi
lea    0xdb7(%rip),%rdi
mov    $0x3,%edx
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x2c(%rbp)
jmp    133b <TEST_count_chr+0x1fb>
jmp    1328 <TEST_count_chr+0x1e8>
jmp    132d <TEST_count_chr+0x1ed>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x2c(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<TEST_count_chr>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    0x2e8f(%rip),%rax
mov    (%rax),%r14d
mov    %rsp,%rbx
mov    %r14,%rax
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
movl   $0x612061,-0x1d(%rbp)
movl   $0x61206120,-0x20(%rbp)
lea    0xe8a(%rip),%rdi
lea    -0x20(%rbp),%r15
mov    %r15,%rsi
mov    $0x61,%edx
mov    $0x6,%ecx
call   1060 <test_check_format@plt>
sub    $0x8,%rsp
lea    0xe79(%rip),%rdx
lea    0xe86(%rip),%rcx
mov    %rbx,%rdi
mov    %r14d,%esi
mov    %r15,%r8
mov    $0x61,%r9d
push   $0x6
call   1040 <snprintf@plt>
add    $0x10,%rsp
mov    %r15,%rdi
mov    $0x61,%esi
mov    $0x6,%edx
call   1050 <count_chr@plt>
cmp    $0x3,%eax
jne    123f <TEST_count_chr+0xff>
lea    -0x1f(%rbp),%r15
lea    0xe26(%rip),%rdi
mov    %r15,%rsi
mov    $0x61,%edx
mov    $0x5,%ecx
call   1060 <test_check_format@plt>
sub    $0x8,%rsp
lea    0xe19(%rip),%rdx
lea    0xe26(%rip),%rcx
mov    %rbx,%rdi
mov    %r14d,%esi
mov    %r15,%r8
mov    $0x61,%r9d
push   $0x5
call   1040 <snprintf@plt>
add    $0x10,%rsp
mov    %r15,%rdi
mov    $0x61,%esi
mov    $0x5,%edx
call   1050 <count_chr@plt>
xor    %ecx,%ecx
cmp    $0x3,%eax
je     127a <TEST_count_chr+0x13a>
mov    $0x5c1,%esi
jmp    1244 <TEST_count_chr+0x104>
mov    $0x5bd,%esi
movslq %eax,%r14
lea    0xde7(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe55(%rip),%rdi
mov    $0x3,%edx
mov    %r14,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0xffffffff,%ecx
mov    %ecx,%eax
lea    -0x18(%rbp),%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@BUFSIZ = global i32 0
@__const.TEST_count_chr.buf = [7 x i8] c" a a a\00"
@.str = [16 x i8] c"\22%s\22, '%c', %zu\00"
@.str.1 = [20 x i8] c"%s(\22%s\22, '%c', %zu)\00"
@.str.2 = [10 x i8] c"count_chr\00"
@.str.3 = [134 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/hadrianw/werf/refs/heads/master/block.c:%d \00"
@.str.4 = [50 x i8] c"\0A\09ret == (size_t)3\0A\09received: %zu\0A\09expected: %zu\0A\00"
define i32 @TEST_count_chr() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i64
%4 = alloca [7 x i8]
%5 = alloca i64
%6 = alloca i32
%7 = load i32, i32* @BUFSIZ
%8 = zext i32 %7 to i64
%9 = call i8* @llvm.stacksave()
store i8* %9, i8** %2
%10 = alloca i8, i64 %8
store i64 %8, i64* %3
%11 = bitcast [7 x i8]* %4 to i8*
%12 = getelementptr inbounds [7 x i8], [7 x i8]* %4, i64 0, i64 0
%13 = call i64 @test_check_format(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* %12, i8 signext 97, i32 6)
%14 = trunc i64 %8 to i32
%15 = getelementptr inbounds [7 x i8], [7 x i8]* %4, i64 0, i64 0
%16 = call i32 @snprintf(i8* %10, i32 %14, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %15, i8 signext 97, i32 6)
%17 = getelementptr inbounds [7 x i8], [7 x i8]* %4, i64 0, i64 0
%18 = call i32 @count_chr(i8* %17, i8 signext 97, i32 6)
%19 = sext i32 %18 to i64
store i64 %19, i64* %5
br label %20
20: ; preds = %0
%21 = load i64, i64* %5
%22 = icmp eq i64 %21, 3
br i1 %22, label %28, label %23
23: ; preds = %20
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([134 x i8], [134 x i8]* @.str.3, i64 0, i64 0), i32 1469)
%25 = call i32 (i8*, ...) @printf(i8* %10)
%26 = load i64, i64* %5
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.4, i64 0, i64 0), i64 %26, i64 3)
store i32 -1, i32* %1
store i32 1, i32* %6
br label %53
28: ; preds = %20
br label %29
29: ; preds = %28
br label %30
30: ; preds = %29
%31 = getelementptr inbounds [7 x i8], [7 x i8]* %4, i64 0, i64 0
%32 = getelementptr inbounds i8, i8* %31, i64 1
%33 = call i64 @test_check_format(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* %32, i8 signext 97, i32 5)
%34 = trunc i64 %8 to i32
%35 = getelementptr inbounds [7 x i8], [7 x i8]* %4, i64 0, i64 0
%36 = getelementptr inbounds i8, i8* %35, i64 1
%37 = call i32 @snprintf(i8* %10, i32 %34, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %36, i8 signext 97, i32 5)
%38 = getelementptr inbounds [7 x i8], [7 x i8]* %4, i64 0, i64 0
%39 = getelementptr inbounds i8, i8* %38, i64 1
%40 = call i32 @count_chr(i8* %39, i8 signext 97, i32 5)
%41 = sext i32 %40 to i64
store i64 %41, i64* %5
br label %42
42: ; preds = %30
%43 = load i64, i64* %5
%44 = icmp eq i64 %43, 3
br i1 %44, label %50, label %45
45: ; preds = %42
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([134 x i8], [134 x i8]* @.str.3, i64 0, i64 0), i32 1473)
%47 = call i32 (i8*, ...) @printf(i8* %10)
%48 = load i64, i64* %5
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.4, i64 0, i64 0), i64 %48, i64 3)
store i32 -1, i32* %1
store i32 1, i32* %6
br label %53
50: ; preds = %42
br label %51
51: ; preds = %50
br label %52
52: ; preds = %51
store i32 0, i32* %1
store i32 1, i32* %6
br label %53
53: ; preds = %52, %45, %23
%54 = load i8*, i8** %2
%55 = load i32, i32* %1
ret i32 %55
}

LLVM IR (-O2):
@BUFSIZ = global i32 0
@__const.TEST_count_chr.buf = [7 x i8] c" a a a\00"
@.str = [16 x i8] c"\22%s\22, '%c', %zu\00"
@.str.1 = [20 x i8] c"%s(\22%s\22, '%c', %zu)\00"
@.str.2 = [10 x i8] c"count_chr\00"
@.str.3 = [134 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/hadrianw/werf/refs/heads/master/block.c:%d \00"
@.str.4 = [50 x i8] c"\0A\09ret == (size_t)3\0A\09received: %zu\0A\09expected: %zu\0A\00"
define i32 @TEST_count_chr() {
%1 = alloca [7 x i8]
%2 = load i32, i32* @BUFSIZ
%3 = zext i32 %2 to i64
%4 = alloca i8, i64 %3
%5 = getelementptr inbounds [7 x i8], [7 x i8]* %1, i64 0, i64 0
%6 = call i64 @test_check_format(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* %5, i8 signext 97, i32 6)
%7 = call i32 @snprintf(i8* %4, i32 %2, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %5, i8 signext 97, i32 6)
%8 = call i32 @count_chr(i8* %5, i8 signext 97, i32 6)
%9 = icmp eq i32 %8, 3
br i1 %9, label %10, label %16
10: ; preds = %0
%11 = getelementptr inbounds [7 x i8], [7 x i8]* %1, i64 0, i64 1
%12 = call i64 @test_check_format(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* %11, i8 signext 97, i32 5)
%13 = call i32 @snprintf(i8* %4, i32 %2, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %11, i8 signext 97, i32 5)
%14 = call i32 @count_chr(i8* %11, i8 signext 97, i32 5)
%15 = icmp eq i32 %14, 3
br i1 %15, label %23, label %16
16: ; preds = %10, %0
%17 = phi i32 [ %8, %0 ], [ %14, %10 ]
%18 = phi i32 [ 1469, %0 ], [ 1473, %10 ]
%19 = sext i32 %17 to i64
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([134 x i8], [134 x i8]* @.str.3, i64 0, i64 0), i32 %18)
%21 = call i32 (i8*, ...) @printf(i8* %4)
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @.str.4, i64 0, i64 0), i64 %19, i64 3)
br label %23
23: ; preds = %16, %10
%24 = phi i32 [ 0, %10 ], [ -1, %16 ]
ret i32 %24
}