#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*/ fputs(char *, int /*<<< orphan*/);
int /*<<< orphan*/ process(char const *, char const *, int /*<<< orphan*/);
int /*<<< orphan*/ stdout;
char *strstr(char const *, char *);
int doparagraph(const char *begin, const char *end, int newblock) {
  const char *p;
  if (!newblock)
    return 0;
  p = strstr(begin, "\n\n");
  if (!p || p > end)
    p = end;
  if (p - begin <= 1)
    return 0;
  fputs("<p>", stdout);
  process(begin, p, 0);
  fputs("</p>\n", stdout);
  return -(p - begin);
}


x86 assembly (clang, -O0):
<doparagraph>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jne    1159 <doparagraph+0x29>
movl   $0x0,-0x4(%rbp)
jmp    11fb <doparagraph+0xcb>
mov    -0x10(%rbp),%rdi
lea    0xe9c(%rip),%rsi
call   1050 <strstr@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     1186 <doparagraph+0x56>
mov    -0x28(%rbp),%rax
cmp    -0x18(%rbp),%rax
jbe    118e <doparagraph+0x5e>
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    %rcx,%rax
cmp    $0x1,%rax
jg     11af <doparagraph+0x7f>
movl   $0x0,-0x4(%rbp)
jmp    11fb <doparagraph+0xcb>
mov    0x2e2a(%rip),%rax
mov    (%rax),%esi
lea    0xe44(%rip),%rdi
call   1030 <fputs@plt>
mov    -0x10(%rbp),%rdi
mov    -0x28(%rbp),%rsi
xor    %edx,%edx
call   1040 <process@plt>
mov    0x2e06(%rip),%rax
mov    (%rax),%esi
lea    0xe24(%rip),%rdi
call   1030 <fputs@plt>
mov    -0x28(%rbp),%rcx
mov    -0x10(%rbp),%rax
sub    %rax,%rcx
xor    %eax,%eax
sub    %rcx,%rax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<doparagraph>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
xor    %r14d,%r14d
test   %edx,%edx
je     11a4 <doparagraph+0x74>
mov    %rsi,%rbx
mov    %rdi,%r15
lea    0xeb5(%rip),%rsi
call   1050 <strstr@plt>
cmp    %rbx,%rax
mov    %rax,%rbp
cmova  %rbx,%rbp
test   %rax,%rax
cmove  %rbx,%rbp
mov    %rbp,%rbx
sub    %r15,%rbx
cmp    $0x2,%rbx
jl     11a4 <doparagraph+0x74>
mov    0x2e6c(%rip),%r14
mov    (%r14),%esi
lea    0xe85(%rip),%rdi
call   1030 <fputs@plt>
mov    %r15,%rdi
mov    %rbp,%rsi
xor    %edx,%edx
call   1040 <process@plt>
mov    (%r14),%esi
lea    0xe6d(%rip),%rdi
call   1030 <fputs@plt>
neg    %ebx
mov    %ebx,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"\0A\0A\00"
@.str.1 = [4 x i8] c"<p>\00"
@stdout = global i32 0
@.str.2 = [6 x i8] c"</p>\0A\00"
define i32 @doparagraph(i8* %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8*
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
%9 = load i32, i32* %7
%10 = icmp ne i32 %9, 0
br i1 %10, label %12, label %11
11: ; preds = %3
store i32 0, i32* %4
br label %46
12: ; preds = %3
%13 = load i8*, i8** %5
%14 = call i8* @strstr(i8* %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i8* %14, i8** %8
%15 = load i8*, i8** %8
%16 = icmp ne i8* %15, null
br i1 %16, label %17, label %21
17: ; preds = %12
%18 = load i8*, i8** %8
%19 = load i8*, i8** %6
%20 = icmp ugt i8* %18, %19
br i1 %20, label %21, label %23
21: ; preds = %17, %12
%22 = load i8*, i8** %6
store i8* %22, i8** %8
br label %23
23: ; preds = %21, %17
%24 = load i8*, i8** %8
%25 = load i8*, i8** %5
%26 = ptrtoint i8* %24 to i64
%27 = ptrtoint i8* %25 to i64
%28 = sub i64 %26, %27
%29 = icmp sle i64 %28, 1
br i1 %29, label %30, label %31
30: ; preds = %23
store i32 0, i32* %4
br label %46
31: ; preds = %23
%32 = load i32, i32* @stdout
%33 = call i32 @fputs(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %32)
%34 = load i8*, i8** %5
%35 = load i8*, i8** %8
%36 = call i32 @process(i8* %34, i8* %35, i32 0)
%37 = load i32, i32* @stdout
%38 = call i32 @fputs(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %37)
%39 = load i8*, i8** %8
%40 = load i8*, i8** %5
%41 = ptrtoint i8* %39 to i64
%42 = ptrtoint i8* %40 to i64
%43 = sub i64 %41, %42
%44 = sub nsw i64 0, %43
%45 = trunc i64 %44 to i32
store i32 %45, i32* %4
br label %46
46: ; preds = %31, %30, %11
%47 = load i32, i32* %4
ret i32 %47
}

LLVM IR (-O2):
@.str = [3 x i8] c"\0A\0A\00"
@.str.1 = [4 x i8] c"<p>\00"
@stdout = global i32 0
@.str.2 = [6 x i8] c"</p>\0A\00"
define i32 @doparagraph(i8* %0, i8* %1, i32 %2) {
%4 = icmp eq i32 %2, 0
br i1 %4, label %23, label %5
5: ; preds = %3
%6 = tail call i8* @strstr(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i8* %6, null
%8 = icmp ugt i8* %6, %1
%9 = or i1 %7, %8
%10 = select i1 %9, i8* %1, i8* %6
%11 = ptrtoint i8* %10 to i64
%12 = ptrtoint i8* %0 to i64
%13 = sub i64 %11, %12
%14 = icmp slt i64 %13, 2
br i1 %14, label %23, label %15
15: ; preds = %5
%16 = load i32, i32* @stdout
%17 = tail call i32 @fputs(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %16)
%18 = tail call i32 @process(i8* %0, i8* %10, i32 0)
%19 = load i32, i32* @stdout
%20 = tail call i32 @fputs(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %19)
%21 = trunc i64 %13 to i32
%22 = sub i32 0, %21
br label %23
23: ; preds = %5, %3, %15
%24 = phi i32 [ %22, %15 ], [ 0, %3 ], [ 0, %5 ]
ret i32 %24
}