#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);
int string_match(char *, char *);
char *test_successful_match() {
  char *text = "hello";
  char *pattern1 = "he";
  do {
    if (!(string_match(text, pattern1) == 1)) {
      printf("Line number is: %d\n", 39);
      return "error, did not find the pattern";
    }
  } while (0);
  char *pattern2 = "lo";
  do {
    if (!(string_match(text, pattern2) == 4)) {
      printf("Line number is: %d\n", 42);
      return "error, did not find the pattern";
    }
  } while (0);
  char *pattern3 = "hello";
  do {
    if (!(string_match(text, pattern3) == 1)) {
      printf("Line number is: %d\n", 45);
      return "error, did not find the pattern";
    }
  } while (0);
  char *text1 = "hehello";
  char *pattern4 = "he";
  do {
    if (!(string_match(text1, pattern4) == 1)) {
      printf("Line number is: %d\n", 49);
      return "error, did not find the pattern";
    }
  } while (0);
  return 0;
}


x86 assembly (clang, -O0):
<test_successful_match>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
lea    0xf0a(%rip),%rax
mov    %rax,-0x10(%rbp)
lea    0xec6(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <string_match@plt>
cmp    $0x1,%eax
je     1175 <test_successful_match+0x55>
lea    0xea8(%rip),%rdi
mov    $0x27,%esi
call   1030 <printf@plt>
lea    0xeab(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1262 <test_successful_match+0x142>
jmp    117a <test_successful_match+0x5a>
lea    0xebb(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1040 <string_match@plt>
cmp    $0x4,%eax
je     11bc <test_successful_match+0x9c>
lea    0xe61(%rip),%rdi
mov    $0x2a,%esi
call   1030 <printf@plt>
lea    0xe64(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1262 <test_successful_match+0x142>
jmp    11c1 <test_successful_match+0xa1>
lea    0xe71(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1040 <string_match@plt>
cmp    $0x1,%eax
je     1203 <test_successful_match+0xe3>
lea    0xe1a(%rip),%rdi
mov    $0x2d,%esi
call   1030 <printf@plt>
lea    0xe1d(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1262 <test_successful_match+0x142>
jmp    1208 <test_successful_match+0xe8>
lea    0xe28(%rip),%rax
mov    %rax,-0x30(%rbp)
lea    0xde6(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x38(%rbp),%rsi
call   1040 <string_match@plt>
cmp    $0x1,%eax
je     1255 <test_successful_match+0x135>
lea    0xdc8(%rip),%rdi
mov    $0x31,%esi
call   1030 <printf@plt>
lea    0xdcb(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1262 <test_successful_match+0x142>
jmp    125a <test_successful_match+0x13a>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_successful_match>:
push   %rax
lea    0xf11(%rip),%rdi
lea    0xed1(%rip),%rsi
call   1040 <string_match@plt>
mov    $0x27,%esi
cmp    $0x1,%eax
jne    1195 <test_successful_match+0x75>
lea    0xef4(%rip),%rdi
lea    0xef0(%rip),%rsi
call   1040 <string_match@plt>
mov    $0x2a,%esi
cmp    $0x4,%eax
jne    1195 <test_successful_match+0x75>
lea    0xed7(%rip),%rdi
mov    %rdi,%rsi
call   1040 <string_match@plt>
mov    $0x2d,%esi
cmp    $0x1,%eax
jne    1195 <test_successful_match+0x75>
lea    0xebc(%rip),%rdi
lea    0xe7e(%rip),%rsi
call   1040 <string_match@plt>
mov    $0x31,%esi
cmp    $0x1,%eax
jne    1195 <test_successful_match+0x75>
xor    %eax,%eax
pop    %rcx
ret
lea    0xe67(%rip),%rdi
call   1030 <printf@plt>
lea    0xe6f(%rip),%rax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [6 x i8] c"hello\00"
@.str.1 = [3 x i8] c"he\00"
@.str.2 = [20 x i8] c"Line number is: %d\0A\00"
@.str.3 = [32 x i8] c"error, did not find the pattern\00"
@.str.4 = [3 x i8] c"lo\00"
@.str.5 = [8 x i8] c"hehello\00"
define i8* @test_successful_match() {
%1 = alloca i8*
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8** %2
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8** %3
br label %8
8: ; preds = %0
%9 = load i8*, i8** %2
%10 = load i8*, i8** %3
%11 = call i32 @string_match(i8* %9, i8* %10)
%12 = icmp eq i32 %11, 1
br i1 %12, label %15, label %13
13: ; preds = %8
%14 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i32 39)
store i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i8** %1
br label %44
15: ; preds = %8
br label %16
16: ; preds = %15
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8** %4
br label %17
17: ; preds = %16
%18 = load i8*, i8** %2
%19 = load i8*, i8** %4
%20 = call i32 @string_match(i8* %18, i8* %19)
%21 = icmp eq i32 %20, 4
br i1 %21, label %24, label %22
22: ; preds = %17
%23 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i32 42)
store i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i8** %1
br label %44
24: ; preds = %17
br label %25
25: ; preds = %24
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8** %5
br label %26
26: ; preds = %25
%27 = load i8*, i8** %2
%28 = load i8*, i8** %5
%29 = call i32 @string_match(i8* %27, i8* %28)
%30 = icmp eq i32 %29, 1
br i1 %30, label %33, label %31
31: ; preds = %26
%32 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i32 45)
store i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i8** %1
br label %44
33: ; preds = %26
br label %34
34: ; preds = %33
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i8** %6
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8** %7
br label %35
35: ; preds = %34
%36 = load i8*, i8** %6
%37 = load i8*, i8** %7
%38 = call i32 @string_match(i8* %36, i8* %37)
%39 = icmp eq i32 %38, 1
br i1 %39, label %42, label %40
40: ; preds = %35
%41 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i32 49)
store i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i8** %1
br label %44
42: ; preds = %35
br label %43
43: ; preds = %42
store i8* null, i8** %1
br label %44
44: ; preds = %43, %40, %31, %22, %13
%45 = load i8*, i8** %1
ret i8* %45
}

LLVM IR (-O2):
@.str = [6 x i8] c"hello\00"
@.str.1 = [3 x i8] c"he\00"
@.str.2 = [20 x i8] c"Line number is: %d\0A\00"
@.str.3 = [32 x i8] c"error, did not find the pattern\00"
@.str.4 = [3 x i8] c"lo\00"
@.str.5 = [8 x i8] c"hehello\00"
define i8* @test_successful_match() {
%1 = tail call i32 @string_match(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%2 = icmp eq i32 %1, 1
br i1 %2, label %3, label %12
3: ; preds = %0
%4 = tail call i32 @string_match(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%5 = icmp eq i32 %4, 4
br i1 %5, label %6, label %12
6: ; preds = %3
%7 = tail call i32 @string_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))
%8 = icmp eq i32 %7, 1
br i1 %8, label %9, label %12
9: ; preds = %6
%10 = tail call i32 @string_match(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%11 = icmp eq i32 %10, 1
br i1 %11, label %15, label %12
12: ; preds = %9, %6, %3, %0
%13 = phi i32 [ 39, %0 ], [ 42, %3 ], [ 45, %6 ], [ 49, %9 ]
%14 = tail call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i32 %13)
br label %15
15: ; preds = %12, %9
%16 = phi i8* [ null, %9 ], [ getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), %12 ]
ret i8* %16
}