#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);
int /*<<< orphan*/ putchar(char);
void third(char *str, size_t len) {
  printf("#.%c.#", str[0]);
  for (int i = 1; i < len; i++) {
    switch (i % 3) {
    case 0:
      printf(".%c.#", str[i]);
      break;
    case 1:
      printf(i == len - 1 ? ".%c.#" : ".%c.*", str[i]);
      break;
    default:
      printf(".%c.*", str[i]);
    }
  }
  putchar('\n');
}


x86 assembly (clang, -O0):
<third>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
lea    0xec5(%rip),%rdi
movsbl (%rax),%esi
call   1040 <printf@plt>
movl   $0x1,-0x14(%rbp)
movslq -0x14(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    1217 <third+0xf7>
movslq -0x14(%rbp),%rcx
mov    %ecx,%eax
imul   $0x55555556,%rcx,%rdx
mov    %rdx,%rcx
shr    $0x3f,%rcx
shr    $0x20,%rdx
add    %ecx,%edx
mov    %edx,%ecx
lea    (%rcx,%rcx,2),%ecx
sub    %ecx,%eax
mov    %eax,-0x18(%rbp)
je     1198 <third+0x78>
jmp    1187 <third+0x67>
mov    -0x18(%rbp),%eax
sub    $0x1,%eax
je     11b5 <third+0x95>
jmp    11ec <third+0xcc>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
lea    0xe5a(%rip),%rdi
movsbl (%rax,%rcx,1),%esi
call   1040 <printf@plt>
jmp    1204 <third+0xe4>
movslq -0x14(%rbp),%rcx
mov    -0x10(%rbp),%rdx
sub    $0x1,%rdx
lea    0xe3f(%rip),%rdi
lea    0xe32(%rip),%rax
cmp    %rdx,%rcx
cmove  %rax,%rdi
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%esi
call   1040 <printf@plt>
jmp    1204 <third+0xe4>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
lea    0xe0c(%rip),%rdi
movsbl (%rax,%rcx,1),%esi
call   1040 <printf@plt>
jmp    1209 <third+0xe9>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    114a <third+0x2a>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<third>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
movsbl (%rdi),%esi
lea    0xec5(%rip),%rdi
call   1040 <printf@plt>
cmp    $0x2,%r14
jb     11b0 <third+0x90>
add    $0xffffffffffffffff,%r14
add    $0x1,%rbx
mov    $0x1,%ebp
mov    $0xaaaaaaab,%r15d
lea    0xea1(%rip),%r12
lea    0xea0(%rip),%r13
jmp    1188 <third+0x68>
nopl   0x0(%rax)
mov    %r13,%rdi
movsbl (%rbx),%esi
call   1040 <printf@plt>
add    $0x1,%rbx
add    $0x1,%ebp
add    $0xffffffffffffffff,%r14
je     11b0 <third+0x90>
mov    %ebp,%eax
imul   %r15,%rax
shr    $0x21,%rax
lea    (%rax,%rax,2),%ecx
mov    %ebp,%eax
mov    %r12,%rdi
sub    %ecx,%eax
je     1173 <third+0x53>
cmp    $0x1,%eax
jne    1170 <third+0x50>
cmp    $0x1,%r14
mov    %r13,%rdi
cmove  %r12,%rdi
jmp    1173 <third+0x53>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@.str = [7 x i8] c"#.%c.#\00"
@.str.1 = [6 x i8] c".%c.#\00"
@.str.2 = [6 x i8] c".%c.*\00"
define void @third(i8* %0, i64 %1) {
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i32
store i8* %0, i8** %3
store i64 %1, i64* %4
%6 = load i8*, i8** %3
%7 = getelementptr inbounds i8, i8* %6, i64 0
%8 = load i8, i8* %7
%9 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8 signext %8)
store i32 1, i32* %5
br label %10
10: ; preds = %47, %2
%11 = load i32, i32* %5
%12 = sext i32 %11 to i64
%13 = load i64, i64* %4
%14 = icmp ult i64 %12, %13
br i1 %14, label %15, label %50
15: ; preds = %10
%16 = load i32, i32* %5
%17 = srem i32 %16, 3
switch i32 %17, label %39 [
i32 0, label %18
i32 1, label %25
]
18: ; preds = %15
%19 = load i8*, i8** %3
%20 = load i32, i32* %5
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8, i8* %19, i64 %21
%23 = load i8, i8* %22
%24 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8 signext %23)
br label %46
25: ; preds = %15
%26 = load i32, i32* %5
%27 = sext i32 %26 to i64
%28 = load i64, i64* %4
%29 = sub i64 %28, 1
%30 = icmp eq i64 %27, %29
%31 = zext i1 %30 to i64
%32 = select i1 %30, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0)
%33 = load i8*, i8** %3
%34 = load i32, i32* %5
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i8, i8* %33, i64 %35
%37 = load i8, i8* %36
%38 = call i32 @printf(i8* %32, i8 signext %37)
br label %46
39: ; preds = %15
%40 = load i8*, i8** %3
%41 = load i32, i32* %5
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i8, i8* %40, i64 %42
%44 = load i8, i8* %43
%45 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8 signext %44)
br label %46
46: ; preds = %39, %25, %18
br label %47
47: ; preds = %46
%48 = load i32, i32* %5
%49 = add nsw i32 %48, 1
store i32 %49, i32* %5
br label %10
50: ; preds = %10
%51 = call i32 @putchar(i8 signext 10)
ret void
}

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