#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*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ stderr;
scalar_t__ strncmp(char *, char *, int);
int /*<<< orphan*/ strncpy(char *, char *, int);
char *ephcom_nxtgrp(char *group, char *expected, FILE *infile) {
  char readbuf[128 + 1];
  char *fgets(char *, int, FILE *);
  fgets(readbuf, 128, infile);
  fgets(readbuf, 128, infile);
  strncpy(group, readbuf, 12);
  group[12] = '\0';
  if (strncmp(group, expected, 12) != 0) {
    fprintf(stderr, "Badly formed header; \"%s\" not found.\n\n", expected);
    exit(1);
  }
  fgets(readbuf, 128, infile);
  return (NULL);
}


x86 assembly (clang, -O0):
<ephcom_nxtgrp>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
lea    -0xa0(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x80,%esi
call   1050 <fgets@plt>
lea    -0xa0(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x80,%esi
call   1050 <fgets@plt>
mov    -0x8(%rbp),%rdi
lea    -0xa0(%rbp),%rsi
mov    $0xc,%edx
call   1030 <strncpy@plt>
mov    -0x8(%rbp),%rax
movb   $0x0,0xc(%rax)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0xc,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
je     11ed <ephcom_nxtgrp+0x9d>
mov    0x2e0f(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xe22(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
lea    -0xa0(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x80,%esi
call   1050 <fgets@plt>
xor    %eax,%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ephcom_nxtgrp>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x88,%rsp
mov    %rdx,%r15
mov    %rsi,%r14
mov    %rdi,%rbx
mov    %rsp,%r12
mov    %r12,%rdi
mov    $0x80,%esi
call   1050 <fgets@plt>
mov    %r12,%rdi
mov    $0x80,%esi
mov    %r15,%rdx
call   1050 <fgets@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    $0xc,%edx
call   1030 <strncpy@plt>
movb   $0x0,0xc(%rbx)
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0xc,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
jne    11d1 <ephcom_nxtgrp+0x81>
mov    %rsp,%rdi
mov    $0x80,%esi
mov    %r15,%rdx
call   1050 <fgets@plt>
xor    %eax,%eax
add    $0x88,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
mov    0x2e08(%rip),%rax
mov    (%rax),%edi
lea    0xe1f(%rip),%rsi
mov    %r14,%rdx
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [39 x i8] c"Badly formed header; \22%s\22 not found.\0A\0A\00"
define i8* @ephcom_nxtgrp(i8* %0, i8* %1, i32* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca [129 x i8]
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32* %2, i32** %6
%8 = getelementptr inbounds [129 x i8], [129 x i8]* %7, i64 0, i64 0
%9 = load i32*, i32** %6
%10 = call i8* @fgets(i8* %8, i32 128, i32* %9)
%11 = getelementptr inbounds [129 x i8], [129 x i8]* %7, i64 0, i64 0
%12 = load i32*, i32** %6
%13 = call i8* @fgets(i8* %11, i32 128, i32* %12)
%14 = load i8*, i8** %4
%15 = getelementptr inbounds [129 x i8], [129 x i8]* %7, i64 0, i64 0
%16 = call i32 @strncpy(i8* %14, i8* %15, i32 12)
%17 = load i8*, i8** %4
%18 = getelementptr inbounds i8, i8* %17, i64 12
store i8 0, i8* %18
%19 = load i8*, i8** %4
%20 = load i8*, i8** %5
%21 = call i64 @strncmp(i8* %19, i8* %20, i32 12)
%22 = icmp ne i64 %21, 0
br i1 %22, label %23, label %28
23: ; preds = %3
%24 = load i32, i32* @stderr
%25 = load i8*, i8** %5
%26 = call i32 @fprintf(i32 %24, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i8* %25)
%27 = call i32 @exit(i32 1)
unreachable
28: ; preds = %3
%29 = getelementptr inbounds [129 x i8], [129 x i8]* %7, i64 0, i64 0
%30 = load i32*, i32** %6
%31 = call i8* @fgets(i8* %29, i32 128, i32* %30)
ret i8* null
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [39 x i8] c"Badly formed header; \22%s\22 not found.\0A\0A\00"
define noalias i8* @ephcom_nxtgrp(i8* %0, i8* %1, i32* nocapture %2) {
%4 = alloca [129 x i8]
%5 = getelementptr inbounds [129 x i8], [129 x i8]* %4, i64 0, i64 0
%6 = call i8* @fgets(i8* %5, i32 128, i32* %2)
%7 = call i8* @fgets(i8* %5, i32 128, i32* %2)
%8 = call i32 @strncpy(i8* %0, i8* %5, i32 12)
%9 = getelementptr inbounds i8, i8* %0, i64 12
store i8 0, i8* %9
%10 = call i64 @strncmp(i8* %0, i8* %1, i32 12)
%11 = icmp eq i64 %10, 0
br i1 %11, label %16, label %12
12: ; preds = %3
%13 = load i32, i32* @stderr
%14 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i8* %1)
%15 = call i32 @exit(i32 1)
unreachable
16: ; preds = %3
%17 = call i8* @fgets(i8* %5, i32 128, i32* %2)
ret i8* null
}