#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*/ putchar(char);
int strlen(char *);
void printfinal(char *finalstring) {
  int i;
  for (i = 1; i < strlen(finalstring) - 1; i++) {
    switch (finalstring[i]) {
    case '0':
    case '1':
      putchar('0');
      break;
    case '[':
      putchar('[');
      break;
    case ']':
      putchar(']');
      break;
    default:
      break;
    }
  }
  putchar('\n');
}


x86 assembly (clang, -O0):
<printfinal>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x1,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%eax
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    11d9 <printfinal+0xb9>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    %eax,-0x14(%rbp)
add    $0xffffffd0,%eax
sub    $0x2,%eax
jb     1194 <printfinal+0x74>
jmp    1172 <printfinal+0x52>
mov    -0x14(%rbp),%eax
sub    $0x5b,%eax
je     11a3 <printfinal+0x83>
jmp    1183 <printfinal+0x63>
mov    -0x14(%rbp),%eax
sub    $0x5d,%eax
je     11b2 <printfinal+0x92>
jmp    11c1 <printfinal+0xa1>
mov    $0x30,%edi
call   1030 <putchar@plt>
jmp    11c6 <printfinal+0xa6>
mov    $0x5b,%edi
call   1030 <putchar@plt>
jmp    11c6 <printfinal+0xa6>
mov    $0x5d,%edi
call   1030 <putchar@plt>
jmp    11c6 <printfinal+0xa6>
jmp    11c6 <printfinal+0xa6>
jmp    11cb <printfinal+0xab>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1133 <printfinal+0x13>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printfinal>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
call   1040 <strlen@plt>
cmp    $0x3,%eax
jl     117d <printfinal+0x5d>
mov    $0x1,%ebx
jmp    1160 <printfinal+0x40>
nopl   0x0(%rax,%rax,1)
mov    $0x5d,%al
movzbl %al,%edi
call   1030 <putchar@plt>
add    $0x1,%rbx
mov    %r14,%rdi
call   1040 <strlen@plt>
add    $0xffffffff,%eax
cltq
cmp    %rax,%rbx
jge    117d <printfinal+0x5d>
movsbl (%r14,%rbx,1),%ecx
mov    $0x30,%al
lea    -0x30(%rcx),%edx
cmp    $0x2,%edx
jb     1142 <printfinal+0x22>
cmp    $0x5d,%ecx
je     1140 <printfinal+0x20>
cmp    $0x5b,%ecx
jne    114a <printfinal+0x2a>
mov    $0x5b,%al
jmp    1142 <printfinal+0x22>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <putchar@plt>

LLVM IR (-O0):
define void @printfinal(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
store i32 1, i32* %3
br label %4
4: ; preds = %25, %1
%5 = load i32, i32* %3
%6 = load i8*, i8** %2
%7 = call i32 @strlen(i8* %6)
%8 = sub nsw i32 %7, 1
%9 = icmp slt i32 %5, %8
br i1 %9, label %10, label %28
10: ; preds = %4
%11 = load i8*, i8** %2
%12 = load i32, i32* %3
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i8, i8* %11, i64 %13
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
switch i32 %16, label %23 [
i32 48, label %17
i32 49, label %17
i32 91, label %19
i32 93, label %21
]
17: ; preds = %10, %10
%18 = call i32 @putchar(i8 signext 48)
br label %24
19: ; preds = %10
%20 = call i32 @putchar(i8 signext 91)
br label %24
21: ; preds = %10
%22 = call i32 @putchar(i8 signext 93)
br label %24
23: ; preds = %10
br label %24
24: ; preds = %23, %21, %19, %17
br label %25
25: ; preds = %24
%26 = load i32, i32* %3
%27 = add nsw i32 %26, 1
store i32 %27, i32* %3
br label %4
28: ; preds = %4
%29 = call i32 @putchar(i8 signext 10)
ret void
}

LLVM IR (-O2):
define void @printfinal(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = icmp sgt i32 %2, 2
br i1 %3, label %4, label %20
4: ; preds = %1, %14
%5 = phi i64 [ %15, %14 ], [ 1, %1 ]
%6 = getelementptr inbounds i8, i8* %0, i64 %5
%7 = load i8, i8* %6
%8 = sext i8 %7 to i32
switch i32 %8, label %14 [
i32 48, label %11
i32 49, label %11
i32 91, label %9
i32 93, label %10
]
9: ; preds = %4
br label %11
10: ; preds = %4
br label %11
11: ; preds = %4, %4, %10, %9
%12 = phi i8 [ 91, %9 ], [ 93, %10 ], [ 48, %4 ], [ 48, %4 ]
%13 = tail call i32 @putchar(i8 signext %12)
br label %14
14: ; preds = %11, %4
%15 = add nuw nsw i64 %5, 1
%16 = tail call i32 @strlen(i8* %0)
%17 = add nsw i32 %16, -1
%18 = sext i32 %17 to i64
%19 = icmp slt i64 %15, %18
br i1 %19, label %4, label %20
20: ; preds = %14, %1
%21 = tail call i32 @putchar(i8 signext 10)
ret void
}