#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*/ disable_mptcp();
int /*<<< orphan*/ enable_mptcp();
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ printf(char *, int);
int toggle_mptcp() {
  int res, current;
  FILE *f = fopen("/proc/sys/net/mptcp/mptcp_enabled", "r");
  current = fgetc(f);
  fclose(f);
  printf("before-change value is %c\n", current);
  if (current == 48) {
    enable_mptcp();
  } else {
    disable_mptcp();
  }
}


x86 assembly (clang, -O0):
<toggle_mptcp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xe91(%rip),%rdi
lea    0xeac(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <fgetc@plt>
mov    %eax,-0xc(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0xc(%rbp),%esi
lea    0xe86(%rip),%rdi
call   1050 <printf@plt>
cmpl   $0x30,-0xc(%rbp)
jne    11b9 <toggle_mptcp+0x59>
mov    $0x0,%al
call   1080 <enable_mptcp@plt>
jmp    11c0 <toggle_mptcp+0x60>
mov    $0x0,%al
call   1040 <disable_mptcp@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<toggle_mptcp>:
push   %rbp
push   %rbx
push   %rax
lea    0xe96(%rip),%rdi
lea    0xeb1(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1060 <fgetc@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1030 <fclose@plt>
lea    0xe92(%rip),%rdi
mov    %ebp,%esi
call   1050 <printf@plt>
xor    %eax,%eax
cmp    $0x30,%ebp
jne    11a7 <toggle_mptcp+0x47>
call   1080 <enable_mptcp@plt>
jmp    11ac <toggle_mptcp+0x4c>
call   1040 <disable_mptcp@plt>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [34 x i8] c"/proc/sys/net/mptcp/mptcp_enabled\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [27 x i8] c"before-change value is %c\0A\00"
define i32 @toggle_mptcp() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32*
%5 = call i32* @fopen(i8* getelementptr inbounds ([34 x i8], [34 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** %4
%6 = load i32*, i32** %4
%7 = call i32 @fgetc(i32* %6)
store i32 %7, i32* %3
%8 = load i32*, i32** %4
%9 = call i32 @fclose(i32* %8)
%10 = load i32, i32* %3
%11 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i32 %10)
%12 = load i32, i32* %3
%13 = icmp eq i32 %12, 48
br i1 %13, label %14, label %16
14: ; preds = %0
%15 = call i32 (...) @enable_mptcp()
br label %18
16: ; preds = %0
%17 = call i32 (...) @disable_mptcp()
br label %18
18: ; preds = %16, %14
%19 = load i32, i32* %1
ret i32 %19
}

LLVM IR (-O2):
@.str = [34 x i8] c"/proc/sys/net/mptcp/mptcp_enabled\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [27 x i8] c"before-change value is %c\0A\00"
define i32 @toggle_mptcp() {
%1 = tail call i32* @fopen(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%2 = tail call i32 @fgetc(i32* %1)
%3 = tail call i32 @fclose(i32* %1)
%4 = tail call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i32 %2)
%5 = icmp eq i32 %2, 48
br i1 %5, label %6, label %8
6: ; preds = %0
%7 = tail call i32 (...) @enable_mptcp()
br label %10
8: ; preds = %0
%9 = tail call i32 (...) @disable_mptcp()
br label %10
10: ; preds = %8, %6
ret i32 undef
}