#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*/ df_path(char *);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
char *strtok(char *, char *);
void df_all(void) {
  FILE *f;
  char tmp[160];
  char *dev;
  char *mntpt;
  f = fopen("/etc/mtab", "r");
  if (f) {
    while (fgets(tmp, 160, f)) {
      dev = strtok(tmp, " ");
      mntpt = strtok(NULL, " ");
      if (mntpt)
        df_path(mntpt);
    }
    fclose(f);
  } else {
    fprintf(stderr, "df: cannot open /etc/mtab: %s\n", strerror(errno));
  }
}


x86 assembly (clang, -O0):
<df_all>:
push   %rbp
mov    %rsp,%rbp
sub    $0xd0,%rsp
lea    0xe7e(%rip),%rdi
lea    0xe81(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     121f <df_all+0xaf>
jmp    11a2 <df_all+0x32>
lea    -0xb0(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    $0xa0,%esi
call   1040 <fgets@plt>
cmp    $0x0,%rax
je     1211 <df_all+0xa1>
lea    -0xb0(%rbp),%rdi
lea    0xe3d(%rip),%rsi
call   1070 <strtok@plt>
mov    %rax,-0xb8(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xe26(%rip),%rsi
call   1070 <strtok@plt>
mov    %rax,-0xc0(%rbp)
cmpq   $0x0,-0xc0(%rbp)
je     120c <df_all+0x9c>
mov    -0xc0(%rbp),%rdi
call   1080 <df_path@plt>
jmp    11a2 <df_all+0x32>
mov    -0x8(%rbp),%rdi
call   1030 <fclose@plt>
jmp    1251 <df_all+0xe1>
mov    0x2dba(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xc4(%rbp)
mov    0x2da3(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
mov    -0xc4(%rbp),%edi
mov    %rax,%rdx
lea    0xdc2(%rip),%rsi
call   1050 <fprintf@plt>
add    $0xd0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<df_all>:
push   %r15
push   %r14
push   %rbx
sub    $0xa0,%rsp
lea    0xe7d(%rip),%rdi
lea    0xe80(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     120e <df_all+0x9e>
mov    %rax,%r14
mov    %rsp,%rdi
mov    $0xa0,%esi
mov    %rax,%rdx
call   1040 <fgets@plt>
test   %rax,%rax
je     11f9 <df_all+0x89>
lea    0xe59(%rip),%r15
mov    %rsp,%rbx
jmp    11d5 <df_all+0x65>
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    $0xa0,%esi
mov    %r14,%rdx
call   1040 <fgets@plt>
test   %rax,%rax
je     11f9 <df_all+0x89>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1070 <strtok@plt>
xor    %edi,%edi
mov    %r15,%rsi
call   1070 <strtok@plt>
test   %rax,%rax
je     11c0 <df_all+0x50>
mov    %rax,%rdi
call   1080 <df_path@plt>
jmp    11c0 <df_all+0x50>
mov    %r14,%rdi
call   1030 <fclose@plt>
add    $0xa0,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
mov    0x2dcb(%rip),%rax
mov    (%rax),%ebx
mov    0x2dba(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
lea    0xde2(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
add    $0xa0,%rsp
pop    %rbx
pop    %r14
pop    %r15
jmp    1050 <fprintf@plt>

LLVM IR (-O0):
@.str = [10 x i8] c"/etc/mtab\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [2 x i8] c" \00"
@stderr = global i32 0
@.str.3 = [31 x i8] c"df: cannot open /etc/mtab: %s\0A\00"
@errno = global i32 0
define void @df_all() {
%1 = alloca i32*
%2 = alloca [160 x i8]
%3 = alloca i8*
%4 = alloca i8*
%5 = call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %5, i32** %1
%6 = load i32*, i32** %1
%7 = icmp ne i32* %6, null
br i1 %7, label %8, label %27
8: ; preds = %0
br label %9
9: ; preds = %23, %8
%10 = getelementptr inbounds [160 x i8], [160 x i8]* %2, i64 0, i64 0
%11 = load i32*, i32** %1
%12 = call i64 @fgets(i8* %10, i32 160, i32* %11)
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %24
14: ; preds = %9
%15 = getelementptr inbounds [160 x i8], [160 x i8]* %2, i64 0, i64 0
%16 = call i8* @strtok(i8* %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i8* %16, i8** %3
%17 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i8* %17, i8** %4
%18 = load i8*, i8** %4
%19 = icmp ne i8* %18, null
br i1 %19, label %20, label %23
20: ; preds = %14
%21 = load i8*, i8** %4
%22 = call i32 @df_path(i8* %21)
br label %23
23: ; preds = %20, %14
br label %9
24: ; preds = %9
%25 = load i32*, i32** %1
%26 = call i32 @fclose(i32* %25)
br label %32
27: ; preds = %0
%28 = load i32, i32* @stderr
%29 = load i32, i32* @errno
%30 = call i8* @strerror(i32 %29)
%31 = call i32 @fprintf(i32 %28, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), i8* %30)
br label %32
32: ; preds = %27, %24
ret void
}

LLVM IR (-O2):
@.str = [10 x i8] c"/etc/mtab\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [2 x i8] c" \00"
@stderr = global i32 0
@.str.3 = [31 x i8] c"df: cannot open /etc/mtab: %s\0A\00"
@errno = global i32 0
define void @df_all() {
%1 = alloca [160 x i8]
%2 = getelementptr inbounds [160 x i8], [160 x i8]* %1, i64 0, i64 0
%3 = tail call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%4 = icmp eq i32* %3, null
br i1 %4, label %19, label %5
5: ; preds = %0
%6 = call i64 @fgets(i8* %2, i32 160, i32* %3)
%7 = icmp eq i64 %6, 0
br i1 %7, label %17, label %8
8: ; preds = %5, %14
%9 = call i8* @strtok(i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%10 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%11 = icmp eq i8* %10, null
br i1 %11, label %14, label %12
12: ; preds = %8
%13 = call i32 @df_path(i8* %10)
br label %14
14: ; preds = %12, %8
%15 = call i64 @fgets(i8* %2, i32 160, i32* %3)
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %8
17: ; preds = %14, %5
%18 = call i32 @fclose(i32* %3)
br label %24
19: ; preds = %0
%20 = load i32, i32* @stderr
%21 = load i32, i32* @errno
%22 = tail call i8* @strerror(i32 %21)
%23 = tail call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), i8* %22)
br label %24
24: ; preds = %19, %17
ret void
}