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

/* Variables and functions */
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int sscanf(char *, char *, int *);
int de_ascii_next_group(FILE *f) {
  char buff[100 + 1];
  memset(buff, 0, sizeof(buff));
  int group;
  while (!feof(f)) {
    if (fgets(buff, sizeof(buff) - 1, f)) {
      if (sscanf(buff, "GROUP   %d\n", &group) == 1) {
        return group;
      }
    }
  }
  return -1;
}


x86 assembly (clang, -O0):
<de_ascii_next_group>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %rdi,-0x10(%rbp)
lea    -0x80(%rbp),%rdi
xor    %esi,%esi
mov    $0x65,%edx
call   1030 <memset@plt>
mov    -0x10(%rbp),%rdi
call   1050 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    117d <de_ascii_next_group+0x3d>
jmp    11d1 <de_ascii_next_group+0x91>
lea    -0x80(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x64,%esi
call   1040 <fgets@plt>
cmp    $0x0,%rax
je     11cc <de_ascii_next_group+0x8c>
lea    -0x80(%rbp),%rdi
lea    0xe5c(%rip),%rsi
lea    -0x84(%rbp),%rdx
call   1060 <sscanf@plt>
cmp    $0x1,%eax
jne    11c7 <de_ascii_next_group+0x87>
mov    -0x84(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11d8 <de_ascii_next_group+0x98>
jmp    11cc <de_ascii_next_group+0x8c>
jmp    115f <de_ascii_next_group+0x1f>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<de_ascii_next_group>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x80,%rsp
mov    %rdi,%rbx
lea    0x10(%rsp),%rdi
xor    %esi,%esi
mov    $0x65,%edx
call   1030 <memset@plt>
mov    %rbx,%rdi
call   1050 <feof@plt>
mov    $0xffffffff,%r14d
test   %eax,%eax
jne    11c9 <de_ascii_next_group+0x89>
lea    0x10(%rsp),%rbp
lea    0xe7f(%rip),%r15
lea    0xc(%rsp),%r12
jmp    119c <de_ascii_next_group+0x5c>
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1050 <feof@plt>
test   %eax,%eax
jne    11c9 <de_ascii_next_group+0x89>
mov    %rbp,%rdi
mov    $0x64,%esi
mov    %rbx,%rdx
call   1040 <fgets@plt>
test   %rax,%rax
je     1190 <de_ascii_next_group+0x50>
mov    %rbp,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
call   1060 <sscanf@plt>
cmp    $0x1,%eax
jne    1190 <de_ascii_next_group+0x50>
mov    0xc(%rsp),%r14d
mov    %r14d,%eax
add    $0x80,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [12 x i8] c"GROUP %d\0A\00"
define i32 @de_ascii_next_group(i32* %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca [101 x i8]
%5 = alloca i32
store i32* %0, i32** %3
%6 = getelementptr inbounds [101 x i8], [101 x i8]* %4, i64 0, i64 0
%7 = call i32 @memset(i8* %6, i32 0, i32 101)
br label %8
8: ; preds = %25, %1
%9 = load i32*, i32** %3
%10 = call i32 @feof(i32* %9)
%11 = icmp ne i32 %10, 0
%12 = xor i1 %11, true
br i1 %12, label %13, label %26
13: ; preds = %8
%14 = getelementptr inbounds [101 x i8], [101 x i8]* %4, i64 0, i64 0
%15 = load i32*, i32** %3
%16 = call i64 @fgets(i8* %14, i32 100, i32* %15)
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %25
18: ; preds = %13
%19 = getelementptr inbounds [101 x i8], [101 x i8]* %4, i64 0, i64 0
%20 = call i32 @sscanf(i8* %19, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32* %5)
%21 = icmp eq i32 %20, 1
br i1 %21, label %22, label %24
22: ; preds = %18
%23 = load i32, i32* %5
store i32 %23, i32* %2
br label %27
24: ; preds = %18
br label %25
25: ; preds = %24, %13
br label %8
26: ; preds = %8
store i32 -1, i32* %2
br label %27
27: ; preds = %26, %22
%28 = load i32, i32* %2
ret i32 %28
}

LLVM IR (-O2):
@.str = [12 x i8] c"GROUP %d\0A\00"
define i32 @de_ascii_next_group(i32* nocapture %0) {
%2 = alloca [101 x i8]
%3 = alloca i32
%4 = getelementptr inbounds [101 x i8], [101 x i8]* %2, i64 0, i64 0
%5 = call i32 @memset(i8* %4, i32 0, i32 101)
%6 = bitcast i32* %3 to i8*
%7 = call i32 @feof(i32* %0)
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %20
9: ; preds = %1, %17
%10 = call i64 @fgets(i8* %4, i32 100, i32* %0)
%11 = icmp eq i64 %10, 0
br i1 %11, label %17, label %12
12: ; preds = %9
%13 = call i32 @sscanf(i8* %4, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32* %3)
%14 = icmp eq i32 %13, 1
br i1 %14, label %15, label %17
15: ; preds = %12
%16 = load i32, i32* %3
br label %20
17: ; preds = %12, %9
%18 = call i32 @feof(i32* %0)
%19 = icmp eq i32 %18, 0
br i1 %19, label %9, label %20
20: ; preds = %17, %1, %15
%21 = phi i32 [ %16, %15 ], [ -1, %1 ], [ -1, %17 ]
ret i32 %21
}