#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 stream {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ assert(struct stream *);
char efp_stream_get_char(struct stream *);
int efp_stream_advance(struct stream *stream, size_t cnt) {
  assert(stream);
  while (cnt--)
    if (efp_stream_get_char(stream) == '\0')
      return 0;
  return 1;
}


x86 assembly (clang, -O0):
<efp_stream_advance>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <assert@plt>
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x18(%rbp)
cmp    $0x0,%rax
je     1178 <efp_stream_advance+0x58>
mov    -0x10(%rbp),%rdi
call   1030 <efp_stream_get_char@plt>
movsbl %al,%eax
cmp    $0x0,%eax
jne    1173 <efp_stream_advance+0x53>
movl   $0x0,-0x4(%rbp)
jmp    117f <efp_stream_advance+0x5f>
jmp    1139 <efp_stream_advance+0x19>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<efp_stream_advance>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
call   1040 <assert@plt>
add    $0x1,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0xffffffffffffffff,%rbx
je     1156 <efp_stream_advance+0x36>
mov    %r14,%rdi
call   1030 <efp_stream_get_char@plt>
test   %al,%al
jne    1140 <efp_stream_advance+0x20>
xor    %eax,%eax
jmp    115b <efp_stream_advance+0x3b>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.stream = type { i32 }
define i32 @efp_stream_advance(%struct.stream* %0, i64 %1) {
%3 = alloca i32
%4 = alloca %struct.stream*
%5 = alloca i64
store %struct.stream* %0, %struct.stream** %4
store i64 %1, i64* %5
%6 = load %struct.stream*, %struct.stream** %4
%7 = call i32 @assert(%struct.stream* %6)
br label %8
8: ; preds = %18, %2
%9 = load i64, i64* %5
%10 = add i64 %9, -1
store i64 %10, i64* %5
%11 = icmp ne i64 %9, 0
br i1 %11, label %12, label %19
12: ; preds = %8
%13 = load %struct.stream*, %struct.stream** %4
%14 = call signext i8 @efp_stream_get_char(%struct.stream* %13)
%15 = sext i8 %14 to i32
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %18
17: ; preds = %12
store i32 0, i32* %3
br label %20
18: ; preds = %12
br label %8
19: ; preds = %8
store i32 1, i32* %3
br label %20
20: ; preds = %19, %17
%21 = load i32, i32* %3
ret i32 %21
}

LLVM IR (-O2):
%struct.stream = type { i32 }
define i32 @efp_stream_advance(%struct.stream* %0, i64 %1) {
%3 = tail call i32 @assert(%struct.stream* %0)
br label %4
4: ; preds = %7, %2
%5 = phi i64 [ %1, %2 ], [ %8, %7 ]
%6 = icmp eq i64 %5, 0
br i1 %6, label %11, label %7
7: ; preds = %4
%8 = add i64 %5, -1
%9 = tail call signext i8 @efp_stream_get_char(%struct.stream* %0)
%10 = icmp eq i8 %9, 0
br i1 %10, label %11, label %4
11: ; preds = %4, %7
%12 = phi i32 [ 0, %7 ], [ 1, %4 ]
ret i32 %12
}