#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 */
char *_agstrcanon(char *, char *);
scalar_t__ aghtmlstr(char *);
char *agstrcanon(char *arg, char *buf) {
  char *s = arg;
  char *p = buf;
  if (aghtmlstr(arg)) {
    *p++ = '<';
    while (*s)
      *p++ = *s++;
    *p++ = '>';
    *p = '\0';
    return buf;
  } else
    return (_agstrcanon(arg, buf));
}


x86 assembly (clang, -O0):
<agstrcanon>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <aghtmlstr@plt>
cmp    $0x0,%rax
je     11bf <agstrcanon+0x9f>
mov    -0x28(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x28(%rbp)
movb   $0x3c,(%rax)
mov    -0x20(%rbp),%rax
cmpb   $0x0,(%rax)
je     1199 <agstrcanon+0x79>
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x20(%rbp)
mov    (%rax),%cl
mov    -0x28(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x28(%rbp)
mov    %cl,(%rax)
jmp    1165 <agstrcanon+0x45>
mov    -0x28(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x28(%rbp)
movb   $0x3e,(%rax)
mov    -0x28(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11d0 <agstrcanon+0xb0>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <_agstrcanon@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<agstrcanon>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
call   1040 <aghtmlstr@plt>
test   %rax,%rax
je     1167 <agstrcanon+0x47>
movb   $0x3c,(%r14)
lea    0x1(%r14),%rax
mov    (%rbx),%cl
test   %cl,%cl
je     1179 <agstrcanon+0x59>
add    $0x1,%rbx
cs nopw 0x0(%rax,%rax,1)
mov    %cl,(%rax)
add    $0x1,%rax
movzbl (%rbx),%ecx
add    $0x1,%rbx
test   %cl,%cl
jne    1150 <agstrcanon+0x30>
lea    -0x1(%rax),%rcx
jmp    117c <agstrcanon+0x5c>
mov    %rbx,%rdi
mov    %r14,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <_agstrcanon@plt>
mov    %r14,%rcx
movb   $0x3e,(%rax)
movb   $0x0,0x2(%rcx)
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i8* @agstrcanon(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
%8 = load i8*, i8** %4
store i8* %8, i8** %6
%9 = load i8*, i8** %5
store i8* %9, i8** %7
%10 = load i8*, i8** %4
%11 = call i64 @aghtmlstr(i8* %10)
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %31
13: ; preds = %2
%14 = load i8*, i8** %7
%15 = getelementptr inbounds i8, i8* %14, i32 1
store i8* %15, i8** %7
store i8 60, i8* %14
br label %16
16: ; preds = %20, %13
%17 = load i8*, i8** %6
%18 = load i8, i8* %17
%19 = icmp ne i8 %18, 0
br i1 %19, label %20, label %26
20: ; preds = %16
%21 = load i8*, i8** %6
%22 = getelementptr inbounds i8, i8* %21, i32 1
store i8* %22, i8** %6
%23 = load i8, i8* %21
%24 = load i8*, i8** %7
%25 = getelementptr inbounds i8, i8* %24, i32 1
store i8* %25, i8** %7
store i8 %23, i8* %24
br label %16
26: ; preds = %16
%27 = load i8*, i8** %7
%28 = getelementptr inbounds i8, i8* %27, i32 1
store i8* %28, i8** %7
store i8 62, i8* %27
%29 = load i8*, i8** %7
store i8 0, i8* %29
%30 = load i8*, i8** %5
store i8* %30, i8** %3
br label %35
31: ; preds = %2
%32 = load i8*, i8** %4
%33 = load i8*, i8** %5
%34 = call i8* @_agstrcanon(i8* %32, i8* %33)
store i8* %34, i8** %3
br label %35
35: ; preds = %31, %26
%36 = load i8*, i8** %3
ret i8* %36
}

LLVM IR (-O2):
define i8* @agstrcanon(i8* %0, i8* %1) {
%3 = tail call i64 @aghtmlstr(i8* %0)
%4 = icmp eq i64 %3, 0
br i1 %4, label %21, label %5
5: ; preds = %2
store i8 60, i8* %1
%6 = getelementptr inbounds i8, i8* %1, i64 1
%7 = load i8, i8* %0
%8 = icmp eq i8 %7, 0
br i1 %8, label %17, label %9
9: ; preds = %5, %9
%10 = phi i8 [ %15, %9 ], [ %7, %5 ]
%11 = phi i8* [ %14, %9 ], [ %6, %5 ]
%12 = phi i8* [ %13, %9 ], [ %0, %5 ]
%13 = getelementptr inbounds i8, i8* %12, i64 1
store i8 %10, i8* %11
%14 = getelementptr inbounds i8, i8* %11, i64 1
%15 = load i8, i8* %13
%16 = icmp eq i8 %15, 0
br i1 %16, label %17, label %9
17: ; preds = %9, %5
%18 = phi i8* [ %1, %5 ], [ %11, %9 ]
%19 = phi i8* [ %6, %5 ], [ %14, %9 ]
%20 = getelementptr inbounds i8, i8* %18, i64 2
store i8 62, i8* %19
store i8 0, i8* %20
br label %23
21: ; preds = %2
%22 = tail call i8* @_agstrcanon(i8* %0, i8* %1)
br label %23
23: ; preds = %21, %17
%24 = phi i8* [ %1, %17 ], [ %22, %21 ]
ret i8* %24
}