#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*/ assert(int);
int parse_depth(char *, char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ sprintf(char *, char *, char *);
int strlen(char *);
void test_parse_depth() {
  char title[(4096 * 4)];
  char line1[(4096 * 4)];
  char header[(4096 * 4)];
  int i;
  printf("test_parse_depth...");
  sprintf(title, "%s", "title");
  sprintf(line1, "*** %s", title);
  header[0] = 0;
  assert(parse_depth(line1, header) == 3);
  assert(strlen(header) == strlen(title));
  for (i = 0; i < strlen(header); i++) {
    assert(header[i] == title[i]);
  }
  sprintf(line1, "**** %s", title);
  assert(parse_depth(line1, header) == 4);
  sprintf(line1, "****\t%s", title);
  assert(parse_depth(line1, header) == 4);
  sprintf(line1, "*%s*", title);
  assert(parse_depth(line1, header) == -1);
  printf("Ok\n");
}


x86 assembly (clang, -O0):
<test_parse_depth>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc010,%rsp
lea    0xe9e(%rip),%rdi
call   1040 <printf@plt>
lea    -0x4000(%rbp),%rdi
lea    0xeb2(%rip),%rsi
lea    0xe98(%rip),%rdx
call   1060 <sprintf@plt>
lea    -0x8000(%rbp),%rdi
lea    -0x4000(%rbp),%rdx
lea    0xe85(%rip),%rsi
call   1060 <sprintf@plt>
movb   $0x0,-0xc000(%rbp)
lea    -0x8000(%rbp),%rdi
lea    -0xc000(%rbp),%rsi
call   1070 <parse_depth@plt>
cmp    $0x3,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
lea    -0xc000(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0xc008(%rbp)
lea    -0x4000(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0xc008(%rbp),%eax
cmp    %ecx,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
movl   $0x0,-0xc004(%rbp)
mov    -0xc004(%rbp),%eax
mov    %eax,-0xc00c(%rbp)
lea    -0xc000(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0xc00c(%rbp),%eax
cmp    %ecx,%eax
jge    126d <test_parse_depth+0x11d>
movslq -0xc004(%rbp),%rax
movsbl -0xc000(%rbp,%rax,1),%eax
ff
movslq -0xc004(%rbp),%rcx
movsbl -0x4000(%rbp,%rcx,1),%ecx
ff
cmp    %ecx,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    -0xc004(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc004(%rbp)
jmp    1204 <test_parse_depth+0xb4>
lea    -0x8000(%rbp),%rdi
lea    -0x4000(%rbp),%rdx
lea    0xd98(%rip),%rsi
call   1060 <sprintf@plt>
lea    -0x8000(%rbp),%rdi
lea    -0xc000(%rbp),%rsi
call   1070 <parse_depth@plt>
cmp    $0x4,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
lea    -0x8000(%rbp),%rdi
lea    -0x4000(%rbp),%rdx
lea    0xd63(%rip),%rsi
call   1060 <sprintf@plt>
lea    -0x8000(%rbp),%rdi
lea    -0xc000(%rbp),%rsi
call   1070 <parse_depth@plt>
cmp    $0x4,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
lea    -0x8000(%rbp),%rdi
lea    -0x4000(%rbp),%rdx
lea    0xd2e(%rip),%rsi
call   1060 <sprintf@plt>
lea    -0x8000(%rbp),%rdi
lea    -0xc000(%rbp),%rsi
call   1070 <parse_depth@plt>
cmp    $0xffffffff,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
lea    0xd04(%rip),%rdi
call   1040 <printf@plt>
add    $0xc010,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_parse_depth>:
push   %r15
push   %r14
push   %rbx
sub    $0xc000,%rsp
lea    0xe8d(%rip),%rdi
call   1050 <printf@plt>
movl   $0x6c746974,0x4000(%rsp)
74 69 74 6c
movw   $0x65,0x4004(%rsp)
lea    0xe87(%rip),%rsi
lea    0x8000(%rsp),%rbx
lea    0x4000(%rsp),%r15
mov    %rbx,%rdi
mov    %r15,%rdx
call   1070 <sprintf@plt>
movb   $0x0,(%rsp)
mov    %rsp,%r14
mov    %rbx,%rdi
mov    %r14,%rsi
call   1080 <parse_depth@plt>
xor    %edi,%edi
cmp    $0x3,%eax
sete   %dil
call   1060 <assert@plt>
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    %eax,%ebx
mov    %r15,%rdi
call   1040 <strlen@plt>
xor    %edi,%edi
cmp    %eax,%ebx
sete   %dil
call   1060 <assert@plt>
mov    %r14,%rdi
call   1040 <strlen@plt>
test   %eax,%eax
jle    1229 <test_parse_depth+0xc9>
xor    %ebx,%ebx
mov    %rsp,%r14
nop
movzbl (%rsp,%rbx,1),%eax
xor    %edi,%edi
cmp    0x4000(%rsp,%rbx,1),%al
sete   %dil
call   1060 <assert@plt>
add    $0x1,%rbx
mov    %r14,%rdi
call   1040 <strlen@plt>
cltq
cmp    %rax,%rbx
jl     1200 <test_parse_depth+0xa0>
lea    0xdea(%rip),%rsi
lea    0x8000(%rsp),%rbx
lea    0x4000(%rsp),%r14
mov    %rbx,%rdi
mov    %r14,%rdx
call   1070 <sprintf@plt>
mov    %rsp,%r15
mov    %rbx,%rdi
mov    %r15,%rsi
call   1080 <parse_depth@plt>
xor    %edi,%edi
cmp    $0x4,%eax
sete   %dil
call   1060 <assert@plt>
lea    0xdb4(%rip),%rsi
mov    %rbx,%rdi
mov    %r14,%rdx
call   1070 <sprintf@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1080 <parse_depth@plt>
xor    %edi,%edi
cmp    $0x4,%eax
sete   %dil
call   1060 <assert@plt>
lea    0xd91(%rip),%rsi
mov    %rbx,%rdi
mov    %r14,%rdx
call   1070 <sprintf@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1080 <parse_depth@plt>
xor    %edi,%edi
cmp    $0xffffffff,%eax
sete   %dil
call   1060 <assert@plt>
lea    0xd6b(%rip),%rdi
call   1030 <puts@plt>
add    $0xc000,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [20 x i8] c"test_parse_depth...\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [6 x i8] c"title\00"
@.str.3 = [7 x i8] c"*** %s\00"
@.str.4 = [8 x i8] c"**** %s\00"
@.str.5 = [8 x i8] c"****\09%s\00"
@.str.6 = [5 x i8] c"*%s*\00"
@.str.7 = [4 x i8] c"Ok\0A\00"
define void @test_parse_depth() {
%1 = alloca [16384 x i8]
%2 = alloca [16384 x i8]
%3 = alloca [16384 x i8]
%4 = alloca i32
%5 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%6 = getelementptr inbounds [16384 x i8], [16384 x i8]* %1, i64 0, i64 0
%7 = call i32 @sprintf(i8* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%8 = getelementptr inbounds [16384 x i8], [16384 x i8]* %2, i64 0, i64 0
%9 = getelementptr inbounds [16384 x i8], [16384 x i8]* %1, i64 0, i64 0
%10 = call i32 @sprintf(i8* %8, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8* %9)
%11 = getelementptr inbounds [16384 x i8], [16384 x i8]* %3, i64 0, i64 0
store i8 0, i8* %11
%12 = getelementptr inbounds [16384 x i8], [16384 x i8]* %2, i64 0, i64 0
%13 = getelementptr inbounds [16384 x i8], [16384 x i8]* %3, i64 0, i64 0
%14 = call i32 @parse_depth(i8* %12, i8* %13)
%15 = icmp eq i32 %14, 3
%16 = zext i1 %15 to i32
%17 = call i32 @assert(i32 %16)
%18 = getelementptr inbounds [16384 x i8], [16384 x i8]* %3, i64 0, i64 0
%19 = call i32 @strlen(i8* %18)
%20 = getelementptr inbounds [16384 x i8], [16384 x i8]* %1, i64 0, i64 0
%21 = call i32 @strlen(i8* %20)
%22 = icmp eq i32 %19, %21
%23 = zext i1 %22 to i32
%24 = call i32 @assert(i32 %23)
store i32 0, i32* %4
br label %25
25: ; preds = %44, %0
%26 = load i32, i32* %4
%27 = getelementptr inbounds [16384 x i8], [16384 x i8]* %3, i64 0, i64 0
%28 = call i32 @strlen(i8* %27)
%29 = icmp slt i32 %26, %28
br i1 %29, label %30, label %47
30: ; preds = %25
%31 = load i32, i32* %4
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [16384 x i8], [16384 x i8]* %3, i64 0, i64 %32
%34 = load i8, i8* %33
%35 = sext i8 %34 to i32
%36 = load i32, i32* %4
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [16384 x i8], [16384 x i8]* %1, i64 0, i64 %37
%39 = load i8, i8* %38
%40 = sext i8 %39 to i32
%41 = icmp eq i32 %35, %40
%42 = zext i1 %41 to i32
%43 = call i32 @assert(i32 %42)
br label %44
44: ; preds = %30
%45 = load i32, i32* %4
%46 = add nsw i32 %45, 1
store i32 %46, i32* %4
br label %25
47: ; preds = %25
%48 = getelementptr inbounds [16384 x i8], [16384 x i8]* %2, i64 0, i64 0
%49 = getelementptr inbounds [16384 x i8], [16384 x i8]* %1, i64 0, i64 0
%50 = call i32 @sprintf(i8* %48, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i8* %49)
%51 = getelementptr inbounds [16384 x i8], [16384 x i8]* %2, i64 0, i64 0
%52 = getelementptr inbounds [16384 x i8], [16384 x i8]* %3, i64 0, i64 0
%53 = call i32 @parse_depth(i8* %51, i8* %52)
%54 = icmp eq i32 %53, 4
%55 = zext i1 %54 to i32
%56 = call i32 @assert(i32 %55)
%57 = getelementptr inbounds [16384 x i8], [16384 x i8]* %2, i64 0, i64 0
%58 = getelementptr inbounds [16384 x i8], [16384 x i8]* %1, i64 0, i64 0
%59 = call i32 @sprintf(i8* %57, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i8* %58)
%60 = getelementptr inbounds [16384 x i8], [16384 x i8]* %2, i64 0, i64 0
%61 = getelementptr inbounds [16384 x i8], [16384 x i8]* %3, i64 0, i64 0
%62 = call i32 @parse_depth(i8* %60, i8* %61)
%63 = icmp eq i32 %62, 4
%64 = zext i1 %63 to i32
%65 = call i32 @assert(i32 %64)
%66 = getelementptr inbounds [16384 x i8], [16384 x i8]* %2, i64 0, i64 0
%67 = getelementptr inbounds [16384 x i8], [16384 x i8]* %1, i64 0, i64 0
%68 = call i32 @sprintf(i8* %66, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i8* %67)
%69 = getelementptr inbounds [16384 x i8], [16384 x i8]* %2, i64 0, i64 0
%70 = getelementptr inbounds [16384 x i8], [16384 x i8]* %3, i64 0, i64 0
%71 = call i32 @parse_depth(i8* %69, i8* %70)
%72 = icmp eq i32 %71, -1
%73 = zext i1 %72 to i32
%74 = call i32 @assert(i32 %73)
%75 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [20 x i8] c"test_parse_depth...\00"
@.str.2 = [6 x i8] c"title\00"
@.str.3 = [7 x i8] c"*** %s\00"
@.str.4 = [8 x i8] c"**** %s\00"
@.str.5 = [8 x i8] c"****\09%s\00"
@.str.6 = [5 x i8] c"*%s*\00"
@str = [3 x i8] c"Ok\00"
define void @test_parse_depth() {
%1 = alloca [16384 x i8]
%2 = alloca [16384 x i8]
%3 = alloca [16384 x i8]
%4 = getelementptr inbounds [16384 x i8], [16384 x i8]* %1, i64 0, i64 0
%5 = getelementptr inbounds [16384 x i8], [16384 x i8]* %2, i64 0, i64 0
%6 = getelementptr inbounds [16384 x i8], [16384 x i8]* %3, i64 0, i64 0
%7 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8* %4)
store i8 0, i8* %6
%9 = call i32 @parse_depth(i8* %5, i8* %6)
%10 = icmp eq i32 %9, 3
%11 = zext i1 %10 to i32
%12 = call i32 @assert(i32 %11)
%13 = call i32 @strlen(i8* %6)
%14 = call i32 @strlen(i8* %4)
%15 = icmp eq i32 %13, %14
%16 = zext i1 %15 to i32
%17 = call i32 @assert(i32 %16)
%18 = call i32 @strlen(i8* %6)
%19 = icmp sgt i32 %18, 0
br i1 %19, label %20, label %33
20: ; preds = %0, %20
%21 = phi i64 [ %29, %20 ], [ 0, %0 ]
%22 = getelementptr inbounds [16384 x i8], [16384 x i8]* %3, i64 0, i64 %21
%23 = load i8, i8* %22
%24 = getelementptr inbounds [16384 x i8], [16384 x i8]* %1, i64 0, i64 %21
%25 = load i8, i8* %24
%26 = icmp eq i8 %23, %25
%27 = zext i1 %26 to i32
%28 = call i32 @assert(i32 %27)
%29 = add nuw nsw i64 %21, 1
%30 = call i32 @strlen(i8* %6)
%31 = sext i32 %30 to i64
%32 = icmp slt i64 %29, %31
br i1 %32, label %20, label %33
33: ; preds = %20, %0
%34 = call i32 @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i8* %4)
%35 = call i32 @parse_depth(i8* %5, i8* %6)
%36 = icmp eq i32 %35, 4
%37 = zext i1 %36 to i32
%38 = call i32 @assert(i32 %37)
%39 = call i32 @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i8* %4)
%40 = call i32 @parse_depth(i8* %5, i8* %6)
%41 = icmp eq i32 %40, 4
%42 = zext i1 %41 to i32
%43 = call i32 @assert(i32 %42)
%44 = call i32 @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i8* %4)
%45 = call i32 @parse_depth(i8* %5, i8* %6)
%46 = icmp eq i32 %45, -1
%47 = zext i1 %46 to i32
%48 = call i32 @assert(i32 %47)
%49 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @str, i64 0, i64 0))
ret void
}