#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 */
scalar_t__ isalpha(char);
scalar_t__ isdigit(char);
int /*<<< orphan*/ putc(char, int /*<<< orphan*/ *);
char tolower(int /*<<< orphan*/);
char toupper(char);
void printre(FILE *f, char *re) {
  while (*re)
    if (isalpha(*re)) {
      putc('[', f);
      putc(toupper(*re), f);
      putc(tolower(*re++), f);
      putc(']', f);
    } else if (isdigit(*re))
      putc(*re++, f);
    else {
      putc('\\', f);
      putc(*re++, f);
    }
}


x86 assembly (clang, -O0):
<printre>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
je     124c <printre+0xfc>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1070 <isalpha@plt>
cmp    $0x0,%rax
je     11df <printre+0x8f>
mov    -0x8(%rbp),%rsi
mov    $0x5b,%edi
call   1050 <putc@plt>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1040 <toupper@plt>
mov    -0x8(%rbp),%rsi
movsbl %al,%edi
call   1050 <putc@plt>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movsbl (%rax),%edi
call   1060 <tolower@plt>
mov    -0x8(%rbp),%rsi
movsbl %al,%edi
call   1050 <putc@plt>
mov    -0x8(%rbp),%rsi
mov    $0x5d,%edi
call   1050 <putc@plt>
jmp    1247 <printre+0xf7>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
je     1217 <printre+0xc7>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
mov    (%rax),%al
mov    -0x8(%rbp),%rsi
movsbl %al,%edi
call   1050 <putc@plt>
jmp    1242 <printre+0xf2>
mov    -0x8(%rbp),%rsi
mov    $0x5c,%edi
call   1050 <putc@plt>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
mov    (%rax),%al
mov    -0x8(%rbp),%rsi
movsbl %al,%edi
call   1050 <putc@plt>
jmp    1247 <printre+0xf7>
jmp    1160 <printre+0x10>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printre>:
push   %r14
push   %rbx
push   %rax
mov    (%rsi),%al
test   %al,%al
je     11e8 <printre+0x98>
mov    %rsi,%rbx
mov    %rdi,%r14
jmp    11bc <printre+0x6c>
cs nopw 0x0(%rax,%rax,1)
mov    $0x5b,%edi
mov    %r14,%rsi
call   1050 <putc@plt>
movsbl (%rbx),%edi
call   1040 <toupper@plt>
movsbl %al,%edi
mov    %r14,%rsi
call   1050 <putc@plt>
movsbl (%rbx),%edi
call   1060 <tolower@plt>
movsbl %al,%edi
mov    %r14,%rsi
call   1050 <putc@plt>
mov    $0x5d,%al
movsbl %al,%edi
mov    %r14,%rsi
call   1050 <putc@plt>
movzbl 0x1(%rbx),%eax
add    $0x1,%rbx
test   %al,%al
je     11e8 <printre+0x98>
movsbl %al,%edi
call   1070 <isalpha@plt>
test   %rax,%rax
jne    1170 <printre+0x20>
movsbl (%rbx),%edi
call   1030 <isdigit@plt>
test   %rax,%rax
jne    11e3 <printre+0x93>
mov    $0x5c,%edi
mov    %r14,%rsi
call   1050 <putc@plt>
movzbl (%rbx),%eax
jmp    11a5 <printre+0x55>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @printre(i32* %0, i8* %1) {
%3 = alloca i32*
%4 = alloca i8*
store i32* %0, i32** %3
store i8* %1, i8** %4
br label %5
5: ; preds = %51, %2
%6 = load i8*, i8** %4
%7 = load i8, i8* %6
%8 = icmp ne i8 %7, 0
br i1 %8, label %9, label %52
9: ; preds = %5
%10 = load i8*, i8** %4
%11 = load i8, i8* %10
%12 = call i64 @isalpha(i8 signext %11)
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %31
14: ; preds = %9
%15 = load i32*, i32** %3
%16 = call i32 @putc(i8 signext 91, i32* %15)
%17 = load i8*, i8** %4
%18 = load i8, i8* %17
%19 = call signext i8 @toupper(i8 signext %18)
%20 = load i32*, i32** %3
%21 = call i32 @putc(i8 signext %19, i32* %20)
%22 = load i8*, i8** %4
%23 = getelementptr inbounds i8, i8* %22, i32 1
store i8* %23, i8** %4
%24 = load i8, i8* %22
%25 = sext i8 %24 to i32
%26 = call signext i8 @tolower(i32 %25)
%27 = load i32*, i32** %3
%28 = call i32 @putc(i8 signext %26, i32* %27)
%29 = load i32*, i32** %3
%30 = call i32 @putc(i8 signext 93, i32* %29)
br label %51
31: ; preds = %9
%32 = load i8*, i8** %4
%33 = load i8, i8* %32
%34 = call i64 @isdigit(i8 signext %33)
%35 = icmp ne i64 %34, 0
br i1 %35, label %36, label %42
36: ; preds = %31
%37 = load i8*, i8** %4
%38 = getelementptr inbounds i8, i8* %37, i32 1
store i8* %38, i8** %4
%39 = load i8, i8* %37
%40 = load i32*, i32** %3
%41 = call i32 @putc(i8 signext %39, i32* %40)
br label %50
42: ; preds = %31
%43 = load i32*, i32** %3
%44 = call i32 @putc(i8 signext 92, i32* %43)
%45 = load i8*, i8** %4
%46 = getelementptr inbounds i8, i8* %45, i32 1
store i8* %46, i8** %4
%47 = load i8, i8* %45
%48 = load i32*, i32** %3
%49 = call i32 @putc(i8 signext %47, i32* %48)
br label %50
50: ; preds = %42, %36
br label %51
51: ; preds = %50, %14
br label %5
52: ; preds = %5
ret void
}

