#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 */
struct html {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ bufncat(struct html *, char *, int);
void bufcat_id(struct html *h, const char *src) {
  for (; '\0' != *src; src++)
    bufncat(h, *src == ' ' ? "_" : src, 1);
}


x86 assembly (clang, -O0):
<bufcat_id>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    %ecx,%eax
je     1184 <bufcat_id+0x74>
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
jne    1159 <bufcat_id+0x49>
lea    0xeb0(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    1161 <bufcat_id+0x51>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    $0x1,%edx
call   1030 <bufncat@plt>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1120 <bufcat_id+0x10>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bufcat_id>:
push   %r15
push   %r14
push   %rbx
mov    (%rsi),%al
test   %al,%al
je     1155 <bufcat_id+0x45>
mov    %rsi,%rbx
mov    %rdi,%r14
lea    0xed8(%rip),%r15
jmp    1149 <bufcat_id+0x39>
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    $0x1,%edx
call   1030 <bufncat@plt>
movzbl 0x1(%rbx),%eax
add    $0x1,%rbx
test   %al,%al
je     1155 <bufcat_id+0x45>
mov    %r15,%rsi
cmp    $0x20,%al
je     1130 <bufcat_id+0x20>
mov    %rbx,%rsi
jmp    1130 <bufcat_id+0x20>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.html = type { i32 }
@.str = [2 x i8] c"_\00"
define void @bufcat_id(%struct.html* %0, i8* %1) {
%3 = alloca %struct.html*
%4 = alloca i8*
store %struct.html* %0, %struct.html** %3
store i8* %1, i8** %4
br label %5
5: ; preds = %22, %2
%6 = load i8*, i8** %4
%7 = load i8, i8* %6
%8 = sext i8 %7 to i32
%9 = icmp ne i32 0, %8
br i1 %9, label %10, label %25
10: ; preds = %5
%11 = load %struct.html*, %struct.html** %3
%12 = load i8*, i8** %4
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
%15 = icmp eq i32 %14, 32
br i1 %15, label %16, label %17
16: ; preds = %10
br label %19
17: ; preds = %10
%18 = load i8*, i8** %4
br label %19
19: ; preds = %17, %16
%20 = phi i8* [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), %16 ], [ %18, %17 ]
%21 = call i32 @bufncat(%struct.html* %11, i8* %20, i32 1)
br label %22
22: ; preds = %19
%23 = load i8*, i8** %4
%24 = getelementptr inbounds i8, i8* %23, i32 1
store i8* %24, i8** %4
br label %5
25: ; preds = %5
ret void
}

LLVM IR (-O2):
%struct.html = type { i32 }
@.str = [2 x i8] c"_\00"
define void @bufcat_id(%struct.html* %0, i8* %1) {
%3 = load i8, i8* %1
%4 = icmp eq i8 %3, 0
br i1 %4, label %14, label %5
5: ; preds = %2, %5
%6 = phi i8 [ %12, %5 ], [ %3, %2 ]
%7 = phi i8* [ %11, %5 ], [ %1, %2 ]
%8 = icmp eq i8 %6, 32
%9 = select i1 %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8* %7
%10 = tail call i32 @bufncat(%struct.html* %0, i8* %9, i32 1)
%11 = getelementptr inbounds i8, i8* %7, i64 1
%12 = load i8, i8* %11
%13 = icmp eq i8 %12, 0
br i1 %13, label %14, label %5
14: ; preds = %5, %2
ret void
}