#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 */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char *, char *);
char *strstr(char *, char *);
int refLine(char *line, FILE *out) {
  char *ref;
  ref = strstr(line, "REF:");
  if (ref) {
    ref += 4;
    fprintf(out, "<div>REF: <a href=\"%s\">%s</a></div>\n", ref, ref);
    return 1;
  } else {
    return 0;
  }
}


x86 assembly (clang, -O0):
<refLine>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xec5(%rip),%rsi
call   1040 <strstr@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     117f <refLine+0x5f>
mov    -0x20(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    -0x20(%rbp),%rcx
lea    0xe97(%rip),%rsi
call   1030 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1186 <refLine+0x66>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<refLine>:
push   %rbx
mov    %rsi,%rbx
lea    0xed5(%rip),%rsi
call   1040 <strstr@plt>
test   %rax,%rax
je     1155 <refLine+0x35>
add    $0x4,%rax
lea    0xec5(%rip),%rsi
mov    %rbx,%rdi
mov    %rax,%rdx
mov    %rax,%rcx
call   1030 <fprintf@plt>
mov    $0x1,%eax
pop    %rbx
ret
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [5 x i8] c"REF:\00"
@.str.1 = [37 x i8] c"<div>REF: <a href=\22%s\22>%s</a></div>\0A\00"
define i32 @refLine(i8* %0, i32* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca i8*
store i8* %0, i8** %4
store i32* %1, i32** %5
%7 = load i8*, i8** %4
%8 = call i8* @strstr(i8* %7, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i8* %8, i8** %6
%9 = load i8*, i8** %6
%10 = icmp ne i8* %9, null
br i1 %10, label %11, label %18
11: ; preds = %2
%12 = load i8*, i8** %6
%13 = getelementptr inbounds i8, i8* %12, i64 4
store i8* %13, i8** %6
%14 = load i32*, i32** %5
%15 = load i8*, i8** %6
%16 = load i8*, i8** %6
%17 = call i32 @fprintf(i32* %14, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i8* %15, i8* %16)
store i32 1, i32* %3
br label %19
18: ; preds = %2
store i32 0, i32* %3
br label %19
19: ; preds = %18, %11
%20 = load i32, i32* %3
ret i32 %20
}

LLVM IR (-O2):
@.str = [5 x i8] c"REF:\00"
@.str.1 = [37 x i8] c"<div>REF: <a href=\22%s\22>%s</a></div>\0A\00"
define i32 @refLine(i8* %0, i32* nocapture %1) {
%3 = tail call i8* @strstr(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i8* %3, null
br i1 %4, label %8, label %5
5: ; preds = %2
%6 = getelementptr inbounds i8, i8* %3, i64 4
%7 = tail call i32 @fprintf(i32* %1, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i8* %6, i8* %6)
br label %8
8: ; preds = %2, %5
%9 = phi i32 [ 1, %5 ], [ 0, %2 ]
ret i32 %9
}