#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 int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ rewind(int /*<<< orphan*/ *);
int /*<<< orphan*/ *strstr(char *, char *);
int check_buffer_size(FILE *fp, int buffer_size) {
  char buffer[buffer_size];
  while (fgets(buffer, sizeof buffer, fp) != NULL) {
    if (strstr(buffer, "\n") == NULL &&
        fgets(buffer, sizeof buffer, fp) != NULL)
      return 1;
  }
  rewind(fp);
  return 0;
}


x86 assembly (clang, -O0):
<check_buffer_size>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %rax,-0x40(%rbp)
mov    %rsp,%rcx
mov    %rcx,-0x20(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x38(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x28(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x40(%rbp),%rax
mov    %eax,%esi
mov    -0x10(%rbp),%rdx
call   1040 <fgets@plt>
cmp    $0x0,%rax
je     11d5 <check_buffer_size+0xa5>
mov    -0x38(%rbp),%rdi
lea    0xe6f(%rip),%rsi
call   1050 <strstr@plt>
cmp    $0x0,%rax
jne    11d0 <check_buffer_size+0xa0>
mov    -0x38(%rbp),%rdi
mov    -0x40(%rbp),%rax
mov    %eax,%esi
mov    -0x10(%rbp),%rdx
call   1040 <fgets@plt>
cmp    $0x0,%rax
je     11d0 <check_buffer_size+0xa0>
movl   $0x1,-0x4(%rbp)
movl   $0x1,-0x2c(%rbp)
jmp    11ec <check_buffer_size+0xbc>
jmp    1169 <check_buffer_size+0x39>
mov    -0x10(%rbp),%rdi
call   1030 <rewind@plt>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x2c(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_buffer_size>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%r15d
mov    %rdi,%r14
mov    %esi,%eax
mov    %rsp,%rbx
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
mov    %rbx,%rdi
jmp    1166 <check_buffer_size+0x36>
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %r15d,%esi
mov    %r14,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
je     119f <check_buffer_size+0x6f>
mov    %rbx,%rdi
mov    $0xa,%esi
call   1030 <strchr@plt>
test   %rax,%rax
jne    1160 <check_buffer_size+0x30>
mov    %rbx,%rdi
mov    %r15d,%esi
mov    %r14,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
je     1160 <check_buffer_size+0x30>
mov    $0x1,%eax
jmp    11a9 <check_buffer_size+0x79>
mov    %r14,%rdi
call   1040 <rewind@plt>
xor    %eax,%eax
lea    -0x18(%rbp),%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"\0A\00"
define i32 @check_buffer_size(i32* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i32
store i32* %0, i32** %4
store i32 %1, i32* %5
%9 = load i32, i32* %5
%10 = zext i32 %9 to i64
%11 = call i8* @llvm.stacksave()
store i8* %11, i8** %6
%12 = alloca i8, i64 %10
store i64 %10, i64* %7
br label %13
13: ; preds = %27, %2
%14 = trunc i64 %10 to i32
%15 = load i32*, i32** %4
%16 = call i32* @fgets(i8* %12, i32 %14, i32* %15)
%17 = icmp ne i32* %16, null
br i1 %17, label %18, label %28
18: ; preds = %13
%19 = call i32* @strstr(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%20 = icmp eq i32* %19, null
br i1 %20, label %21, label %27
21: ; preds = %18
%22 = trunc i64 %10 to i32
%23 = load i32*, i32** %4
%24 = call i32* @fgets(i8* %12, i32 %22, i32* %23)
%25 = icmp ne i32* %24, null
br i1 %25, label %26, label %27
26: ; preds = %21
store i32 1, i32* %3
store i32 1, i32* %8
br label %31
27: ; preds = %21, %18
br label %13
28: ; preds = %13
%29 = load i32*, i32** %4
%30 = call i32 @rewind(i32* %29)
store i32 0, i32* %3
store i32 1, i32* %8
br label %31
31: ; preds = %28, %26
%32 = load i8*, i8** %6
%33 = load i32, i32* %3
ret i32 %33
}

LLVM IR (-O2):
define i32 @check_buffer_size(i32* nocapture %0, i32 %1) {
%3 = zext i32 %1 to i64
%4 = alloca i8, i64 %3
%5 = call i32* @fgets(i8* %4, i32 %1, i32* %0)
%6 = icmp eq i32* %5, null
br i1 %6, label %16, label %7
7: ; preds = %2, %13
%8 = call i8* @strchr(i8* %4, i32 10)
%9 = icmp eq i8* %8, null
br i1 %9, label %10, label %13
10: ; preds = %7
%11 = call i32* @fgets(i8* %4, i32 %1, i32* %0)
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %18
13: ; preds = %10, %7
%14 = call i32* @fgets(i8* %4, i32 %1, i32* %0)
%15 = icmp eq i32* %14, null
br i1 %15, label %16, label %7
16: ; preds = %13, %2
%17 = call i32 @rewind(i32* %0)
br label %18
18: ; preds = %10, %16
%19 = phi i32 [ 0, %16 ], [ 1, %10 ]
ret i32 %19
}