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

/* Variables and functions */
int /*<<< orphan*/ BUFSIZ;
int /*<<< orphan*/ abort();
struct mntent *getmntent_r(int /*<<< orphan*/ *, struct mntent *, char *,
                           int /*<<< orphan*/);
char *malloc(int /*<<< orphan*/);
struct mntent *getmntent(FILE *filep) {
  struct mntent *tmp;
  static char *buff = NULL;
  static struct mntent mnt;
  ;
  if (!buff) {
    buff = malloc(BUFSIZ);
    if (!buff)
      abort();
  }
  tmp = getmntent_r(filep, &mnt, buff, BUFSIZ);
  ;
  return (tmp);
}


x86 assembly (clang, -O0):
<getmntent>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
cmpq   $0x0,0x2efc(%rip)
jne    1179 <getmntent+0x49>
mov    0x2e8f(%rip),%rax
mov    (%rax),%edi
call   1050 <malloc@plt>
mov    %rax,0x2ee1(%rip)
cmpq   $0x0,0x2ed9(%rip)
jne    1174 <getmntent+0x44>
mov    $0x0,%al
call   1030 <abort@plt>
jmp    1179 <getmntent+0x49>
mov    -0x8(%rbp),%rdi
mov    0x2ebc(%rip),%rdx
mov    0x2e55(%rip),%rax
mov    (%rax),%ecx
lea    0x2eb4(%rip),%rsi
call   1040 <getmntent_r@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getmntent>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    0x2f03(%rip),%rdx
mov    0x2e9c(%rip),%rax
mov    (%rax),%ebp
test   %rdx,%rdx
jne    1161 <getmntent+0x31>
mov    %ebp,%edi
call   1050 <malloc@plt>
mov    %rax,%rdx
mov    %rax,0x2ee4(%rip)
test   %rax,%rax
je     1178 <getmntent+0x48>
lea    0x2ee0(%rip),%rsi
mov    %rbx,%rdi
mov    %ebp,%ecx
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1040 <getmntent_r@plt>
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
%struct.mntent = type { i32 }
@getmntent.buff = internal global i8* null
@getmntent.mnt = internal global %struct.mntent zeroinitializer
@BUFSIZ = global i32 0
define %struct.mntent* @getmntent(i32* %0) {
%2 = alloca i32*
%3 = alloca %struct.mntent*
store i32* %0, i32** %2
%4 = load i8*, i8** @getmntent.buff
%5 = icmp ne i8* %4, null
br i1 %5, label %14, label %6
6: ; preds = %1
%7 = load i32, i32* @BUFSIZ
%8 = call i8* @malloc(i32 %7)
store i8* %8, i8** @getmntent.buff
%9 = load i8*, i8** @getmntent.buff
%10 = icmp ne i8* %9, null
br i1 %10, label %13, label %11
11: ; preds = %6
%12 = call i32 (...) @abort()
unreachable
13: ; preds = %6
br label %14
14: ; preds = %13, %1
%15 = load i32*, i32** %2
%16 = load i8*, i8** @getmntent.buff
%17 = load i32, i32* @BUFSIZ
%18 = call %struct.mntent* @getmntent_r(i32* %15, %struct.mntent* @getmntent.mnt, i8* %16, i32 %17)
store %struct.mntent* %18, %struct.mntent** %3
%19 = load %struct.mntent*, %struct.mntent** %3
ret %struct.mntent* %19
}

LLVM IR (-O2):
%struct.mntent = type { i32 }
@getmntent.buff = internal unnamed_addr global i8* null
@getmntent.mnt = internal global %struct.mntent zeroinitializer
@BUFSIZ = global i32 0
define %struct.mntent* @getmntent(i32* %0) {
%2 = load i8*, i8** @getmntent.buff
%3 = icmp eq i8* %2, null
%4 = load i32, i32* @BUFSIZ
br i1 %3, label %5, label %10
5: ; preds = %1
%6 = tail call i8* @malloc(i32 %4)
store i8* %6, i8** @getmntent.buff
%7 = icmp eq i8* %6, null
br i1 %7, label %8, label %10
8: ; preds = %5
%9 = tail call i32 (...) @abort()
unreachable
10: ; preds = %1, %5
%11 = phi i8* [ %6, %5 ], [ %2, %1 ]
%12 = tail call %struct.mntent* @getmntent_r(i32* %0, %struct.mntent* @getmntent.mnt, i8* %11, i32 %4)
ret %struct.mntent* %12
}