#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 */
int /*<<< orphan*/ toupper(char);
void genGuard(char *filename, char *guard) {
  char c;
  while ((c = *filename++)) {
    if (c == '.')
      *guard++ = '_';
    else
      *guard++ = toupper(c);
  }
  *guard = '\0';
}


x86 assembly (clang, -O0):
<genGuard>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
mov    (%rax),%al
mov    %al,-0x11(%rbp)
cmp    $0x0,%al
je     1181 <genGuard+0x71>
movsbl -0x11(%rbp),%eax
cmp    $0x2e,%eax
jne    1160 <genGuard+0x50>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movb   $0x5f,(%rax)
jmp    117c <genGuard+0x6c>
movsbl -0x11(%rbp),%edi
call   1030 <toupper@plt>
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x10(%rbp)
mov    %cl,(%rax)
jmp    1120 <genGuard+0x10>
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<genGuard>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
xor    %ebx,%ebx
jmp    1128 <genGuard+0x18>
nop
mov    %al,(%r14,%rbx,1)
add    $0x1,%rbx
movzbl (%r15,%rbx,1),%ecx
mov    $0x5f,%al
cmp    $0x2e,%cl
je     1120 <genGuard+0x10>
test   %cl,%cl
je     1142 <genGuard+0x32>
movsbl %cl,%edi
call   1030 <toupper@plt>
jmp    1120 <genGuard+0x10>
movb   $0x0,(%r14,%rbx,1)
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @genGuard(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8
store i8* %0, i8** %3
store i8* %1, i8** %4
br label %6
6: ; preds = %24, %2
%7 = load i8*, i8** %3
%8 = getelementptr inbounds i8, i8* %7, i32 1
store i8* %8, i8** %3
%9 = load i8, i8* %7
store i8 %9, i8* %5
%10 = icmp ne i8 %9, 0
br i1 %10, label %11, label %25
11: ; preds = %6
%12 = load i8, i8* %5
%13 = sext i8 %12 to i32
%14 = icmp eq i32 %13, 46
br i1 %14, label %15, label %18
15: ; preds = %11
%16 = load i8*, i8** %4
%17 = getelementptr inbounds i8, i8* %16, i32 1
store i8* %17, i8** %4
store i8 95, i8* %16
br label %24
18: ; preds = %11
%19 = load i8, i8* %5
%20 = call i32 @toupper(i8 signext %19)
%21 = trunc i32 %20 to i8
%22 = load i8*, i8** %4
%23 = getelementptr inbounds i8, i8* %22, i32 1
store i8* %23, i8** %4
store i8 %21, i8* %22
br label %24
24: ; preds = %18, %15
br label %6
25: ; preds = %6
%26 = load i8*, i8** %4
store i8 0, i8* %26
ret void
}

LLVM IR (-O2):
define void @genGuard(i8* nocapture %0, i8* nocapture writeonly %1) {
br label %3
3: ; preds = %11, %2
%4 = phi i8* [ %1, %2 ], [ %13, %11 ]
%5 = phi i8* [ %0, %2 ], [ %6, %11 ]
%6 = getelementptr inbounds i8, i8* %5, i64 1
%7 = load i8, i8* %5
switch i8 %7, label %8 [
i8 0, label %14
i8 46, label %11
]
8: ; preds = %3
%9 = tail call i32 @toupper(i8 signext %7)
%10 = trunc i32 %9 to i8
br label %11
11: ; preds = %3, %8
%12 = phi i8 [ %10, %8 ], [ 95, %3 ]
%13 = getelementptr inbounds i8, i8* %4, i64 1
store i8 %12, i8* %4
br label %3
14: ; preds = %3
store i8 0, i8* %4
ret void
}