#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*/ fail_test(int);
scalar_t__ str_match(char *, char *, char);
void test_match() {
  if (str_match("hello", "world", '\0'))
    fail_test(331);
  ;
  if (!str_match("hello", "hello", '\0'))
    fail_test(333);
  ;
  if (!str_match("localhost:12345", "localhost:54321", ':'))
    fail_test(335);
  ;
}


x86 assembly (clang, -O0):
<test_match>:
push   %rbp
mov    %rsp,%rbp
lea    0xed5(%rip),%rdi
lea    0xed4(%rip),%rsi
xor    %edx,%edx
call   1040 <str_match@plt>
cmp    $0x0,%rax
je     114d <test_match+0x2d>
mov    $0x14b,%edi
call   1030 <fail_test@plt>
lea    0xeac(%rip),%rsi
xor    %edx,%edx
mov    %rsi,%rdi
call   1040 <str_match@plt>
cmp    $0x0,%rax
jne    1172 <test_match+0x52>
mov    $0x14d,%edi
call   1030 <fail_test@plt>
lea    0xe93(%rip),%rdi
lea    0xe9c(%rip),%rsi
mov    $0x3a,%edx
call   1040 <str_match@plt>
cmp    $0x0,%rax
jne    119e <test_match+0x7e>
mov    $0x14f,%edi
call   1030 <fail_test@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_match>:
push   %rax
lea    0xed8(%rip),%rdi
lea    0xed7(%rip),%rsi
xor    %edx,%edx
call   1040 <str_match@plt>
test   %rax,%rax
je     1145 <test_match+0x25>
mov    $0x14b,%edi
call   1030 <fail_test@plt>
lea    0xeb4(%rip),%rdi
mov    %rdi,%rsi
xor    %edx,%edx
call   1040 <str_match@plt>
test   %rax,%rax
jne    1165 <test_match+0x45>
mov    $0x14d,%edi
call   1030 <fail_test@plt>
lea    0xea0(%rip),%rdi
lea    0xea9(%rip),%rsi
mov    $0x3a,%edx
call   1040 <str_match@plt>
test   %rax,%rax
je     1184 <test_match+0x64>
pop    %rax
ret
mov    $0x14f,%edi
pop    %rax
jmp    1030 <fail_test@plt>

LLVM IR (-O0):
@.str = [6 x i8] c"hello\00"
@.str.1 = [6 x i8] c"world\00"
@.str.2 = [16 x i8] c"localhost:12345\00"
@.str.3 = [16 x i8] c"localhost:54321\00"
define void @test_match() {
%1 = call i64 @str_match(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8 signext 0)
%2 = icmp ne i64 %1, 0
br i1 %2, label %3, label %5
3: ; preds = %0
%4 = call i32 @fail_test(i32 331)
br label %5
5: ; preds = %3, %0
%6 = call i64 @str_match(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8 signext 0)
%7 = icmp ne i64 %6, 0
br i1 %7, label %10, label %8
8: ; preds = %5
%9 = call i32 @fail_test(i32 333)
br label %10
10: ; preds = %8, %5
%11 = call i64 @str_match(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i8 signext 58)
%12 = icmp ne i64 %11, 0
br i1 %12, label %15, label %13
13: ; preds = %10
%14 = call i32 @fail_test(i32 335)
br label %15
15: ; preds = %13, %10
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"hello\00"
@.str.1 = [6 x i8] c"world\00"
@.str.2 = [16 x i8] c"localhost:12345\00"
@.str.3 = [16 x i8] c"localhost:54321\00"
define void @test_match() {
%1 = tail call i64 @str_match(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8 signext 0)
%2 = icmp eq i64 %1, 0
br i1 %2, label %5, label %3
3: ; preds = %0
%4 = tail call i32 @fail_test(i32 331)
br label %5
5: ; preds = %3, %0
%6 = tail call i64 @str_match(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8 signext 0)
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %5
%9 = tail call i32 @fail_test(i32 333)
br label %10
10: ; preds = %8, %5
%11 = tail call i64 @str_match(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i8 signext 58)
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %10
%14 = tail call i32 @fail_test(i32 335)
br label %15
15: ; preds = %13, %10
ret void
}