#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 */
void *getbits(int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ putchar(char);
void readCommentExtension(void) {
  unsigned int c;
  int size, j;
  printf("Comment:\n");
  while (1) {
    size = getbits(8);
    if (size == 0)
      break;
    for (j = 0; j < size; j++) {
      c = getbits(8);
      putchar(c);
    }
  }
  putchar('\n');
}


x86 assembly (clang, -O0):
<readCommentExtension>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xec1(%rip),%rdi
call   1040 <printf@plt>
mov    $0x8,%edi
call   1050 <getbits@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    1160 <readCommentExtension+0x30>
jmp    119e <readCommentExtension+0x6e>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1199 <readCommentExtension+0x69>
mov    $0x8,%edi
call   1050 <getbits@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
movsbl %al,%edi
call   1030 <putchar@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1167 <readCommentExtension+0x37>
jmp    1144 <readCommentExtension+0x14>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readCommentExtension>:
push   %rbx
lea    0xec8(%rip),%rdi
call   1040 <puts@plt>
nopl   (%rax)
mov    $0x8,%edi
call   1050 <getbits@plt>
mov    %rax,%rbx
test   %ebx,%ebx
je     1179 <readCommentExtension+0x49>
test   %ebx,%ebx
jle    1140 <readCommentExtension+0x10>
cs nopw 0x0(%rax,%rax,1)
nop
mov    $0x8,%edi
call   1050 <getbits@plt>
movsbl %al,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebx
jne    1160 <readCommentExtension+0x30>
jmp    1140 <readCommentExtension+0x10>
mov    $0xa,%edi
pop    %rbx
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@.str = [10 x i8] c"Comment:\0A\00"
define void @readCommentExtension() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
br label %5
5: ; preds = %0, %25
%6 = call i8* @getbits(i32 8)
%7 = ptrtoint i8* %6 to i32
store i32 %7, i32* %2
%8 = load i32, i32* %2
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %11
10: ; preds = %5
br label %26
11: ; preds = %5
store i32 0, i32* %3
br label %12
12: ; preds = %22, %11
%13 = load i32, i32* %3
%14 = load i32, i32* %2
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %25
16: ; preds = %12
%17 = call i8* @getbits(i32 8)
%18 = ptrtoint i8* %17 to i32
store i32 %18, i32* %1
%19 = load i32, i32* %1
%20 = trunc i32 %19 to i8
%21 = call i32 @putchar(i8 signext %20)
br label %22
22: ; preds = %16
%23 = load i32, i32* %3
%24 = add nsw i32 %23, 1
store i32 %24, i32* %3
br label %12
25: ; preds = %12
br label %5
26: ; preds = %10
%27 = call i32 @putchar(i8 signext 10)
ret void
}

LLVM IR (-O2):
@str = [9 x i8] c"Comment:\00"
define void @readCommentExtension() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str, i64 0, i64 0))
%2 = tail call i8* @getbits(i32 8)
%3 = ptrtoint i8* %2 to i64
%4 = trunc i64 %3 to i32
%5 = icmp eq i32 %4, 0
br i1 %5, label %22, label %11
6: ; preds = %14, %11
%7 = tail call i8* @getbits(i32 8)
%8 = ptrtoint i8* %7 to i64
%9 = trunc i64 %8 to i32
%10 = icmp eq i32 %9, 0
br i1 %10, label %22, label %11
11: ; preds = %0, %6
%12 = phi i32 [ %9, %6 ], [ %4, %0 ]
%13 = icmp sgt i32 %12, 0
br i1 %13, label %14, label %6
14: ; preds = %11, %14
%15 = phi i32 [ %20, %14 ], [ 0, %11 ]
%16 = tail call i8* @getbits(i32 8)
%17 = ptrtoint i8* %16 to i64
%18 = trunc i64 %17 to i8
%19 = tail call i32 @putchar(i8 signext %18)
%20 = add nuw nsw i32 %15, 1
%21 = icmp eq i32 %20, %12
br i1 %21, label %6, label %14
22: ; preds = %6, %0
%23 = tail call i32 @putchar(i8 signext 10)
ret void
}