#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 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*/ trace_events_fprintf(char *, char *);
int /*<<< orphan*/ trace_fprintf(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");
  trace_events_fprintf("uselib", "1");
  trace_events_fprintf("open_exec", "1");
  trace_events_fprintf("do_sys_open", "1");
  trace_fprintf("tracing/tracing_enabled", "1");
  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    0xe42(%rip),%rdx
lea    0xe27(%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     120f <trace_start+0x4f>
lea    0xe20(%rip),%rdi
call   10d0 <perror@plt>
mov    0x2dd8(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>
lea    0xdea(%rip),%rdi
call   1060 <chdir@plt>
lea    0xe13(%rip),%rdi
lea    0xe13(%rip),%rsi
call   1080 <trace_events_fprintf@plt>
lea    0xe09(%rip),%rdi
lea    0xe00(%rip),%rsi
call   1080 <trace_events_fprintf@plt>
lea    0xe00(%rip),%rdi
lea    0xded(%rip),%rsi
call   1080 <trace_events_fprintf@plt>
lea    0xdf9(%rip),%rdi
lea    0xdda(%rip),%rsi
call   10b0 <trace_fprintf@plt>
lea    0xde6(%rip),%rdi
lea    0xdf7(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x10(%rbp)
lea    -0x1010(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x1000,%esi
call   1090 <fgets@plt>
mov    -0x10(%rbp),%rdi
call   1040 <fclose@plt>
lea    -0x1010(%rbp),%rdi
lea    0xdc4(%rip),%rsi
call   10a0 <strcmp@plt>
cmp    $0x0,%rax
je     12d3 <trace_start+0x113>
lea    0xdb1(%rip),%rdi
call   10d0 <perror@plt>
mov    0x2d14(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>
lea    0xdb0(%rip),%rdi
call   1060 <chdir@plt>
lea    0xd1a(%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    12ad <trace_start+0xed>
lea    0xe0c(%rip),%rdi
call   1060 <chdir@plt>
lea    0xe35(%rip),%rdi
lea    0xe35(%rip),%rbx
mov    %rbx,%rsi
call   1080 <trace_events_fprintf@plt>
lea    0xe28(%rip),%rdi
mov    %rbx,%rsi
call   1080 <trace_events_fprintf@plt>
lea    0xe23(%rip),%rdi
mov    %rbx,%rsi
call   1080 <trace_events_fprintf@plt>
lea    0xe20(%rip),%r14
mov    %r14,%rdi
mov    %rbx,%rsi
call   10b0 <trace_fprintf@plt>
lea    0xe26(%rip),%rsi
mov    %r14,%rdi
call   10c0 <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    12b6 <trace_start+0xf6>
lea    0xe03(%rip),%rdi
call   1060 <chdir@plt>
lea    0xd6d(%rip),%rdi
call   1030 <umount@plt>
mov    $0x10,%edi
call   1070 <readahead_set_len@plt>
add    $0x1008,%rsp
pop    %rbx
pop    %r14
ret
lea    0xd68(%rip),%rdi
jmp    12bd <trace_start+0xfd>
lea    0xdb4(%rip),%rdi
call   10d0 <perror@plt>
mov    0x2d17(%rip),%rax
mov    (%rax),%edi
call   10e0 <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 = [7 x i8] c"uselib\00"
@.str.4 = [2 x i8] c"1\00"
@.str.5 = [10 x i8] c"open_exec\00"
@.str.6 = [12 x i8] c"do_sys_open\00"
@.str.7 = [24 x i8] c"tracing/tracing_enabled\00"
@.str.8 = [2 x i8] c"r\00"
@.str.9 = [3 x i8] c"1\0A\00"
@.str.10 = [25 x i8] c"Enabling tracing failed\0A\00"
@.str.11 = [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 @trace_events_fprintf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%14 = call i32 @trace_events_fprintf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%15 = call i32 @trace_events_fprintf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%16 = call i32 @trace_fprintf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%17 = call i32* @fopen(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
store i32* %17, i32** %2
%18 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 0
%19 = load i32*, i32** %2
%20 = call i32 @fgets(i8* %18, i32 4096, i32* %19)
%21 = load i32*, i32** %2
%22 = call i32 @fclose(i32* %21)
%23 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 0
%24 = call i64 @strcmp(i8* %23, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0))
%25 = icmp ne i64 %24, 0
br i1 %25, label %26, label %30
26: ; preds = %11
%27 = call i32 @perror(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.10, i64 0, i64 0))
%28 = load i32, i32* @EXIT_FAILURE
%29 = call i32 @exit(i32 %28)
unreachable
30: ; preds = %11
%31 = call i32 @chdir(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.11, i64 0, i64 0))
%32 = call i32 @umount(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
%33 = 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 = [7 x i8] c"uselib\00"
@.str.4 = [2 x i8] c"1\00"
@.str.5 = [10 x i8] c"open_exec\00"
@.str.6 = [12 x i8] c"do_sys_open\00"
@.str.7 = [24 x i8] c"tracing/tracing_enabled\00"
@.str.8 = [2 x i8] c"r\00"
@.str.9 = [3 x i8] c"1\0A\00"
@.str.10 = [25 x i8] c"Enabling tracing failed\0A\00"
@.str.11 = [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 @trace_events_fprintf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%12 = tail call i32 @trace_events_fprintf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%13 = tail call i32 @trace_events_fprintf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%14 = tail call i32 @trace_fprintf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%15 = tail call i32* @fopen(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
%16 = call i32 @fgets(i8* %2, i32 4096, i32* %15)
%17 = call i32 @fclose(i32* %15)
%18 = call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
br i1 %19, label %24, label %20
20: ; preds = %9
%21 = call i32 @perror(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.10, i64 0, i64 0))
%22 = load i32, i32* @EXIT_FAILURE
%23 = call i32 @exit(i32 %22)
unreachable
24: ; preds = %9
%25 = call i32 @chdir(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.11, i64 0, i64 0))
%26 = call i32 @umount(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
%27 = call i32 @readahead_set_len(i32 16)
ret void
}