#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_FAILURE;
int /*<<< orphan*/ chdir(char *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *);
int mount(char *, char *, char *, int /*<<< orphan*/, int /*<<< orphan*/ *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ readahead_set_len(int);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ umount(char *);
void trace_start(void) {
  int ret;
  FILE *file;
  char buf[4096];
  ret = mount("debugfs", "/var/lib/sreadahead/debugfs", "debugfs", 0, NULL);
  if (ret != 0) {
    perror("Unable to mount debugfs\n");
    exit(EXIT_FAILURE);
  }
  chdir("/var/lib/sreadahead/debugfs");
  file = fopen("tracing/current_tracer", "w");
  if (!file) {
    perror("Unable to select tracer\n");
    exit(EXIT_FAILURE);
  }
  fprintf(file, "open");
  fclose(file);
  file = fopen("tracing/current_tracer", "r");
  fgets(buf, 4096, file);
  fclose(file);
  if (strcmp(buf, "open\n") != 0) {
    perror("Unable to select open tracer\n");
    exit(EXIT_FAILURE);
  }
  file = fopen("tracing/tracing_enabled", "w");
  if (!file) {
    perror("Unable to enable tracing\n");
    exit(EXIT_FAILURE);
  }
  fprintf(file, "1");
  fclose(file);
  file = fopen("tracing/tracing_enabled", "r");
  fgets(buf, 4096, file);
  fclose(file);
  if (strcmp(buf, "1\n") != 0) {
    perror("Enabling tracing failed\n");
    exit(EXIT_FAILURE);
  }
  chdir("/");
  umount("/var/lib/sreadahead/debugfs");
  readahead_set_len(16);
}


x86 assembly (clang, -O0):
<trace_start>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1010,%rsp
lea    0xe52(%rip),%rdx
lea    0xe37(%rip),%rsi
xor    %ecx,%ecx
xor    %eax,%eax
mov    %eax,%r8d
mov    %rdx,%rdi
call   1050 <mount@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
je     11ff <trace_start+0x4f>
lea    0xe30(%rip),%rdi
call   10c0 <perror@plt>
mov    0x2de8(%rip),%rax
mov    (%rax),%edi
call   10d0 <exit@plt>
lea    0xdfa(%rip),%rdi
call   1060 <chdir@plt>
lea    0xe23(%rip),%rdi
lea    0xe33(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1247 <trace_start+0x97>
lea    0xe1a(%rip),%rdi
call   10c0 <perror@plt>
mov    0x2da0(%rip),%rax
mov    (%rax),%edi
call   10d0 <exit@plt>
mov    -0x10(%rbp),%rdi
lea    0xe15(%rip),%rsi
call   10a0 <fprintf@plt>
mov    -0x10(%rbp),%rdi
call   1040 <fclose@plt>
lea    0xdce(%rip),%rdi
lea    0xddc(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x10(%rbp)
lea    -0x1010(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x1000,%esi
call   1080 <fgets@plt>
mov    -0x10(%rbp),%rdi
call   1040 <fclose@plt>
lea    -0x1010(%rbp),%rdi
lea    0xdc9(%rip),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%rax
je     12cc <trace_start+0x11c>
lea    0xdb9(%rip),%rdi
call   10c0 <perror@plt>
mov    0x2d1b(%rip),%rax
mov    (%rax),%edi
call   10d0 <exit@plt>
lea    0xdbd(%rip),%rdi
lea    0xd72(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1308 <trace_start+0x158>
lea    0xdb3(%rip),%rdi
call   10c0 <perror@plt>
mov    0x2cdf(%rip),%rax
mov    (%rax),%edi
call   10d0 <exit@plt>
mov    -0x10(%rbp),%rdi
lea    0xdaf(%rip),%rsi
call   10a0 <fprintf@plt>
mov    -0x10(%rbp),%rdi
call   1040 <fclose@plt>
lea    0xd68(%rip),%rdi
lea    0xd1b(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x10(%rbp)
lea    -0x1010(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x1000,%esi
call   1080 <fgets@plt>
mov    -0x10(%rbp),%rdi
call   1040 <fclose@plt>
lea    -0x1010(%rbp),%rdi
lea    0xd60(%rip),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%rax
je     138d <trace_start+0x1dd>
lea    0xd4d(%rip),%rdi
call   10c0 <perror@plt>
mov    0x2c5a(%rip),%rax
mov    (%rax),%edi
call   10d0 <exit@plt>
lea    0xd4c(%rip),%rdi
call   1060 <chdir@plt>
lea    0xc60(%rip),%rdi
call   1030 <umount@plt>
mov    $0x10,%edi
call   1070 <readahead_set_len@plt>
add    $0x1010,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<trace_start>:
push   %r14
push   %rbx
sub    $0x1008,%rsp
lea    0xe2f(%rip),%rsi
lea    0xe3c(%rip),%rdi
mov    %rdi,%rdx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1050 <mount@plt>
test   %eax,%eax
jne    1328 <trace_start+0x168>
lea    0xe0c(%rip),%rdi
call   1060 <chdir@plt>
lea    0xe35(%rip),%rdi
lea    0xe45(%rip),%rsi
call   10b0 <fopen@plt>
test   %rax,%rax
je     1331 <trace_start+0x171>
mov    %rax,%rbx
lea    0xe48(%rip),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %rax,%rcx
call   10e0 <fwrite@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
lea    0xdf5(%rip),%rdi
lea    0xe03(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,%rbx
mov    %rsp,%r14
mov    %r14,%rdi
mov    $0x1000,%esi
mov    %rax,%rdx
call   1090 <fgets@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
lea    0xdfb(%rip),%rsi
mov    %r14,%rdi
call   10a0 <strcmp@plt>
test   %rax,%rax
jne    133a <trace_start+0x17a>
lea    0xe07(%rip),%rdi
lea    0xdbc(%rip),%rsi
call   10b0 <fopen@plt>
test   %rax,%rax
je     1343 <trace_start+0x183>
mov    %rax,%rbx
mov    $0x31,%edi
mov    %rax,%rsi
call   1080 <fputc@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
lea    0xdd3(%rip),%rdi
lea    0xd86(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,%rbx
mov    %rsp,%r14
mov    %r14,%rdi
mov    $0x1000,%esi
mov    %rax,%rdx
call   1090 <fgets@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
lea    0xdd4(%rip),%rsi
mov    %r14,%rdi
call   10a0 <strcmp@plt>
test   %rax,%rax
jne    134c <trace_start+0x18c>
lea    0xddc(%rip),%rdi
call   1060 <chdir@plt>
lea    0xcf2(%rip),%rdi
call   1030 <umount@plt>
mov    $0x10,%edi
call   1070 <readahead_set_len@plt>
add    $0x1008,%rsp
pop    %rbx
pop    %r14
ret
lea    0xced(%rip),%rdi
jmp    1353 <trace_start+0x193>
lea    0xd16(%rip),%rdi
jmp    1353 <trace_start+0x193>
lea    0xd31(%rip),%rdi
jmp    1353 <trace_start+0x193>
lea    0xd5e(%rip),%rdi
jmp    1353 <trace_start+0x193>
lea    0xd72(%rip),%rdi
call   10c0 <perror@plt>
mov    0x2c81(%rip),%rax
mov    (%rax),%edi
call   10d0 <exit@plt>

LLVM IR (-O0):
@.str = [8 x i8] c"debugfs\00"
@.str.1 = [28 x i8] c"/var/lib/sreadahead/debugfs\00"
@.str.2 = [25 x i8] c"Unable to mount debugfs\0A\00"
@EXIT_FAILURE = global i32 0
@.str.3 = [23 x i8] c"tracing/current_tracer\00"
@.str.4 = [2 x i8] c"w\00"
@.str.5 = [25 x i8] c"Unable to select tracer\0A\00"
@.str.6 = [5 x i8] c"open\00"
@.str.7 = [2 x i8] c"r\00"
@.str.8 = [6 x i8] c"open\0A\00"
@.str.9 = [30 x i8] c"Unable to select open tracer\0A\00"
@.str.10 = [24 x i8] c"tracing/tracing_enabled\00"
@.str.11 = [26 x i8] c"Unable to enable tracing\0A\00"
@.str.12 = [2 x i8] c"1\00"
@.str.13 = [3 x i8] c"1\0A\00"
@.str.14 = [25 x i8] c"Enabling tracing failed\0A\00"
@.str.15 = [2 x i8] c"/\00"
define void @trace_start() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca [4096 x i8]
%4 = call i32 @mount(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 0, i32* null)
store i32 %4, i32* %1
%5 = load i32, i32* %1
%6 = icmp ne i32 %5, 0
br i1 %6, label %7, label %11
7: ; preds = %0
%8 = call i32 @perror(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
%9 = load i32, i32* @EXIT_FAILURE
%10 = call i32 @exit(i32 %9)
unreachable
11: ; preds = %0
%12 = call i32 @chdir(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
%13 = call i32* @fopen(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i32* %13, i32** %2
%14 = load i32*, i32** %2
%15 = icmp ne i32* %14, null
br i1 %15, label %20, label %16
16: ; preds = %11
%17 = call i32 @perror(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0))
%18 = load i32, i32* @EXIT_FAILURE
%19 = call i32 @exit(i32 %18)
unreachable
20: ; preds = %11
%21 = load i32*, i32** %2
%22 = call i32 @fprintf(i32* %21, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%23 = load i32*, i32** %2
%24 = call i32 @fclose(i32* %23)
%25 = call i32* @fopen(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
store i32* %25, i32** %2
%26 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 0
%27 = load i32*, i32** %2
%28 = call i32 @fgets(i8* %26, i32 4096, i32* %27)
%29 = load i32*, i32** %2
%30 = call i32 @fclose(i32* %29)
%31 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 0
%32 = call i64 @strcmp(i8* %31, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0))
%33 = icmp ne i64 %32, 0
br i1 %33, label %34, label %38
34: ; preds = %20
%35 = call i32 @perror(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.9, i64 0, i64 0))
%36 = load i32, i32* @EXIT_FAILURE
%37 = call i32 @exit(i32 %36)
unreachable
38: ; preds = %20
%39 = call i32* @fopen(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i32* %39, i32** %2
%40 = load i32*, i32** %2
%41 = icmp ne i32* %40, null
br i1 %41, label %46, label %42
42: ; preds = %38
%43 = call i32 @perror(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.11, i64 0, i64 0))
%44 = load i32, i32* @EXIT_FAILURE
%45 = call i32 @exit(i32 %44)
unreachable
46: ; preds = %38
%47 = load i32*, i32** %2
%48 = call i32 @fprintf(i32* %47, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.12, i64 0, i64 0))
%49 = load i32*, i32** %2
%50 = call i32 @fclose(i32* %49)
%51 = call i32* @fopen(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
store i32* %51, i32** %2
%52 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 0
%53 = load i32*, i32** %2
%54 = call i32 @fgets(i8* %52, i32 4096, i32* %53)
%55 = load i32*, i32** %2
%56 = call i32 @fclose(i32* %55)
%57 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 0
%58 = call i64 @strcmp(i8* %57, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.13, i64 0, i64 0))
%59 = icmp ne i64 %58, 0
br i1 %59, label %60, label %64
60: ; preds = %46
%61 = call i32 @perror(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.14, i64 0, i64 0))
%62 = load i32, i32* @EXIT_FAILURE
%63 = call i32 @exit(i32 %62)
unreachable
64: ; preds = %46
%65 = call i32 @chdir(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.15, i64 0, i64 0))
%66 = call i32 @umount(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
%67 = call i32 @readahead_set_len(i32 16)
ret void
}

LLVM IR (-O2):
@.str = [8 x i8] c"debugfs\00"
@.str.1 = [28 x i8] c"/var/lib/sreadahead/debugfs\00"
@.str.2 = [25 x i8] c"Unable to mount debugfs\0A\00"
@EXIT_FAILURE = global i32 0
@.str.3 = [23 x i8] c"tracing/current_tracer\00"
@.str.4 = [2 x i8] c"w\00"
@.str.5 = [25 x i8] c"Unable to select tracer\0A\00"
@.str.6 = [5 x i8] c"open\00"
@.str.7 = [2 x i8] c"r\00"
@.str.8 = [6 x i8] c"open\0A\00"
@.str.9 = [30 x i8] c"Unable to select open tracer\0A\00"
@.str.10 = [24 x i8] c"tracing/tracing_enabled\00"
@.str.11 = [26 x i8] c"Unable to enable tracing\0A\00"
@.str.13 = [3 x i8] c"1\0A\00"
@.str.14 = [25 x i8] c"Enabling tracing failed\0A\00"
@.str.15 = [2 x i8] c"/\00"
define void @trace_start() {
%1 = alloca [4096 x i8]
%2 = getelementptr inbounds [4096 x i8], [4096 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @mount(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 0, i32* null)
%4 = icmp eq i32 %3, 0
br i1 %4, label %9, label %5
5: ; preds = %0
%6 = tail call i32 @perror(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
%7 = load i32, i32* @EXIT_FAILURE
%8 = tail call i32 @exit(i32 %7)
unreachable
9: ; preds = %0
%10 = tail call i32 @chdir(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
%11 = tail call i32* @fopen(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %17
13: ; preds = %9
%14 = tail call i32 @perror(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0))
%15 = load i32, i32* @EXIT_FAILURE
%16 = tail call i32 @exit(i32 %15)
unreachable
17: ; preds = %9
%18 = tail call i64 @fwrite(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i64 4, i64 1, i32* %11)
%19 = tail call i32 @fclose(i32* %11)
%20 = tail call i32* @fopen(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%21 = call i32 @fgets(i8* %2, i32 4096, i32* %20)
%22 = call i32 @fclose(i32* %20)
%23 = call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0))
%24 = icmp eq i64 %23, 0
br i1 %24, label %29, label %25
25: ; preds = %17
%26 = call i32 @perror(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.9, i64 0, i64 0))
%27 = load i32, i32* @EXIT_FAILURE
%28 = call i32 @exit(i32 %27)
unreachable
29: ; preds = %17
%30 = call i32* @fopen(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%31 = icmp eq i32* %30, null
br i1 %31, label %32, label %36
32: ; preds = %29
%33 = call i32 @perror(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.11, i64 0, i64 0))
%34 = load i32, i32* @EXIT_FAILURE
%35 = call i32 @exit(i32 %34)
unreachable
36: ; preds = %29
%37 = call i32 @fputc(i32 49, i32* %30)
%38 = call i32 @fclose(i32* %30)
%39 = call i32* @fopen(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%40 = call i32 @fgets(i8* %2, i32 4096, i32* %39)
%41 = call i32 @fclose(i32* %39)
%42 = call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.13, i64 0, i64 0))
%43 = icmp eq i64 %42, 0
br i1 %43, label %48, label %44
44: ; preds = %36
%45 = call i32 @perror(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.14, i64 0, i64 0))
%46 = load i32, i32* @EXIT_FAILURE
%47 = call i32 @exit(i32 %46)
unreachable
48: ; preds = %36
%49 = call i32 @chdir(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.15, i64 0, i64 0))
%50 = call i32 @umount(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
%51 = call i32 @readahead_set_len(i32 16)
ret void
}