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

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
struct group *fgetgrent(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ test_entry(char *, int, struct group *);
void test_fgetgrent(const char *filename) {
  struct group *g;
  FILE *f;
  f = fopen(filename, "r");
  g = fgetgrent(f);
  test_entry("one", 1, g);
  g = fgetgrent(f);
  test_entry("two", 2, g);
  g = fgetgrent(f);
  test_entry("three", 3, g);
  fclose(f);
}


x86 assembly (clang, -O0):
<test_fgetgrent>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xea9(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <fgetgrent@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdx
lea    0xe8a(%rip),%rdi
mov    $0x1,%esi
call   1040 <test_entry@plt>
mov    -0x18(%rbp),%rdi
call   1060 <fgetgrent@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdx
lea    0xe6c(%rip),%rdi
mov    $0x2,%esi
call   1040 <test_entry@plt>
mov    -0x18(%rbp),%rdi
call   1060 <fgetgrent@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdx
lea    0xe4e(%rip),%rdi
mov    $0x3,%esi
call   1040 <test_entry@plt>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_fgetgrent>:
push   %rbx
lea    0xeb8(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1060 <fgetgrent@plt>
lea    0xea3(%rip),%rdi
mov    $0x1,%esi
mov    %rax,%rdx
call   1040 <test_entry@plt>
mov    %rbx,%rdi
call   1060 <fgetgrent@plt>
lea    0xe8b(%rip),%rdi
mov    $0x2,%esi
mov    %rax,%rdx
call   1040 <test_entry@plt>
mov    %rbx,%rdi
call   1060 <fgetgrent@plt>
lea    0xe73(%rip),%rdi
mov    $0x3,%esi
mov    %rax,%rdx
call   1040 <test_entry@plt>
mov    %rbx,%rdi
pop    %rbx
jmp    1030 <fclose@plt>

LLVM IR (-O0):
%struct.group = type { i32 }
@.str = [2 x i8] c"r\00"
@.str.1 = [4 x i8] c"one\00"
@.str.2 = [4 x i8] c"two\00"
@.str.3 = [6 x i8] c"three\00"
define void @test_fgetgrent(i8* %0) {
%2 = alloca i8*
%3 = alloca %struct.group*
%4 = alloca i32*
store i8* %0, i8** %2
%5 = load i8*, i8** %2
%6 = call i32* @fopen(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %6, i32** %4
%7 = load i32*, i32** %4
%8 = call %struct.group* @fgetgrent(i32* %7)
store %struct.group* %8, %struct.group** %3
%9 = load %struct.group*, %struct.group** %3
%10 = call i32 @test_entry(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 1, %struct.group* %9)
%11 = load i32*, i32** %4
%12 = call %struct.group* @fgetgrent(i32* %11)
store %struct.group* %12, %struct.group** %3
%13 = load %struct.group*, %struct.group** %3
%14 = call i32 @test_entry(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 2, %struct.group* %13)
%15 = load i32*, i32** %4
%16 = call %struct.group* @fgetgrent(i32* %15)
store %struct.group* %16, %struct.group** %3
%17 = load %struct.group*, %struct.group** %3
%18 = call i32 @test_entry(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 3, %struct.group* %17)
%19 = load i32*, i32** %4
%20 = call i32 @fclose(i32* %19)
ret void
}

LLVM IR (-O2):
%struct.group = type { i32 }
@.str = [2 x i8] c"r\00"
@.str.1 = [4 x i8] c"one\00"
@.str.2 = [4 x i8] c"two\00"
@.str.3 = [6 x i8] c"three\00"
define void @test_fgetgrent(i8* nocapture %0) {
%2 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%3 = tail call %struct.group* @fgetgrent(i32* %2)
%4 = tail call i32 @test_entry(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 1, %struct.group* %3)
%5 = tail call %struct.group* @fgetgrent(i32* %2)
%6 = tail call i32 @test_entry(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 2, %struct.group* %5)
%7 = tail call %struct.group* @fgetgrent(i32* %2)
%8 = tail call i32 @test_entry(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 3, %struct.group* %7)
%9 = tail call i32 @fclose(i32* %2)
ret void
}