#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 */
scalar_t__ get_bit(void *, int);
int /*<<< orphan*/ printf(char *, ...);
void show_bit(void *self, const unsigned int n) {
  printf(" | ");
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j)
      printf("%c", get_bit(self, i + n * j) > 0 ? '*' : '.');
    printf(" | ");
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<show_bit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jae    11c4 <show_bit+0xa4>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jae    11a8 <show_bit+0x88>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%esi
mov    -0xc(%rbp),%eax
imul   -0x14(%rbp),%eax
add    %eax,%esi
call   1040 <get_bit@plt>
mov    %rax,%rcx
mov    $0x2e,%esi
mov    $0x2a,%eax
cmp    $0x0,%rcx
cmovg  %eax,%esi
lea    0xe71(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1157 <show_bit+0x37>
lea    0xe51(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1144 <show_bit+0x24>
lea    0xe3c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<show_bit>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,%r13d
mov    %rdi,%r14
lea    0xeb8(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
test   %r13d,%r13d
je     11ac <show_bit+0x7c>
lea    0xea5(%rip),%r15
xor    %r12d,%r12d
xchg   %ax,%ax
xor    %ebx,%ebx
mov    %r12d,%ebp
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r14,%rdi
mov    %ebp,%esi
call   1050 <get_bit@plt>
xor    %ecx,%ecx
test   %rax,%rax
setle  %cl
lea    0x2a(,%rcx,4),%edi
call   1030 <putchar@plt>
add    $0x1,%ebx
add    %r13d,%ebp
cmp    %ebx,%r13d
jne    1170 <show_bit+0x40>
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%r12d
cmp    %r13d,%r12d
jne    1160 <show_bit+0x30>
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 = [4 x i8] c" | \00"
@.str.1 = [3 x i8] c"%c\00"
@.str.2 = [2 x i8] c"\0A\00"
define void @show_bit(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %5
br label %8
8: ; preds = %34, %2
%9 = load i32, i32* %5
%10 = load i32, i32* %4
%11 = icmp ult i32 %9, %10
br i1 %11, label %12, label %37
12: ; preds = %8
store i32 0, i32* %6
br label %13
13: ; preds = %29, %12
%14 = load i32, i32* %6
%15 = load i32, i32* %4
%16 = icmp ult i32 %14, %15
br i1 %16, label %17, label %32
17: ; preds = %13
%18 = load i8*, i8** %3
%19 = load i32, i32* %5
%20 = load i32, i32* %4
%21 = load i32, i32* %6
%22 = mul i32 %20, %21
%23 = add i32 %19, %22
%24 = call i64 @get_bit(i8* %18, i32 %23)
%25 = icmp sgt i64 %24, 0
%26 = zext i1 %25 to i64
%27 = select i1 %25, i32 42, i32 46
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %27)
br label %29
29: ; preds = %17
%30 = load i32, i32* %6
%31 = add nsw i32 %30, 1
store i32 %31, i32* %6
br label %13
32: ; preds = %13
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
br label %34
34: ; preds = %32
%35 = load i32, i32* %5
%36 = add nsw i32 %35, 1
store i32 %36, i32* %5
br label %8
37: ; preds = %8
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c" | \00"
define void @show_bit(i8* %0, i32 %1) {
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i32 %1, 0
br i1 %4, label %7, label %5
5: ; preds = %2, %9
%6 = phi i32 [ %11, %9 ], [ 0, %2 ]
br label %13
7: ; preds = %9, %2
%8 = tail call i32 @putchar(i32 10)
ret void
9: ; preds = %13
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%11 = add nuw i32 %6, 1
%12 = icmp eq i32 %11, %1
br i1 %12, label %7, label %5
13: ; preds = %5, %13
%14 = phi i32 [ 0, %5 ], [ %21, %13 ]
%15 = mul i32 %14, %1
%16 = add i32 %15, %6
%17 = tail call i64 @get_bit(i8* %0, i32 %16)
%18 = icmp sgt i64 %17, 0
%19 = select i1 %18, i32 42, i32 46
%20 = tail call i32 @putchar(i32 %19)
%21 = add nuw i32 %14, 1
%22 = icmp eq i32 %21, %1
br i1 %22, label %9, label %13
}