#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_null() {
  char *text1 = NULL;
  char *pattern1 = "Hello";
  do {
    if (!(string_match(text1, pattern1) == -2)) {
      printf("Line number is: %d\n", 17);
      return "error, searched NULL array";
    }
  } while (0);
  char *text2 = "hello";
  char *pattern2 = NULL;
  do {
    if (!(string_match(text1, pattern1) == -2)) {
      printf("Line number is: %d\n", 21);
      return "error, searched NULL array";
    }
  } while (0);
  char *text3 = NULL;
  char *pattern3 = NULL;
  do {
    if (!(string_match(text1, pattern1) == -2)) {
      printf("Line number is: %d\n", 25);
      return "error, searched NULL array";
    }
  } while (0);
  return 0;
}


x86 assembly (clang, -O0):
<test_null>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movq   $0x0,-0x10(%rbp)
lea    0xec9(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <string_match@plt>
cmp    $0xfffffffe,%eax
je     1172 <test_null+0x52>
lea    0xeae(%rip),%rdi
mov    $0x11,%esi
call   1030 <printf@plt>
lea    0xeb1(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    121a <test_null+0xfa>
jmp    1177 <test_null+0x57>
lea    0xeb7(%rip),%rax
mov    %rax,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <string_match@plt>
cmp    $0xfffffffe,%eax
je     11c1 <test_null+0xa1>
lea    0xe5f(%rip),%rdi
mov    $0x15,%esi
call   1030 <printf@plt>
lea    0xe62(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    121a <test_null+0xfa>
jmp    11c6 <test_null+0xa6>
movq   $0x0,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <string_match@plt>
cmp    $0xfffffffe,%eax
je     120d <test_null+0xed>
lea    0xe13(%rip),%rdi
mov    $0x19,%esi
call   1030 <printf@plt>
lea    0xe16(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    121a <test_null+0xfa>
jmp    1212 <test_null+0xf2>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_null>:
push   %rbx
lea    0xed8(%rip),%rsi
xor    %edi,%edi
call   1040 <string_match@plt>
mov    $0x11,%esi
cmp    $0xfffffffe,%eax
jne    116b <test_null+0x4b>
lea    0xec0(%rip),%rsi
xor    %edi,%edi
call   1040 <string_match@plt>
mov    $0x15,%esi
cmp    $0xfffffffe,%eax
jne    116b <test_null+0x4b>
lea    0xea8(%rip),%rsi
xor    %ebx,%ebx
xor    %edi,%edi
call   1040 <string_match@plt>
mov    $0x19,%esi
cmp    $0xfffffffe,%eax
je     117e <test_null+0x5e>
lea    0xe94(%rip),%rdi
call   1030 <printf@plt>
lea    0xe9c(%rip),%rbx
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [6 x i8] c"Hello\00"
@.str.1 = [20 x i8] c"Line number is: %d\0A\00"
@.str.2 = [27 x i8] c"error, searched NULL array\00"
@.str.3 = [6 x i8] c"hello\00"
define i8* @test_null() {
%1 = alloca i8*
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
store i8* null, i8** %2
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, 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, -2
br i1 %12, label %15, label %13
13: ; preds = %8
%14 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i32 17)
store i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i8** %1
br label %35
15: ; preds = %8
br label %16
16: ; preds = %15
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8** %4
store i8* null, i8** %5
br label %17
17: ; preds = %16
%18 = load i8*, i8** %2
%19 = load i8*, i8** %3
%20 = call i32 @string_match(i8* %18, i8* %19)
%21 = icmp eq i32 %20, -2
br i1 %21, label %24, label %22
22: ; preds = %17
%23 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i32 21)
store i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i8** %1
br label %35
24: ; preds = %17
br label %25
25: ; preds = %24
store i8* null, i8** %6
store i8* null, i8** %7
br label %26
26: ; preds = %25
%27 = load i8*, i8** %2
%28 = load i8*, i8** %3
%29 = call i32 @string_match(i8* %27, i8* %28)
%30 = icmp eq i32 %29, -2
br i1 %30, label %33, label %31
31: ; preds = %26
%32 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i32 25)
store i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i8** %1
br label %35
33: ; preds = %26
br label %34
34: ; preds = %33
store i8* null, i8** %1
br label %35
35: ; preds = %34, %31, %22, %13
%36 = load i8*, i8** %1
ret i8* %36
}

LLVM IR (-O2):
@.str = [6 x i8] c"Hello\00"
@.str.1 = [20 x i8] c"Line number is: %d\0A\00"
@.str.2 = [27 x i8] c"error, searched NULL array\00"
define i8* @test_null() {
%1 = tail call i32 @string_match(i8* null, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%2 = icmp eq i32 %1, -2
br i1 %2, label %3, label %9
3: ; preds = %0
%4 = tail call i32 @string_match(i8* null, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i32 %4, -2
br i1 %5, label %6, label %9
6: ; preds = %3
%7 = tail call i32 @string_match(i8* null, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i32 %7, -2
br i1 %8, label %12, label %9
9: ; preds = %6, %3, %0
%10 = phi i32 [ 17, %0 ], [ 21, %3 ], [ 25, %6 ]
%11 = tail call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i32 %10)
br label %12
12: ; preds = %9, %6
%13 = phi i8* [ null, %6 ], [ getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), %9 ]
ret i8* %13
}