#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*/ printf(char *);
int /*<<< orphan*/ test_string_concat();
int /*<<< orphan*/ test_string_concat_multi();
int /*<<< orphan*/ test_string_create();
int /*<<< orphan*/ test_string_find_char();
int /*<<< orphan*/ test_string_find_last_char();
int /*<<< orphan*/ test_string_find_string();
int /*<<< orphan*/ test_string_set();
unsigned int test_string(void) {
  printf("\nTesting string...\n");
  if (!test_string_create())
    return 0;
  ;
  if (!test_string_set())
    return 0;
  ;
  if (!test_string_concat())
    return 0;
  ;
  if (!test_string_concat_multi())
    return 0;
  ;
  if (!test_string_find_char())
    return 0;
  ;
  if (!test_string_find_last_char())
    return 0;
  ;
  if (!test_string_find_string())
    return 0;
  ;
  printf("All string tests passed!\n");
  return 1;
}


x86 assembly (clang, -O0):
<test_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xe71(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   10a0 <test_string_create@plt>
cmp    $0x0,%eax
jne    11b0 <test_string+0x30>
movl   $0x0,-0x4(%rbp)
jmp    126b <test_string+0xeb>
mov    $0x0,%al
call   1090 <test_string_set@plt>
cmp    $0x0,%eax
jne    11cc <test_string+0x4c>
movl   $0x0,-0x4(%rbp)
jmp    126b <test_string+0xeb>
mov    $0x0,%al
call   1030 <test_string_concat@plt>
cmp    $0x0,%eax
jne    11e8 <test_string+0x68>
movl   $0x0,-0x4(%rbp)
jmp    126b <test_string+0xeb>
mov    $0x0,%al
call   1060 <test_string_concat_multi@plt>
cmp    $0x0,%eax
jne    1204 <test_string+0x84>
movl   $0x0,-0x4(%rbp)
jmp    126b <test_string+0xeb>
mov    $0x0,%al
call   1050 <test_string_find_char@plt>
cmp    $0x0,%eax
jne    1220 <test_string+0xa0>
movl   $0x0,-0x4(%rbp)
jmp    126b <test_string+0xeb>
mov    $0x0,%al
call   1080 <test_string_find_last_char@plt>
cmp    $0x0,%eax
jne    123c <test_string+0xbc>
movl   $0x0,-0x4(%rbp)
jmp    126b <test_string+0xeb>
mov    $0x0,%al
call   1070 <test_string_find_string@plt>
cmp    $0x0,%eax
jne    1258 <test_string+0xd8>
movl   $0x0,-0x4(%rbp)
jmp    126b <test_string+0xeb>
lea    0xdb5(%rip),%rdi
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_string>:
push   %rbx
lea    0xe78(%rip),%rdi
call   1030 <puts@plt>
xor    %ebx,%ebx
xor    %eax,%eax
call   10a0 <test_string_create@plt>
test   %eax,%eax
je     11f9 <test_string+0x79>
xor    %ebx,%ebx
xor    %eax,%eax
call   1090 <test_string_set@plt>
test   %eax,%eax
je     11f9 <test_string+0x79>
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <test_string_concat@plt>
test   %eax,%eax
je     11f9 <test_string+0x79>
xor    %ebx,%ebx
xor    %eax,%eax
call   1060 <test_string_concat_multi@plt>
test   %eax,%eax
je     11f9 <test_string+0x79>
xor    %ebx,%ebx
xor    %eax,%eax
call   1050 <test_string_find_char@plt>
test   %eax,%eax
je     11f9 <test_string+0x79>
xor    %ebx,%ebx
xor    %eax,%eax
call   1080 <test_string_find_last_char@plt>
test   %eax,%eax
je     11f9 <test_string+0x79>
xor    %ebx,%ebx
xor    %eax,%eax
call   1070 <test_string_find_string@plt>
test   %eax,%eax
je     11f9 <test_string+0x79>
lea    0xe24(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [20 x i8] c"\0ATesting string...\0A\00"
@.str.1 = [26 x i8] c"All string tests passed!\0A\00"
define i32 @test_string() {
%1 = alloca i32
%2 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%3 = call i32 (...) @test_string_create()
%4 = icmp ne i32 %3, 0
br i1 %4, label %6, label %5
5: ; preds = %0
store i32 0, i32* %1
br label %32
6: ; preds = %0
%7 = call i32 (...) @test_string_set()
%8 = icmp ne i32 %7, 0
br i1 %8, label %10, label %9
9: ; preds = %6
store i32 0, i32* %1
br label %32
10: ; preds = %6
%11 = call i32 (...) @test_string_concat()
%12 = icmp ne i32 %11, 0
br i1 %12, label %14, label %13
13: ; preds = %10
store i32 0, i32* %1
br label %32
14: ; preds = %10
%15 = call i32 (...) @test_string_concat_multi()
%16 = icmp ne i32 %15, 0
br i1 %16, label %18, label %17
17: ; preds = %14
store i32 0, i32* %1
br label %32
18: ; preds = %14
%19 = call i32 (...) @test_string_find_char()
%20 = icmp ne i32 %19, 0
br i1 %20, label %22, label %21
21: ; preds = %18
store i32 0, i32* %1
br label %32
22: ; preds = %18
%23 = call i32 (...) @test_string_find_last_char()
%24 = icmp ne i32 %23, 0
br i1 %24, label %26, label %25
25: ; preds = %22
store i32 0, i32* %1
br label %32
26: ; preds = %22
%27 = call i32 (...) @test_string_find_string()
%28 = icmp ne i32 %27, 0
br i1 %28, label %30, label %29
29: ; preds = %26
store i32 0, i32* %1
br label %32
30: ; preds = %26
%31 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %1
br label %32
32: ; preds = %30, %29, %25, %21, %17, %13, %9, %5
%33 = load i32, i32* %1
ret i32 %33
}

LLVM IR (-O2):
@str = [19 x i8] c"\0ATesting string...\00"
@str.2 = [25 x i8] c"All string tests passed!\00"
define i32 @test_string() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str, i64 0, i64 0))
%2 = tail call i32 (...) @test_string_create()
%3 = icmp eq i32 %2, 0
br i1 %3, label %24, label %4
4: ; preds = %0
%5 = tail call i32 (...) @test_string_set()
%6 = icmp eq i32 %5, 0
br i1 %6, label %24, label %7
7: ; preds = %4
%8 = tail call i32 (...) @test_string_concat()
%9 = icmp eq i32 %8, 0
br i1 %9, label %24, label %10
10: ; preds = %7
%11 = tail call i32 (...) @test_string_concat_multi()
%12 = icmp eq i32 %11, 0
br i1 %12, label %24, label %13
13: ; preds = %10
%14 = tail call i32 (...) @test_string_find_char()
%15 = icmp eq i32 %14, 0
br i1 %15, label %24, label %16
16: ; preds = %13
%17 = tail call i32 (...) @test_string_find_last_char()
%18 = icmp eq i32 %17, 0
br i1 %18, label %24, label %19
19: ; preds = %16
%20 = tail call i32 (...) @test_string_find_string()
%21 = icmp eq i32 %20, 0
br i1 %21, label %24, label %22
22: ; preds = %19
%23 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.2, i64 0, i64 0))
br label %24
24: ; preds = %19, %16, %13, %10, %7, %4, %0, %22
%25 = phi i32 [ 1, %22 ], [ 0, %0 ], [ 0, %4 ], [ 0, %7 ], [ 0, %10 ], [ 0, %13 ], [ 0, %16 ], [ 0, %19 ]
ret i32 %25
}