#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 */
struct buf {
  int dummy;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int EOF;
int /*<<< orphan*/ buf_append(struct buf *, int);
int getc(int /*<<< orphan*/ *);
void buf_read_until_star_slash(struct buf *b, FILE *fp) {
  int ch;
  bool asterisked = false;
  for (;;) {
    ch = getc(fp);
    if (ch == EOF)
      break;
    buf_append(b, ch);
    if (asterisked && ch == '/')
      break;
    if (ch == '*')
      asterisked = true;
    else
      asterisked = false;
  }
}


x86 assembly (clang, -O0):
<buf_read_until_star_slash>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <getc@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    0x2e9b(%rip),%rcx
cmp    (%rcx),%eax
jne    115a <buf_read_until_star_slash+0x3a>
jmp    11a1 <buf_read_until_star_slash+0x81>
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1030 <buf_append@plt>
cmpl   $0x0,-0x18(%rbp)
je     117f <buf_read_until_star_slash+0x5f>
cmpl   $0x2f,-0x14(%rbp)
jne    117f <buf_read_until_star_slash+0x5f>
jmp    11a1 <buf_read_until_star_slash+0x81>
cmpl   $0x2a,-0x14(%rbp)
jne    1195 <buf_read_until_star_slash+0x75>
movl   $0x1,-0x18(%rbp)
jmp    119c <buf_read_until_star_slash+0x7c>
movl   $0x0,-0x18(%rbp)
jmp    1137 <buf_read_until_star_slash+0x17>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<buf_read_until_star_slash>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r12
mov    %rdi,%r14
mov    %rsi,%rdi
call   1040 <getc@plt>
mov    0x2eab(%rip),%r15
cmp    (%r15),%eax
je     117a <buf_read_until_star_slash+0x5a>
mov    %eax,%ebp
xor    %ebx,%ebx
jmp    1167 <buf_read_until_star_slash+0x47>
nopl   0x0(%rax,%rax,1)
xor    %ebx,%ebx
cmp    $0x2a,%ebp
sete   %bl
mov    %r12,%rdi
call   1040 <getc@plt>
mov    %eax,%ebp
cmp    (%r15),%eax
je     117a <buf_read_until_star_slash+0x5a>
mov    %r14,%rdi
mov    %ebp,%esi
call   1030 <buf_append@plt>
test   %ebx,%ebx
je     1150 <buf_read_until_star_slash+0x30>
cmp    $0x2f,%ebp
jne    1150 <buf_read_until_star_slash+0x30>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.buf = type { i32 }
@EOF = global i32 0
define void @buf_read_until_star_slash(%struct.buf* %0, i32* %1) {
%3 = alloca %struct.buf*
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
store %struct.buf* %0, %struct.buf** %3
store i32* %1, i32** %4
store i32 0, i32* %6
br label %7
7: ; preds = %29, %2
%8 = load i32*, i32** %4
%9 = call i32 @getc(i32* %8)
store i32 %9, i32* %5
%10 = load i32, i32* %5
%11 = load i32, i32* @EOF
%12 = icmp eq i32 %10, %11
br i1 %12, label %13, label %14
13: ; preds = %7
br label %30
14: ; preds = %7
%15 = load %struct.buf*, %struct.buf** %3
%16 = load i32, i32* %5
%17 = call i32 @buf_append(%struct.buf* %15, i32 %16)
%18 = load i32, i32* %6
%19 = icmp ne i32 %18, 0
br i1 %19, label %20, label %24
20: ; preds = %14
%21 = load i32, i32* %5
%22 = icmp eq i32 %21, 47
br i1 %22, label %23, label %24
23: ; preds = %20
br label %30
24: ; preds = %20, %14
%25 = load i32, i32* %5
%26 = icmp eq i32 %25, 42
br i1 %26, label %27, label %28
27: ; preds = %24
store i32 1, i32* %6
br label %29
28: ; preds = %24
store i32 0, i32* %6
br label %29
29: ; preds = %28, %27
br label %7
30: ; preds = %23, %13
ret void
}

LLVM IR (-O2):
%struct.buf = type { i32 }
@EOF = global i32 0
define void @buf_read_until_star_slash(%struct.buf* %0, i32* nocapture %1) {
%3 = tail call i32 @getc(i32* %1)
%4 = load i32, i32* @EOF
%5 = icmp eq i32 %3, %4
br i1 %5, label %19, label %6
6: ; preds = %2, %13
%7 = phi i32 [ %16, %13 ], [ %3, %2 ]
%8 = phi i32 [ %15, %13 ], [ 0, %2 ]
%9 = tail call i32 @buf_append(%struct.buf* %0, i32 %7)
%10 = icmp ne i32 %8, 0
%11 = icmp eq i32 %7, 47
%12 = and i1 %10, %11
br i1 %12, label %19, label %13
13: ; preds = %6
%14 = icmp eq i32 %7, 42
%15 = zext i1 %14 to i32
%16 = tail call i32 @getc(i32* %1)
%17 = load i32, i32* @EOF
%18 = icmp eq i32 %16, %17
br i1 %18, label %19, label %6
19: ; preds = %13, %6, %2
ret void
}