#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 */
typedef size_t uint32_t;

/* Variables and functions */
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ fputc(size_t, int /*<<< orphan*/);
int /*<<< orphan*/ stdout;
void show_counter(uint32_t *c, uint32_t n) {
  while (n > 0) {
    n--;
    assert(c[n] == 0 || c[n] == 1);
    fputc('0' + c[n], stdout);
  }
}


x86 assembly (clang, -O0):
<show_counter>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jbe    11a2 <show_counter+0x82>
mov    -0x10(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rcx
mov    -0x10(%rbp),%rdx
mov    $0x1,%al
cmpq   $0x0,(%rcx,%rdx,8)
mov    %al,-0x11(%rbp)
je     1172 <show_counter+0x52>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
cmpq   $0x1,(%rax,%rcx,8)
sete   %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
add    $0x30,%rdi
mov    0x2e4a(%rip),%rax
mov    (%rax),%esi
call   1030 <fputc@plt>
jmp    1130 <show_counter+0x10>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<show_counter>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
test   %rsi,%rsi
je     116e <show_counter+0x4e>
mov    %rsi,%rbx
mov    %rdi,%r14
mov    0x2ea6(%rip),%r15
nopw   0x0(%rax,%rax,1)
lea    -0x1(%rbx),%r12
xor    %edi,%edi
cmpq   $0x2,-0x8(%r14,%rbx,8)
setb   %dil
call   1040 <assert@plt>
mov    -0x8(%r14,%rbx,8),%rdi
add    $0x30,%rdi
mov    (%r15),%esi
call   1030 <fputc@plt>
mov    %r12,%rbx
test   %r12,%r12
jne    1140 <show_counter+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@stdout = global i32 0
define void @show_counter(i64* %0, i64 %1) {
%3 = alloca i64*
%4 = alloca i64
store i64* %0, i64** %3
store i64 %1, i64* %4
br label %5
5: ; preds = %22, %2
%6 = load i64, i64* %4
%7 = icmp ugt i64 %6, 0
br i1 %7, label %8, label %33
8: ; preds = %5
%9 = load i64, i64* %4
%10 = add i64 %9, -1
store i64 %10, i64* %4
%11 = load i64*, i64** %3
%12 = load i64, i64* %4
%13 = getelementptr inbounds i64, i64* %11, i64 %12
%14 = load i64, i64* %13
%15 = icmp eq i64 %14, 0
br i1 %15, label %22, label %16
16: ; preds = %8
%17 = load i64*, i64** %3
%18 = load i64, i64* %4
%19 = getelementptr inbounds i64, i64* %17, i64 %18
%20 = load i64, i64* %19
%21 = icmp eq i64 %20, 1
br label %22
22: ; preds = %16, %8
%23 = phi i1 [ true, %8 ], [ %21, %16 ]
%24 = zext i1 %23 to i32
%25 = call i32 @assert(i32 %24)
%26 = load i64*, i64** %3
%27 = load i64, i64* %4
%28 = getelementptr inbounds i64, i64* %26, i64 %27
%29 = load i64, i64* %28
%30 = add i64 48, %29
%31 = load i32, i32* @stdout
%32 = call i32 @fputc(i64 %30, i32 %31)
br label %5
33: ; preds = %5
ret void
}

LLVM IR (-O2):
@stdout = global i32 0
define void @show_counter(i64* nocapture %0, i64 %1) {
%3 = icmp eq i64 %1, 0
br i1 %3, label %17, label %4
4: ; preds = %2, %4
%5 = phi i64 [ %6, %4 ], [ %1, %2 ]
%6 = add i64 %5, -1
%7 = getelementptr inbounds i64, i64* %0, i64 %6
%8 = load i64, i64* %7
%9 = icmp ult i64 %8, 2
%10 = zext i1 %9 to i32
%11 = tail call i32 @assert(i32 %10)
%12 = load i64, i64* %7
%13 = add i64 %12, 48
%14 = load i32, i32* @stdout
%15 = tail call i32 @fputc(i64 %13, i32 %14)
%16 = icmp eq i64 %6, 0
br i1 %16, label %17, label %4
17: ; preds = %4, %2
ret void
}