#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 */
struct test_suite {
  int dummy;
};
struct test_context {
  int dummy;
};

/* Variables and functions */
scalar_t__ memcmp(char const *, char const *, size_t);
int /*<<< orphan*/ test_abort(struct test_context *, char *, int, char *,
                              char const *, size_t, ...);
int /*<<< orphan*/ test_format_data(char const *, size_t);
void test_case_memory_failure_2(struct test_suite *test_suite,
                                struct test_context *test_context) {
  do {
    const char *value__ = (const char *)("foo\nbar");
    size_t value_sz__ = 7;
    const char *expected__ = (const char *)("foo\tbar");
    size_t expected_sz__ = 7;
    const char *value_str_ = "\"foo\\nbar\"";
    if (value__ && expected__) {
      if (value_sz__ != expected_sz__) {
        test_abort(test_context,
                   "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                   "outputs/2022-01-22/02-19-57/repos/galdor/libutest/refs/"
                   "heads/master/tests/main.c",
                   87,
                   "%s is %zu bytes long but should be "
                   "%zu bytes long",
                   value_str_, value_sz__, expected_sz__);
      }
      if (memcmp(value__, expected__, value_sz__) != 0) {
        test_abort(test_context,
                   "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                   "outputs/2022-01-22/02-19-57/repos/galdor/libutest/refs/"
                   "heads/master/tests/main.c",
                   87,
                   "%s contains \"%s\" "
                   "but should contain \"%s\"",
                   value_str_, test_format_data(value__, value_sz__),
                   test_format_data(expected__, expected_sz__));
      }
    } else if (expected__) {
      test_abort(test_context,
                 "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                 "outputs/2022-01-22/02-19-57/repos/galdor/libutest/refs/heads/"
                 "master/tests/main.c",
                 87, "%s is null but should be the string \"%s\"", value_str_,
                 test_format_data(expected__, expected_sz__));
    } else if (value__) {
      test_abort(test_context,
                 "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                 "outputs/2022-01-22/02-19-57/repos/galdor/libutest/refs/heads/"
                 "master/tests/main.c",
                 87, "%s is the string \"%s\" but should be null", value_str_,
                 test_format_data(value__, value_sz__));
    }
  } while (0);
}


