#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 print_PC(char *str, int pc, int num_bits) {
  int i = 1, j, k;
  printf("(/* pc=%d */ ", pc);
  while (pc > 0) {
    j = pc % 2;
    pc = pc / 2;
    if (i > 1)
      printf(" & ");
    printf("%s.b%d=%d", str, i, j);
    i++;
  }
  for (k = i; k <= num_bits; k++) {
    if (k > 1)
      printf(" & ");
    printf("%s.b%d=0", str, k);
  }
  printf(")");
}


x86 assembly (clang, -O0):
<print_PC>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
mov    -0xc(%rbp),%esi
lea    0xecd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x0,-0xc(%rbp)
jle    119e <print_PC+0x8e>
mov    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %edx,-0x18(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0xc(%rbp)
cmpl   $0x1,-0x14(%rbp)
jle    1178 <print_PC+0x68>
lea    0xe9d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
lea    0xe89(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    113a <print_PC+0x2a>
mov    -0x14(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x10(%rbp),%eax
jg     11eb <print_PC+0xdb>
cmpl   $0x1,-0x1c(%rbp)
jle    11c8 <print_PC+0xb8>
lea    0xe4d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rsi
mov    -0x1c(%rbp),%edx
lea    0xe46(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11a4 <print_PC+0x94>
lea    0xe33(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_PC>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%r14d
mov    %esi,%r13d
mov    %rdi,%r15
lea    0xec5(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
test   %r13d,%r13d
jle    11c0 <print_PC+0xa0>
mov    %r13d,%ecx
and    $0x1,%ecx
lea    0xebe(%rip),%rdi
mov    %r15,%rsi
mov    $0x1,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x2,%ebp
cmp    $0x1,%r13d
je     11b9 <print_PC+0x99>
mov    $0x2,%ebp
mov    %r13d,%ebx
cs nopw 0x0(%rax,%rax,1)
shr    %ebx
mov    %ebx,%r12d
and    $0x1,%r12d
lea    0xe7e(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe74(%rip),%rdi
mov    %r15,%rsi
mov    %ebp,%edx
mov    %r12d,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%ebp
cmp    $0x4,%r13d
mov    %ebx,%r13d
jae    1180 <print_PC+0x60>
cmp    %r14d,%ebp
jg     11ca <print_PC+0xaa>
jmp    11e2 <print_PC+0xc2>
mov    $0x1,%ebp
cmp    %r14d,%ebp
jle    11e2 <print_PC+0xc2>
mov    $0x29,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>
add    $0x1,%r14d
lea    0xe21(%rip),%r12
lea    0xe28(%rip),%rbx
jmp    1217 <print_PC+0xf7>
cs nopw 0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %ebp,%edx
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%ebp
cmp    %ebp,%r14d
je     11ca <print_PC+0xaa>
cmp    $0x2,%ebp
jb     1200 <print_PC+0xe0>
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1200 <print_PC+0xe0>

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

LLVM IR (-O2):
@.str = [14 x i8] c"(/* pc=%d */ \00"
@.str.1 = [4 x i8] c" & \00"
@.str.2 = [10 x i8] c"%s.b%d=%d\00"
@.str.3 = [9 x i8] c"%s.b%d=0\00"
define void @print_PC(i8* %0, i32 %1, i32 %2) {
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 %1)
%5 = icmp sgt i32 %1, 0
br i1 %5, label %6, label %10
6: ; preds = %3
%7 = and i32 %1, 1
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %0, i32 1, i32 %7)
%9 = icmp eq i32 %1, 1
br i1 %9, label %10, label %13
10: ; preds = %13, %6, %3
%11 = phi i32 [ 1, %3 ], [ 2, %6 ], [ %20, %13 ]
%12 = icmp sgt i32 %11, %2
br i1 %12, label %31, label %22
13: ; preds = %6, %13
%14 = phi i32 [ %16, %13 ], [ %1, %6 ]
%15 = phi i32 [ %20, %13 ], [ 2, %6 ]
%16 = lshr i32 %14, 1
%17 = and i32 %16, 1
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %0, i32 %15, i32 %17)
%20 = add nuw nsw i32 %15, 1
%21 = icmp ult i32 %14, 4
br i1 %21, label %10, label %13
22: ; preds = %10, %27
%23 = phi i32 [ %29, %27 ], [ %11, %10 ]
%24 = icmp ugt i32 %23, 1
br i1 %24, label %25, label %27
25: ; preds = %22
%26 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
br label %27
27: ; preds = %25, %22
%28 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i8* %0, i32 %23)
%29 = add nuw i32 %23, 1
%30 = icmp eq i32 %23, %2
br i1 %30, label %31, label %22
31: ; preds = %27, %10
%32 = tail call i32 @putchar(i32 41)
ret void
}