#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 */
scalar_t__ isalnum(char);
scalar_t__ isdigit(char);
int /*<<< orphan*/ printf(char *, ...);
void print_escaped_path(char *path) {
  if (isdigit(*path)) {
    printf("__");
  }
  for (; *path != '\0'; ++path) {
    printf("%c", isalnum(*path) ? *path : '_');
  }
}


x86 assembly (clang, -O0):
<print_escaped_path>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
je     1160 <print_escaped_path+0x30>
lea    0xea7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1165 <print_escaped_path+0x35>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11c9 <print_escaped_path+0x99>
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1050 <isalnum@plt>
cmp    $0x0,%rax
je     119a <print_escaped_path+0x6a>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0xc(%rbp)
jmp    11a7 <print_escaped_path+0x77>
mov    $0x5f,%eax
mov    %eax,-0xc(%rbp)
jmp    11a7 <print_escaped_path+0x77>
mov    -0xc(%rbp),%esi
lea    0xe52(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1165 <print_escaped_path+0x35>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_escaped_path>:
push   %rbx
mov    %rdi,%rbx
movsbl (%rdi),%edi
call   1040 <isdigit@plt>
test   %rax,%rax
je     115f <print_escaped_path+0x1f>
lea    0xea8(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    (%rbx),%al
test   %al,%al
je     1198 <print_escaped_path+0x58>
add    $0x1,%rbx
jmp    1184 <print_escaped_path+0x44>
nopl   0x0(%rax,%rax,1)
movsbl -0x1(%rbx),%edi
call   1030 <putchar@plt>
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
je     1198 <print_escaped_path+0x58>
movsbl %al,%edi
call   1060 <isalnum@plt>
test   %rax,%rax
jne    1170 <print_escaped_path+0x30>
mov    $0x5f,%edi
jmp    1174 <print_escaped_path+0x34>
pop    %rbx
ret

LLVM IR (-O0):
@.str = [3 x i8] c"__\00"
@.str.1 = [3 x i8] c"%c\00"
define void @print_escaped_path(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i8*, i8** %2
%4 = load i8, i8* %3
%5 = call i64 @isdigit(i8 signext %4)
%6 = icmp ne i64 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %1
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %9
9: ; preds = %7, %1
br label %10
10: ; preds = %28, %9
%11 = load i8*, i8** %2
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %31
15: ; preds = %10
%16 = load i8*, i8** %2
%17 = load i8, i8* %16
%18 = call i64 @isalnum(i8 signext %17)
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %24
20: ; preds = %15
%21 = load i8*, i8** %2
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
br label %25
24: ; preds = %15
br label %25
25: ; preds = %24, %20
%26 = phi i32 [ %23, %20 ], [ 95, %24 ]
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %26)
br label %28
28: ; preds = %25
%29 = load i8*, i8** %2
%30 = getelementptr inbounds i8, i8* %29, i32 1
store i8* %30, i8** %2
br label %10
31: ; preds = %10
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"__\00"
define void @print_escaped_path(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = tail call i64 @isdigit(i8 signext %2)
%4 = icmp eq i64 %3, 0
br i1 %4, label %7, label %5
5: ; preds = %1
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %7
7: ; preds = %5, %1
%8 = load i8, i8* %0
%9 = icmp eq i8 %8, 0
br i1 %9, label %24, label %10
10: ; preds = %7, %18
%11 = phi i8 [ %22, %18 ], [ %8, %7 ]
%12 = phi i8* [ %21, %18 ], [ %0, %7 ]
%13 = tail call i64 @isalnum(i8 signext %11)
%14 = icmp eq i64 %13, 0
br i1 %14, label %18, label %15
15: ; preds = %10
%16 = load i8, i8* %12
%17 = sext i8 %16 to i32
br label %18
18: ; preds = %10, %15
%19 = phi i32 [ %17, %15 ], [ 95, %10 ]
%20 = tail call i32 @putchar(i32 %19)
%21 = getelementptr inbounds i8, i8* %12, i64 1
%22 = load i8, i8* %21
%23 = icmp eq i8 %22, 0
br i1 %23, label %24, label %10
24: ; preds = %18, %7
ret void
}