#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*/ outc(char);
void decodestr(const char *str) {
  register char ch;
  int n;
  while ((ch = *str++) != '\0')
    if (ch != '\01')
      outc(ch);
    else if (*str != '\0' && str[1] != '\0') {
      ch = *str++;
      n = *str++;
      while (--n >= 0)
        outc(ch);
    }
}


x86 assembly (clang, -O0):
<decodestr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
mov    (%rax),%al
mov    %al,-0x9(%rbp)
movsbl %al,%eax
cmp    $0x0,%eax
je     11d0 <decodestr+0xc0>
movsbl -0x9(%rbp),%eax
cmp    $0x1,%eax
je     1157 <decodestr+0x47>
movsbl -0x9(%rbp),%edi
call   1030 <outc@plt>
jmp    11cb <decodestr+0xbb>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11c6 <decodestr+0xb6>
mov    -0x8(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x0,%eax
je     11c6 <decodestr+0xb6>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
mov    (%rax),%al
mov    %al,-0x9(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movsbl (%rax),%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x10(%rbp)
cmp    $0x0,%eax
jl     11c1 <decodestr+0xb1>
movsbl -0x9(%rbp),%edi
call   1030 <outc@plt>
jmp    11a1 <decodestr+0x91>
jmp    11c6 <decodestr+0xb6>
jmp    11cb <decodestr+0xbb>
jmp    111c <decodestr+0xc>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<decodestr>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
nopw   0x0(%rax,%rax,1)
mov    %r14,%r15
add    $0x1,%r14
mov    (%r15),%al
cmp    $0x1,%al
je     1140 <decodestr+0x30>
test   %al,%al
je     1175 <decodestr+0x65>
movsbl %al,%edi
call   1030 <outc@plt>
jmp    1120 <decodestr+0x10>
nopl   0x0(%rax)
mov    (%r14),%bl
test   %bl,%bl
je     1120 <decodestr+0x10>
movzbl 0x2(%r15),%ebp
test   %ebp,%ebp
je     1120 <decodestr+0x10>
add    $0x3,%r15
mov    %r15,%r14
test   %bpl,%bpl
jle    1120 <decodestr+0x10>
add    $0x1,%ebp
nop
movsbl %bl,%edi
call   1030 <outc@plt>
add    $0xffffffff,%ebp
cmp    $0x1,%ebp
ja     1160 <decodestr+0x50>
mov    %r15,%r14
jmp    1120 <decodestr+0x10>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @decodestr(i8* nocapture %0) {
br label %2
2: ; preds = %18, %1
%3 = phi i8* [ %0, %1 ], [ %19, %18 ]
%4 = getelementptr inbounds i8, i8* %3, i64 1
%5 = load i8, i8* %3
switch i8 %5, label %6 [
i8 0, label %27
i8 1, label %8
]
6: ; preds = %2
%7 = tail call i32 @outc(i8 signext %5)
br label %18
8: ; preds = %2
%9 = load i8, i8* %4
%10 = icmp eq i8 %9, 0
br i1 %10, label %18, label %11
11: ; preds = %8
%12 = getelementptr inbounds i8, i8* %3, i64 2
%13 = load i8, i8* %12
%14 = icmp eq i8 %13, 0
br i1 %14, label %18, label %15
15: ; preds = %11
%16 = getelementptr inbounds i8, i8* %3, i64 3
%17 = icmp sgt i8 %13, 0
br i1 %17, label %20, label %18
18: ; preds = %22, %15, %8, %11, %6
%19 = phi i8* [ %4, %6 ], [ %4, %11 ], [ %4, %8 ], [ %16, %15 ], [ %16, %22 ]
br label %2
20: ; preds = %15
%21 = zext i8 %13 to i32
br label %22
22: ; preds = %20, %22
%23 = phi i32 [ %24, %22 ], [ %21, %20 ]
%24 = add nsw i32 %23, -1
%25 = tail call i32 @outc(i8 signext %9)
%26 = icmp ugt i32 %23, 1
br i1 %26, label %22, label %18
27: ; preds = %2
ret void
}