#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 *, ...);
void show_sample(int sample, int fill, const char *text) {
  int a, b, c;
  b = 0;
  for (a = 0; a < 78; a++) {
    c = (sample + 32768) / (65536 / 78);
    if (a == c) {
      printf("#");
      b++;
      continue;
    }
    if (a == (78 / 2)) {
      printf("|");
      b++;
      continue;
    }
    if (!fill && (b == 2))
      break;
    printf(" ");
  }
  printf("%s", text);
}


x86 assembly (clang, -O0):
<show_sample>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x4e,-0x14(%rbp)
jge    11d0 <show_sample+0xc0>
mov    -0x4(%rbp),%eax
add    $0x8000,%eax
mov    $0x348,%ecx
cltd
idiv   %ecx
mov    %eax,-0x1c(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jne    1175 <show_sample+0x65>
lea    0xea0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11c2 <show_sample+0xb2>
cmpl   $0x27,-0x14(%rbp)
jne    119b <show_sample+0x8b>
lea    0xe7c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11c2 <show_sample+0xb2>
cmpl   $0x0,-0x8(%rbp)
jne    11b4 <show_sample+0xa4>
cmpl   $0x2,-0x18(%rbp)
jne    11b4 <show_sample+0xa4>
jmp    11d0 <show_sample+0xc0>
lea    0xe49(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1130 <show_sample+0x20>
mov    -0x10(%rbp),%rsi
lea    0xe2b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<show_sample>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdx,%r14
mov    %esi,%r15d
mov    %edi,%eax
add    $0x8000,%eax
cltq
imul   $0xffffffff9c09c09d,%rax,%rax
shr    $0x20,%rax
lea    (%rax,%rdi,1),%r12d
add    $0x8000,%r12d
mov    %r12d,%eax
shr    $0x1f,%eax
sar    $0x9,%r12d
add    %eax,%r12d
xor    %ebp,%ebp
xor    %ebx,%ebx
jmp    1175 <show_sample+0x55>
mov    $0x23,%edi
call   1030 <putchar@plt>
add    $0x1,%ebx
add    $0x1,%ebp
cmp    $0x4e,%ebp
je     11a6 <show_sample+0x86>
cmp    %ebp,%r12d
je     1160 <show_sample+0x40>
cmp    $0x27,%ebp
jne    1190 <show_sample+0x70>
mov    $0x7c,%edi
jmp    1165 <show_sample+0x45>
cs nopw 0x0(%rax,%rax,1)
test   %r15d,%r15d
jne    119a <show_sample+0x7a>
cmp    $0x2,%ebx
je     11a6 <show_sample+0x86>
mov    $0x20,%edi
call   1030 <putchar@plt>
jmp    116d <show_sample+0x4d>
lea    0xe53(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <printf@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"#\00"
@.str.1 = [2 x i8] c"|\00"
@.str.2 = [2 x i8] c" \00"
@.str.3 = [3 x i8] c"%s\00"
define void @show_sample(i32 %0, i32 %1, i8* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i8* %2, i8** %6
store i32 0, i32* %8
store i32 0, i32* %7
br label %10
10: ; preds = %40, %3
%11 = load i32, i32* %7
%12 = icmp slt i32 %11, 78
br i1 %12, label %13, label %43
13: ; preds = %10
%14 = load i32, i32* %4
%15 = add nsw i32 %14, 32768
%16 = sdiv i32 %15, 840
store i32 %16, i32* %9
%17 = load i32, i32* %7
%18 = load i32, i32* %9
%19 = icmp eq i32 %17, %18
br i1 %19, label %20, label %24
20: ; preds = %13
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%22 = load i32, i32* %8
%23 = add nsw i32 %22, 1
store i32 %23, i32* %8
br label %40
24: ; preds = %13
%25 = load i32, i32* %7
%26 = icmp eq i32 %25, 39
br i1 %26, label %27, label %31
27: ; preds = %24
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%29 = load i32, i32* %8
%30 = add nsw i32 %29, 1
store i32 %30, i32* %8
br label %40
31: ; preds = %24
%32 = load i32, i32* %5
%33 = icmp ne i32 %32, 0
br i1 %33, label %38, label %34
34: ; preds = %31
%35 = load i32, i32* %8
%36 = icmp eq i32 %35, 2
br i1 %36, label %37, label %38
37: ; preds = %34
br label %43
38: ; preds = %34, %31
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %40
40: ; preds = %38, %27, %20
%41 = load i32, i32* %7
%42 = add nsw i32 %41, 1
store i32 %42, i32* %7
br label %10
43: ; preds = %37, %10
%44 = load i8*, i8** %6
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %44)
ret void
}

LLVM IR (-O2):
@.str.3 = [3 x i8] c"%s\00"
define void @show_sample(i32 %0, i32 %1, i8* %2) {
%4 = add nsw i32 %0, 32768
%5 = sdiv i32 %4, 840
%6 = icmp eq i32 %1, 0
br label %7
7: ; preds = %3, %24
%8 = phi i32 [ 0, %3 ], [ %26, %24 ]
%9 = phi i32 [ 0, %3 ], [ %25, %24 ]
%10 = icmp eq i32 %8, %5
br i1 %10, label %11, label %14
11: ; preds = %7
%12 = tail call i32 @putchar(i32 35)
%13 = add nsw i32 %9, 1
br label %24
14: ; preds = %7
%15 = icmp eq i32 %8, 39
br i1 %15, label %16, label %19
16: ; preds = %14
%17 = tail call i32 @putchar(i32 124)
%18 = add nsw i32 %9, 1
br label %24
19: ; preds = %14
%20 = icmp eq i32 %9, 2
%21 = select i1 %6, i1 %20, i1 false
br i1 %21, label %28, label %22
22: ; preds = %19
%23 = tail call i32 @putchar(i32 32)
br label %24
24: ; preds = %22, %16, %11
%25 = phi i32 [ %13, %11 ], [ %18, %16 ], [ %9, %22 ]
%26 = add nuw nsw i32 %8, 1
%27 = icmp eq i32 %26, 78
br i1 %27, label %28, label %7
28: ; preds = %19, %24
%29 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %2)
ret void
}