#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 */
scalar_t__ json_getNull(char *, int, int *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ puts(char *);
void test_json_getNull() {
  puts("Test json_getNull");
  puts("======================================================================="
       "=========");
  char *str[100] = {"abcnullabc", "null", "n", "nullabc", ""};
  int i, startIndex, endIndex;
  for (i = 0; str[i] != NULL; i++) {
    startIndex = 0;
    if (json_getNull(str[i], startIndex, &endIndex) == 0) {
      printf("%d. %s [%d..%d] is null\n\n", i + 1, str[i], startIndex,
             endIndex);
    } else {
      printf("%d. %s is not null\n\n", i + 1, str[i]);
    }
  }
  char *s = str[0];
  startIndex = 3;
  if (json_getNull(s, startIndex, &endIndex) == 0) {
    printf("%s [%d..%d] is null\n\n", s, startIndex, endIndex);
  } else {
    printf("%s [%d..] is not null\n\n", s, startIndex);
  }
  puts("======================================================================="
       "=========\n");
}


x86 assembly (clang, -O0):
<test_json_getNull>:
push   %rbp
mov    %rsp,%rbp
sub    $0x340,%rsp
lea    0xeae(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb4(%rip),%rdi
call   1030 <puts@plt>
lea    -0x320(%rbp),%rdi
xor    %esi,%esi
mov    $0x320,%edx
call   1050 <memset@plt>
lea    0xee6(%rip),%rax
mov    %rax,-0x320(%rbp)
lea    0xee3(%rip),%rax
mov    %rax,-0x318(%rbp)
lea    0xeda(%rip),%rax
mov    %rax,-0x310(%rbp)
lea    0xebf(%rip),%rax
mov    %rax,-0x308(%rbp)
lea    0xed9(%rip),%rax
mov    %rax,-0x300(%rbp)
movl   $0x0,-0x324(%rbp)
movslq -0x324(%rbp),%rax
cmpq   $0x0,-0x320(%rbp,%rax,8)
je     1288 <test_json_getNull+0x148>
movl   $0x0,-0x328(%rbp)
movslq -0x324(%rbp),%rax
mov    -0x320(%rbp,%rax,8),%rdi
ff
mov    -0x328(%rbp),%esi
lea    -0x32c(%rbp),%rdx
call   1060 <json_getNull@plt>
cmp    $0x0,%rax
jne    1249 <test_json_getNull+0x109>
mov    -0x324(%rbp),%esi
add    $0x1,%esi
movslq -0x324(%rbp),%rax
mov    -0x320(%rbp,%rax,8),%rdx
ff
mov    -0x328(%rbp),%ecx
mov    -0x32c(%rbp),%r8d
lea    0xe38(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    126f <test_json_getNull+0x12f>
mov    -0x324(%rbp),%esi
add    $0x1,%esi
movslq -0x324(%rbp),%rax
mov    -0x320(%rbp,%rax,8),%rdx
ff
lea    0xe27(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1274 <test_json_getNull+0x134>
mov    -0x324(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x324(%rbp)
jmp    11c6 <test_json_getNull+0x86>
mov    -0x320(%rbp),%rax
mov    %rax,-0x338(%rbp)
movl   $0x3,-0x328(%rbp)
mov    -0x338(%rbp),%rdi
mov    -0x328(%rbp),%esi
lea    -0x32c(%rbp),%rdx
call   1060 <json_getNull@plt>
cmp    $0x0,%rax
jne    12e9 <test_json_getNull+0x1a9>
mov    -0x338(%rbp),%rsi
mov    -0x328(%rbp),%edx
mov    -0x32c(%rbp),%ecx
lea    0xd9c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1304 <test_json_getNull+0x1c4>
mov    -0x338(%rbp),%rsi
mov    -0x328(%rbp),%edx
lea    0xda7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xdb1(%rip),%rdi
call   1030 <puts@plt>
add    $0x340,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_json_getNull>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x330,%rsp
lea    0xea9(%rip),%rdi
call   1030 <puts@plt>
lea    0xeaf(%rip),%rdi
call   1030 <puts@plt>
lea    0x30(%rsp),%rdi
mov    $0x300,%edx
xor    %esi,%esi
call   1050 <memset@plt>
lea    0xee3(%rip),%r15
mov    %r15,0x10(%rsp)
lea    0xee2(%rip),%rax
mov    %rax,0x18(%rsp)
lea    0xedb(%rip),%rax
mov    %rax,0x20(%rsp)
lea    0xec2(%rip),%rax
mov    %rax,0x28(%rsp)
lea    0xede(%rip),%rax
mov    %rax,0x30(%rsp)
mov    $0x1,%ebx
lea    0xc(%rsp),%r14
lea    0xeaf(%rip),%r12
lea    0xec2(%rip),%r13
jmp    11ed <test_json_getNull+0xad>
nop
mov    %r13,%rdi
mov    %ebx,%esi
mov    %r15,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x10(%rsp,%rbx,8),%r15
add    $0x1,%rbx
test   %r15,%r15
je     1217 <test_json_getNull+0xd7>
mov    %r15,%rdi
xor    %esi,%esi
mov    %r14,%rdx
call   1060 <json_getNull@plt>
test   %rax,%rax
jne    11d0 <test_json_getNull+0x90>
mov    0xc(%rsp),%r8d
mov    %r12,%rdi
mov    %ebx,%esi
mov    %r15,%rdx
xor    %ecx,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11df <test_json_getNull+0x9f>
lea    0xe45(%rip),%rdi
lea    0xc(%rsp),%rdx
mov    $0x3,%esi
call   1060 <json_getNull@plt>
test   %rax,%rax
je     124e <test_json_getNull+0x10e>
lea    0xe6b(%rip),%rdi
lea    0xe23(%rip),%rsi
mov    $0x3,%edx
xor    %eax,%eax
call   1040 <printf@plt>
jmp    126c <test_json_getNull+0x12c>
mov    0xc(%rsp),%ecx
lea    0xe20(%rip),%rdi
lea    0xe03(%rip),%rsi
mov    $0x3,%edx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe49(%rip),%rdi
call   1030 <puts@plt>
add    $0x330,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [18 x i8] c"Test json_getNull\00"
@.str.1 = [81 x i8] c"================================================================================\00"
@.str.2 = [11 x i8] c"abcnullabc\00"
@.str.3 = [5 x i8] c"null\00"
@.str.4 = [2 x i8] c"n\00"
@.str.5 = [8 x i8] c"nullabc\00"
@.str.6 = [1 x i8] zeroinitializer
@.str.7 = [26 x i8] c"%d. %s [%d..%d] is null\0A\0A\00"
@.str.8 = [21 x i8] c"%d. %s is not null\0A\0A\00"
@.str.9 = [22 x i8] c"%s [%d..%d] is null\0A\0A\00"
@.str.10 = [24 x i8] c"%s [%d..] is not null\0A\0A\00"
@.str.11 = [82 x i8] c"================================================================================\0A\00"
define void @test_json_getNull() {
%1 = alloca [100 x i8*]
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
%6 = call i32 @puts(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @puts(i8* getelementptr inbounds ([81 x i8], [81 x i8]* @.str.1, i64 0, i64 0))
%8 = bitcast [100 x i8*]* %1 to i8*
%9 = bitcast i8* %8 to <{ i8*, i8*, i8*, i8*, i8*, [95 x i8*] }>*
%10 = getelementptr inbounds <{ i8*, i8*, i8*, i8*, i8*, [95 x i8*] }>, <{ i8*, i8*, i8*, i8*, i8*, [95 x i8*] }>* %9, i32 0, i32 0
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i32 0, i32 0), i8** %10
%11 = getelementptr inbounds <{ i8*, i8*, i8*, i8*, i8*, [95 x i8*] }>, <{ i8*, i8*, i8*, i8*, i8*, [95 x i8*] }>* %9, i32 0, i32 1
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i32 0, i32 0), i8** %11
%12 = getelementptr inbounds <{ i8*, i8*, i8*, i8*, i8*, [95 x i8*] }>, <{ i8*, i8*, i8*, i8*, i8*, [95 x i8*] }>* %9, i32 0, i32 2
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i32 0, i32 0), i8** %12
%13 = getelementptr inbounds <{ i8*, i8*, i8*, i8*, i8*, [95 x i8*] }>, <{ i8*, i8*, i8*, i8*, i8*, [95 x i8*] }>* %9, i32 0, i32 3
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i32 0, i32 0), i8** %13
%14 = getelementptr inbounds <{ i8*, i8*, i8*, i8*, i8*, [95 x i8*] }>, <{ i8*, i8*, i8*, i8*, i8*, [95 x i8*] }>* %9, i32 0, i32 4
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.6, i32 0, i32 0), i8** %14
store i32 0, i32* %2
br label %15
15: ; preds = %48, %0
%16 = load i32, i32* %2
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [100 x i8*], [100 x i8*]* %1, i64 0, i64 %17
%19 = load i8*, i8** %18
%20 = icmp ne i8* %19, null
br i1 %20, label %21, label %51
21: ; preds = %15
store i32 0, i32* %3
%22 = load i32, i32* %2
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [100 x i8*], [100 x i8*]* %1, i64 0, i64 %23
%25 = load i8*, i8** %24
%26 = load i32, i32* %3
%27 = call i64 @json_getNull(i8* %25, i32 %26, i32* %4)
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %39
29: ; preds = %21
%30 = load i32, i32* %2
%31 = add nsw i32 %30, 1
%32 = load i32, i32* %2
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [100 x i8*], [100 x i8*]* %1, i64 0, i64 %33
%35 = load i8*, i8** %34
%36 = load i32, i32* %3
%37 = load i32, i32* %4
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.7, i64 0, i64 0), i32 %31, i8* %35, i32 %36, i32 %37)
br label %47
39: ; preds = %21
%40 = load i32, i32* %2
%41 = add nsw i32 %40, 1
%42 = load i32, i32* %2
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds [100 x i8*], [100 x i8*]* %1, i64 0, i64 %43
%45 = load i8*, i8** %44
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.8, i64 0, i64 0), i32 %41, i8* %45)
br label %47
47: ; preds = %39, %29
br label %48
48: ; preds = %47
%49 = load i32, i32* %2
%50 = add nsw i32 %49, 1
store i32 %50, i32* %2
br label %15
51: ; preds = %15
%52 = getelementptr inbounds [100 x i8*], [100 x i8*]* %1, i64 0, i64 0
%53 = load i8*, i8** %52
store i8* %53, i8** %5
store i32 3, i32* %3
%54 = load i8*, i8** %5
%55 = load i32, i32* %3
%56 = call i64 @json_getNull(i8* %54, i32 %55, i32* %4)
%57 = icmp eq i64 %56, 0
br i1 %57, label %58, label %63
58: ; preds = %51
%59 = load i8*, i8** %5
%60 = load i32, i32* %3
%61 = load i32, i32* %4
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.9, i64 0, i64 0), i8* %59, i32 %60, i32 %61)
br label %67
63: ; preds = %51
%64 = load i8*, i8** %5
%65 = load i32, i32* %3
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.10, i64 0, i64 0), i8* %64, i32 %65)
br label %67
67: ; preds = %63, %58
%68 = call i32 @puts(i8* getelementptr inbounds ([82 x i8], [82 x i8]* @.str.11, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [18 x i8] c"Test json_getNull\00"
@.str.1 = [81 x i8] c"================================================================================\00"
@.str.2 = [11 x i8] c"abcnullabc\00"
@.str.3 = [5 x i8] c"null\00"
@.str.4 = [2 x i8] c"n\00"
@.str.5 = [8 x i8] c"nullabc\00"
@.str.6 = [1 x i8] zeroinitializer
@.str.7 = [26 x i8] c"%d. %s [%d..%d] is null\0A\0A\00"
@.str.8 = [21 x i8] c"%d. %s is not null\0A\0A\00"
@.str.9 = [22 x i8] c"%s [%d..%d] is null\0A\0A\00"
@.str.10 = [24 x i8] c"%s [%d..] is not null\0A\0A\00"
@.str.11 = [82 x i8] c"================================================================================\0A\00"
define void @test_json_getNull() {
%1 = alloca [100 x i8*]
%2 = alloca i32
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([81 x i8], [81 x i8]* @.str.1, i64 0, i64 0))
%5 = bitcast [100 x i8*]* %1 to i8*
%6 = getelementptr inbounds [100 x i8*], [100 x i8*]* %1, i64 0, i64 4
%7 = bitcast i8** %6 to i8*
%8 = getelementptr inbounds [100 x i8*], [100 x i8*]* %1, i64 0, i64 0
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8** %8
%9 = getelementptr inbounds [100 x i8*], [100 x i8*]* %1, i64 0, i64 1
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8** %9
%10 = getelementptr inbounds [100 x i8*], [100 x i8*]* %1, i64 0, i64 2
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i8** %10
%11 = getelementptr inbounds [100 x i8*], [100 x i8*]* %1, i64 0, i64 3
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i8** %11
%12 = getelementptr inbounds [100 x i8*], [100 x i8*]* %1, i64 0, i64 4
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.6, i64 0, i64 0), i8** %12
%13 = bitcast i32* %2 to i8*
br label %14
14: ; preds = %0, %27
%15 = phi i64 [ 0, %0 ], [ %19, %27 ]
%16 = phi i8* [ getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), %0 ], [ %29, %27 ]
%17 = call i64 @json_getNull(i8* %16, i32 0, i32* %2)
%18 = icmp eq i64 %17, 0
%19 = add nuw i64 %15, 1
br i1 %18, label %20, label %24
20: ; preds = %14
%21 = load i32, i32* %2
%22 = trunc i64 %19 to i32
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.7, i64 0, i64 0), i32 %22, i8* %16, i32 0, i32 %21)
br label %27
24: ; preds = %14
%25 = trunc i64 %19 to i32
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.8, i64 0, i64 0), i32 %25, i8* %16)
br label %27
27: ; preds = %20, %24
%28 = getelementptr inbounds [100 x i8*], [100 x i8*]* %1, i64 0, i64 %19
%29 = load i8*, i8** %28
%30 = icmp eq i8* %29, null
br i1 %30, label %31, label %14
31: ; preds = %27
%32 = call i64 @json_getNull(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 3, i32* %2)
%33 = icmp eq i64 %32, 0
br i1 %33, label %34, label %37
34: ; preds = %31
%35 = load i32, i32* %2
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 3, i32 %35)
br label %39
37: ; preds = %31
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 3)
br label %39
39: ; preds = %37, %34
%40 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([82 x i8], [82 x i8]* @.str.11, i64 0, i64 0))
ret void
}