#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*/ putc(char, int /*<<< orphan*/ *);
void generate_name(FILE *output, const char *name) {
  while (name && *name != '\0') {
    int ch = (*name++ & 0xFF);
    if (ch != '.')
      putc(ch, output);
    else
      putc('_', output);
  }
}


x86 assembly (clang, -O0):
<generate_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x10(%rbp)
mov    %al,-0x15(%rbp)
je     1140 <generate_name+0x30>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x15(%rbp)
mov    -0x15(%rbp),%al
test   $0x1,%al
jne    1150 <generate_name+0x40>
jmp    119b <generate_name+0x8b>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movsbl (%rax),%eax
and    $0xff,%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x2e,-0x14(%rbp)
je     1188 <generate_name+0x78>
mov    -0x14(%rbp),%eax
mov    -0x8(%rbp),%rsi
movsbl %al,%edi
call   1030 <putc@plt>
jmp    1196 <generate_name+0x86>
mov    -0x8(%rbp),%rsi
mov    $0x5f,%edi
call   1030 <putc@plt>
jmp    1120 <generate_name+0x10>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<generate_name>:
push   %rbp
push   %r14
push   %rbx
test   %rsi,%rsi
je     114e <generate_name+0x3e>
mov    %rsi,%rbx
mov    (%rsi),%al
test   %al,%al
je     114e <generate_name+0x3e>
mov    %rdi,%r14
add    $0x1,%rbx
mov    $0x5f,%ebp
xchg   %ax,%ax
cmp    $0x2e,%al
movzbl %al,%eax
cmove  %ebp,%eax
movsbl %al,%edi
mov    %r14,%rsi
call   1030 <putc@plt>
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1130 <generate_name+0x20>
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define void @generate_name(i32* %0, i8* %1) {
%3 = alloca i32*
%4 = alloca i8*
%5 = alloca i32
store i32* %0, i32** %3
store i8* %1, i8** %4
br label %6
6: ; preds = %32, %2
%7 = load i8*, i8** %4
%8 = icmp ne i8* %7, null
br i1 %8, label %9, label %14
9: ; preds = %6
%10 = load i8*, i8** %4
%11 = load i8, i8* %10
%12 = sext i8 %11 to i32
%13 = icmp ne i32 %12, 0
br label %14
14: ; preds = %9, %6
%15 = phi i1 [ false, %6 ], [ %13, %9 ]
br i1 %15, label %16, label %33
16: ; preds = %14
%17 = load i8*, i8** %4
%18 = getelementptr inbounds i8, i8* %17, i32 1
store i8* %18, i8** %4
%19 = load i8, i8* %17
%20 = sext i8 %19 to i32
%21 = and i32 %20, 255
store i32 %21, i32* %5
%22 = load i32, i32* %5
%23 = icmp ne i32 %22, 46
br i1 %23, label %24, label %29
24: ; preds = %16
%25 = load i32, i32* %5
%26 = trunc i32 %25 to i8
%27 = load i32*, i32** %3
%28 = call i32 @putc(i8 signext %26, i32* %27)
br label %32
29: ; preds = %16
%30 = load i32*, i32** %3
%31 = call i32 @putc(i8 signext 95, i32* %30)
br label %32
32: ; preds = %29, %24
br label %6
33: ; preds = %14
ret void
}

LLVM IR (-O2):
define void @generate_name(i32* nocapture %0, i8* %1) {
%3 = icmp eq i8* %1, null
br i1 %3, label %16, label %4
4: ; preds = %2
%5 = load i8, i8* %1
%6 = icmp eq i8 %5, 0
br i1 %6, label %16, label %7
7: ; preds = %4, %7
%8 = phi i8 [ %14, %7 ], [ %5, %4 ]
%9 = phi i8* [ %10, %7 ], [ %1, %4 ]
%10 = getelementptr inbounds i8, i8* %9, i64 1
%11 = icmp eq i8 %8, 46
%12 = select i1 %11, i8 95, i8 %8
%13 = tail call i32 @putc(i8 signext %12, i32* %0)
%14 = load i8, i8* %10
%15 = icmp eq i8 %14, 0
br i1 %15, label %16, label %7
16: ; preds = %7, %4, %2
ret void
}