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

/* Variables and functions */
int _mount_error(char const *, int);
scalar_t__ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
size_t fread(char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fwrite(char *, int, size_t, int /*<<< orphan*/);
int /*<<< orphan*/ stdout;
int _mount_print(void) {
  int ret = 0;
  FILE *fp;
  const char mtab[] = "/etc/mtab";
  const char mounts[] = "/proc/mounts";
  char const *file = mtab;
  size_t res;
  char buf[256];
  if ((fp = fopen(file, "r")) == NULL) {
    _mount_error(file, 1);
    file = mounts;
    if ((fp = fopen(file, "r")) == NULL)
      return -_mount_error(file, 1);
  }
  while ((res = fread(buf, 1, sizeof(buf), fp)) > 0)
    fwrite(buf, 1, res, stdout);
  if (!feof(fp))
    ret = -_mount_error(file, 1);
  if (fclose(fp) != 0)
    ret = -_mount_error(file, 1);
  return ret;
}


x86 assembly (clang, -O0):
<_mount_print>:
push   %rbp
mov    %rsp,%rbp
sub    $0x140,%rsp
movl   $0x0,-0x8(%rbp)
mov    0xe87(%rip),%rax
mov    %rax,-0x1a(%rbp)
mov    0xe84(%rip),%ax
mov    %ax,-0x12(%rbp)
mov    0xe7b(%rip),%rax
mov    %rax,-0x27(%rbp)
mov    0xe79(%rip),%eax
mov    %eax,-0x1f(%rbp)
mov    0xe74(%rip),%al
mov    %al,-0x1b(%rbp)
lea    -0x1a(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
lea    0xe5f(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
jne    1220 <_mount_print+0xc0>
mov    -0x30(%rbp),%rdi
mov    $0x1,%esi
call   1060 <_mount_error@plt>
lea    -0x27(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
lea    0xe2b(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
jne    121b <_mount_print+0xbb>
mov    -0x30(%rbp),%rdi
mov    $0x1,%esi
call   1060 <_mount_error@plt>
mov    %eax,%ecx
xor    %eax,%eax
sub    %ecx,%eax
mov    %eax,-0x4(%rbp)
jmp    12c9 <_mount_print+0x169>
jmp    1220 <_mount_print+0xc0>
jmp    1225 <_mount_print+0xc5>
lea    -0x140(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x1,%esi
mov    $0x100,%edx
call   1030 <fread@plt>
mov    %rax,-0x38(%rbp)
cmp    $0x0,%rax
jbe    1270 <_mount_print+0x110>
lea    -0x140(%rbp),%rdi
mov    -0x38(%rbp),%rdx
mov    0x2d81(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%esi
call   1080 <fwrite@plt>
jmp    1225 <_mount_print+0xc5>
mov    -0x10(%rbp),%rdi
call   1050 <feof@plt>
cmp    $0x0,%eax
jne    1299 <_mount_print+0x139>
mov    -0x30(%rbp),%rdi
mov    $0x1,%esi
call   1060 <_mount_error@plt>
mov    %eax,%ecx
xor    %eax,%eax
sub    %ecx,%eax
mov    %eax,-0x8(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <fclose@plt>
cmp    $0x0,%rax
je     12c3 <_mount_print+0x163>
mov    -0x30(%rbp),%rdi
mov    $0x1,%esi
call   1060 <_mount_error@plt>
mov    %eax,%ecx
xor    %eax,%eax
sub    %ecx,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x140,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_mount_print>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x128,%rsp
mov    %rsp,%r14
movabs $0x61746d2f6374652f,%rax
6d 74 61
mov    %rax,(%rsp)
movw   $0x62,0x8(%rsp)
movabs $0x73746e756f6d2f,%rax
mov    %rax,0x15(%rsp)
movabs $0x6f6d2f636f72702f,%rax
2f 6d 6f
mov    %rax,0x10(%rsp)
lea    0xe6d(%rip),%rsi
mov    %r14,%rdi
call   1070 <fopen@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    11e7 <_mount_print+0x87>
lea    0x10(%rsp),%r14
mov    %rsp,%rdi
mov    $0x1,%esi
call   1060 <_mount_error@plt>
lea    0xe44(%rip),%rsi
mov    %r14,%rdi
call   1070 <fopen@plt>
mov    %rax,%rbx
test   %rax,%rax
je     126e <_mount_print+0x10e>
lea    0x20(%rsp),%rdi
mov    $0x1,%esi
mov    $0x100,%edx
mov    %rbx,%rcx
call   1030 <fread@plt>
test   %rax,%rax
je     123d <_mount_print+0xdd>
mov    0x2dd6(%rip),%r15
lea    0x20(%rsp),%rbp
nop
mov    (%r15),%ecx
mov    %rbp,%rdi
mov    $0x1,%esi
mov    %rax,%rdx
call   1080 <fwrite@plt>
mov    %rbp,%rdi
mov    $0x1,%esi
mov    $0x100,%edx
mov    %rbx,%rcx
call   1030 <fread@plt>
test   %rax,%rax
jne    1210 <_mount_print+0xb0>
mov    %rbx,%rdi
call   1050 <feof@plt>
xor    %ebp,%ebp
test   %eax,%eax
jne    125c <_mount_print+0xfc>
mov    %r14,%rdi
mov    $0x1,%esi
call   1060 <_mount_error@plt>
mov    %eax,%ebp
neg    %ebp
mov    %rbx,%rdi
call   1040 <fclose@plt>
test   %rax,%rax
je     1281 <_mount_print+0x121>
mov    %r14,%rdi
jmp    1273 <_mount_print+0x113>
lea    0x10(%rsp),%rdi
mov    $0x1,%esi
call   1060 <_mount_error@plt>
mov    %eax,%ebp
neg    %ebp
mov    %ebp,%eax
add    $0x128,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const._mount_print.mtab = [10 x i8] c"/etc/mtab\00"
@__const._mount_print.mounts = [13 x i8] c"/proc/mounts\00"
@.str = [2 x i8] c"r\00"
@stdout = global i32 0
define i32 @_mount_print() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32*
%4 = alloca [10 x i8]
%5 = alloca [13 x i8]
%6 = alloca i8*
%7 = alloca i64
%8 = alloca [256 x i8]
store i32 0, i32* %2
%9 = bitcast [10 x i8]* %4 to i8*
%10 = bitcast [13 x i8]* %5 to i8*
%11 = getelementptr inbounds [10 x i8], [10 x i8]* %4, i64 0, i64 0
store i8* %11, i8** %6
%12 = load i8*, i8** %6
%13 = call i32* @fopen(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %13, i32** %3
%14 = icmp eq i32* %13, null
br i1 %14, label %15, label %27
15: ; preds = %0
%16 = load i8*, i8** %6
%17 = call i32 @_mount_error(i8* %16, i32 1)
%18 = getelementptr inbounds [13 x i8], [13 x i8]* %5, i64 0, i64 0
store i8* %18, i8** %6
%19 = load i8*, i8** %6
%20 = call i32* @fopen(i8* %19, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %20, i32** %3
%21 = icmp eq i32* %20, null
br i1 %21, label %22, label %26
22: ; preds = %15
%23 = load i8*, i8** %6
%24 = call i32 @_mount_error(i8* %23, i32 1)
%25 = sub nsw i32 0, %24
store i32 %25, i32* %1
br label %56
26: ; preds = %15
br label %27
27: ; preds = %26, %0
br label %28
28: ; preds = %33, %27
%29 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%30 = load i32*, i32** %3
%31 = call i64 @fread(i8* %29, i32 1, i32 256, i32* %30)
store i64 %31, i64* %7
%32 = icmp ugt i64 %31, 0
br i1 %32, label %33, label %38
33: ; preds = %28
%34 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%35 = load i64, i64* %7
%36 = load i32, i32* @stdout
%37 = call i32 @fwrite(i8* %34, i32 1, i64 %35, i32 %36)
br label %28
38: ; preds = %28
%39 = load i32*, i32** %3
%40 = call i32 @feof(i32* %39)
%41 = icmp ne i32 %40, 0
br i1 %41, label %46, label %42
42: ; preds = %38
%43 = load i8*, i8** %6
%44 = call i32 @_mount_error(i8* %43, i32 1)
%45 = sub nsw i32 0, %44
store i32 %45, i32* %2
br label %46
46: ; preds = %42, %38
%47 = load i32*, i32** %3
%48 = call i64 @fclose(i32* %47)
%49 = icmp ne i64 %48, 0
br i1 %49, label %50, label %54
50: ; preds = %46
%51 = load i8*, i8** %6
%52 = call i32 @_mount_error(i8* %51, i32 1)
%53 = sub nsw i32 0, %52
store i32 %53, i32* %2
br label %54
54: ; preds = %50, %46
%55 = load i32, i32* %2
store i32 %55, i32* %1
br label %56
56: ; preds = %54, %22
%57 = load i32, i32* %1
ret i32 %57
}

LLVM IR (-O2):
@__const._mount_print.mtab = [10 x i8] c"/etc/mtab\00"
@__const._mount_print.mounts = [13 x i8] c"/proc/mounts\00"
@.str = [2 x i8] c"r\00"
@stdout = global i32 0
define i32 @_mount_print() {
%1 = alloca [10 x i8]
%2 = alloca [13 x i8]
%3 = alloca [256 x i8]
%4 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%5 = getelementptr inbounds [13 x i8], [13 x i8]* %2, i64 0, i64 0
%6 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%7 = call i32* @fopen(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i32* %7, null
br i1 %8, label %9, label %16
9: ; preds = %0
%10 = call i32 @_mount_error(i8* %4, i32 1)
%11 = call i32* @fopen(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %16
13: ; preds = %9
%14 = call i32 @_mount_error(i8* %5, i32 1)
%15 = sub nsw i32 0, %14
br label %40
16: ; preds = %9, %0
%17 = phi i32* [ %11, %9 ], [ %7, %0 ]
%18 = phi i8* [ %5, %9 ], [ %4, %0 ]
%19 = call i64 @fread(i8* %6, i32 1, i32 256, i32* %17)
%20 = icmp eq i64 %19, 0
br i1 %20, label %27, label %21
21: ; preds = %16, %21
%22 = phi i64 [ %25, %21 ], [ %19, %16 ]
%23 = load i32, i32* @stdout
%24 = call i32 @fwrite(i8* %6, i32 1, i64 %22, i32 %23)
%25 = call i64 @fread(i8* %6, i32 1, i32 256, i32* %17)
%26 = icmp eq i64 %25, 0
br i1 %26, label %27, label %21
27: ; preds = %21, %16
%28 = call i32 @feof(i32* %17)
%29 = icmp eq i32 %28, 0
br i1 %29, label %30, label %33
30: ; preds = %27
%31 = call i32 @_mount_error(i8* %18, i32 1)
%32 = sub nsw i32 0, %31
br label %33
33: ; preds = %30, %27
%34 = phi i32 [ 0, %27 ], [ %32, %30 ]
%35 = call i64 @fclose(i32* %17)
%36 = icmp eq i64 %35, 0
br i1 %36, label %40, label %37
37: ; preds = %33
%38 = call i32 @_mount_error(i8* %18, i32 1)
%39 = sub nsw i32 0, %38
br label %40
40: ; preds = %33, %37, %13
%41 = phi i32 [ %15, %13 ], [ %39, %37 ], [ %34, %33 ]
ret i32 %41
}