LLVM IR (-O2):
define void @printre(i32* nocapture %0, i8* nocapture %1) {
%3 = load i8, i8* %1
%4 = icmp eq i8 %3, 0
br i1 %4, label %34, label %5
5: ; preds = %2, %28
%6 = phi i8 [ %32, %28 ], [ %3, %2 ]
%7 = phi i8* [ %31, %28 ], [ %1, %2 ]
%8 = tail call i64 @isalpha(i8 signext %6)
%9 = icmp eq i64 %8, 0
br i1 %9, label %19, label %10
10: ; preds = %5
%11 = tail call i32 @putc(i8 signext 91, i32* %0)
%12 = load i8, i8* %7
%13 = tail call signext i8 @toupper(i8 signext %12)
%14 = tail call i32 @putc(i8 signext %13, i32* %0)
%15 = load i8, i8* %7
%16 = sext i8 %15 to i32
%17 = tail call signext i8 @tolower(i32 %16)
%18 = tail call i32 @putc(i8 signext %17, i32* %0)
br label %28
19: ; preds = %5
%20 = load i8, i8* %7
%21 = tail call i64 @isdigit(i8 signext %20)
%22 = icmp eq i64 %21, 0
br i1 %22, label %25, label %23
23: ; preds = %19
%24 = load i8, i8* %7
br label %28
25: ; preds = %19
%26 = tail call i32 @putc(i8 signext 92, i32* %0)
%27 = load i8, i8* %7
br label %28
28: ; preds = %23, %25, %10
%29 = phi i8 [ %24, %23 ], [ %27, %25 ], [ 93, %10 ]
%30 = tail call i32 @putc(i8 signext %29, i32* %0)
%31 = getelementptr inbounds i8, i8* %7, i64 1
%32 = load i8, i8* %31
%33 = icmp eq i8 %32, 0
br i1 %33, label %34, label %5
34: ; preds = %28, %2
ret void
}