#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*/ config_second_options();
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ nvram_get(char *);
scalar_t__ strcmp(int /*<<< orphan*/, char *);
int /*<<< orphan*/ system(char *);
void start_second_session(void) {
  FILE *fp;
  if (strcmp(nvram_get("wan_enable_session2"), "0") == 0)
    return;
  if ((fp = fopen("/var/run/ppp0.pid", "r")) == NULL) {
    if ((fp = fopen("/tmp/resolv.conf", "w")) != NULL) {
      fputs("", fp);
      fclose(fp);
    }
  } else {
    fclose(fp);
  }
  config_second_options();
  system("/usr/sbin/pppd call pppoe-session2 updetach");
}


x86 assembly (clang, -O0):
<start_second_session>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xe81(%rip),%rdi
call   1090 <nvram_get@plt>
mov    %eax,%edi
lea    0xe87(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    11a1 <start_second_session+0x31>
jmp    121d <start_second_session+0xad>
lea    0xe6e(%rip),%rdi
lea    0xe79(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x8(%rbp)
cmp    $0x0,%rax
jne    1201 <start_second_session+0x91>
lea    0xe61(%rip),%rdi
lea    0xe6b(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x8(%rbp)
cmp    $0x0,%rax
je     11fc <start_second_session+0x8c>
mov    -0x8(%rbp),%rsi
lea    0xe27(%rip),%rdi
call   1050 <fputs@plt>
mov    -0x8(%rbp),%rdi
call   1030 <fclose@plt>
jmp    120a <start_second_session+0x9a>
mov    -0x8(%rbp),%rdi
call   1030 <fclose@plt>
mov    $0x0,%al
call   1060 <config_second_options@plt>
lea    0xe25(%rip),%rdi
call   1040 <system@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<start_second_session>:
push   %rax
lea    0xe98(%rip),%rdi
call   1080 <nvram_get@plt>
lea    0xea0(%rip),%rsi
mov    %eax,%edi
call   1060 <strcmp@plt>
test   %rax,%rax
je     11cc <start_second_session+0x6c>
lea    0xe8f(%rip),%rdi
lea    0xe9a(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
jne    11b0 <start_second_session+0x50>
lea    0xe8b(%rip),%rdi
lea    0xe95(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     11b8 <start_second_session+0x58>
mov    %rax,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
call   1050 <config_second_options@plt>
lea    0xe77(%rip),%rdi
pop    %rax
jmp    1040 <system@plt>
pop    %rax
ret

LLVM IR (-O0):
@.str = [20 x i8] c"wan_enable_session2\00"
@.str.1 = [2 x i8] c"0\00"
@.str.2 = [18 x i8] c"/var/run/ppp0.pid\00"
@.str.3 = [2 x i8] c"r\00"
@.str.4 = [17 x i8] c"/tmp/resolv.conf\00"
@.str.5 = [2 x i8] c"w\00"
@.str.6 = [1 x i8] zeroinitializer
@.str.7 = [44 x i8] c"/usr/sbin/pppd call pppoe-session2 updetach\00"
define void @start_second_session() {
%1 = alloca i32*
%2 = call i32 @nvram_get(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%3 = call i64 @strcmp(i32 %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %6
5: ; preds = %0
br label %24
6: ; preds = %0
%7 = call i32* @fopen(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %7, i32** %1
%8 = icmp eq i32* %7, null
br i1 %8, label %9, label %18
9: ; preds = %6
%10 = call i32* @fopen(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
store i32* %10, i32** %1
%11 = icmp ne i32* %10, null
br i1 %11, label %12, label %17
12: ; preds = %9
%13 = load i32*, i32** %1
%14 = call i32 @fputs(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.6, i64 0, i64 0), i32* %13)
%15 = load i32*, i32** %1
%16 = call i32 @fclose(i32* %15)
br label %17
17: ; preds = %12, %9
br label %21
18: ; preds = %6
%19 = load i32*, i32** %1
%20 = call i32 @fclose(i32* %19)
br label %21
21: ; preds = %18, %17
%22 = call i32 (...) @config_second_options()
%23 = call i32 @system(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.7, i64 0, i64 0))
br label %24
24: ; preds = %21, %5
ret void
}

LLVM IR (-O2):
@.str = [20 x i8] c"wan_enable_session2\00"
@.str.1 = [2 x i8] c"0\00"
@.str.2 = [18 x i8] c"/var/run/ppp0.pid\00"
@.str.3 = [2 x i8] c"r\00"
@.str.4 = [17 x i8] c"/tmp/resolv.conf\00"
@.str.5 = [2 x i8] c"w\00"
@.str.7 = [44 x i8] c"/usr/sbin/pppd call pppoe-session2 updetach\00"
define void @start_second_session() {
%1 = tail call i32 @nvram_get(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%2 = tail call i64 @strcmp(i32 %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%3 = icmp eq i64 %2, 0
br i1 %3, label %16, label %4
4: ; preds = %0
%5 = tail call i32* @fopen(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%6 = icmp eq i32* %5, null
br i1 %6, label %7, label %10
7: ; preds = %4
%8 = tail call i32* @fopen(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%9 = icmp eq i32* %8, null
br i1 %9, label %13, label %10
10: ; preds = %4, %7
%11 = phi i32* [ %8, %7 ], [ %5, %4 ]
%12 = tail call i32 @fclose(i32* %11)
br label %13
13: ; preds = %10, %7
%14 = tail call i32 (...) @config_second_options()
%15 = tail call i32 @system(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.7, i64 0, i64 0))
br label %16
16: ; preds = %0, %13
ret void
}