#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
char EOF;
char fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ fputc(char, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ *stdin;
int /*<<< orphan*/ *stdout;
int /*<<< orphan*/ strcmp(char *, char *);
int main(int argc, char **argv) {
  if (argc > 2 && (!strcmp(argv[1], "-h") || !strcmp(argv[1], "--help"))) {
    printf("Insert <p> and </p> tags around every paragraph. Give me a file "
           "name, or I'll use stdin. Always writes to stdout.");
    return 0;
  }
  FILE *in = (argc == 2) ? fopen(argv[1], "r") : stdin;
  FILE *out = stdout;
  char c;
  bool one_nl = false, multi_nl = false;
  while ((c = fgetc(in)) != EOF)
    if (c == '\n' && one_nl)
      multi_nl = true;
    else if (c == '\n' && !one_nl)
      one_nl = true;
    else {
      if (multi_nl)
        fprintf(out, "</p>\n\n<p>");
      else if (one_nl)
        fputc('\n', out);
      fputc(c, out);
      multi_nl = one_nl = false;
    }
  fputc('\n', out);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jle    11d2 <main+0x72>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe71(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
je     11ba <main+0x5a>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe57(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
jne    11d2 <main+0x72>
lea    0xe49(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1303 <main+0x1a3>
cmpl   $0x2,-0x8(%rbp)
jne    11f9 <main+0x99>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe91(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x38(%rbp)
jmp    1207 <main+0xa7>
mov    0x2de8(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    0x2dba(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <fgetc@plt>
mov    %al,-0x21(%rbp)
movsbl %al,%eax
mov    0x2d9f(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     12f5 <main+0x195>
movsbl -0x21(%rbp),%eax
cmp    $0xa,%eax
jne    126f <main+0x10f>
cmpl   $0x0,-0x28(%rbp)
je     126f <main+0x10f>
movl   $0x1,-0x2c(%rbp)
jmp    12f0 <main+0x190>
movsbl -0x21(%rbp),%eax
cmp    $0xa,%eax
jne    1292 <main+0x132>
cmpl   $0x0,-0x28(%rbp)
jne    1292 <main+0x132>
movl   $0x1,-0x28(%rbp)
jmp    12eb <main+0x18b>
cmpl   $0x0,-0x2c(%rbp)
je     12b1 <main+0x151>
mov    -0x20(%rbp),%rdi
lea    0xdd7(%rip),%rsi
call   1070 <fprintf@plt>
jmp    12ce <main+0x16e>
cmpl   $0x0,-0x28(%rbp)
je     12c9 <main+0x169>
mov    -0x20(%rbp),%rsi
mov    $0xa,%edi
call   1050 <fputc@plt>
jmp    12ce <main+0x16e>
mov    -0x21(%rbp),%al
mov    -0x20(%rbp),%rsi
movsbl %al,%edi
call   1050 <fputc@plt>
movl   $0x0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
jmp    12f0 <main+0x190>
jmp    122b <main+0xcb>
mov    -0x20(%rbp),%rsi
mov    $0xa,%edi
call   1050 <fputc@plt>
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
cmp    $0x3,%edi
jl     11a8 <main+0x48>
mov    0x8(%rsi),%rbx
lea    0xe85(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strcmp@plt>
test   %eax,%eax
je     119a <main+0x3a>
lea    0xe75(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strcmp@plt>
test   %eax,%eax
jne    11c2 <main+0x62>
lea    0xe69(%rip),%rdi
call   1030 <printf@plt>
jmp    11f8 <main+0x98>
cmp    $0x2,%edi
jne    11c2 <main+0x62>
mov    0x8(%rsi),%rdi
lea    0xec4(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%r12
jmp    11cc <main+0x6c>
mov    0x2e1f(%rip),%rax
mov    (%rax),%r12
mov    0x2dfd(%rip),%rax
mov    (%rax),%r14
mov    %r12,%rdi
call   1040 <fgetc@plt>
mov    0x2dfb(%rip),%r13
cmp    0x0(%r13),%al
jne    1209 <main+0xa9>
mov    $0xa,%edi
mov    %r14,%rsi
call   1050 <fputc@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %eax,%ebx
xor    %ebp,%ebp
xor    %eax,%eax
jmp    1238 <main+0xd8>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    $0x1,%ebp
mov    %r12,%rdi
call   1040 <fgetc@plt>
mov    %eax,%ebx
mov    %r15d,%eax
cmp    0x0(%r13),%bl
je     11eb <main+0x8b>
mov    $0x1,%r15d
test   %eax,%eax
je     1247 <main+0xe7>
cmp    $0xa,%bl
je     1220 <main+0xc0>
test   %eax,%eax
jne    1250 <main+0xf0>
cmp    $0xa,%bl
je     1225 <main+0xc5>
test   %ebp,%ebp
je     126f <main+0x10f>
mov    $0x9,%esi
mov    $0x1,%edx
lea    0xe19(%rip),%rdi
mov    %r14,%rcx
call   1080 <fwrite@plt>
jmp    1280 <main+0x120>
test   %eax,%eax
je     1280 <main+0x120>
mov    $0xa,%edi
mov    %r14,%rsi
call   1050 <fputc@plt>
movsbl %bl,%edi
mov    %r14,%rsi
call   1050 <fputc@plt>
xor    %r15d,%r15d
xor    %ebp,%ebp
jmp    1225 <main+0xc5>

LLVM IR (-O0):
@.str = [3 x i8] c"-h\00"
@.str.1 = [7 x i8] c"--help\00"
@.str.2 = [114 x i8] c"Insert <p> and </p> tags around every paragraph. Give me a file name, or I'll use stdin. Always writes to stdout.\00"
@.str.3 = [2 x i8] c"r\00"
@stdin = global i32* null
@stdout = global i32* null
@EOF = global i8 0
@.str.4 = [10 x i8] c"</p>\0A\0A<p>\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i8
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i32, i32* %4
%12 = icmp sgt i32 %11, 2
br i1 %12, label %13, label %27
13: ; preds = %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
%17 = call i32 @strcmp(i8* %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %25
19: ; preds = %13
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 1
%22 = load i8*, i8** %21
%23 = call i32 @strcmp(i8* %22, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%24 = icmp ne i32 %23, 0
br i1 %24, label %27, label %25
25: ; preds = %19, %13
%26 = call i32 @printf(i8* getelementptr inbounds ([114 x i8], [114 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %3
br label %85
27: ; preds = %19, %2
%28 = load i32, i32* %4
%29 = icmp eq i32 %28, 2
br i1 %29, label %30, label %35
30: ; preds = %27
%31 = load i8**, i8*** %5
%32 = getelementptr inbounds i8*, i8** %31, i64 1
%33 = load i8*, i8** %32
%34 = call i32* @fopen(i8* %33, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %37
35: ; preds = %27
%36 = load i32*, i32** @stdin
br label %37
37: ; preds = %35, %30
%38 = phi i32* [ %34, %30 ], [ %36, %35 ]
store i32* %38, i32** %6
%39 = load i32*, i32** @stdout
store i32* %39, i32** %7
store i32 0, i32* %9
store i32 0, i32* %10
br label %40
40: ; preds = %81, %37
%41 = load i32*, i32** %6
%42 = call signext i8 @fgetc(i32* %41)
store i8 %42, i8* %8
%43 = sext i8 %42 to i32
%44 = load i8, i8* @EOF
%45 = sext i8 %44 to i32
%46 = icmp ne i32 %43, %45
br i1 %46, label %47, label %82
47: ; preds = %40
%48 = load i8, i8* %8
%49 = sext i8 %48 to i32
%50 = icmp eq i32 %49, 10
br i1 %50, label %51, label %55
51: ; preds = %47
%52 = load i32, i32* %9
%53 = icmp ne i32 %52, 0
br i1 %53, label %54, label %55
54: ; preds = %51
store i32 1, i32* %10
br label %81
55: ; preds = %51, %47
%56 = load i8, i8* %8
%57 = sext i8 %56 to i32
%58 = icmp eq i32 %57, 10
br i1 %58, label %59, label %63
59: ; preds = %55
%60 = load i32, i32* %9
%61 = icmp ne i32 %60, 0
br i1 %61, label %63, label %62
62: ; preds = %59
store i32 1, i32* %9
br label %80
63: ; preds = %59, %55
%64 = load i32, i32* %10
%65 = icmp ne i32 %64, 0
br i1 %65, label %66, label %69
66: ; preds = %63
%67 = load i32*, i32** %7
%68 = call i32 @fprintf(i32* %67, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
br label %76
69: ; preds = %63
%70 = load i32, i32* %9
%71 = icmp ne i32 %70, 0
br i1 %71, label %72, label %75
72: ; preds = %69
%73 = load i32*, i32** %7
%74 = call i32 @fputc(i8 signext 10, i32* %73)
br label %75
75: ; preds = %72, %69
br label %76
76: ; preds = %75, %66
%77 = load i8, i8* %8
%78 = load i32*, i32** %7
%79 = call i32 @fputc(i8 signext %77, i32* %78)
store i32 0, i32* %9
store i32 0, i32* %10
br label %80
80: ; preds = %76, %62
br label %81
81: ; preds = %80, %54
br label %40
82: ; preds = %40
%83 = load i32*, i32** %7
%84 = call i32 @fputc(i8 signext 10, i32* %83)
br label %85
85: ; preds = %82, %25
%86 = load i32, i32* %3
ret i32 %86
}

LLVM IR (-O2):
@.str = [3 x i8] c"-h\00"
@.str.1 = [7 x i8] c"--help\00"
@.str.2 = [114 x i8] c"Insert <p> and </p> tags around every paragraph. Give me a file name, or I'll use stdin. Always writes to stdout.\00"
@.str.3 = [2 x i8] c"r\00"
@stdin = global i32* null
@stdout = global i32* null
@EOF = global i8 0
@.str.4 = [10 x i8] c"</p>\0A\0A<p>\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 2
br i1 %3, label %4, label %14
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i32 @strcmp(i8* dereferenceable(1) %6, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i32 %7, 0
br i1 %8, label %12, label %9
9: ; preds = %4
%10 = tail call i32 @strcmp(i8* dereferenceable(1) %6, i8* dereferenceable(7) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %20
12: ; preds = %9, %4
%13 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([114 x i8], [114 x i8]* @.str.2, i64 0, i64 0))
br label %55
14: ; preds = %2
%15 = icmp eq i32 %0, 2
br i1 %15, label %16, label %20
16: ; preds = %14
%17 = getelementptr inbounds i8*, i8** %1, i64 1
%18 = load i8*, i8** %17
%19 = tail call i32* @fopen(i8* %18, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %22
20: ; preds = %9, %14
%21 = load i32*, i32** @stdin
br label %22
22: ; preds = %20, %16
%23 = phi i32* [ %19, %16 ], [ %21, %20 ]
%24 = load i32*, i32** @stdout
%25 = tail call signext i8 @fgetc(i32* %23)
%26 = load i8, i8* @EOF
%27 = icmp eq i8 %25, %26
br i1 %27, label %53, label %28
28: ; preds = %22, %47
%29 = phi i8 [ %50, %47 ], [ %25, %22 ]
%30 = phi i32 [ %49, %47 ], [ 0, %22 ]
%31 = phi i32 [ %48, %47 ], [ 0, %22 ]
%32 = icmp eq i8 %29, 10
%33 = icmp ne i32 %31, 0
%34 = and i1 %33, %32
br i1 %34, label %47, label %35
35: ; preds = %28
%36 = icmp ne i8 %29, 10
%37 = or i1 %33, %36
br i1 %37, label %38, label %47
38: ; preds = %35
%39 = icmp eq i32 %30, 0
br i1 %39, label %42, label %40
40: ; preds = %38
%41 = tail call i64 @fwrite(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i64 9, i64 1, i32* %24)
br label %45
42: ; preds = %38
br i1 %33, label %43, label %45
43: ; preds = %42
%44 = tail call i32 @fputc(i8 signext 10, i32* %24)
br label %45
45: ; preds = %42, %43, %40
%46 = tail call i32 @fputc(i8 signext %29, i32* %24)
br label %47
47: ; preds = %35, %28, %45
%48 = phi i32 [ 0, %45 ], [ 1, %28 ], [ 1, %35 ]
%49 = phi i32 [ 0, %45 ], [ 1, %28 ], [ %30, %35 ]
%50 = tail call signext i8 @fgetc(i32* %23)
%51 = load i8, i8* @EOF
%52 = icmp eq i8 %50, %51
br i1 %52, label %53, label %28
53: ; preds = %47, %22
%54 = tail call i32 @fputc(i8 signext 10, i32* %24)
br label %55
55: ; preds = %53, %12
ret i32 0
}