x86 assembly (clang, -O0):
<test_case_memory_failure_2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xeb6(%rip),%rax
mov    %rax,-0x18(%rbp)
movq   $0x7,-0x20(%rbp)
lea    0xeab(%rip),%rax
mov    %rax,-0x28(%rbp)
movq   $0x7,-0x30(%rbp)
lea    0xea0(%rip),%rax
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     123f <test_case_memory_failure_2+0x10f>
cmpq   $0x0,-0x28(%rbp)
je     123f <test_case_memory_failure_2+0x10f>
mov    -0x20(%rbp),%rax
cmp    -0x30(%rbp),%rax
je     11c6 <test_case_memory_failure_2+0x96>
mov    -0x10(%rbp),%rdi
mov    -0x38(%rbp),%r8
mov    -0x20(%rbp),%r9
mov    -0x30(%rbp),%rax
lea    0xe6c(%rip),%rsi
mov    $0x57,%edx
lea    0xee9(%rip),%rcx
mov    %rax,(%rsp)
mov    $0x0,%al
call   1050 <test_abort@plt>
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1030 <memcmp@plt>
cmp    $0x0,%rax
je     123a <test_case_memory_failure_2+0x10a>
mov    -0x10(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x38(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1040 <test_format_data@plt>
cltq
mov    %rax,-0x40(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1040 <test_format_data@plt>
mov    -0x50(%rbp),%rdi
mov    -0x48(%rbp),%r8
mov    -0x40(%rbp),%r9
lea    0xdf7(%rip),%rsi
mov    $0x57,%edx
lea    0xea6(%rip),%rcx
mov    %eax,(%rsp)
mov    $0x0,%al
call   1050 <test_abort@plt>
jmp    12e8 <test_case_memory_failure_2+0x1b8>
cmpq   $0x0,-0x28(%rbp)
je     1291 <test_case_memory_failure_2+0x161>
mov    -0x10(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    -0x38(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1040 <test_format_data@plt>
mov    -0x60(%rbp),%rdi
mov    -0x58(%rbp),%r8
movslq %eax,%r9
lea    0xda2(%rip),%rsi
mov    $0x57,%edx
lea    0xe7a(%rip),%rcx
mov    $0x0,%al
call   1050 <test_abort@plt>
jmp    12e3 <test_case_memory_failure_2+0x1b3>
cmpq   $0x0,-0x18(%rbp)
je     12de <test_case_memory_failure_2+0x1ae>
mov    -0x10(%rbp),%rax
mov    %rax,-0x70(%rbp)
mov    -0x38(%rbp),%rax
mov    %rax,-0x68(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1040 <test_format_data@plt>
mov    -0x70(%rbp),%rdi
mov    -0x68(%rbp),%r8
movslq %eax,%r9
lea    0xd50(%rip),%rsi
mov    $0x57,%edx
lea    0xe51(%rip),%rcx
mov    $0x0,%al
call   1050 <test_abort@plt>
jmp    12e3 <test_case_memory_failure_2+0x1b3>
jmp    12e8 <test_case_memory_failure_2+0x1b8>
jmp    12ed <test_case_memory_failure_2+0x1bd>
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_case_memory_failure_2>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
lea    0xec2(%rip),%rdi
lea    0xec3(%rip),%rsi
mov    $0x7,%edx
call   1030 <memcmp@plt>
test   %rax,%rax
je     11a3 <test_case_memory_failure_2+0x73>
lea    0xea5(%rip),%rdi
mov    $0x7,%esi
call   1040 <test_format_data@plt>
movslq %eax,%rbx
lea    0xe99(%rip),%rdi
mov    $0x7,%esi
call   1040 <test_format_data@plt>
mov    %eax,(%rsp)
lea    0xe98(%rip),%rsi
lea    0xf1a(%rip),%rcx
lea    0xe7f(%rip),%r8
mov    %r14,%rdi
mov    $0x57,%edx
mov    %rbx,%r9
xor    %eax,%eax
call   1050 <test_abort@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.test_suite = type { i32 }
%struct.test_context = type { i32 }
@.str = [8 x i8] c"foo\0Abar\00"
@.str.1 = [8 x i8] c"foo\09bar\00"
@.str.2 = [11 x i8] c"\22foo\\nbar\22\00"
@.str.3 = [137 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/galdor/libutest/refs/heads/master/tests/main.c\00"
@.str.4 = [50 x i8] c"%s is %zu bytes long but should be %zu bytes long\00"
@.str.5 = [41 x i8] c"%s contains \22%s\22 but should contain \22%s\22\00"
@.str.6 = [41 x i8] c"%s is null but should be the string \22%s\22\00"
@.str.7 = [41 x i8] c"%s is the string \22%s\22 but should be null\00"
define void @test_case_memory_failure_2(%struct.test_suite* %0, %struct.test_context* %1) {
%3 = alloca %struct.test_suite*
%4 = alloca %struct.test_context*
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i8*
store %struct.test_suite* %0, %struct.test_suite** %3
store %struct.test_context* %1, %struct.test_context** %4
br label %10
10: ; preds = %2
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8** %5
store i64 7, i64* %6
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8** %7
store i64 7, i64* %8
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8** %9
%11 = load i8*, i8** %5
%12 = icmp ne i8* %11, null
br i1 %12, label %13, label %44
13: ; preds = %10
%14 = load i8*, i8** %7
%15 = icmp ne i8* %14, null
br i1 %15, label %16, label %44
16: ; preds = %13
%17 = load i64, i64* %6
%18 = load i64, i64* %8
%19 = icmp ne i64 %17, %18
br i1 %19, label %20, label %26
20: ; preds = %16
%21 = load %struct.test_context*, %struct.test_context** %4
%22 = load i8*, i8** %9
%23 = load i64, i64* %6
%24 = load i64, i64* %8
%25 = call i32 (%struct.test_context*, i8*, i32, i8*, i8*, i64, ...) @test_abort(%struct.test_context* %21, i8* getelementptr inbounds ([137 x i8], [137 x i8]* @.str.3, i64 0, i64 0), i32 87, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.4, i64 0, i64 0), i8* %22, i64 %23, i64 %24)
br label %26
26: ; preds = %20, %16
%27 = load i8*, i8** %5
%28 = load i8*, i8** %7
%29 = load i64, i64* %6
%30 = call i64 @memcmp(i8* %27, i8* %28, i64 %29)
%31 = icmp ne i64 %30, 0
br i1 %31, label %32, label %43
32: ; preds = %26
%33 = load %struct.test_context*, %struct.test_context** %4
%34 = load i8*, i8** %9
%35 = load i8*, i8** %5
%36 = load i64, i64* %6
%37 = call i32 @test_format_data(i8* %35, i64 %36)
%38 = sext i32 %37 to i64
%39 = load i8*, i8** %7
%40 = load i64, i64* %8
%41 = call i32 @test_format_data(i8* %39, i64 %40)
%42 = call i32 (%struct.test_context*, i8*, i32, i8*, i8*, i64, ...) @test_abort(%struct.test_context* %33, i8* getelementptr inbounds ([137 x i8], [137 x i8]* @.str.3, i64 0, i64 0), i32 87, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.5, i64 0, i64 0), i8* %34, i64 %38, i32 %41)
br label %43
43: ; preds = %32, %26
br label %68
44: ; preds = %13, %10
%45 = load i8*, i8** %7
%46 = icmp ne i8* %45, null
br i1 %46, label %47, label %55
47: ; preds = %44
%48 = load %struct.test_context*, %struct.test_context** %4
%49 = load i8*, i8** %9
%50 = load i8*, i8** %7
%51 = load i64, i64* %8
%52 = call i32 @test_format_data(i8* %50, i64 %51)
%53 = sext i32 %52 to i64
%54 = call i32 (%struct.test_context*, i8*, i32, i8*, i8*, i64, ...) @test_abort(%struct.test_context* %48, i8* getelementptr inbounds ([137 x i8], [137 x i8]* @.str.3, i64 0, i64 0), i32 87, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.6, i64 0, i64 0), i8* %49, i64 %53)
br label %67
55: ; preds = %44
%56 = load i8*, i8** %5
%57 = icmp ne i8* %56, null
br i1 %57, label %58, label %66
58: ; preds = %55
%59 = load %struct.test_context*, %struct.test_context** %4
%60 = load i8*, i8** %9
%61 = load i8*, i8** %5
%62 = load i64, i64* %6
%63 = call i32 @test_format_data(i8* %61, i64 %62)
%64 = sext i32 %63 to i64
%65 = call i32 (%struct.test_context*, i8*, i32, i8*, i8*, i64, ...) @test_abort(%struct.test_context* %59, i8* getelementptr inbounds ([137 x i8], [137 x i8]* @.str.3, i64 0, i64 0), i32 87, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.7, i64 0, i64 0), i8* %60, i64 %64)
br label %66
66: ; preds = %58, %55
br label %67
67: ; preds = %66, %47
br label %68
68: ; preds = %67, %43
br label %69
69: ; preds = %68
ret void
}

LLVM IR (-O2):
%struct.test_suite = type { i32 }
%struct.test_context = type { i32 }
@.str = [8 x i8] c"foo\0Abar\00"
@.str.1 = [8 x i8] c"foo\09bar\00"
@.str.2 = [11 x i8] c"\22foo\\nbar\22\00"
@.str.3 = [137 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/galdor/libutest/refs/heads/master/tests/main.c\00"
@.str.5 = [41 x i8] c"%s contains \22%s\22 but should contain \22%s\22\00"
define void @test_case_memory_failure_2(%struct.test_suite* nocapture readnone %0, %struct.test_context* %1) {
%3 = tail call i64 @memcmp(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i64 7)
%4 = icmp eq i64 %3, 0
br i1 %4, label %10, label %5
5: ; preds = %2
%6 = tail call i32 @test_format_data(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i64 7)
%7 = sext i32 %6 to i64
%8 = tail call i32 @test_format_data(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i64 7)
%9 = tail call i32 (%struct.test_context*, i8*, i32, i8*, i8*, i64, ...) @test_abort(%struct.test_context* %1, i8* getelementptr inbounds ([137 x i8], [137 x i8]* @.str.3, i64 0, i64 0), i32 87, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i64 %7, i32 %8)
br label %10
10: ; preds = %2, %5
ret void
}