#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*/ printf(char *, char const);
int /*<<< orphan*/ putchar(char const);
void print_userid(const char *id) {
  for (; id && *id; id++) {
    if (*id >= ' ' && *id <= 'z' && *id != ':')
      putchar(*id);
    else
      printf("\\x%02x", (*id) & 0xff);
  }
}


x86 assembly (clang, -O0):
<print_userid>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x8(%rbp)
mov    %al,-0x9(%rbp)
je     114c <print_userid+0x2c>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x9(%rbp)
mov    -0x9(%rbp),%al
test   $0x1,%al
jne    115c <print_userid+0x3c>
jmp    11ce <print_userid+0xae>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
jl     119d <print_userid+0x7d>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x7a,%eax
jg     119d <print_userid+0x7d>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x3a,%eax
je     119d <print_userid+0x7d>
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1030 <putchar@plt>
jmp    11b8 <print_userid+0x98>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
and    $0xff,%eax
lea    0xe50(%rip),%rdi
movsbl %al,%esi
call   1040 <printf@plt>
jmp    11bd <print_userid+0x9d>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    112c <print_userid+0xc>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_userid>:
push   %r14
push   %rbx
push   %rax
test   %rdi,%rdi
je     1169 <print_userid+0x49>
mov    %rdi,%rbx
mov    (%rdi),%al
test   %al,%al
je     1169 <print_userid+0x49>
add    $0x1,%rbx
lea    0xec3(%rip),%r14
jmp    1153 <print_userid+0x33>
nop
mov    %r14,%rdi
call   1040 <printf@plt>
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
je     1169 <print_userid+0x49>
movsbl %al,%esi
cmp    $0x3a,%al
je     1140 <print_userid+0x20>
add    $0x85,%al
cmp    $0xa5,%al
jb     1140 <print_userid+0x20>
mov    %esi,%edi
call   1030 <putchar@plt>
jmp    1148 <print_userid+0x28>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [7 x i8] c"\\x%02x\00"
define void @print_userid(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
br label %3
3: ; preds = %40, %1
%4 = load i8*, i8** %2
%5 = icmp ne i8* %4, null
br i1 %5, label %6, label %11
6: ; preds = %3
%7 = load i8*, i8** %2
%8 = load i8, i8* %7
%9 = sext i8 %8 to i32
%10 = icmp ne i32 %9, 0
br label %11
11: ; preds = %6, %3
%12 = phi i1 [ false, %3 ], [ %10, %6 ]
br i1 %12, label %13, label %43
13: ; preds = %11
%14 = load i8*, i8** %2
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp sge i32 %16, 32
br i1 %17, label %18, label %32
18: ; preds = %13
%19 = load i8*, i8** %2
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = icmp sle i32 %21, 122
br i1 %22, label %23, label %32
23: ; preds = %18
%24 = load i8*, i8** %2
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp ne i32 %26, 58
br i1 %27, label %28, label %32
28: ; preds = %23
%29 = load i8*, i8** %2
%30 = load i8, i8* %29
%31 = call i32 @putchar(i8 signext %30)
br label %39
32: ; preds = %23, %18, %13
%33 = load i8*, i8** %2
%34 = load i8, i8* %33
%35 = sext i8 %34 to i32
%36 = and i32 %35, 255
%37 = trunc i32 %36 to i8
%38 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8 signext %37)
br label %39
39: ; preds = %32, %28
br label %40
40: ; preds = %39
%41 = load i8*, i8** %2
%42 = getelementptr inbounds i8, i8* %41, i32 1
store i8* %42, i8** %2
br label %3
43: ; preds = %11
ret void
}

LLVM IR (-O2):
@.str = [7 x i8] c"\\x%02x\00"
define void @print_userid(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %21, label %3
3: ; preds = %1
%4 = load i8, i8* %0
%5 = icmp eq i8 %4, 0
br i1 %5, label %21, label %6
6: ; preds = %3, %17
%7 = phi i8 [ %19, %17 ], [ %4, %3 ]
%8 = phi i8* [ %18, %17 ], [ %0, %3 ]
%9 = add i8 %7, -123
%10 = icmp ult i8 %9, -91
%11 = icmp eq i8 %7, 58
%12 = or i1 %11, %10
br i1 %12, label %15, label %13
13: ; preds = %6
%14 = tail call i32 @putchar(i8 signext %7)
br label %17
15: ; preds = %6
%16 = tail call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8 signext %7)
br label %17
17: ; preds = %13, %15
%18 = getelementptr inbounds i8, i8* %8, i64 1
%19 = load i8, i8* %18
%20 = icmp eq i8 %19, 0
br i1 %20, label %21, label %6
21: ; preds = %17, %3, %1
ret void
}